/* ==========================================================================
   Cruze System Window – ERP UI
   Light/dark, desktop + mobile
   ========================================================================== */

:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --border: #dde5ef;
  --border-strong: #c9d5e5;
  --text: #101b2d;
  --muted: #5c6f88;
  --faint: #8b9bb0;

  --nav: #0b1727;
  --nav-2: #101f33;
  --nav-line: #1e3149;
  --nav-text: #9fb3cc;
  --nav-text-strong: #eaf1fb;

  --accent: #0d9488;
  --accent-strong: #0b7a70;
  --accent-soft: #e6f6f4;
  --blue: #2563eb;
  --amber: #d97706;
  --violet: #7c3aed;
  --red: #dc2626;
  --green: #0f9d58;
  --cyan: #0891b2;
  --orange: #ea580c;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 27, 45, 0.06), 0 1px 3px rgba(16, 27, 45, 0.04);
  --shadow: 0 10px 30px -12px rgba(16, 27, 45, 0.25);
  --shadow-lg: 0 24px 60px -20px rgba(11, 23, 39, 0.45);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0a1220;
  --surface: #101a2b;
  --surface-2: #0d1624;
  --surface-3: #172437;
  --border: #1f2f47;
  --border-strong: #2b405d;
  --text: #e8eefc;
  --muted: #93a6c2;
  --faint: #6f84a2;
  --nav: #070f1b;
  --nav-2: #0c1828;
  --nav-line: #1a2a41;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --accent-soft: #0f2b2a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------- layout --------------------------------- */

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

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--nav) 0%, var(--nav-2) 100%);
  color: var(--nav-text);
  border-right: 1px solid var(--nav-line);
  z-index: 60;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 18px 18px 16px; border-bottom: 1px solid var(--nav-line); }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 38px;
  background: linear-gradient(140deg, #14b8a6, #0b7a70);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 16px -6px rgba(20, 184, 166, 0.9);
}
.brand-name { font-weight: 700; font-size: 15px; color: var(--nav-text-strong); letter-spacing: .2px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--nav-text); opacity: .8; letter-spacing: .5px; text-transform: uppercase; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-label { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: #5f7692; padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px; margin-bottom: 2px;
  color: var(--nav-text); font-weight: 500; font-size: 13.5px;
  cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--nav-text-strong); text-decoration: none; }
