/* 엑셀 「매출마감 결산」 모양: 흰 종이, 맑은 고딕 굵게, 얇은 검은 테두리, 0 은 「-」, 음수는 빨강 */
:root {
  --paper: #fff; --desk: #e9ecef; --ink: #000; --line: #000; --soft: #f2f2f2; --link: #0563c1;
  --red: #e00; --bar: #1f4e3d; --bar-ink: #fff; --hint: #666; --sel: #fff2cc;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--desk); color: var(--ink);
  font-family: "맑은 고딕", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; font-weight: 700;
}
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--bar); color: var(--bar-ink); font-size: 14px; }
.bar a { color: inherit; text-decoration: none; }
.bar .home { font-size: 16px; }
#crumbs { display: flex; flex-wrap: wrap; gap: 4px; opacity: .92; }
#crumbs a:hover { text-decoration: underline; }
#crumbs span.sep { opacity: .6; }
#userbar { margin-left: auto; display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
#userbar a:hover { text-decoration: underline; }

main { padding: 16px; }
.sheet { background: var(--paper); padding: 18px 22px 28px; margin: 0 auto; width: max-content; max-width: 100%; min-width: min(100%, 900px); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.scroll { overflow-x: auto; max-width: 100%; }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.title { font-size: 28px; margin: 4px 0 10px; letter-spacing: -.5px; }
.subtitle { font-size: 20px; margin: 0 0 8px; }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: 14px; margin: 6px 0 6px; }
.meta .left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 3px 10px; font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--soft); }
.btn.on { background: var(--ink); color: var(--paper); }
input[type=date], select { font: inherit; font-size: 13px; border: 1px solid var(--line); padding: 2px 4px; background: var(--paper); }
label.opt { font-size: 12px; color: var(--hint); display: inline-flex; gap: 4px; align-items: center; }

/* 결재란 */
table.sign { border-collapse: collapse; font-size: 12px; }
table.sign td { border: 1px solid var(--line); text-align: center; padding: 2px 6px; }
table.sign td.blank { width: 76px; height: 40px; }
table.sign td.side { width: 40px; line-height: 1.25; font-size: 11px; }

/* 표 */
table.grid { border-collapse: collapse; font-size: 13px; }
.grid th, .grid td { border: 1px solid var(--line); padding: 3px 6px; height: 26px; white-space: nowrap; }
.grid th { font-weight: 700; text-align: center; }
.grid td.n { text-align: right; font-variant-numeric: tabular-nums; min-width: 64px; }
.grid td.c { text-align: center; }
.grid td.neg { color: var(--red); }
.grid tr.total td { background: var(--soft); }
.grid tr.sub td { background: #fafafa; }
.grid td.kind { text-align: center; width: 42px; }
.grid tr.plan td.kind { color: #333; }
.grid .day { min-width: 46px; }
.grid th.day a { color: var(--link); }
.grid th.sun, .grid td.sun { color: var(--red); }
.grid td.today, .grid th.today { background: var(--sel) !important; }
.grid td.pending { color: #aaa; }
a.lk { color: var(--link); text-decoration: none; }
a.lk:hover { text-decoration: underline; }

/* 목차 */
table.toc { border-collapse: collapse; font-size: 15px; margin-top: 8px; }
.toc th, .toc td { border: 1px solid var(--line); padding: 6px 10px; height: 34px; }
.toc td.no { text-align: center; width: 48px; }
.toc td.sq { text-align: center; width: 40px; }
.toc td.sq a { color: var(--ink); text-decoration: none; font-size: 18px; }
.toc td.sq a:hover { color: var(--link); }
.toc tr.later td { color: #999; }
.toc td.note { font-size: 12px; color: var(--hint); }
.toc .sublinks a { margin-right: 10px; }

.note-box { font-size: 12px; color: var(--hint); margin-top: 10px; line-height: 1.6; font-weight: 400; }
.empty { padding: 30px; text-align: center; color: var(--hint); }

/* 2단계: 결재·입력·로그인 */
table.sign td.signed { vertical-align: middle; }
table.sign .who { font-size: 12px; color: #c00; white-space: nowrap; }
table.sign .when { font-size: 10px; color: var(--hint); font-weight: 400; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border: 1px solid #b58900; color: #8a6d00; background: #fff8e1; }
.badge.ok { border-color: #2e7d32; color: #2e7d32; background: #e8f5e9; }
.badge.none { border-color: #bbb; color: #888; background: #fafafa; }
.badge.edit { border-color: #1565c0; color: #1565c0; background: #e3f2fd; font-size: 13px; vertical-align: middle; }
.approvebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin: 4px 0 8px; padding: 6px 8px; background: #f7f7f7; border: 1px solid #ddd; }
.approvebar span { margin-right: auto; }
.grid td.in { padding: 0; }
.grid td.in input { width: 56px; border: 0; padding: 3px 4px; text-align: right; font: inherit; font-size: 13px; background: #fffef3; height: 25px; }
.grid td.in input:focus { outline: 2px solid #1565c0; background: #fff; }
.grid td.lockd, .grid th.lockd { background: #e6e6e6 !important; color: #777; }
.grid td.live { text-decoration: underline; text-decoration-color: #9ab; }
.grid td.note-cell { padding: 0; vertical-align: top; }
.grid td.note-cell textarea { display: block; width: 100%; min-width: 150px; height: 64px; border: 0; resize: vertical; font: inherit; font-weight: 400; font-size: 12px; padding: 4px; background: #fffef3; }
.addcust { margin-top: 12px; font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.addcust input, .sheet input:not([type]), .sheet input[type=password], .sheet input[type=text] { font: inherit; font-size: 13px; border: 1px solid var(--line); padding: 3px 6px; }
.sheet.login { max-width: 380px; min-width: 0; width: 100%; }
.sheet.login form { display: flex; flex-direction: column; gap: 10px; }
.sheet.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.err { color: var(--red); font-size: 13px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff; padding: 8px 16px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
#toast.show { opacity: .95; }
#toast.bad { background: #b71c1c; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.badge.late { border-color: #c62828; color: #c62828; background: #ffebee; }
.tbcell { padding: 2px 4px 4px; font-size: 12px; }
.tbcell .btn { font-size: 11px; padding: 1px 6px; }
.tbform { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.tbpanel { background: var(--paper); border: 1px solid var(--line); padding: 16px 20px; width: min(640px, 100%); display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.tbpanel h3 { margin: 0 0 4px; }
.tbpanel label { display: flex; flex-direction: column; gap: 3px; }
.tbpanel input, .tbpanel select, .tbpanel textarea { font: inherit; font-weight: 400; font-size: 13px; border: 1px solid var(--line); padding: 4px 6px; }
.tbpanel .tfrow { display: flex; gap: 10px; flex-wrap: wrap; }
.tbpanel .tfrow label { flex: 1 1 150px; }

@media (max-width: 700px) {
  main { padding: 8px 0; }
  .sheet { padding: 12px 12px 20px; }
  .title { font-size: 22px; }
  .head { flex-direction: column; gap: 8px; }
}
@media print {
  .bar, .btns, .noprint, #toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .sheet { box-shadow: none; padding: 0; }
  a.lk { color: inherit; }
}
