:root {
  --bg: #f3f4f1; --surface: #ffffff; --surface-2: #f8f9f6; --line: #e2e5df; --line-2: #d3d7cf;
  --ink: #1a1e1b; --ink-2: #474e49; --muted: #79807a;
  --accent: #15603a; --accent-ink: #ffffff; --accent-soft: #e4f1e9;
  --ok: #1d8348; --ok-bg: #e3f3e8; --warn: #a96300; --warn-bg: #fcefd8; --crit: #c42f28; --crit-bg: #fbe4e2;
  --info: #2c5cad; --info-bg: #e5ecf8; --off: #9aa19b; --violet: #6d45b8; --violet-bg: #efe8fa;
  --side: #0f1f17; --side-ink: #cfe0d5; --side-muted: #7f978a; --side-on: #1d3a2a;
  --chat-bg: #8fa9c4; --bubble: #ffffff; --bubble-ink: #111;
  --radius: 10px; --shadow: 0 1px 2px rgba(18, 24, 20, .06);
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101311; --surface: #171b18; --surface-2: #1c211d; --line: #283029; --line-2: #343d36;
    --ink: #e6eae6; --ink-2: #b4bbb5; --muted: #848c86;
    --accent: #43b86f; --accent-ink: #08130c; --accent-soft: #15301f;
    --ok: #4cc27c; --ok-bg: #15301f; --warn: #e3a240; --warn-bg: #33260e; --crit: #f06a61; --crit-bg: #3a1a17;
    --info: #7fa6ec; --info-bg: #17233a; --off: #5f6761; --violet: #b38ef0; --violet-bg: #2a2140;
    --side: #0b120e; --side-ink: #cfe0d5; --side-muted: #6f857a; --side-on: #183024;
    --chat-bg: #2b3a4b; --bubble: #2a2f2b; --bubble-ink: #eef1ee;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101311; --surface: #171b18; --surface-2: #1c211d; --line: #283029; --line-2: #343d36;
  --ink: #e6eae6; --ink-2: #b4bbb5; --muted: #848c86;
  --accent: #43b86f; --accent-ink: #08130c; --accent-soft: #15301f;
  --ok: #4cc27c; --ok-bg: #15301f; --warn: #e3a240; --warn-bg: #33260e; --crit: #f06a61; --crit-bg: #3a1a17;
  --info: #7fa6ec; --info-bg: #17233a; --off: #5f6761; --violet: #b38ef0; --violet-bg: #2a2140;
  --side: #0b120e; --side-ink: #cfe0d5; --side-muted: #6f857a; --side-on: #183024;
  --chat-bg: #2b3a4b; --bubble: #2a2f2b; --bubble-ink: #eef1ee;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
[hidden] { display: none !important; }

/* shell */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 600; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand small { display: block; font-weight: 400; color: var(--side-muted); font-size: 11.5px; line-height: 1.2; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .grp { font-size: 11px; color: var(--side-muted); padding: 12px 10px 4px; letter-spacing: .02em; }
.nav .it { all: unset; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--side-ink); font-size: 13.5px; }
.nav .it svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav .it:hover { background: rgba(255,255,255,.05); }
.nav .it[aria-current="page"] { background: var(--side-on); color: #fff; }
.nav .it[aria-current="page"] svg { opacity: 1; }
.nav .it:focus-visible { outline: 2px solid #8fd3a8; }
.nav .badge { margin-left: auto; font-size: 11px; font-family: var(--mono); background: rgba(255,255,255,.1); border-radius: 99px; padding: 0 7px; }
.nav .badge.crit { background: #c42f28; color: #fff; }
.nav .badge.warn { background: #a96300; color: #fff; }
.side .foot { margin-top: auto; padding: 12px 8px 2px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: var(--side-muted); display: flex; flex-direction: column; gap: 6px; }
.side .foot .srv { display: flex; align-items: center; gap: 7px; color: var(--side-ink); }

.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .in { display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 22px; }
.top h1 { margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; }
.top .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.search { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 10px; width: 220px; max-width: 40vw; }
.content { padding: 16px 22px 48px; max-width: 1380px; }
.demo { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12.5px; color: var(--ink-2); padding: 8px 12px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 14px; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: auto; z-index: 20; flex-direction: row; align-items: center; padding: 8px 10px; gap: 8px; overflow: visible; }
  .brand { padding: 0; } .brand span { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .nav .grp, .side .foot { display: none; }
  .nav .it { white-space: nowrap; padding: 6px 10px; }
  .nav .it svg { display: none; }
  .top { position: static; }
  .top .in { padding: 0 16px; height: auto; min-height: 54px; flex-wrap: wrap; padding-block: 8px; }
  .content { padding: 14px 16px 40px; }
  .search { width: 160px; }
}

/* cards & grid */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.g2e { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mt { margin-top: 14px; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .g2, .g2e { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) { .g4 { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card > header { display: flex; align-items: center; gap: 8px; padding: 12px 14px 0; flex-wrap: wrap; }
.card > header h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card > header .right { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card .body { padding: 12px 14px 14px; }
.count { font-size: 12px; padding: 0 7px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-family: var(--mono); }
.kpi { padding: 13px 14px; display: flex; flex-direction: column; gap: 4px; cursor: default; }
.kpi.link { cursor: pointer; } .kpi.link:hover { border-color: var(--line-2); }
.kpi .label { font-size: 12.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 6px; }
.kpi .big { font-family: var(--mono); font-size: 26px; line-height: 1.15; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .big small { font-size: 13px; color: var(--muted); margin-left: 3px; letter-spacing: 0; font-family: var(--font); }
.kpi .sub { font-size: 12px; color: var(--muted); }

/* pills, dots, bars */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 99px; white-space: nowrap; font-weight: 500; }
.pill.ok { color: var(--ok); background: var(--ok-bg); } .pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.crit { color: var(--crit); background: var(--crit-bg); } .pill.info { color: var(--info); background: var(--info-bg); }
.pill.off { color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); } .pill.violet { color: var(--violet); background: var(--violet-bg); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--off); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); }
.bar { position: relative; height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); min-width: 70px; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--ok); }
.bar > span.warn { background: var(--warn); } .bar > span.crit { background: var(--crit); }
.days { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.days.warn { color: var(--warn); font-weight: 500; } .days.crit { color: var(--crit); font-weight: 500; }

/* buttons */
.btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 5px 12px; cursor: pointer; font-size: 13px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--crit); }
.btn.sm { padding: 2px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: none; }
.iconbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface-2); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 2px 10px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* tables */
.tablewrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover td { background: var(--surface-2); }
td .t { font-weight: 500; } td small { display: block; color: var(--muted); font-size: 11.5px; }
.r { text-align: right; } .nowrap { white-space: nowrap; }

/* todo */
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; padding-top: 2px; }
.todo .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; }
.todo .ic.crit { background: var(--crit-bg); } .todo .ic.warn { background: var(--warn-bg); } .todo .ic.info { background: var(--info-bg); } .todo .ic.violet { background: var(--violet-bg); } .todo .ic.ok { background: var(--ok-bg); }
.todo .t { font-weight: 500; } .todo small { display: block; color: var(--muted); font-size: 12px; }

/* bars chart */
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 170px; padding-top: 10px; }
.bars .b { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b span { width: 100%; max-width: 28px; border-radius: 5px 5px 2px 2px; background: color-mix(in srgb, var(--accent) 70%, transparent); min-height: 2px; position: relative; }
.bars .b.cur span { background: var(--accent); }
.bars .b i { font-style: normal; font-size: 10.5px; color: var(--muted); }
.bars .b span:hover::after { content: attr(data-v); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); font-size: 11px; padding: 2px 6px; border-radius: 5px; white-space: nowrap; font-family: var(--mono); }

