/* Static Inter weights — NOT the variable font. The variable font (100–900
   range) is expensive to rasterise in software-rendered Chromium (WSL) and
   causes navigation freezes; static weights render as plain glyphs. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/Inter-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/Inter-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/Inter-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/Inter-Bold.woff2') format('woff2');
}

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --sidebar: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);
  --accent: #2080c0;
  --accent-ink: #0d5b96;
  --accent-soft: rgba(32, 128, 192, 0.12);
  --accent-grad: linear-gradient(135deg, #4a9bd6 0%, #1767a5 100%);
  --success: #34c759;
  --danger: #ff3b30;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --sidebar: #161617;
  --text: #f5f5f7;
  --text-2: #98989d;
  --text-3: #86868b;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #4a9bd6;
  --accent-ink: #9cc8ec;
  --accent-soft: rgba(74, 155, 214, 0.18);
  --success: #30d158;
  --danger: #ff453a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
  font-size: 15px;
  letter-spacing: -0.01em;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--sidebar);
  /* NOTE: no backdrop-filter here. A blur(20px) on this full-height fixed
     element was re-composited on every navigation and could stall Chromium's
     GPU compositor on Windows (the reported "freeze, F5 to recover"). The
     backdrop behind the sidebar is a flat page background, so the blur was
     doing nothing visually anyway — removing it changes nothing pixel-wise. */
  border-right: 1px solid var(--border);
  z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 10px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px;
  box-shadow: 0 4px 12px rgba(32, 128, 192, 0.3);
  flex-shrink: 0;
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-logo { width: 100%; height: auto; max-height: 56px; object-fit: contain; display: block; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.sidebar nav { flex: 1; padding: 8px 0; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 18px; height: 18px; stroke-width: 1.7; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.sidebar-foot { padding: 12px 4px 0; border-top: 1px solid var(--border); }
.nav-item.small { font-size: 13px; color: var(--text-3); }
.sidebar-version {
  margin-top: 10px; padding: 10px 12px 4px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-3); letter-spacing: 0.02em;
}

/* ---------- Content ---------- */
.content { margin-left: 250px; flex: 1; padding: 28px 40px 60px; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.topbar h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-tag { color: var(--text-3); font-size: 13px; }

.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 8px; }
.card p { color: var(--text-2); font-size: 14px; line-height: 1.6; }
.card.wide { padding: 0; overflow: hidden; }
.card.wide > h2, .card.wide > p { padding: 24px 22px 0; }
.card.wide > p { padding-top: 6px; padding-bottom: 22px; }

/* ---------- Hero / intro ---------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 260px; height: 260px; border-radius: 50%;
  /* soft glow via a radial fade — NO filter/blur, which can stall Chromium's
     GPU compositor on Windows/WSL (the reported freeze) */
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.12;
}
.hero h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.04em; margin-bottom: 8px; }
.hero p { color: var(--text-2); max-width: 560px; line-height: 1.6; }
.hero .eyebrow {
  display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--accent-ink); background: var(--accent-soft);
  padding: 4px 10px; border-radius: 20px; margin-bottom: 14px;
}

