/* ===========================================================================
   云打印中控台 · design system
   Light/dark via tokens; no external fonts, no inline styles (strict CSP).
   ======================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f5;
  --border: #e4e8ee;
  --border-strong: #d2d9e2;
  --text: #17202b;
  --text-2: #475467;
  --text-3: #78859a;

  --accent: #2f6feb;
  --accent-hover: #255cc7;
  --accent-weak: #eaf0fe;
  --accent-text: #1d4fae;

  --ok: #0f8a5c;
  --ok-weak: #e4f6ed;
  --warn: #96660f;
  --warn-weak: #fdf3e0;
  --danger: #c33b3b;
  --danger-weak: #fdecec;

  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 18px 40px -30px rgba(16, 24, 40, 0.5);

  --sidebar-w: 244px;
  --header-h: 64px;
  --focus: 0 0 0 3px rgba(47, 111, 235, 0.18);
}

:root[data-theme="dark"] {
  --bg: #0f141b;
  --surface: #161d26;
  --surface-2: #1a222c;
  --surface-3: #212b37;
  --border: #26313d;
  --border-strong: #35424f;
  --text: #e8eef6;
  --text-2: #a9b6c6;
  --text-3: #7c8a9c;

  --accent: #5b8dfb;
  --accent-hover: #7aa3fc;
  --accent-weak: #1a2942;
  --accent-text: #a9c5ff;

  --ok: #3db681;
  --ok-weak: #122b21;
  --warn: #d8a340;
  --warn-weak: #2b2313;
  --danger: #ec7070;
  --danger-weak: #2d1819;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 22px 48px -32px rgba(0, 0, 0, 0.8);
  --focus: 0 0 0 3px rgba(91, 141, 251, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b;
    --surface: #161d26;
    --surface-2: #1a222c;
    --surface-3: #212b37;
    --border: #26313d;
    --border-strong: #35424f;
    --text: #e8eef6;
    --text-2: #a9b6c6;
    --text-3: #7c8a9c;

    --accent: #5b8dfb;
    --accent-hover: #7aa3fc;
    --accent-weak: #1a2942;
    --accent-text: #a9c5ff;

    --ok: #3db681;
    --ok-weak: #122b21;
    --warn: #d8a340;
    --warn-weak: #2b2313;
    --danger: #ec7070;
    --danger-weak: #2d1819;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 22px 48px -32px rgba(0, 0, 0, 0.8);
    --focus: 0 0 0 3px rgba(91, 141, 251, 0.28);
  }
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { color-scheme: light dark; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, dt, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
code { font-family: var(--font-mono); font-size: 0.92em; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border-strong); color: var(--text);
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.hash { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { display: inline-block; vertical-align: middle; flex: 0 0 auto; }

.clipboard-shim { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ------------------------------------------------------------- app shell */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.main { min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  position: sticky; top: 0; z-index: 30;
  height: 100vh; display: flex; flex-direction: column; gap: 10px;
  padding: 18px 14px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; }

.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #3f7cf6, #1c49b8);
  color: #fff; flex: 0 0 auto;
  box-shadow: 0 8px 18px -10px rgba(47, 111, 235, 0.9);
}

.brand-text { min-width: 0; }
.brand-name { font-size: 14.5px; font-weight: 650; letter-spacing: 0.2px; }
.brand-sub { margin-top: 2px; font-size: 11px; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding: 2px; }

.nav-label {
  margin: 0 10px 6px; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: 9px; color: var(--text-2); font-weight: 520; font-size: 13.5px;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--accent-weak); color: var(--accent-text); }
.nav-item.is-active .icon { color: var(--accent); }
.nav-text { flex: 1; min-width: 0; }

.nav-badge {
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.nav-item.is-active .nav-badge { background: rgba(47, 111, 235, 0.16); color: var(--accent-text); }

.sidebar-foot {
  margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}

.conn {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 10px; background: var(--surface-2);
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }
.conn-dot.is-ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(15, 138, 92, 0.16); }
.conn-dot.is-error { background: var(--danger); box-shadow: 0 0 0 3px rgba(195, 59, 59, 0.16); }
.conn-dot.is-idle { background: var(--warn); }
.conn-text { flex: 1; min-width: 0; }
.conn-text p { font-size: 12.5px; }
.conn-text p.muted { font-size: 11px; margin-top: 1px; }