/* kanban */
.flow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.flow span.s { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 3px 9px; }
.flow i { font-style: normal; color: var(--muted); }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-width: 0; }
.col > h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.col > h3 .count { margin-left: auto; }
.rcard { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 5px; }
.rcard + .rcard { margin-top: 8px; }
.rcard .t { font-weight: 500; font-size: 13.5px; } .rcard .c { font-size: 12px; color: var(--ink-2); }
.rcard .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; align-items: center; }
.rcard .next { font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 5px; }
.rcard .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.col .empty { color: var(--muted); font-size: 12.5px; padding: 14px 4px; text-align: center; }

/* forms */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: minmax(0, 1fr); } }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
label.f input, label.f select, label.f textarea, .in-tbl input, .in-tbl select { border: 1px solid var(--line-2); background: var(--surface-2); border-radius: 7px; padding: 6px 9px; font-size: 13.5px; color: var(--ink); min-width: 0; width: 100%; }
label.f textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; } .row small { display: block; color: var(--muted); font-size: 11.5px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { font-size: 11.5px; border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; background: var(--surface-2); color: var(--ink-2); font-family: var(--mono); }
button.chip { cursor: pointer; }
.switch { position: relative; width: 36px; height: 20px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-2); cursor: pointer; transition: .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--info); outline-offset: 2px; }
.note { font-size: 12.5px; color: var(--ink-2); background: var(--info-bg); border-radius: 8px; padding: 8px 11px; }
.note.warn { background: var(--warn-bg); } .note.crit { background: var(--crit-bg); }

