:root {
  --bg: #f5f7f6; --card: #fff; --ink: #14201a; --muted: #5d6b64; --line: #dfe6e2;
  --green: #11683f; --green-d: #0b4a2c; --green-l: #e4f2ea; --amber: #a86400; --amber-l: #fff3dc;
  --red: #b3261e; --red-l: #fde8e6; --blue: #1d4e89; --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.hidden { display: none !important; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 1rem; }

/* layout */
#app { min-height: 100%; }
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--green-d); color: #e9f3ed; padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { font-weight: 700; font-size: 1.05rem; padding: .25rem .6rem 1rem; display: flex; gap: .5rem; align-items: center; }
.brand svg { flex: none; }
.side a.nav { display: block; color: #cfe3d7; text-decoration: none; padding: .55rem .7rem; border-radius: 8px; margin-bottom: 2px; }
.side a.nav:hover { background: rgba(255,255,255,.08); }
.side a.nav.active { background: #fff; color: var(--green-d); font-weight: 600; }
.side .who { margin-top: 1.2rem; padding: .7rem; border-top: 1px solid rgba(255,255,255,.15); font-size: .85rem; }
.side .who button { margin-top: .5rem; }
.main { padding: 1.4rem clamp(.8rem, 3vw, 2rem) 4rem; max-width: 1280px; width: 100%; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; width: 250px; left: -260px; transition: left .2s; }
  .side.open { left: 0; }
  .topbar { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; background: var(--green-d); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar button { background: transparent; border: 0; color: #fff; font-size: 1.4rem; }
}

/* cards & tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.grid { display: grid; gap: .8rem; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: .15rem; }
.stat .sub { color: var(--muted); font-size: .8rem; }
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f0f4f2; position: sticky; top: 0; z-index: 2; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: #fafcfb; }
tr.click { cursor: pointer; }
tfoot td { font-weight: 700; background: #f7faf8; position: sticky; bottom: 0; }
.sticky-col { position: sticky; left: 0; background: var(--card); z-index: 1; }
th.sticky-col { z-index: 3; background: #f0f4f2; }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { width: 100%; padding: .5rem .6rem; border: 1px solid #c4cfc9; border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.form { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form .full { grid-column: 1 / -1; }
.btn { background: var(--green); color: #fff; border: 0; border-radius: 8px; padding: .5rem .95rem; cursor: pointer; font-weight: 600; width: auto; }
.btn:hover { background: var(--green-d); }
.btn.ghost { background: #fff; color: var(--green); border: 1px solid var(--green); }
.btn.ghost:hover { background: var(--green-l); }
.btn.danger { background: var(--red); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.side .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
input.cell { padding: .3rem .4rem; width: 92px; text-align: right; border-radius: 6px; }
input.cell.changed { background: var(--amber-l); border-color: var(--amber); }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab { background: none; border: 0; padding: .55rem .9rem; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; width: auto; }
.tab.active { color: var(--green-d); border-bottom-color: var(--green); }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--green-l); color: var(--green-d); }
.badge.amber { background: var(--amber-l); color: var(--amber); }
.badge.red { background: var(--red-l); color: var(--red); }
.badge.gray { background: #eceff1; color: #455a64; }
.alert { padding: .7rem .9rem; border-radius: 8px; background: var(--amber-l); color: #5b3b00; border: 1px solid #f0d49a; }
.alert.error { background: var(--red-l); color: #6e1510; border-color: #f2b8b4; }
.alert.ok { background: var(--green-l); color: var(--green-d); border-color: #b9dcc7; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #14201a; color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 100; max-width: 90vw; }
.toast.error { background: var(--red); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(10,25,18,.5); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow: auto; z-index: 60; }
.modal { background: #fff; border-radius: 12px; padding: 1.2rem; width: min(640px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h2 { margin-bottom: 1rem; }
.modal .actions { margin-top: 1.2rem; display: flex; gap: .6rem; justify-content: flex-end; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #0b4a2c, #11683f 60%, #3b8f63); }
.auth .box { background: #fff; border-radius: 14px; padding: 1.6rem; width: min(430px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth .box h1 { margin-bottom: .2rem; }
.auth form > * + * { margin-top: .8rem; }
.auth .btn { width: 100%; padding: .65rem; }

.bars .bar { height: 8px; background: var(--green-l); border-radius: 6px; overflow: hidden; }
.bars .bar > i { display: block; height: 100%; background: var(--green); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

@media print {
  .side, .topbar, .no-print, .tabs, .toast { display: none !important; }
  .shell { display: block; } body { background: #fff; } .main { padding: 0; max-width: none; }
  .tablewrap { max-height: none; overflow: visible; border: 0; }
  .card { border: 0; padding: 0; }
}

/* progress steps, history, notices */
.steps { list-style: none; margin: .4rem 0 0; padding: 0; }
.steps li { display: flex; gap: .7rem; padding: .35rem 0; position: relative; }
.steps li:not(:last-child)::before { content: ""; position: absolute; left: 11px; top: 28px; bottom: -4px; width: 2px; background: var(--line); }
.steps .dot { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: #fff; }
.steps li.done .dot { background: var(--green); border-color: var(--green); }
.steps li.current .dot { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-l); }
.steps li.fail .dot { background: var(--red); border-color: var(--red); }
.steps li.pending { color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.count { display: inline-block; margin-left: .4rem; min-width: 1.3rem; padding: 0 .35rem; border-radius: 99px; background: #e8590c; color: #fff; font-size: .75rem; font-weight: 700; text-align: center; }
.notice.unread { border-left: 4px solid var(--green); background: #f7fbf9; }
.alert.ok { background: var(--green-l); }