.sidebar-links { display: flex; flex-direction: column; }

.link-button {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border: 0; border-radius: 8px; background: none;
  color: var(--text-3); font-size: 12.5px; cursor: pointer; text-align: left;
}
.link-button:hover { background: var(--surface-2); color: var(--text); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  min-height: var(--header-h); padding: 10px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-titles { flex: 1; min-width: 0; }
.topbar-titles h1 { font-size: 18px; font-weight: 650; letter-spacing: 0.2px; }
.topbar-titles p { margin-top: 2px; font-size: 12.5px; color: var(--text-3); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.sync {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  font-size: 12px; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border);
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.sync.is-ok { color: var(--ok); background: var(--ok-weak); border-color: transparent; }
.sync.is-ok .sync-dot { background: var(--ok); }
.sync.is-stale { color: var(--danger); background: var(--danger-weak); border-color: transparent; }
.sync.is-stale .sync-dot { background: var(--danger); }
.sync.is-idle { color: var(--warn); background: var(--warn-weak); border-color: transparent; }
.sync.is-idle .sync-dot { background: var(--warn); }

.content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 22px 28px 36px; flex: 1; }

.app-foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 16px 28px 24px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
}

.nav-toggle, .nav-close { display: none; }
.scrim { display: none; }

.loading-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; margin-bottom: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-3);
}

/* ------------------------------------------------------------------ page */

.page { display: flex; flex-direction: column; gap: 16px; }

.page-footnote { font-size: 12px; color: var(--text-3); }

.eyebrow {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3);
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 13px; border-radius: 9px;
  border: 1px solid transparent; background: transparent;
  font-size: 13.5px; font-weight: 560; white-space: nowrap; cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-square { width: 36px; padding: 0; }
.btn-square.btn-sm { width: 30px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(47, 111, 235, 0.35); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn-secondary:hover:not(:disabled) { border-color: var(--text-3); color: var(--text); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

/* --------------------------------------------------------------- surfaces */

.card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: flex-start; gap: 16px; padding: 15px 18px 10px; }
.card-titles { flex: 1; min-width: 0; }
.card-title { font-size: 14.5px; font-weight: 650; }
.card-subtitle { margin-top: 3px; font-size: 12.5px; color: var(--text-3); }
.card-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.card-body { padding: 6px 18px 18px; }
.card-body.table-body { padding: 0; }

/* -------------------------------------------------------------------- kpi */

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

.kpi {
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.kpi-top { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.kpi-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); }
.kpi-label { font-size: 12.5px; }
.kpi-value { margin: 10px 0 2px; font-size: 29px; font-weight: 660; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 12px; color: var(--text-3); }
.kpi-ok .kpi-value { color: var(--ok); }
.kpi-warn .kpi-value { color: var(--warn); }
.kpi-error .kpi-value { color: var(--danger); }

/* --------------------------------------------------------------- overview */

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.printer-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; }

