:root {
  --ink: #16211d;
  --ink-soft: #5b6b64;
  --line: #d7dfdb;
  --paper: #f3f6f4;
  --card: #ffffff;
  --accent: #0f5c46;
  --accent-soft: #e3efe9;
  --green: #1c8c4d;
  --red: #b4231f;
  --amber: #b5730a;
  --radius: 6px;
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
/*
 * The console shows and hides whole views with the `hidden` attribute. The
 * browser implements that as a user-agent `display: none`, which any author
 * rule setting `display` silently beats: `.shell { display: grid }` alone is
 * enough to leave a hidden view on screen. This rule makes `hidden` mean
 * hidden, whatever else an element's class says.
 */
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 var(--sans); color: var(--ink); background: var(--paper); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 20px; margin: 0 0 14px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 18px 0 8px; }
h3:first-child { margin-top: 0; }
label { display: block; font-size: 12px; color: var(--ink-soft); margin: 10px 0 3px; }
input, select { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, button:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; padding: 7px 14px; cursor: pointer; color: var(--ink); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary.big { padding: 12px 20px; font-size: 15px; }
button.ghost { background: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.hint { font-size: 12px; color: var(--ink-soft); margin: 6px 0; }
.error { color: var(--red); font-size: 13px; margin: 8px 0; }
.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.rra { background: var(--accent-soft); color: var(--accent); font-size: 10px; padding: 1px 5px; border-radius: 3px; letter-spacing: .04em; }

/* ---------------- sign in ---------------- */
.signin { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #0f5c46, #083025); padding: 24px; }
.signin-card { width: 100%; max-width: 380px; background: var(--card); padding: 26px; border-radius: 10px; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700; font-size: 20px; }
.brand-mark.small { width: 26px; height: 26px; font-size: 14px; border-radius: 6px; }
.modes { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 12px; margin: 16px 0 4px; }
.modes legend { font-size: 12px; color: var(--ink-soft); padding: 0 4px; }
.radio { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); margin: 4px 0; }
.radio input { width: auto; }
.radio .hint { margin: 0; }
.totp { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
#signin-code { font-family: var(--mono); letter-spacing: .4em; text-align: center; font-size: 18px; }
.signin-card button.primary { width: 100%; margin-top: 16px; padding: 10px; }
.version { text-align: center; font-size: 11px; color: var(--ink-soft); margin: 14px 0 0; }

/* ---------------- shell ---------------- */
.shell { display: grid; grid-template-columns: 208px 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "banner banner" "top top" "nav content"; min-height: 100vh; }
.banner { grid-area: banner; text-align: center; padding: 7px; font-weight: 700; font-size: 12px; letter-spacing: .1em; }
.banner.training { background: #fde9c4; color: #6d4405; border-bottom: 2px solid var(--amber); }
.banner.service { background: #e1e8f7; color: #1f3a70; border-bottom: 2px solid #2d4f96; }

.topbar { grid-area: top; display: flex; align-items: center; gap: 12px; background: var(--card); border-bottom: 1px solid var(--line); padding: 9px 16px; }
.topbar-title { font-size: 15px; }
.topbar-org { font-size: 12px; color: var(--ink-soft); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--ink-soft); }

.vsdc { display: flex; align-items: center; gap: 8px; margin-left: 20px; border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px 4px 8px; }
.light { width: 12px; height: 12px; border-radius: 50%; background: #b9c4bf; flex: 0 0 auto; }
.light.on { background: var(--green); box-shadow: 0 0 0 3px rgba(28,140,77,.2); }
.light.off { background: var(--red); box-shadow: 0 0 0 3px rgba(180,35,31,.2); }
.vsdc-text { display: flex; flex-direction: column; line-height: 1.2; }
.vsdc-text b { font-size: 12px; }
.vsdc-text small { font-size: 10px; color: var(--ink-soft); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidenav { grid-area: nav; background: var(--card); border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 1px; }
.nav { border: none; background: none; text-align: left; padding: 8px 12px; border-radius: var(--radius); color: var(--ink); }
.nav:hover { background: var(--paper); }
.nav.sub { padding-left: 22px; font-size: 13px; }
.nav.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group { margin: 14px 0 2px; padding: 0 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }

.content { grid-area: content; padding: 20px 24px 60px; max-width: 1180px; }
.screen-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.screen-head h2 { margin: 0; }
.screen-head button { margin-left: auto; }
.screen-head span { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.screen-head label { margin: 0; }
.screen-head input { width: auto; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.panel.narrow { max-width: 460px; margin-top: 18px; }
.row { display: flex; gap: 12px; }
.row > div { flex: 1; }
.check { display: flex; align-items: flex-end; }
.check label { margin: 0; display: flex; gap: 6px; align-items: center; color: var(--ink); }
.check input, .switch input { width: auto; }
.switch { display: flex; gap: 8px; align-items: center; margin: 8px 0; color: var(--ink); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

table.lines { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.lines th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafcfb; }
table.lines td { padding: 7px 10px; border-bottom: 1px solid #eef2f0; font-variant-numeric: tabular-nums; }
table.lines tr:last-child td { border-bottom: none; }
table.lines tr.empty td { color: var(--ink-soft); text-align: center; padding: 18px; }
table.lines input { padding: 4px 6px; }
table.lines td button { padding: 3px 9px; font-size: 12px; }
.total { font-size: 22px; font-weight: 700; text-align: right; margin: 14px 0 0; font-variant-numeric: tabular-nums; }
.total small { font-size: 12px; color: var(--ink-soft); font-weight: 400; }

.slip { font-family: var(--mono); font-size: 12px; line-height: 1.35; white-space: pre; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; overflow-x: auto; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }

.toast { position: fixed; top: 74px; right: 24px; background: var(--ink); color: #fff; padding: 9px 14px; border-radius: var(--radius); z-index: 40; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 420px; }
.toast.bad { background: var(--red); }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 430px; background: var(--paper); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; box-shadow: -10px 0 30px rgba(0,0,0,.12); z-index: 30; }
.drawer-head { display: flex; align-items: center; margin-bottom: 12px; }
.drawer-head button { margin-left: auto; }
/* The drawer shows the receipt exactly as the print layer renders it, scaled to fit. */
.preview { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #e9ecea; }
.preview iframe { display: block; border: 0; width: 100%; transform-origin: 0 0; background: #e9ecea; }

.paper { display: flex; align-items: center; gap: 6px; margin: 0 0 0 12px; font-size: 12px; color: var(--ink-soft); }
.paper select { width: auto; padding: 4px 6px; font-size: 12px; }
.lookup { display: block; font-size: 11px; margin-top: 3px; color: var(--accent); }
.lookup.bad { color: var(--red); }
.audit-gap { margin-top: 18px; }
.status { font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 2px 7px; border-radius: 10px; background: var(--paper); color: var(--ink-soft); }
.status.ok { background: var(--accent-soft); color: var(--accent); }
.status.bad { background: #fbe4e3; color: var(--red); }
.status.wait { background: #fdf0d8; color: #7a4d06; }
table.lines td select, table.lines td input { width: 100%; min-width: 90px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "banner" "top" "nav" "content"; }
  .sidenav { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .nav-group { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}

/*
 * Documents print through the print layer only (the Print buttons), never as a
 * screenshot of the console: an original receipt must go to the printer once
 * (CIS art. 7.18), and that is counted where it is printed.
 */
@media print {
  body { background: #fff; }
  .topbar, .sidenav, .banner, .toast, .actions, .drawer { display: none !important; }
  .slip { border: none; padding: 0; }
}
