:root {
  --bg: #f6f5f2; --panel: #fff; --ink: #1d1c1a; --sub: #6d6a64; --line: #e6e3dd;
  --brand: #8a5a2b; --brand-soft: #f3ebe1; --ok: #2f7d4f; --warn: #b7791f; --bad: #c0392b;
  --r: 10px;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }

.layout { display: flex; min-height: 100vh; }
#nav { width: 220px; flex: 0 0 220px; background: #24211d; color: #e9e4dc; padding: 18px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#nav .logo { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; letter-spacing: -0.2px; }
#nav .logo small { display: block; font-weight: 400; color: #a39c90; font-size: 12px; margin-top: 2px; }
#nav .grp { color: #8f877a; font-size: 11px; padding: 14px 10px 4px; }
#nav a { display: block; color: #e9e4dc; text-decoration: none; padding: 7px 10px; border-radius: 7px; }
#nav a:hover { background: #33302b; }
#nav a.on { background: var(--brand); color: #fff; }
#navToggle { display: none; }
main { flex: 1; padding: 22px 26px 60px; min-width: 0; }

h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.3px; }
h2 { font-size: 16px; margin: 22px 0 8px; }
.sub { color: var(--sub); font-size: 13px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; }
.bar .grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat b { display: block; font-size: 20px; margin-top: 4px; }
.stat span { color: var(--sub); font-size: 12px; }

.btn { border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cfc9bf; }
.btn.pri { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--sub); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--ink); border-color: var(--brand); font-weight: 600; }

input[type=text], input[type=date], input[type=month], input[type=number], input[type=password], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; min-width: 0;
}
textarea { width: 100%; min-height: 60px; }
input.money { text-align: right; }
label.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #faf9f6; font-weight: 600; font-size: 12px; color: var(--sub); position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fbf8f4; }
tr.total td { font-weight: 700; background: #faf9f6; }
td.wrap { white-space: normal; min-width: 160px; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; background: #eee; color: #555; }
.tag.brand { background: var(--brand-soft); color: var(--brand); }
.tag.ok { background: #e3f3e9; color: var(--ok); }
.tag.warn { background: #fbf0dc; color: var(--warn); }
.tag.bad { background: #fbe4e1; color: var(--bad); }

.dl { display: flex; flex-direction: column; gap: 8px; }
.dl .item { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.dl .dday { width: 64px; text-align: center; font-weight: 700; flex: 0 0 64px; }
.dl .dday.soon { color: var(--warn); }
.dl .dday.late { color: var(--bad); }
.dl .body { flex: 1; min-width: 0; }
.dl .body .t { font-weight: 600; }
.dl .item.done { opacity: .5; }

.notice { background: #fffaf0; border: 1px solid #f1e1bf; color: #6b4e16; border-radius: var(--r); padding: 10px 12px; font-size: 13px; margin: 10px 0; line-height: 1.55; }
.notice.info { background: #f2f6fb; border-color: #d7e2f0; color: #2b4466; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.form .full { grid-column: 1 / -1; }
.form label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--sub); }
.form label.f > * { color: var(--ink); font-size: 14px; }

#modal-root .mback { position: fixed; inset: 0; background: rgba(20, 18, 15, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 620px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { max-width: 980px; }
.mhead { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.mhead .x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--sub); }
.mbody { padding: 16px 18px; }
.mfoot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.mfoot .left { margin-right: auto; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumbs .th { position: relative; width: 90px; height: 90px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #faf9f6; font-size: 12px; }
.thumbs .th img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .th button { position: absolute; top: 2px; right: 2px; border: 0; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; line-height: 18px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; }
#toast div { background: #24211d; color: #fff; padding: 10px 16px; border-radius: 10px; margin-top: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast div.err { background: var(--bad); }
.loading, .err { padding: 30px; color: var(--sub); }
.err { color: var(--bad); }

.vat td:first-child { color: var(--sub); }
.vat tr.sec td { background: var(--brand-soft); font-weight: 700; color: var(--brand); }
.vat tr.big td { font-size: 16px; font-weight: 800; }

.login { max-width: 340px; margin: 14vh auto; }
.login h1 { margin-bottom: 14px; }
.login input { width: 100%; margin-bottom: 10px; padding: 11px; }
.login .btn { width: 100%; padding: 11px; }

@media (max-width: 860px) {
  .layout { display: block; }
  #nav { position: fixed; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s; z-index: 60; height: 100%; }
  #nav.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  #navToggle { display: inline-block; position: fixed; top: 10px; right: 10px; z-index: 55; }
  main { padding: 56px 14px 60px; }
  .form { grid-template-columns: 1fr; }
}
@media print {
  #nav, #navToggle, .bar, .noprint, .btn { display: none !important; }
  main { padding: 0; }
  .tbl-wrap { border: 0; overflow: visible; }
  body { background: #fff; }
}