/* dialog */
dialog { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog.wide { width: min(980px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 16, 12, .45); }
dialog .dh { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog .dh h2 { margin: 0; font-size: 15px; font-weight: 600; }
dialog .dh .x { margin-left: auto; }
dialog .db { padding: 16px 18px; }
dialog .df { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); position: sticky; bottom: 0; flex-wrap: wrap; }

/* document (A4) */
.paper { background: #fff; color: #1b1b1b; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.12); padding: 34px 38px; font-size: 13px; line-height: 1.6; max-width: 794px; margin: 0 auto; }
.paper .dhd { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.paper .co { display: flex; gap: 12px; align-items: center; }
.paper .co svg { width: 42px; height: 42px; }
.paper .co b { font-size: 16px; display: block; }
.paper .co small, .paper .meta small { color: #666; font-size: 11.5px; display: block; }
.paper h3 { margin: 0; font-size: 22px; color: #15603a; text-align: right; font-weight: 600; }
.paper .meta { text-align: right; font-size: 12.5px; }
.paper .billto { margin: 22px 0 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.paper .billto div { background: #f5f7f4; border-radius: 6px; padding: 10px 12px; }
.paper .billto b { display: block; font-size: 11px; color: #666; font-weight: 500; }
.paper table th { color: #555; border-bottom: 1.5px solid #222; font-size: 12px; }
.paper table td { border-bottom: 1px solid #e5e5e5; }
.paper .tot { margin-left: auto; width: 290px; margin-top: 10px; }
.paper .tot div { display: flex; justify-content: space-between; padding: 3px 0; }
.paper .tot .g { border-top: 1.5px solid #222; margin-top: 4px; padding-top: 7px; font-weight: 600; font-size: 15px; }
.paper .words { margin-top: 8px; text-align: right; font-size: 12.5px; color: #333; }
.paper .pay { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; font-size: 12px; color: #444; }
.paper .stamp { display: inline-block; border: 2px solid #c42f28; color: #c42f28; font-weight: 600; padding: 2px 10px; border-radius: 6px; transform: rotate(-6deg); font-size: 14px; }
.paper .stamp.paid { border-color: #1d8348; color: #1d8348; }
@media (max-width: 560px) { .paper { padding: 20px 16px; } .paper .dhd, .paper .billto, .paper .pay { grid-template-columns: 1fr; flex-direction: column; } .paper h3, .paper .meta { text-align: left; } .paper .tot { width: 100%; } }

/* preview: email + line */
.mail { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mail .mh { background: var(--surface-2); padding: 9px 12px; font-size: 12.5px; border-bottom: 1px solid var(--line); }
.mail .mh b { font-weight: 600; }
.mail .mb { padding: 12px 14px; white-space: pre-wrap; font-size: 13px; line-height: 1.65; }
.chat { background: var(--chat-bg); border-radius: 10px; padding: 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 6px; align-items: flex-end; }
.msg .b { background: var(--bubble); color: var(--bubble-ink); border-radius: 4px 14px 14px 14px; padding: 8px 11px; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; min-width: 0; }
.msg time { font-size: 10px; color: #f1f4f8; flex: none; }

/* finance */
.fin { width: 100%; height: auto; display: block; overflow: visible; margin-top: 6px; }
.fin .gl { stroke: var(--line); } .fin .ax { fill: var(--muted); font-size: 10.5px; font-family: var(--mono); }
.fin .bi { fill: color-mix(in srgb, var(--ok) 75%, transparent); } .fin .bo { fill: color-mix(in srgb, var(--crit) 65%, transparent); }
.fin .cum { fill: none; stroke: var(--info); stroke-width: 2; } .fin .cumdot { fill: var(--info); }
.fin rect:hover { opacity: .8; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hb { display: grid; grid-template-columns: minmax(0, 1fr) 2fr 128px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.hb .track { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.hb .track span { display: block; height: 100%; border-radius: 99px; }
.amt-in { color: var(--ok); } .amt-out { color: var(--crit); }
.crit-note { font-size: 11.5px; color: var(--crit); }
.grp-h { font-size: 12px; color: var(--muted); font-weight: 500; margin: 14px 0 4px; }
.grp-h:first-child { margin-top: 0; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 9px; font-size: 13px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 100; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }

@media print {
  body * { visibility: hidden; }
  .paper, .paper * { visibility: visible; }
  .paper { position: absolute; left: 0; top: 0; box-shadow: none; max-width: none; width: 100%; }
  dialog { box-shadow: none; }
}

/* ===================== hub (server-rendered) additions ===================== */
/* shell */
.nav a.it:hover, a.brand:hover, .side .foot a:hover { text-decoration: none; }
.nav .it span:first-of-type { flex: 1; min-width: 0; }
.side .foot a.srv { color: var(--side-ink); }
.side .foot form { display: inline; }
.linkbtn { all: unset; cursor: pointer; color: var(--side-ink); }
.linkbtn:hover { text-decoration: underline; }
.mobile-only { display: none; }
@media (max-width: 960px) { .mobile-only { display: inline-flex; } }
.top form { display: contents; }
.iconbtn svg { width: 16px; height: 16px; }
.flash { margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); }
.hdr-note { font-size: 12px; }
.small-note { font-size: 12px; margin: 10px 0 0; }
.mt-s { margin-top: 8px; }
.empty-row { text-align: center; color: var(--muted); padding: 22px 0; }
.pre { white-space: pre-wrap; }
.dim td { opacity: .55; }
a.card { color: inherit; } a.card:hover { text-decoration: none; border-color: var(--line-2); }
a.rcard { color: inherit; } a.rcard:hover { text-decoration: none; border-color: var(--line-2); }
a.btn { color: inherit; text-decoration: none; }
a.btn.primary { color: var(--accent-ink); }
a.row-link { color: inherit; } a.row-link:hover { color: var(--info); text-decoration: none; }
form.inline { display: inline; }
td form, .row form, .card > header form, .acts form, .todo form, .df form { display: inline; }
.card > header .right .search { width: 200px; }
.kpi .big.warn { color: var(--warn); } .kpi .big.crit { color: var(--crit); }

/* segmented links (filters) */
.seg a { padding: 2px 10px; border-radius: 6px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg a .num { color: var(--muted); font-size: 11.5px; }

/* forms */
.err { color: var(--crit); font-size: 12px; }
label.f.bad input, label.f.bad textarea, label.f.bad select { border-color: var(--crit); }
label.f .hint { color: var(--muted); font-size: 11.5px; }
.req { color: var(--crit); }
div.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
label.check.inline { display: inline-flex; margin-left: 10px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.actions form { display: inline; }
.h3 { font-size: 13px; margin: 0 0 6px; font-weight: 600; }
.sec { margin-top: 18px; } .sec:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--crit) 35%, var(--line)); }
.danger-zone .fields { align-items: end; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dlg-lead { margin: 0 0 12px; }
dialog .db .fields + .note { margin-top: 12px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); }
.login .brand { color: var(--ink); padding: 18px 18px 0; }
.login .brand span { display: block; }
.login .brand small { color: var(--muted); }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login .btn { justify-content: center; padding: 8px 12px; }

/* bars and meters drawn with SVG (no inline styles under the CSP) */
svg.meter { width: 100%; height: 6px; display: block; margin: 3px 0; }
svg.meter .bg { fill: var(--surface-2); stroke: var(--line); stroke-width: .5; }
svg.meter .fg { fill: var(--ok); } svg.meter .fg.warn { fill: var(--warn); } svg.meter .fg.crit { fill: var(--crit); }
.usage { min-width: 150px; }
.hb svg.track { width: 100%; height: 8px; display: block; }
.hb svg.track .ti { fill: var(--ok); } .hb svg.track .to { fill: var(--crit); }
.hb svg.track rect { opacity: .85; }

/* charts */
.legend .lg-in { background: color-mix(in srgb, var(--ok) 75%, transparent); }
.legend .lg-out { background: color-mix(in srgb, var(--crit) 65%, transparent); }
.legend .lg-cum { background: var(--info); height: 3px; vertical-align: 3px; }
.legend .lg-cpu { background: var(--info); } .legend .lg-mem { background: var(--violet); } .legend .lg-disk { background: var(--warn); }
.fin .zero { stroke: var(--ink-2); opacity: .4; }
.fin polyline.ln-cpu, .fin polyline.ln-mem, .fin polyline.ln-disk { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.fin .ln-cpu { stroke: var(--info); } .fin .ln-mem { stroke: var(--violet); } .fin .ln-disk { stroke: var(--warn); }

/* todo list on the overview */
.todo .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.todo li > span:nth-child(2) { min-width: 0; }
.todo .ic.off { background: var(--surface-2); }

/* kanban */
.kanban .col { align-self: start; }
.col-tools { margin-bottom: 8px; }

/* documents */
.doc-actions { justify-content: flex-start; align-items: center; margin-top: 0; }
.doc-actions .grow { flex: 1; }
.items-tbl td { padding-right: 8px; }
.items-tbl .w-full { min-width: 260px; }
.items-tbl .w-qty { width: 70px; text-align: right; }
.items-tbl .w-price, .sumbox .w-price { width: 120px; text-align: right; }
.iconbtn.sm { width: 28px; height: 28px; font-size: 12px; }
.svc-chips { margin: 4px 0 10px; }
.sumbox { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.sumbox > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sumbox > div > label, .sumbox > div > span { color: var(--ink-2); }
.sumbox select { border: 1px solid var(--line-2); background: var(--surface-2); border-radius: 7px; padding: 5px 8px; margin-left: auto; }
.sumbox .w-price { border: 1px solid var(--line-2); background: var(--surface-2); border-radius: 7px; padding: 5px 9px; }
.sumbox .g { border-top: 1px solid var(--line); padding-top: 8px; font-size: 15px; }
.sumbox .g b { font-size: 17px; }
.sumbox .words { justify-content: flex-end; font-size: 12px; color: var(--muted); }
.paper .logo { width: 96px; height: auto; flex: none; }
.paper h3 small { display: block; font-size: 12px; color: #666; font-weight: 500; letter-spacing: .08em; }
.paper .meta b.num { white-space: nowrap; }
.paper .billto div { line-height: 1.55; }
.paper .muted-p { color: #666; }
.paper td, .paper th { padding: 7px 8px; }
.paper .c { text-align: center; width: 36px; }
.paper .sign { text-align: right; }
.pay-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .pay-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .pay-fields { grid-template-columns: minmax(0, 1fr); } }
.tf-sum { font-weight: 600; }
tfoot td { padding-top: 8px; border-bottom: 0; }

/* notifications preview */
.linkcode b { font-size: 18px; letter-spacing: .12em; margin: 0 6px; }
.chat.off { opacity: .45; }
.wrap { word-break: break-all; }
body.public { background: #e9ece8; }
.public-wrap { max-width: 860px; margin: 0 auto; padding: 16px; }
.public-wrap .doc-actions { margin-bottom: 12px; }
.ledger-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .ledger-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .side, .top, .doc-actions, .no-print, .flash { display: none !important; }
  .app { display: block; } .content { padding: 0; }
  .paper { position: static; padding: 0; border-radius: 0; }
}
.doc-no { font-size: 11.5px; }
.top form.mobile-only { display: none; } @media (max-width: 960px) { .top form.mobile-only { display: contents; } }
.dot.info { background: var(--info); }
.chip-ok { color: var(--ok); } .chip-off { opacity: .6; }
.mb { margin-bottom: 10px; }
.mail.off { opacity: .45; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.row .w-days { width: 76px; text-align: right; }
.row .w-steps { width: 120px; text-align: right; }
.in-tbl td { padding-right: 8px; }
.fin .hov { fill: transparent; }
.fin .hov:hover { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
.fin polyline.ln-rx, .fin polyline.ln-tx { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.fin .ln-rx { stroke: var(--ok); } .fin .ln-tx { stroke: var(--info); }
.legend .lg-rx { background: var(--ok); } .legend .lg-tx { background: var(--info); }
.net-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.net-stats b { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.chart-h { font-size: 12.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
#history.loading .body { opacity: .5; transition: opacity .15s; }
.fin .dot-ln-cpu { fill: var(--info); } .fin .dot-ln-mem { fill: var(--violet); } .fin .dot-ln-disk { fill: var(--warn); }
.fin .dot-ln-rx { fill: var(--ok); } .fin .dot-ln-tx { fill: var(--info); }

/* toast (action result) */
.toast { pointer-events: auto; cursor: pointer; max-width: min(560px, calc(100% - 32px)); text-align: left; line-height: 1.5; box-shadow: 0 6px 24px rgba(0,0,0,.25); transition: opacity .4s; }
.toast.ok { background: var(--accent); color: var(--accent-ink); }
.toast.warn { background: var(--warn); color: #fff; }
.toast.crit { background: var(--crit); color: #fff; }
.toast.info { background: var(--info); color: #fff; }
.toast:not(.show) { pointer-events: none; }
.live-stamp { font-size: 12px; color: var(--muted); }
.live-stamp::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live-stamp::before { animation: none; } }
.renew-opt { font-size: 12px; color: var(--ink-2); margin-top: 4px; }

.payqr { margin-top: 10px; } .payqr img { width: 150px; height: auto; display: block; border: 1px solid #ddd; border-radius: 6px; }
.qr-prev img { height: auto; border: 1px solid var(--line); border-radius: 8px; margin: 4px 0 10px; display: block; }
.qr-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.payqr small { display: block; margin-top: 4px; color: #555; font-size: 11.5px; line-height: 1.4; } .payqr svg { display: block; border: 1px solid #ddd; border-radius: 6px; }

/* disk and inode usage per partition */
.usebar { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.usebar svg.meter { flex: 1; min-width: 70px; }
.usebar .num { min-width: 46px; text-align: right; font-weight: 600; }
.usebar .num.warn { color: var(--warn); }
.usebar .num.crit { color: var(--crit); }