/* ---------- Metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.metric { text-align: left; padding: 24px; }
.metric-value { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric-label { color: var(--text-2); font-size: 13px; margin-top: 6px; font-weight: 500; }
.metric .metric-icon { color: var(--accent); margin-bottom: 14px; }
.metric .metric-icon svg { width: 24px; height: 24px; stroke-width: 1.6; }

/* ---------- Facts ---------- */
.facts { display: flex; gap: 44px; flex-wrap: wrap; padding: 26px; }
.fact { display: flex; flex-direction: column; }
.fact-num { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.fact-label { color: var(--text-2); font-size: 13px; margin-top: 4px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.count-badge {
  background: var(--surface-2); color: var(--text-2);
  font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--border);
}
.search { display: flex; gap: 8px; }
.search input {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 14px; min-width: 240px;
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search button {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 8px 18px; font-weight: 600;
  font-size: 14px; cursor: pointer; transition: opacity 0.15s ease, transform 0.1s ease;
}
.search button:hover { opacity: 0.9; }
.search button:active { transform: scale(0.97); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--text-3);
  padding: 12px 22px; border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 22px; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tfoot td { padding: 14px 22px; border-top: 1px solid var(--border-strong); font-size: 14px; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--text-3); padding: 32px; text-align: center; }
.hint { color: var(--text-2); font-size: 13px; padding: 16px 22px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 22px; border-top: 1px solid var(--border);
}
.page-meta { color: var(--text-3); font-size: 13px; font-weight: 500; }
.page-nav { display: flex; gap: 6px; }
.page-btn {
  display: inline-flex; align-items: center;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background 0.15s ease;
}
.page-btn:hover { background: var(--surface-2); text-decoration: none; }
.page-btn.disabled { color: var(--text-3); opacity: 0.55; pointer-events: none; }

/* ---------- Buttons / links ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none; color: var(--accent); font-weight: 600; font-size: 13px;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.75; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Invoice detail ---------- */
.invoice-head {
  display: flex; justify-content: space-between; gap: 24px;
  padding: 26px; border-bottom: 1px solid var(--border);
  font-size: 14px; line-height: 1.7;
}
.invoice-head .to { color: var(--text-2); }
.invoice-head strong { color: var(--text); font-weight: 600; }
.invoice-meta { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.invoice-meta strong { color: var(--text); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 10px;
  padding: 9px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 6px rgba(32, 128, 192, 0.3);
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { opacity: 0.9; text-decoration: none; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary svg { width: 15px; height: 15px; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px 16px; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s ease;
}
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn-ghost.danger { color: var(--danger); }

.row-actions { display: flex; gap: 6px; }
.row-actions a { font-size: 13px; font-weight: 500; }
.row-actions a:hover { text-decoration: underline; }

/* ---------- Toolbar actions ---------- */
.toolbar-actions { display: flex; gap: 10px; }

/* ---------- Forms ---------- */
.form-card { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 10px 14px; font-size: 15px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-error { color: var(--danger); font-size: 13px; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }

/* ---------- Flash messages ---------- */
.messages { margin-bottom: 20px; }
.flash {
  padding: 12px 16px; border-radius: 10px; font-size: 14px;
  margin-bottom: 8px; border: 1px solid var(--border);
  background: var(--surface-2);
}
.flash.success { border-color: rgba(52, 199, 89, 0.4); background: rgba(52, 199, 89, 0.1); color: var(--success); }

/* ---------- Certificate of Conformity ---------- */
.cert-doc { max-width: 760px; margin: 0 auto; padding: 40px 48px; }
.cert-letterhead { text-align: center; margin-bottom: 28px; }
.cert-logo { font-size: 22px; font-weight: 800; letter-spacing: 0.04em; color: var(--accent); }
.cert-logo-img { height: 60px; width: auto; display: block; margin: 0 auto; }
.cert-dept { font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-2); margin-top: 4px; }
.cert-rule { height: 2px; background: var(--accent-grad); width: 80px; margin: 14px auto 0; border-radius: 2px; }
.cert-title { text-align: center; font-size: 22px; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 24px; }
.cert-body p { color: var(--text-2); line-height: 1.7; margin-bottom: 18px; }
.cert-fields { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.cert-fields td { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.cert-fields td:first-child { color: var(--text-2); width: 40%; }
.cert-notes { white-space: pre-line; }
.cert-sign { text-align: center; margin-top: 40px; }
.cert-sign-line { width: 220px; border-top: 1px solid var(--border-strong); margin: 0 auto 8px; }
.cert-sign { color: var(--text-2); font-size: 13px; }
.cert-footer { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: 11px; color: var(--text-3); letter-spacing: 0.05em; }

/* ---------- line table in order form ---------- */
.line-table th, .line-table td { padding: 8px 10px; }
.line-table input, .line-table select {
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 7px 10px; font-size: 14px; width: 100%;
  background: var(--surface); color: var(--text);
}
.line-table input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Dynamic formset rows ---------- */
.del-col { text-align: center; width: 38px; white-space: nowrap; }
.del-check { display: none; }
.remove-row {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-3); cursor: pointer; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.remove-row:hover { color: var(--danger); background: var(--surface-2); border-color: var(--danger); }

/* ================= Auth (login / logout) — clean & professional ================= */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(1000px 520px at 85% -10%, rgba(32, 128, 192, 0.10), transparent 60%),
    radial-gradient(800px 480px at 0% 110%, rgba(32, 128, 192, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  position: relative;
  letter-spacing: 0;
}
.auth-card {
  width: min(400px, calc(100vw - 48px));
  padding: 44px 40px 36px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.auth-brand { text-align: center; margin-bottom: 30px; }
.auth-wordmark {
  font-size: 30px; font-weight: 800; letter-spacing: 0.16em; color: var(--text);
}
.auth-wordmark::after {
  content: ""; display: block; width: 42px; height: 2px;
  margin: 15px auto 0; border-radius: 2px;
  background: var(--accent-grad);
}
.auth-tagline {
  font-size: 13px; color: var(--text-2); margin-top: 12px;
  letter-spacing: 0.02em; font-weight: 500;
}
.auth-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.auth-field label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-2);
}
.auth-field input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 15px; font-family: inherit; color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-field input::placeholder { color: var(--text-3); }
.auth-field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.auth-error {
  background: rgba(255, 69, 58, 0.08); border: 1px solid rgba(255, 69, 58, 0.3);
  color: var(--danger); border-radius: 10px; padding: 10px 14px; font-size: 13px;
  margin-bottom: 16px;
}
.auth-btn {
  width: 100%; border: none; border-radius: 12px; padding: 14px;
  background: var(--accent-grad);
  color: #fff; font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(32, 128, 192, 0.3);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.auth-btn:hover { box-shadow: 0 10px 28px rgba(32, 128, 192, 0.4); }
.auth-btn:active { transform: scale(0.985); }
.auth-foot {
  margin-top: 26px; text-align: center; font-size: 12px; color: var(--text-3);
}
.auth-foot a { color: var(--accent-ink); text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

/* Sign-in button spinner (GPU-safe: transform rotate only) */
.auth-btn.loading { opacity: 0.85; cursor: progress; }
.auth-btn.loading::after {
  content: ""; display: inline-block; width: 14px; height: 14px;
  margin-left: 10px; vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff; border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* Dashboard entrance — GPU-safe: opacity only (no transform/animation that can
   stall the WSL Chromium compositor on navigation). */
.page-enter { animation: page-in 0.3s ease both; }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- User menu (topbar) ---------- */
.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 13px 4px 4px;
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text);
  transition: background 0.15s ease;
}
.user-chip:hover { background: var(--surface-2); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 210px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-md); padding: 6px;
  display: none; z-index: 50;
}
.user-menu:hover .user-dropdown, .user-menu:focus-within .user-dropdown { display: block; }
.user-dropdown .user-dropdown-name {
  padding: 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
  font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-dropdown a, .user-dropdown button {
  display: flex; width: 100%; text-align: left; align-items: center;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--text); text-decoration: none; background: none; border: none; cursor: pointer; font-family: inherit;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.user-dropdown button.danger { color: var(--danger); }

/* ---------- Brand mark (sharp bird) ---------- */
.brand-mark svg { width: 22px; height: 22px; }

/* ---------- Checkbox fields ---------- */
.form-field input[type="checkbox"] {
  width: 16px; height: 16px; padding: 0; border: none;
  accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.check-label {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
}
.guide-toggle {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-2); user-select: none; white-space: nowrap;
}
.guide-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.guide-toggle .track {
  width: 38px; height: 21px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background 0.18s ease; flex-shrink: 0;
}
.guide-toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.18s ease;
}
.guide-toggle input:checked + .track { background: var(--accent); }
.guide-toggle input:checked + .track::after { transform: translateX(17px); }
.guide-toggle input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }
.module-checks ul {
  list-style: none; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px 16px; margin-top: 2px;
}
.module-checks li { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); font-weight: 500; }

/* ---------- User permission grid ---------- */
.perm-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 20px; margin-top: 4px; }
.perm-col { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.perm-head { margin: 0 0 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-2); }
.perm-col .module-checks ul { grid-template-columns: 1fr; }
.level-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; }
@media (max-width: 820px) { .perm-cols { grid-template-columns: 1fr; } }

/* ---------- Document template editor ---------- */
.editor-wrap { display: flex; gap: 20px; align-items: flex-start; }
.editor-canvas-col { flex: 1; min-width: 0; overflow: auto; }
.editor-side { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }
.doc-canvas { background: #fff; color: #1a1a1a; border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 2px 16px rgba(0,0,0,0.08); position: relative; font-family: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
.doc-canvas::before {
  /* Printable-area guide — laser printers can't print to the paper edge, so this
     light-blue dashed line marks the safe boundary (~5mm inset). Visible only in the
     editor/preview; hidden when printing. */
  content: "";
  position: absolute;
  inset: 19px;
  border: 1px dashed rgba(32, 128, 192, 0.5);
  pointer-events: none;
}
.doc-canvas.guide-off::before { display: none; }  /* user toggled the printable-area guide off */
.doc-el { position: absolute; cursor: move; padding: 4px 6px; border: 1px dashed transparent; line-height: 1.25; overflow: hidden; box-sizing: border-box; font-family: inherit; }
.doc-el:hover { border-color: var(--accent); background: rgba(59,130,246,0.05); }
.doc-el.selected { border: 1px solid var(--accent); background: rgba(59,130,246,0.08); }
.doc-logo { border: 1px dashed #ccc; background: #f5f5f5; color: #999; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.doc-logo.has-logo { background: transparent; border-color: transparent; }  /* real logo: no grey box/border */
.doc-field { color: #0b6bcb; }
.logo-placeholder { font-size: 12px; }
.doc-el.blocked { border: 1px dashed #9ca3af; padding-top: 12px; }
.block-tag {
  position: absolute; top: 0; left: 0; font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.3px; color: #6b7280; background: #eef2f7; padding: 0 4px; pointer-events: none;
}
.editor-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-props { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.prop-row { display: flex; flex-direction: column; gap: 4px; }
.prop-row.two { flex-direction: row; gap: 8px; }
.prop-row.two > div { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.prop-row label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.prop-row input, .prop-row select, .prop-row textarea {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 9px; font-size: 13px; background: var(--surface); color: var(--text);
}
.prop-row input:focus, .prop-row select:focus, .prop-row textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.preview-page { padding: 20px; background: var(--surface-2); border-radius: var(--radius); display: flex; justify-content: center; overflow: auto; }
.preview-page .doc-canvas { box-shadow: 0 4px 20px rgba(0,0,0,0.12); }
.preview-page .doc-el { cursor: default; }
.preview-page .doc-el:hover { border-color: transparent; background: transparent; }
@media (max-width: 900px) { .editor-wrap { flex-direction: column; } .editor-side { width: 100%; } }

/* ---------- Financial reports ---------- */
.report-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.report-meta { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.report-meta input {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 14px; width: 118px;
  background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums;
}
.report-meta input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-left: auto; }
.seg a { padding: 7px 16px; font-size: 13px; font-weight: 600; color: var(--text-2); text-decoration: none; }
.seg a:hover { background: var(--surface-2); text-decoration: none; }
.seg a.active { background: var(--accent); color: #fff; }
.report-body { padding: 4px 22px 22px; }
.sec-row td {
  background: var(--surface-2); font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; font-size: 12px; color: var(--text-2);
}
tr.net td { border-top: 2px solid var(--border-strong); font-size: 16px; font-weight: 700; padding-top: 16px; }
tr.net td.num { color: var(--accent-ink); }
.bs-cols { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.bs-col { flex: 1 1 320px; min-width: 0; }
.report-note { color: var(--text-2); font-size: 13px; line-height: 1.55; padding: 0 22px 20px; }
.final-head { padding: 24px 22px 6px; }
.final-head h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.final-head .sub { color: var(--text-2); font-size: 13px; margin-top: 4px; line-height: 1.6; }
.final-head .sub .sep { margin: 0 8px; color: var(--text-3); }

/* ---------- Document print (letterhead + live line-items table) ---------- */
.print-stage { padding: 24px; background: var(--surface-2); display: flex; justify-content: center; align-items: flex-start; }
.print-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.print-toolbar .hint { color: var(--text-2); font-size: 13px; font-weight: 500; margin-right: auto; }
.doc-lines { font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif; color: #1a1a1a; font-variant-numeric: tabular-nums; }
.doc-lines th, .doc-lines td { padding: 3px 8px; text-align: left; vertical-align: top; }
.doc-lines th { font-weight: 700; font-size: 11px; border-top: 1px solid #000; border-bottom: 1px solid #000; }
.doc-lines td { font-size: 11px; border-bottom: 1px solid #e4e4e4; }
.doc-lines th.right, .doc-lines td.right { text-align: right; }
.doc-lines th.center, .doc-lines td.center { text-align: center; }
.doc-lines tfoot td { font-weight: 700; border-top: 1px solid #000; border-bottom: none; }

/* ---------- Print ---------- */
@media print {
  .doc-canvas::before { display: none; }  /* hide the printable-area guide on paper */
  .doc-logo { background: transparent !important; border-color: transparent !important; }  /* never print the logo placeholder box */
  .no-print, .print-toolbar, .sidebar, .topbar, .messages { display: none !important; }
  body { background: #fff !important; }
  .print-stage { padding: 0; margin: 0; background: #fff; display: block; }
  .doc-canvas { box-shadow: none !important; border: none !important; border-radius: 0 !important; margin: 0 auto; }
  @page { size: A4; margin: 0; }
}
