:root {
  --bg: #f6f3ee;
  --panel: #ffffff;
  --ink: #26221d;
  --muted: #6f675d;
  --line: #e4ddd2;
  --accent: #9b2c2c;      /* 단청 붉은색 */
  --accent-soft: #f6e6e3;
  --indigo: #2c4a6b;
  --ok: #2f6b3d;
  --warn: #9a6200;
  --side: #2b2621;
  --side-ink: #e9e2d6;
  --radius: 10px;
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--indigo); }

/* 틀 */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 20px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; font-weight: 700; font-size: 16px; padding: 0 8px 4px; letter-spacing: -0.3px; color: inherit; text-decoration: none; }
.brand:hover { opacity: .85; }
.topbar-home { color: inherit; font-weight: 700; text-decoration: none; }
.brand-sub { font-size: 12px; opacity: .65; padding: 0 8px 18px; }
.nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--side-ink); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.on { background: var(--accent); color: #fff; }
.nav .sep { font-size: 11px; opacity: .5; padding: 14px 12px 4px; }
.side-foot { margin-top: 20px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.side-foot button { background: none; border: 1px solid rgba(255,255,255,.25); color: var(--side-ink); border-radius: 6px; padding: 4px 10px; cursor: pointer; margin-top: 6px; margin-right: 4px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.topbar { display: none; }

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.5px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #c9bfb0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #842424; }
.btn.danger { color: var(--accent); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th, .t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.t th { font-weight: 600; color: var(--muted); font-size: 13px; background: #faf8f4; white-space: nowrap; }
.t td.n, .t th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tr.total td { font-weight: 700; background: #faf8f4; }
.t.nowrap td { white-space: nowrap; }
.t tbody tr:hover { background: #fcfaf7; }
.t input, .t select { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: #fff; }
.muted { color: var(--muted); }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: #efe9df; color: var(--muted); white-space: nowrap; }
.tag.red { background: var(--accent-soft); color: var(--accent); }
.tag.blue { background: #e3ebf3; color: var(--indigo); }
.tag.green { background: #e2efe5; color: var(--ok); }
.bar { height: 6px; background: #eee7dc; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; }
.toolbar input[type=search] { min-width: 200px; }

/* 폼 */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.form input, .form select, .form textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.form textarea { min-height: 70px; resize: vertical; }
.form .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: rgba(30, 25, 20, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 680px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal h2 { margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.calc { background: #faf8f4; border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; font-variant-numeric: tabular-nums; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }

/* 체크리스트 */
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.steps .t1 { font-weight: 600; }
.steps .t2 { font-size: 13px; color: var(--muted); }
.steps li.done .t1 { text-decoration: line-through; color: var(--muted); }

/* 로그인 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin-bottom: 2px; }
.login .form { grid-template-columns: 1fr; }
.err { color: var(--accent); font-size: 14px; min-height: 20px; margin-top: 8px; }

.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.notice { background: #fff8e6; border: 1px solid #f0dca8; color: #6b4b00; border-radius: 8px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }

/* 인쇄 서류 */
.doc-toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.doc { background: #fff; color: #000; width: 100%; max-width: 820px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--line); font-family: "Batang", "Malgun Gothic", serif; font-size: 13.5px; }
.doc h1 { text-align: center; font-size: 24px; letter-spacing: 8px; margin: 0 0 20px; }
.doc h3 { font-size: 15px; margin: 18px 0 8px; }
.doc table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.doc th, .doc td { border: 1px solid #000; padding: 5px 6px; font-size: 12.5px; }
.doc th { background: #f2f2f2; font-weight: 600; }
.doc td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc td.c, .doc th.c { text-align: center; }
.doc .sign { width: 260px; margin-left: auto; }
.doc .sign td { height: 54px; text-align: center; vertical-align: bottom; }
.doc .right { text-align: right; }
.doc .center { text-align: center; }
.doc .big { font-size: 16px; }
.doc .gap { height: 20px; }
.doc .kv td:first-child { width: 120px; background: #f7f7f7; text-align: center; }
.doc .mt { margin-top: 28px; }

@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: var(--side-ink); position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 1px solid rgba(255,255,255,.3); color: inherit; border-radius: 6px; padding: 3px 10px; }
  .main { padding: 16px 16px 60px; }
  .g2 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .tile .v { font-size: 18px; }
  .doc { padding: 18px 14px; overflow-x: auto; }
  .toolbar input[type=search] { min-width: 0; flex: 1; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .side, .topbar, .doc-toolbar, .no-print, #toast { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .doc { border: 0; padding: 0; max-width: none; }
  .page-break { page-break-before: always; }
}

/* 회원 스프레드시트 보기 */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
.card.flush { padding: 0; overflow: hidden; }
.sheet-wrap { overflow: auto; max-height: calc(100vh - 230px); }
table.sheet { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; font-size: 13px; }
.sheet th, .sheet td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; height: 30px; background: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet thead th { position: sticky; top: 0; z-index: 2; background: #f3efe7; font-weight: 600; color: var(--muted); padding: 0 8px; text-align: left; cursor: pointer; user-select: none; }
.sheet .rn { position: sticky; left: 0; z-index: 1; background: #f3efe7; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; cursor: pointer; }
.sheet thead .rn { z-index: 3; cursor: default; }
.sheet td.rn:hover { background: var(--accent-soft); color: var(--accent); }
.sheet td input:not([type=checkbox]), .sheet td select { width: 100%; height: 29px; border: 0; padding: 0 8px; font: inherit; background: transparent; color: inherit; border-radius: 0; }
.sheet td input:focus, .sheet td select:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fffdf8; }
.sheet td.c { text-align: center; }
.sheet td.lock { padding: 0 8px; color: var(--muted); background: #faf8f4; }
.sheet td.saving { background: #fff8e6; }
.sheet td.saved { background: #e9f6ec; transition: background .6s; }
.sheet tr.off td:not(.rn) { color: #aaa; }
.sheet tbody tr:hover td:not(.rn):not(.lock) { background: #fcfaf7; }
.sheet .empty { padding: 20px; text-align: center; }
@media (max-width: 760px) { .sheet-wrap { max-height: calc(100vh - 260px); } }

/* 업무 흐름 9단계 */
.flow-card { padding: 14px 16px; }
.flow-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.flow-head h2 { margin: 0; }
.flow-head .btn { margin-left: auto; }
ol.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; counter-reset: none; }
.flow li { position: relative; border: 1px solid var(--line); border-radius: 8px; padding: 8px 8px 7px; background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 13px; }
.flow li:not(:last-child)::after { content: '›'; position: absolute; right: -6px; top: 50%; transform: translate(50%, -50%); color: var(--muted); font-size: 14px; z-index: 1; }
.flow li:hover { border-color: var(--accent); }
.flow li b { font-size: 13px; line-height: 1.3; word-break: keep-all; }
.flow .no { width: 20px; height: 20px; border-radius: 50%; background: #efe9df; color: var(--muted); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.flow .who { font-size: 11px; color: var(--accent); }
.flow .who.org { color: var(--indigo); }
.flow .when { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 14px; }
.flow .when.late { color: var(--accent); font-weight: 700; }
.flow .memo { position: absolute; top: 7px; right: 7px; font-size: 10px; color: var(--muted); }
.flow li.done { background: #f3f8f4; border-color: #cfe3d4; }
.flow li.done .no { background: var(--ok); color: #fff; }
.flow li.now { border: 2px solid var(--accent); padding: 7px 7px 6px; background: var(--accent-soft); }
.flow li.now .no { background: var(--accent); color: #fff; }
@media (max-width: 1100px) { ol.flow { grid-template-columns: repeat(5, minmax(0, 1fr)); } .flow li::after { display: none; } }
@media (max-width: 760px) { ol.flow { grid-template-columns: repeat(3, minmax(0, 1fr)); } .flow-head .btn { margin-left: 0; width: 100%; } }