.nav-item.active { background: rgba(45, 212, 191, 0.14); color: #7ff0e4; box-shadow: inset 2px 0 0 #2dd4bf; }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.nav-count { margin-left: auto; background: rgba(255,255,255,.12); font-size: 11px; padding: 1px 7px; border-radius: 20px; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--nav-line); }
.side-user { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.side-user .avatar { width: 34px; height: 34px; font-size: 12px; }
.side-user-name { color: var(--nav-text-strong); font-weight: 600; font-size: 13px; line-height: 1.2; }
.side-user-role { font-size: 11px; color: var(--nav-text); }
.side-clock { display: flex; justify-content: space-between; font-size: 11px; color: var(--nav-text); padding: 8px 10px 2px; font-variant-numeric: tabular-nums; }

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

.header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-title { min-width: 0; }
.header-title h1 { font-size: 18px; margin: 0; font-weight: 680; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-title .crumb { font-size: 11.5px; color: var(--muted); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content { padding: 20px 22px 40px; max-width: 1480px; width: 100%; margin: 0 auto; }

.hamburger { display: none; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: 13px;
  padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-strong)); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-dark { background: var(--nav-2); border-color: var(--nav-2); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: #fff; border-color: #fecdd3; color: var(--red); }
.btn-danger:hover { background: #fff1f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 11px 18px; font-size: 14px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 600; cursor: pointer; box-shadow: none; }
.btn-link:hover { text-decoration: underline; background: none; }

.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; position: relative; color: var(--muted); box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.dot-badge { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; border-radius: 9px; background: var(--red); color: #fff; font-size: 9.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 12.5px; color: #fff; background: #475569; letter-spacing: .3px;
}
.avatar--sm { width: 30px; height: 30px; font-size: 10.5px; }
.avatar--lg { width: 52px; height: 52px; font-size: 16px; }

/* -------------------------------- cards --------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 14.5px; font-weight: 680; letter-spacing: -.1px; }
.card-head .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 18px; }
.card-body.tight { padding: 10px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 10px; align-items: center; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi .kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.kpi .kpi-value { font-size: 24px; font-weight: 720; letter-spacing: -.6px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .kpi-icon { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi .kpi-icon svg { width: 18px; height: 18px; }
.tone-teal { background: var(--accent-soft); color: var(--accent-strong); }
.tone-blue { background: #e8efff; color: var(--blue); }
.tone-amber { background: #fef3e2; color: var(--amber); }
.tone-violet { background: #f1ebff; color: var(--violet); }
.tone-red { background: #feecec; color: var(--red); }
.tone-green { background: #e7f7ee; color: var(--green); }
[data-theme="dark"] .tone-blue { background: #14233f; }
[data-theme="dark"] .tone-amber { background: #2c2113; }
[data-theme="dark"] .tone-violet { background: #241a3d; }
[data-theme="dark"] .tone-red { background: #331518; }
[data-theme="dark"] .tone-green { background: #10291c; }

/* -------------------------------- badges -------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 650; letter-spacing: .2px;
  padding: 2.5px 9px; border-radius: 20px; white-space: nowrap;
  background: var(--surface-3); color: var(--muted); border: 1px solid transparent;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge[data-tone="slate"] { background: #eef2f7; color: #52627a; }
.badge[data-tone="amber"] { background: #fff5e5; color: #b45309; }
.badge[data-tone="blue"] { background: #e9f0ff; color: #1d4ed8; }
.badge[data-tone="violet"] { background: #f3ecff; color: #6d28d9; }
.badge[data-tone="teal"] { background: #e2f8f4; color: #0f766e; }
.badge[data-tone="green"] { background: #e5f8ec; color: #047857; }
.badge[data-tone="red"] { background: #ffe9e9; color: #b91c1c; }
.badge[data-tone="cyan"] { background: #e3f5fb; color: #0e7490; }
.badge[data-tone="orange"] { background: #fff0e5; color: #c2410c; }
[data-theme="dark"] .badge[data-tone="slate"] { background: #1b2a3d; color: #a9bcd4; }
[data-theme="dark"] .badge[data-tone="amber"] { background: #33260f; color: #fbbf24; }
[data-theme="dark"] .badge[data-tone="blue"] { background: #16233f; color: #93b4ff; }
[data-theme="dark"] .badge[data-tone="violet"] { background: #241a3d; color: #c4b5fd; }
[data-theme="dark"] .badge[data-tone="teal"] { background: #0d2b2a; color: #5eead4; }
[data-theme="dark"] .badge[data-tone="green"] { background: #0f2a1d; color: #6ee7a8; }
[data-theme="dark"] .badge[data-tone="red"] { background: #331518; color: #fca5a5; }
[data-theme="dark"] .badge[data-tone="cyan"] { background: #0c2a33; color: #67e8f9; }
[data-theme="dark"] .badge[data-tone="orange"] { background: #331d10; color: #fdba74; }
.badge--plain::before { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600;
  cursor: pointer; color: var(--muted);
}
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip:hover { border-color: var(--border-strong); }

/* -------------------------------- tables -------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--faint); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .strong { font-weight: 640; }
.table .muted { color: var(--muted); font-size: 12px; }
.table tfoot td { background: var(--surface-2); font-weight: 650; }

/* -------------------------------- forms --------------------------------- */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 620; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--faint); }
.input, .field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 14px; outline: none; transition: border .15s, box-shadow .15s;
}
.field textarea { min-height: 74px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.search {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 0 12px; background: var(--surface); min-width: 220px; height: 38px;
}
.search input { border: 0; outline: none; background: transparent; width: 100%; font-size: 13.5px; }
.search svg { width: 16px; height: 16px; color: var(--faint); }

/* --------------------------------- tabs --------------------------------- */

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; padding: 8px 13px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { background: var(--surface); color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab .n { font-size: 11px; background: var(--surface-3); padding: 1px 6px; border-radius: 10px; margin-left: 4px; }

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

.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 21px; letter-spacing: -.4px; font-weight: 700; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); font-weight: 700; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .empty-icon { width: 46px; height: 46px; margin: 0 auto 10px; color: var(--faint); opacity: .8; }
.empty h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.empty p { margin: 0 0 14px; font-size: 13px; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ------------------------------- stepper -------------------------------- */

.stepper { display: flex; gap: 0; overflow-x: auto; padding: 2px 0 6px; }
.step { display: flex; align-items: center; gap: 8px; min-width: max-content; }
.step-dot {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; border: 2px solid var(--border-strong); color: var(--faint); background: var(--surface);
}
.step-label { font-size: 11.5px; font-weight: 600; color: var(--faint); }
.step-bar { width: 26px; height: 2px; background: var(--border); margin: 0 6px; }
.step.done .step-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.done .step-label { color: var(--text); }
.step.current .step-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step.current .step-label { color: var(--accent-strong); }
.step.done + .step-bar, .step-bar.done { background: var(--accent); }

/* ------------------------------ timeline -------------------------------- */

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 2px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; padding: 0 0 16px 12px; }
.tl-item::before {
  content: ""; position: absolute; left: -18px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.tl-item[data-act="CREATE"]::before { border-color: var(--green); }
.tl-item[data-act="UPDATE"]::before { border-color: var(--blue); }
.tl-item[data-act="DELETE"]::before { border-color: var(--red); }
.tl-item[data-act="LOGIN"]::before, .tl-item[data-act="LOGOUT"]::before { border-color: var(--faint); }
.tl-title { font-size: 13px; font-weight: 600; }
.tl-meta { font-size: 11.5px; color: var(--faint); margin-top: 1px; }

/* ------------------------------- progress ------------------------------- */

.bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #38d9c6); border-radius: 4px; }
.progress-row { display: flex; gap: 10px; align-items: center; }
.progress-row .bar { flex: 1; }

/* ------------------------------- measure -------------------------------- */

.measure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.measure-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px; }
.measure-card.done { border-color: #a7e8cf; background: linear-gradient(180deg, var(--surface), #f3fdf9); }
[data-theme="dark"] .measure-card.done { background: linear-gradient(180deg, var(--surface), #0d2119); }
.measure-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.measure-no { font-weight: 750; font-size: 15px; letter-spacing: -.2px; }
.measure-loc { font-size: 12px; color: var(--muted); }
.measure-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.m-input { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 11px; overflow: hidden; background: var(--surface); }
.m-input button { width: 34px; height: 44px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 16px; font-weight: 600; color: var(--muted); }
.m-input button:hover { background: var(--surface-3); color: var(--text); }
.m-input input { flex: 1; width: 100%; border: 0; text-align: center; font-size: 17px; font-weight: 700; height: 44px; outline: none; background: transparent; font-variant-numeric: tabular-nums; }
.m-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); font-weight: 700; margin-bottom: 4px; }
.measure-delta { font-size: 11.5px; margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; }
.delta-up { color: var(--red); font-weight: 650; }
.delta-down { color: var(--green); font-weight: 650; }
.delta-nil { color: var(--faint); }

/* -------------------------------- modal --------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(9, 18, 32, 0.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px 16px; z-index: 200;
  animation: fade .15s ease;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  animation: pop .16s ease;
}
.modal.wide { max-width: 860px; }
.modal.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 680; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }

/* -------------------------------- toast --------------------------------- */

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 300; }
.toast {
  background: var(--nav-2); color: #fff; padding: 11px 15px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-size: 13px; display: flex; gap: 9px; align-items: flex-start;
  max-width: 380px; animation: pop .18s ease;
}
.toast.err { background: #7f1d1d; }
.toast.ok { background: #0b5147; }
.toast svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }

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

.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-aside {
  position: relative; overflow: hidden; color: #eaf1fb;
  background: radial-gradient(1200px 600px at 10% 0%, #123b3d 0%, #0b1727 55%, #08101c 100%);
  padding: 44px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-aside::after {
  content: ""; position: absolute; inset: 0; opacity: .35; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 42px 42px;
}
.login-brand { display: flex; gap: 13px; align-items: center; position: relative; z-index: 1; }
.login-hero { position: relative; z-index: 1; margin-top: 6vh; }
.login-hero h1 { font-size: clamp(26px, 3vw, 40px); line-height: 1.12; letter-spacing: -1.1px; font-weight: 750; margin: 0 0 14px; }
.login-hero p { color: #9fb3cc; font-size: 14.5px; max-width: 460px; margin: 0 0 22px; }
.hero-points { display: flex; flex-direction: column; gap: 11px; margin-top: 8px; }
.hero-point { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: #c3d2e5; }
.hero-point svg { width: 17px; height: 17px; color: #2dd4bf; flex: 0 0 17px; margin-top: 2px; }
.login-foot { position: relative; z-index: 1; font-size: 11.5px; color: #6d84a0; }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 34px 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { margin: 0 0 4px; font-size: 23px; letter-spacing: -.5px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 13.5px; }
.login-card .btn { height: 44px; }
.demo-users { margin-top: 22px; border-top: 1px dashed var(--border-strong); padding-top: 16px; }
.demo-users .small { color: var(--faint); margin-bottom: 8px; }
.demo-chip {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; cursor: pointer; margin-bottom: 5px; text-align: left;
}
.demo-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.demo-chip .role { color: var(--muted); font-size: 11px; }

/* ------------------------------ misc bits ------------------------------- */

.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-title { font-size: 13px; font-weight: 600; }
.list-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.drawer-note {
  display: flex; gap: 10px; padding: 11px 13px; border-radius: 11px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.drawer-note svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 2px; color: var(--accent); }
.notice { padding: 12px 14px; border-radius: 11px; font-size: 13px; border: 1px solid; }
.notice.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.notice.errm { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.notice.info { background: var(--accent-soft); border-color: #b7e8e2; color: #0f766e; }
[data-theme="dark"] .notice.warn { background: #2a2010; border-color: #4a3813; color: #fbbf24; }
[data-theme="dark"] .notice.errm { background: #2a1215; border-color: #4a1d21; color: #fca5a5; }
[data-theme="dark"] .notice.info { background: #0d2b2a; border-color: #14504a; color: #5eead4; }

.doc-sheet { background: #fff; color: #111; padding: 26px; border: 1px solid #e5e5e5; border-radius: 4px; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 14px; }
.doc-head h2 { margin: 0; font-size: 19px; }
.doc-meta { font-size: 11.5px; text-align: right; line-height: 1.6; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.doc-table th, .doc-table td { border: 1px solid #ddd; padding: 5px 7px; text-align: left; }
.doc-table th { background: #f3f4f6; font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.doc-table .num { text-align: right; }
.doc-total { margin-top: 12px; margin-left: auto; width: 300px; font-size: 12px; }
.doc-total .line { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed #ddd; }
.doc-total .grand { font-weight: 700; font-size: 14px; border-bottom: 0; border-top: 2px solid #111; margin-top: 4px; padding-top: 6px; }
.doc-note { font-size: 10.5px; color: #555; margin-top: 14px; line-height: 1.5; }

.svg-window { width: 100%; max-width: 360px; margin: 0 auto; display: block; }

/* -------------------------------- designer ------------------------------- */

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

.topo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.topo-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left; min-height: 100px;
  padding: 10px 12px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color .15s ease, background .15s ease;
}
.topo-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.topo-card.active {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.topo-code { font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .7px; color: var(--accent-strong); text-transform: uppercase; }
.topo-name { font-size: 13px; font-weight: 650; color: var(--text); line-height: 1.25; }
.topo-desc { font-size: 11px; color: var(--muted); line-height: 1.35; margin-top: 1px; }
.topo-meta { margin-top: auto; padding-top: 6px; font-size: 10px; color: var(--faint); }

.stage {
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  min-height: 320px; padding: 10px; border-radius: 14px;
  border: 1px dashed var(--border-strong); background-color: var(--surface-2);
  background-image:
    linear-gradient(rgba(120, 140, 165, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 140, 165, .08) 1px, transparent 1px);
  background-size: 24px 24px;
}
.dz-svg { width: 100%; max-width: 640px; height: auto; display: block; }
.dz-svg text { fill: #475569; font-family: var(--mono); font-size: 10px; }
.dz-svg text.dz-title { fill: #0f172a; font-family: var(--font); font-size: 11px; font-weight: 650; letter-spacing: .2px; }
.assemble-caption { text-align: center; font-size: 12px; color: var(--muted); margin-top: 10px; min-height: 18px; }

.dz-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 8px; margin-top: 12px; }
.dz-stat { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface-2); }
.dz-stat span { display: block; font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); }
.dz-stat strong { font-size: 13px; font-variant-numeric: tabular-nums; }

.dz-print .dz-svg { max-width: 330px; }

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

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 276px; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; inset: 0; background: rgba(8, 15, 26, .5); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .hamburger { display: inline-grid; }
  .header { padding: 10px 14px; }
  .content { padding: 16px 14px 36px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .designer-grid { grid-template-columns: 1fr; }
  .designer-grid .stack { display: contents; }
  .designer-grid .dz-step1 { order: 1; }
  .designer-grid .dz-step2 { order: 2; }
  .designer-grid .dz-drawing { order: 3; }
  .designer-grid .dz-hardware { order: 4; }
  .designer-grid .dz-step3 { order: 5; }
  .designer-grid .dz-step4 { order: 6; }
  .designer-grid .dz-saved { order: 7; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}

@media (max-width: 720px) {
  body { font-size: 14px; }
  .grid { grid-template-columns: 1fr !important; }
  .table td, .table th { font-size: 12px; }
  .header-title h1 { font-size: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .kpi-value { font-size: 19px; }
  .kpi .kpi-icon { display: none; }
  .card-head { padding: 13px 14px; flex-wrap: wrap; }
  .card-body { padding: 14px; }
  .page-head h2 { font-size: 18px; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .measure-grid { grid-template-columns: 1fr; }
  .stage { min-height: 250px; padding: 6px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; border-radius: 16px 16px 0 0; max-height: 94vh; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
  .hide-sm { display: none !important; }
  .table th, .table td { padding: 9px 10px; }
  .doc-sheet { padding: 16px; }
  .grid-4 { grid-template-columns: 1fr; }
}

@media (min-width: 1025px) { .nav-scrim { display: none; } }

/* -------------------------------- print --------------------------------- */

#print-area { display: none; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; }
  .shell, .toasts, .modal-backdrop, #boot { display: none !important; }
  #print-area { display: block !important; }
  .doc-sheet { border: 0; padding: 0; }
  .doc-page-break { page-break-after: always; }
  .no-print { display: none !important; }
}

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

#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 500; }
.boot-inner { text-align: center; color: var(--muted); font-size: 13px; }
.boot-logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(140deg, #14b8a6, #0b7a70); display: grid; place-items: center; color: #fff; margin: 0 auto 14px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.94); opacity: .8; } }

.skel { border-radius: 10px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