.printer-tile {
  display: flex; flex-direction: column; gap: 10px;
  padding: 13px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.tile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tile-ident { min-width: 0; }
.tile-name { font-size: 13.5px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-id { margin-top: 2px; font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { display: flex; gap: 18px; }
.tile-meta dt { font-size: 11px; color: var(--text-3); }
.tile-meta dd { margin-top: 2px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tile-actions { display: flex; gap: 6px; margin-top: auto; }

.activity-list { display: flex; flex-direction: column; }
.activity-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: 0; }
.activity-main { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; font-weight: 540; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-meta { margin-top: 2px; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- toolbar */

.toolbar { display: flex; align-items: center; gap: 10px; }
.toolbar-wrap { flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }

.search { position: relative; display: flex; align-items: center; min-width: 230px; }
.search .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 33px; }

.inline-field { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); }
.inline-field .select { width: auto; min-width: 140px; }

/* ----------------------------------------------------------------- inputs */

.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 8px 11px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 9px;
  font-size: 13.5px; transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.textarea { resize: vertical; line-height: 1.55; min-height: 96px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-3); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 560; color: var(--text-2); }
.field-hint { font-size: 11.5px; color: var(--text-3); }
.field-warning {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--warn-weak); color: var(--warn); font-size: 12.5px;
}
.req { padding: 1px 6px; border-radius: 999px; background: var(--danger-weak); color: var(--danger); font-size: 10.5px; font-weight: 600; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 2px; }
.form-note { font-size: 12px; color: var(--text-3); }
.form-error { font-size: 12.5px; color: var(--danger); }

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  align-self: flex-start; max-width: 100%; flex-wrap: wrap;
}
.segmented-item {
  padding: 5px 10px; border: 0; border-radius: 7px; background: transparent;
  color: var(--text-3); font-size: 12.5px; white-space: nowrap; cursor: pointer;
}
.segmented-item:hover { color: var(--text); }
.segmented-item.is-active { background: var(--surface); color: var(--text); font-weight: 560; box-shadow: var(--shadow-sm); }

.disclosure { padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 10px; }
.disclosure summary { cursor: pointer; font-size: 13px; color: var(--text-2); }
.disclosure[open] summary { margin-bottom: 12px; }

/* ------------------------------------------------------------------ pills */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-weak); color: var(--ok); }
.pill-info { background: var(--accent-weak); color: var(--accent-text); }
.pill-warn { background: var(--warn-weak); color: var(--warn); }
.pill-error { background: var(--danger-weak); color: var(--danger); }
.count-pill { padding: 2px 8px; border-radius: 999px; background: var(--surface-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- banners */

.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid transparent;
}
.banner-icon { flex: 0 0 auto; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: rgba(255, 255, 255, 0.45); }
.banner-main { flex: 1; min-width: 0; }
.banner-title { font-size: 13px; font-weight: 620; }
.banner-text { margin-top: 2px; font-size: 12.5px; color: var(--text-2); }
.banner-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.banner-info { background: var(--accent-weak); }
.banner-info .banner-title { color: var(--accent-text); }
.banner-warn { background: var(--warn-weak); }
.banner-warn .banner-title { color: var(--warn); }
.banner-error { background: var(--danger-weak); }
.banner-error .banner-title { color: var(--danger); }
.banner-ok { background: var(--ok-weak); }
.banner-ok .banner-title { color: var(--ok); }
:root[data-theme="dark"] .banner-icon { background: rgba(0, 0, 0, 0.18); }

/* ------------------------------------------------------------------ empty */

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px 16px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--text-3); }
.empty-title { font-size: 13.5px; font-weight: 600; }
.empty-hint { max-width: 400px; font-size: 12.5px; color: var(--text-3); }
.empty-action { margin-top: 4px; }

/* ---------------------------------------------------------------- printers */

.printers-layout { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: 16px; align-items: start; }
.printers-list-card { min-width: 0; }

