:root {
  --brand: #1f3b57; --brand-2: #2c5478; --accent: #f0b44c; --bg: #eef2f6; --panel: #ffffff;
  --ink: #1b2430; --muted: #607080; --line: #d5dde6; --sel: #ffe7a8; --sel-ink: #1b2430;
  --dr: #0b6e4f; --cr: #9b2c2c; --head: #e3eaf2; --focus: #2f7de1;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
#app { display: flex; flex-direction: column; height: 100vh; }
#top { display: flex; align-items: center; gap: 16px; background: var(--brand); color: #fff; padding: 6px 14px; min-height: 40px; }
.brand { font-size: 16px; white-space: nowrap; letter-spacing: .3px; }
.brand b { color: var(--accent); }
.logo { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; background: var(--accent); color: var(--brand); font-weight: 800; margin-right: 4px; }
#top-info { flex: 1; display: flex; gap: 18px; font-size: 13px; opacity: .95; overflow: hidden; white-space: nowrap; }
#top-info span b { color: var(--accent); font-weight: 600; }
#top-user { font-size: 13px; white-space: nowrap; }
#top-user button { margin-left: 8px; }
#shell { flex: 1; display: flex; min-height: 0; }
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#titlebar { background: var(--brand-2); color: #fff; padding: 6px 14px; font-weight: 600; display: flex; gap: 14px; align-items: baseline; }
#subtitle { font-weight: 400; font-size: 12.5px; opacity: .9; }
#content { flex: 1; overflow: auto; padding: 14px; background: var(--panel); }
#keys { width: 170px; background: #dfe6ee; border-left: 1px solid var(--line); overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
#keys button { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; font-size: 12.5px; cursor: pointer; color: var(--ink); }
#keys button:hover { border-color: var(--brand-2); }
#keys button kbd { display: inline-block; min-width: 46px; font-weight: 700; color: var(--brand-2); font-family: inherit; }
#keys .sep { height: 6px; }
#hint { background: var(--brand); color: #cfd9e4; font-size: 12px; padding: 4px 14px; }
#hint kbd { color: var(--accent); font-family: inherit; font-weight: 700; }
button { font: inherit; }
.btn { background: var(--brand-2); color: #fff; border: 0; border-radius: 4px; padding: 7px 14px; cursor: pointer; }
.btn.ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn.danger { background: #a33; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 3px; padding: 4px 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; background: #fffdf3; }
.amt, td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.err { color: var(--cr); }
.ok { color: var(--dr); }

/* menus */
.gw { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 24px; align-items: start; }
.menu { border: 1px solid var(--line); border-radius: 6px; padding: 6px 0 10px; background: #fbfcfe; }
.menu h4 { margin: 10px 18px 3px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.menu .mi { padding: 4px 22px; cursor: pointer; }
.menu .mi u { text-decoration: none; color: var(--cr); font-weight: 700; }
.menu .mi.sel { background: var(--sel); color: var(--sel-ink); font-weight: 600; }
.panel { border: 1px solid var(--line); border-radius: 6px; padding: 14px 18px; background: #fbfcfe; }
.panel h3 { margin: 0 0 8px; color: var(--brand); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: #fff; }
.stat small { color: var(--muted); display: block; font-size: 11.5px; }
.stat b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* tables / reports */
table.rep { border-collapse: collapse; width: 100%; font-size: 13px; }
table.rep th { background: var(--head); text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); position: sticky; top: -14px; z-index: 1; font-weight: 600; }
table.rep th.n, table.vg th.n { text-align: right; }
table.rep td { padding: 3px 8px; border-bottom: 1px solid #edf1f5; vertical-align: top; }
table.rep tr[data-sel] { cursor: pointer; }
table.rep tr.sel td, .bs-line.sel { background: var(--sel) !important; }
table.rep tr.grp td { font-weight: 600; }
table.rep tr.sub td:first-child { padding-left: 26px; color: #34495e; }
table.rep tr.sub2 td:first-child { padding-left: 44px; color: #4a5c6e; font-size: 12.5px; }
table.rep tr.tot td { border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); font-weight: 700; background: #f7f9fb; }
table.rep tr.info td { color: var(--muted); font-style: italic; }
.rep-head { text-align: center; margin-bottom: 10px; }
.rep-head h2 { margin: 0; font-size: 17px; color: var(--brand); }
.rep-head div { color: var(--muted); font-size: 12.5px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line); }
.two > div { border-right: 1px solid var(--line); }
.two > div:last-child { border-right: 0; }
.two table.rep th { position: static; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.card h4 { margin: 0 0 6px; color: var(--brand); }
.card .row { display: flex; justify-content: space-between; font-size: 13px; padding: 1px 0; font-variant-numeric: tabular-nums; }
h3.sec { color: var(--brand); margin: 18px 0 6px; font-size: 14px; }
.low { color: var(--cr); font-weight: 600; }

/* forms */
.mform { max-width: 760px; }
.frow { display: grid; grid-template-columns: 200px 1fr; align-items: center; gap: 10px; padding: 3px 0; }
.frow label { color: #34495e; }
.frow input, .frow select { width: 100%; max-width: 380px; }
.frow .pair { display: flex; gap: 6px; max-width: 380px; }
.frow .pair input { flex: 1; }
.frow .pair select { width: 70px; }
.fsec { margin: 14px 0 4px; font-weight: 700; color: var(--brand); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.search { width: 100%; max-width: 420px; margin-bottom: 10px; padding: 6px 9px; }

/* voucher */
.vhead { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.vhead .vt { font-size: 16px; font-weight: 700; background: var(--brand); color: #fff; padding: 4px 10px; border-radius: 4px; border: 0; }
.vhead label { color: var(--muted); font-size: 12.5px; margin-right: 4px; }
.vhead input { width: 130px; }
.vhead .day { color: var(--muted); font-size: 12.5px; }
.vmode { font-size: 12px; background: #eef4fb; color: var(--brand-2); border: 1px solid #c9d9ec; border-radius: 10px; padding: 2px 9px; }
table.vg { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.vg th { background: var(--head); padding: 5px 6px; text-align: left; font-weight: 600; }
table.vg td { padding: 2px 4px; border-bottom: 1px solid #eef2f6; vertical-align: top; }
table.vg input { width: 100%; border-color: transparent; border-bottom: 1px dashed #c8d2dc; background: transparent; border-radius: 0; }
table.vg input:focus { border-color: var(--focus); background: #fffdf3; }
table.vg tr:hover input { border-color: #e3e9ef; }
table.vg .cb { font-size: 11.5px; color: var(--muted); padding: 0 6px 3px; }
table.vg tfoot td { font-weight: 700; border-top: 2px solid var(--ink); padding: 5px 6px; }
.party { display: grid; grid-template-columns: 170px minmax(200px, 380px) 1fr; gap: 6px 10px; align-items: center; margin-bottom: 10px; }
.party .info { font-size: 12px; color: var(--muted); }
.vtot { display: flex; justify-content: flex-end; margin-top: 8px; }
.vtot table { font-size: 13.5px; min-width: 320px; }
.vtot td { padding: 2px 8px; }
.vtot td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.vtot tr.big td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--ink); }
.narr { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.narr input { flex: 1; max-width: 700px; }
.diff { color: var(--cr); font-weight: 600; }

/* picker dropdown */
.dd { position: fixed; z-index: 50; background: #fff; border: 1px solid var(--brand-2); box-shadow: 0 6px 18px rgba(0,0,0,.18); max-height: 300px; overflow-y: auto; font-size: 13px; border-radius: 3px; }
.dd-h { background: var(--brand-2); color: #fff; padding: 4px 8px; font-weight: 600; position: sticky; top: 0; }
.dd-c { padding: 3px 8px; color: var(--brand-2); font-size: 12px; border-bottom: 1px solid var(--line); }
.dd-i { padding: 3px 8px; display: flex; justify-content: space-between; gap: 14px; cursor: pointer; }
.dd-i small { color: var(--muted); }
.dd-i.hi { background: var(--sel); }
.dd-e { padding: 6px 8px; color: var(--muted); }

/* modal & toast */
.ov { position: fixed; inset: 0; background: rgba(15, 30, 45, .45); display: grid; place-items: center; z-index: 40; }
.modal { background: #fff; border-radius: 6px; min-width: 320px; max-width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.modal h3 { margin: 0; background: var(--brand); color: #fff; padding: 8px 14px; font-size: 14px; border-radius: 6px 6px 0 0; }
.modal .mb { padding: 14px; }
.modal .ma { display: flex; justify-content: flex-end; gap: 8px; padding: 0 14px 14px; }
#toast { position: fixed; right: 18px; bottom: 34px; z-index: 60; display: flex; flex-direction: column; gap: 6px; }
#toast div { background: var(--brand); color: #fff; padding: 9px 14px; border-radius: 5px; box-shadow: 0 4px 12px rgba(0,0,0,.2); font-size: 13px; }
#toast div.e { background: #a33; }

/* auth */
.auth { max-width: 380px; margin: 6vh auto; border: 1px solid var(--line); border-radius: 8px; padding: 26px; background: #fff; }
.auth h2 { margin: 0 0 4px; color: var(--brand); }
.auth p { color: var(--muted); margin: 0 0 18px; }
.auth input { width: 100%; margin-bottom: 10px; padding: 8px 10px; }
.auth .btn { width: 100%; padding: 9px; }
.auth .sw { text-align: center; margin-top: 14px; font-size: 13px; }
.auth a { color: var(--brand-2); cursor: pointer; }

@media (max-width: 860px) {
  #keys { display: none; }
  .gw, .two { grid-template-columns: 1fr; }
  .frow, .party { grid-template-columns: 1fr; }
  #top-info { display: none; }
}
@media print {
  #top, #keys, #hint, #titlebar, #toast { display: none !important; }
  #app, #shell, #main { display: block; height: auto; }
  #content { overflow: visible; padding: 0; }
  table.rep th { position: static; }
  tr.sel td { background: none !important; }
}

.sl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 4px; }
table.vg .sl input { width: auto; border-bottom: 1px dashed #c8d2dc; font-size: 12.5px; }
.sl label { font-size: 11.5px; }
.fxl { display: flex; gap: 6px; align-items: center; margin: 2px 0 2px; font-size: 12.5px; }
table.vg .fxl input { width: 110px; border-bottom: 1px dashed #c8d2dc; font-size: 12.5px; }
table.vg.pr td { white-space: nowrap; }
table.vg.pr th { white-space: normal; font-size: 12px; vertical-align: bottom; }
table.vg.pr { font-size: 13px; }
table.vg.pr input.amt { width: 64px; }
.qr { background: #fff; display: inline-block; padding: 6px; border: 1px solid #dde3ea; border-radius: 6px; }
code.key { font-size: 14px; letter-spacing: 1px; background: #f1f4f8; padding: 2px 6px; border-radius: 4px; }
.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 28px; margin: 10px 0; font-size: 16px; }
.codes code { background: #f1f4f8; padding: 3px 8px; border-radius: 4px; letter-spacing: 1px; }

.mform input:disabled, .mform select:disabled { background: #eef1f5; color: #5b6878; cursor: not-allowed; }

.tsync { display: grid; gap: 14px; max-width: 1100px; }
.tsync h3 { margin: 0 0 8px; color: var(--brand); font-size: 15px; }
.btn.sm { padding: 3px 10px; font-size: 12.5px; }
pre.cmd { background: #0f2236; color: #e8f0f8; padding: 10px 12px; border-radius: 6px; white-space: pre-wrap; word-break: break-all; font-size: 13px; }
ul.tlog { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.6; max-height: 260px; overflow: auto; }