.printer-rows { display: flex; flex-direction: column; gap: 3px; }
.printer-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; text-align: left; cursor: pointer;
}
.printer-row:hover { background: var(--surface-2); }
.printer-row.is-selected { background: var(--accent-weak); border-color: rgba(47, 111, 235, 0.24); }
.printer-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.printer-row-name { font-size: 13px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.printer-row-id { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.printer-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.printer-row-heartbeat { font-size: 10.5px; }

.printer-detail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.printer-detail .info-grid, .result-body .info-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.info-grid-single { grid-template-columns: 1fr; }
.info-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.info-row-wide { grid-column: 1 / -1; }
.info-row dt { font-size: 11.5px; color: var(--text-3); }
.info-row dd { font-size: 13px; overflow-wrap: anywhere; }
.copy-line { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.detail-note { margin-top: 12px; font-size: 12px; }

.observation-list { display: flex; flex-direction: column; }
.observation-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.observation-row:last-child { border-bottom: 0; }
.observation-main { flex: 1; min-width: 0; }
.observation-key { font-size: 12.5px; overflow-wrap: anywhere; }

/* ----------------------------------------------------------------- table */

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  padding: 10px 14px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover td { background: var(--surface-2); }
.cell-id { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-action { width: 46px; text-align: right; }

/* ---------------------------------------------------------------- drawer */

.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(10, 16, 24, 0.45);
}
.overlay-side { padding: 0; align-items: stretch; justify-content: flex-end; }

.modal {
  width: min(560px, 100%); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 30px 70px -30px rgba(10, 16, 24, 0.65);
}
.modal-wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 16px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.modal-head > div { flex: 1; min-width: 0; }
.modal-head h2 { font-size: 16px; font-weight: 650; }
.modal-description { margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; border-top: 1px solid var(--border); }

.drawer {
  width: min(540px, 100%); height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -30px 0 60px -40px rgba(10, 16, 24, 0.6);
}
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.drawer-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.drawer-section:first-child { padding-top: 0; }
.drawer-section:last-child { border-bottom: 0; }
.drawer-title { margin-bottom: 10px; font-size: 13px; font-weight: 620; color: var(--text-2); }
.drawer-note { margin-top: 6px; font-size: 12.5px; color: var(--text-2); }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-item { display: flex; align-items: flex-start; gap: 10px; color: var(--text-3); }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); margin-top: 5px; flex: 0 0 auto; }
.timeline-item p { font-size: 12.5px; }
.timeline-item.is-done { color: var(--text); }
.timeline-item.is-done .timeline-dot { background: var(--ok); }

.code-block {
  padding: 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto;
}

/* ---------------------------------------------------------------- compose */

.compose-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.compose-preview { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.paper-stage {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 22px 12px 14px; border-radius: 12px; background: var(--surface-2);
}
.paper {
  width: 100%; min-height: 132px; padding: 14px;
  display: flex; align-items: flex-start;
  background: #fff; color: #111827;
  border-radius: 4px;
  box-shadow: 0 14px 30px -18px rgba(16, 24, 40, 0.55);
}
.paper-narrow { max-width: 168px; }
.paper-medium { max-width: 248px; }
.paper-wide { max-width: 320px; }
.paper-content { display: flex; flex-direction: column; gap: 3px; width: 100%; font-size: 12px; line-height: 1.5; }
.paper-title { margin-bottom: 4px; font-size: 13px; font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.paper-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.paper-empty { color: #9ca3af; font-size: 11.5px; }
.paper-placeholder {
  margin-top: 8px; padding: 14px 8px; text-align: center;
  font-size: 10.5px; color: #6b7280;
  border: 1px dashed #bcc3cd; border-radius: 4px;
}
.paper-barcode { letter-spacing: 0.35em; }
.paper-receipt { border-radius: 3px 3px 6px 6px; }
.paper-caption { font-size: 11.5px; color: var(--text-3); }

.preview-state { font-size: 12px; color: var(--text-3); }
.preview-state.is-valid { color: var(--ok); font-weight: 600; }
.preview-meta { margin-top: 14px; }
.note-list { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.note-list li { position: relative; padding-left: 14px; }
.note-list li::before { content: ""; position: absolute; left: 0; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong); }

.result-card { border-left: 3px solid var(--border-strong); }
.result-ok { border-left-color: var(--ok); }
.result-info { border-left-color: var(--accent); }
.result-warn { border-left-color: var(--warn); }
.result-error { border-left-color: var(--danger); }
.result-body { display: flex; flex-direction: column; gap: 10px; }
.result-text { font-size: 13px; color: var(--text-2); }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* --------------------------------------------------------------- settings */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ------------------------------------------------------------------ login */

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 540px) minmax(0, 1fr); }

.login-panel {
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  padding: 56px clamp(28px, 5vw, 64px);
  background: var(--surface);
}
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.login-panel h1 { margin-top: 6px; font-size: 27px; font-weight: 680; letter-spacing: -0.4px; }
.login-lede { font-size: 13.5px; color: var(--text-3); max-width: 420px; }
.login-form { display: flex; flex-direction: column; gap: 12px; max-width: 380px; margin-top: 4px; }
.login-submit { height: 40px; }
.login-points { display: flex; flex-direction: column; gap: 10px; max-width: 430px; margin-top: 4px; }
.login-points li { display: flex; gap: 9px; font-size: 12.5px; color: var(--text-3); }
.login-points .icon { margin-top: 2px; color: var(--text-3); }

.login-aside {
  display: grid; place-items: center; padding: 48px;
  background: radial-gradient(1200px 600px at 20% 10%, #24406e 0%, #14203a 45%, #0e1728 100%);
  color: #dce6f5;
}
.login-aside-inner { max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.login-aside .eyebrow { color: #8fa8cc; }
.login-aside h2 { font-size: 20px; font-weight: 650; color: #f2f7ff; }
.login-aside p { font-size: 13px; line-height: 1.7; color: #c3d2e6; }
.login-aside code { background: rgba(255, 255, 255, 0.1); padding: 1px 5px; border-radius: 5px; }
.login-aside .muted { color: #93a7c1; }

/* ------------------------------------------------------------------ boot */

.boot-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  padding: 24px; text-align: center;
}
.boot-mark {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px;
  background: linear-gradient(150deg, #3f7cf6, #1c49b8); color: #fff;
}
.boot-title { font-size: 15px; font-weight: 620; }
.boot-hint { font-size: 12.5px; color: var(--text-3); }

/* ---------------------------------------------------------------- toasts */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 9px;
  max-width: 400px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--ok);
  border-radius: 10px; box-shadow: var(--shadow); font-size: 12.5px;
}
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--danger); }
.toast .icon { color: var(--ok); }
.toast-warn .icon { color: var(--warn); }
.toast-close { margin-left: auto; display: grid; place-items: center; padding: 2px; border: 0; background: none; color: var(--text-3); cursor: pointer; }

/* --------------------------------------------------------------- spinner */

.spinner {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1100px) {
  .printers-layout, .compose-grid, .settings-grid { grid-template-columns: 1fr; }
  .printers-list-card { position: static; }
}

@media (min-width: 1101px) {
  .printers-list-card { position: sticky; top: calc(var(--header-h) + 22px); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 70;
    transform: translateX(-102%); transition: transform 0.2s ease;
    box-shadow: 0 30px 60px -20px rgba(10, 16, 24, 0.5);
  }
  .app.nav-open .sidebar { transform: none; }

  .nav-toggle {
    display: grid; place-items: center; width: 36px; height: 36px;
    border: 1px solid var(--border); border-radius: 9px;
    background: var(--surface); color: var(--text-2); cursor: pointer;
  }
  .nav-close {
    display: grid; place-items: center; margin-left: auto; padding: 4px;
    border: 0; background: none; color: var(--text-3); cursor: pointer;
  }

  .scrim {
    display: block; position: fixed; inset: 0; z-index: 65;
    padding: 0; border: 0; background: rgba(10, 16, 24, 0.42);
    opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  }
  .scrim.is-open { opacity: 1; pointer-events: auto; }

  .topbar { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .topbar-titles { flex: 1 1 140px; }
  .content { padding: 16px 16px 28px; }
  .app-foot { padding: 14px 16px 22px; flex-direction: column; gap: 4px; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-head { flex-wrap: wrap; }
  .info-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  .sync-text { display: none; }
  .refresh-button span { display: none; }
  .refresh-button { width: 36px; padding: 0; }

  .table th:nth-child(4), .table td:nth-child(4),
  .table th:nth-child(7), .table td:nth-child(7) { display: none; }

  .login-page { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-panel { min-height: 100vh; padding: 36px 22px; }

  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }

  .modal { max-height: calc(100vh - 24px); }
  .overlay { padding: 12px; }
}

@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar-titles p { display: none; }
  .search { min-width: 0; flex: 1 1 100%; }
  .inline-field { flex: 1 1 40%; justify-content: space-between; }
  .inline-field .select { width: 100%; min-width: 0; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .spinner { animation: none; border-top-color: var(--accent); }
}
