/* ============================================================
   EasyXInvoice — E-Invoicing SaaS · Design System
   Apple HIG inspired · light + dark · 8pt grid · SF Pro stack
   ============================================================ */

/* -------- Tokens -------- */
:root {
  /* canvas + surfaces */
  --canvas: #FBFBFD;
  --surface: #FFFFFF;
  --surface-2: #F5F5F7;
  --surface-3: #EBEBF0;
  --surface-elevated: #FFFFFF;

  /* borders */
  --border: #E5E5EA;
  --border-strong: #D2D2D7;
  --hairline: rgba(0,0,0,0.06);

  /* text */
  --text: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #86868B;
  --text-quaternary: #AEAEB2;

  /* accent + semantic (calibrated against light) */
  --accent: #0A84FF;
  --accent-strong: #0066CC;
  --accent-tint: rgba(10,132,255,0.10);
  --accent-tint-strong: rgba(10,132,255,0.18);

  --green: #34C759;
  --green-tint: rgba(52,199,89,0.12);
  --amber: #FF9F0A;
  --amber-tint: rgba(255,159,10,0.14);
  --red: #FF3B30;
  --red-tint: rgba(255,59,48,0.12);
  --purple: #AF52DE;
  --purple-tint: rgba(175,82,222,0.12);

  /* elevation */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.04), 0 6px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-focus: 0 0 0 4px rgba(10,132,255,0.18);

  /* motion */
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.5, 1.4, 0.4, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 160ms;
  --t-base: 240ms;
  --t-slow: 360ms;

  /* radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 16px;
  --r-2xl: 22px;
  --r-pill: 999px;

  /* shell */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 64px;
  --canvas-max: 1280px;
}

[data-theme="dark"] {
  --canvas: #000000;
  --surface: #1C1C1E;
  --surface-2: #2C2C2E;
  --surface-3: #3A3A3C;
  --surface-elevated: #2C2C2E;

  --border: #2C2C2E;
  --border-strong: #3A3A3C;
  --hairline: rgba(255,255,255,0.08);

  --text: #F5F5F7;
  --text-secondary: #98989D;
  --text-tertiary: #8E8E93;
  --text-quaternary: #636366;

  --accent: #0A84FF;
  --accent-strong: #409CFF;
  --accent-tint: rgba(10,132,255,0.18);
  --accent-tint-strong: rgba(10,132,255,0.28);

  --green: #30D158;
  --green-tint: rgba(48,209,88,0.20);
  --amber: #FF9F0A;
  --amber-tint: rgba(255,159,10,0.20);
  --red: #FF453A;
  --red-tint: rgba(255,69,58,0.20);
  --purple: #BF5AF2;
  --purple-tint: rgba(191,90,242,0.20);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.3), 0 6px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-focus: 0 0 0 4px rgba(10,132,255,0.32);
}

/* -------- Reset -------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.47;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  transition: background-color var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
  min-height: 100vh;
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* numbers tabular everywhere */
.num, td.num, .kpi-value, .table-num, time { font-variant-numeric: tabular-nums lining-nums; }

::selection { background: var(--accent-tint-strong); color: var(--text); }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-quaternary); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* -------- Typography -------- */
.display { font-size: 32px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.title { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.subtitle { font-size: 17px; line-height: 1.35; font-weight: 600; letter-spacing: -0.005em; }
.body { font-size: 15px; line-height: 1.47; font-weight: 400; }
.caption { font-size: 13px; line-height: 1.4; font-weight: 400; color: var(--text-secondary); }
.micro { font-size: 11px; line-height: 1.3; font-weight: 500; color: var(--text-tertiary); letter-spacing: 0.04em; text-transform: uppercase; }

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

/* -------- App shell -------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.app[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* -------- Sidebar -------- */
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  transition: background-color var(--t-base) var(--ease-out);
  z-index: 10;
}
[data-theme="dark"] .sidebar { background: #0E0E10; }
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 16px;
  font-weight: 600; letter-spacing: -0.01em; font-size: 16px;
}
.sidebar-brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #5E5CE6 100%);
  display: grid; place-items: center; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 1px 2px rgba(0,0,0,0.18);
  flex-shrink: 0;
}
.sidebar-brand .logo svg { width: 16px; height: 16px; }
.sidebar-section { padding: 12px 8px 6px; }
.sidebar-section .micro { padding: 0 8px; }
[data-sidebar="collapsed"] .sidebar-section .micro,
[data-sidebar="collapsed"] .sidebar-brand .brand-name,
[data-sidebar="collapsed"] .nav-item .label { display: none; }
[data-sidebar="collapsed"] .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }

.nav {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
  position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] {
  background: var(--accent-tint);
  color: var(--accent-strong);
  box-shadow: none;
  font-weight: 600;
}
[data-theme="dark"] .nav-item[aria-current="page"] {
  background: var(--accent-tint);
  color: var(--accent);
}
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-tertiary); }
.nav-item[aria-current="page"] .icon { color: var(--accent-strong); }
[data-theme="dark"] .nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-item .badge { margin-left: auto; }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

/* -------- Topbar -------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  height: var(--topbar-h);
  background: rgba(251,251,253,0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
}
[data-theme="dark"] .topbar { background: rgba(0,0,0,0.72); }
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }
.topbar-title { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; }
.crumbs svg { width: 12px; height: 12px; color: var(--text-quaternary); }
.crumbs .crumb { color: var(--text-secondary); }
.crumbs .crumb.current { color: var(--text); font-weight: 500; }

.search {
  flex: 0 1 320px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-tertiary);
  font-size: 13px;
  cursor: text;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.search:hover { background: var(--surface-3); }
.search svg { width: 14px; height: 14px; }
.search .kbd {
  margin-left: auto;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-tertiary);
}
[data-theme="dark"] .search .kbd { background: var(--surface-3); border-color: var(--border-strong); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-spring);
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 2px var(--canvas);
}

/* Theme toggle */
.theme-toggle {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  cursor: pointer;
  overflow: hidden;
  color: var(--text);
  transition: background var(--t-fast) var(--ease-out);
}
.theme-toggle svg { width: 16px; height: 16px; transition: transform var(--t-slow) var(--ease-spring), opacity var(--t-base) var(--ease-out); position: absolute; }
.theme-toggle .sun { opacity: 1; transform: rotate(0) scale(1); }
.theme-toggle .moon { opacity: 0; transform: rotate(-90deg) scale(0.4); }
[data-theme="dark"] .theme-toggle .sun { opacity: 0; transform: rotate(90deg) scale(0.4); }
[data-theme="dark"] .theme-toggle .moon { opacity: 1; transform: rotate(0) scale(1); }

/* -------- Quick-Actions tiles (Dashboard) -------- */
.quick-actions .qa-tile {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  text-decoration: none;
  color: inherit;
}
.quick-actions .qa-tile:hover { text-decoration: none; }
.quick-actions .qa-tile .ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.quick-actions .qa-tile h4 { font-size: 16px; font-weight: 600; letter-spacing: -0.005em; }
.quick-actions .qa-tile p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.quick-actions .qa-tile .arrow {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-strong);
}
[data-theme="dark"] .quick-actions .qa-tile .arrow { color: var(--accent); }
.quick-actions .qa-tile:hover .arrow svg { transform: translateX(2px); transition: transform var(--t-fast) var(--ease-out); }
@media (max-width: 900px) {
  .quick-actions { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 560px) {
  .quick-actions { grid-template-columns: 1fr !important; }
}

/* -------- Compact article tiles (Fundamentals) -------- */
.article-grid-compact {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* Standalone video grid (Watch section) — 3 columns of 16:9 thumbnails.
   Third slot is reserved for an upcoming video and currently holds a dimmed
   placeholder so the section reads as intentional, not broken. */
.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.video-grid .video-tile {
  grid-row: auto;
  min-height: 0;
  aspect-ratio: 16 / 9;
}
.video-grid .video-tile h4 { font-size: 14.5px; line-height: 1.3; }
.video-grid .video-tile .video-play { width: 36px; height: 36px; }
.video-grid .video-tile .video-play svg { width: 14px; height: 14px; }

@media (max-width: 900px) {
  .video-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .video-grid { grid-template-columns: 1fr; }
}

/* Mixed grid · article tiles + video tiles (videos span 2 rows) — legacy */
.article-grid-mixed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 70px;
  gap: 12px;
}
.article-grid-mixed .article-compact { height: auto; }

/* Video tutorial tile — uses real thumbnail as background-image */
.video-tile {
  grid-row: span 2;
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  background: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 100%);
  background-size: cover;
  background-position: center;
  color: #fff;
  transition: transform 240ms var(--ease-out), box-shadow 240ms var(--ease-out);
  min-height: 152px;
}
/* Dark overlay so the white title + duration stay readable on any thumbnail */
.video-tile .video-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.10) 0%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
}
.video-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: #fff;
}
.video-tile.alt {
  background: linear-gradient(135deg, #34C759 0%, #0A84FF 100%);
}
.video-play {
  position: relative;
  z-index: 1;
  align-self: flex-end;
  width: 44px; height: 44px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.28);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform var(--t-base) var(--ease-spring);
}
.video-tile:hover .video-play { transform: scale(1.08); }
.video-play svg { width: 18px; height: 18px; fill: #fff; margin-left: 2px; }
.video-info {
  position: relative;
  z-index: 1;
  color: #fff;
}
.video-duration {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 6px;
}
.video-tile h4 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
  color: #fff;
}

@media (max-width: 1000px) {
  .article-grid-mixed { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .article-grid-mixed { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .video-tile { grid-row: span 1; aspect-ratio: 16/9; min-height: 0; }
}
.article-compact {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.article-compact:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
  text-decoration: none;
  color: var(--text);
}
.article-compact .ico {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-secondary);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.article-compact:hover .ico { background: var(--accent-tint); color: var(--accent-strong); }
[data-theme="dark"] .article-compact:hover .ico { color: var(--accent); }
.article-compact .ico svg { width: 18px; height: 18px; }
.article-compact h4 { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; flex: 1; line-height: 1.35; }
.article-compact .meta { font-size: 12px; color: var(--text-tertiary); display: flex; align-items: center; gap: 4px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.article-compact .meta svg { width: 11px; height: 11px; }
@media (max-width: 1000px) { .article-grid-compact { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px)  { .article-grid-compact { grid-template-columns: 1fr; } }

/* -------- Compliance gauge + Invoice summary (standalone Validate) -------- */
.upload-extras {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 24px;
  margin-bottom: 24px;
}
@media (max-width: 900px) {
  .upload-extras { grid-template-columns: 1fr; }
}
.compliance-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 24px 28px;
}
.compliance-gauge {
  position: relative;
  width: 180px; height: 180px;
  margin-bottom: 16px;
}
.compliance-gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.gauge-track { fill: none; stroke: var(--border); stroke-width: 14; }
.gauge-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 502.65;
  stroke-dashoffset: 502.65;
  transition: stroke-dashoffset 1000ms var(--ease-out), stroke 240ms var(--ease-out);
}
.gauge-fill.warn   { stroke: var(--amber); }
.gauge-fill.danger { stroke: var(--red); }
.gauge-pct {
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  font-size: 38px;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  transition: color 240ms var(--ease-out);
}
.gauge-pct.warn   { color: var(--amber); }
.gauge-pct.danger { color: var(--red); }
.compliance-card h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.compliance-card p.caption { margin-top: 4px; }

.invoice-summary { padding: 24px 26px; }
.invoice-summary h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 20px; }
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 12px 18px;
  margin: 0;
  font-size: 14.5px;
}
.summary-grid dt {
  color: var(--text-secondary);
  font-weight: 400;
}
.summary-grid dd {
  margin: 0;
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.summary-grid hr {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 6px 0;
}
.summary-grid dt.is-total,
.summary-grid dd.is-total {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--text);
}

/* -------- Upload drop zone (standalone Validate) -------- */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  padding: 56px 24px;
  text-align: center;
  transition: border-color var(--t-base) var(--ease-out), background var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out);
  cursor: pointer;
}
.upload-zone:hover { border-color: var(--accent); background: var(--surface-2); }
.upload-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-tint);
  transform: scale(1.005);
}
.upload-zone .ico-lg {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  display: grid; place-items: center;
  margin: 0 auto 18px;
  transition: transform var(--t-base) var(--ease-spring);
}
[data-theme="dark"] .upload-zone .ico-lg { color: var(--accent); }
.upload-zone.is-dragging .ico-lg { transform: scale(1.1) rotate(-4deg); }
.upload-zone .ico-lg svg { width: 28px; height: 28px; }
.upload-zone h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.upload-zone .lede { color: var(--text-secondary); font-size: 14px; max-width: 50ch; margin: 8px auto 24px; line-height: 1.5; }
.upload-zone .formats {
  display: inline-flex; gap: 6px; margin-top: 14px;
  font-size: 11.5px; color: var(--text-tertiary);
  align-items: center;
}

/* -------- Mode picker (Create Invoice entry screen) -------- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 900px) { .mode-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .mode-grid { grid-template-columns: 1fr; } }
.mode-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 24px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
}
.mode-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.mode-card .ico {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  display: grid; place-items: center;
  margin-bottom: 6px;
}
[data-theme="dark"] .mode-card .ico { color: var(--accent); }
.mode-card .ico svg { width: 24px; height: 24px; }
.mode-card h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.005em; }
.mode-card p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.mode-card .cta {
  margin-top: auto;
  padding-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-strong);
}
[data-theme="dark"] .mode-card .cta { color: var(--accent); }
.mode-card:hover .cta svg { transform: translateX(2px); transition: transform var(--t-fast) var(--ease-out); }

/* -------- Template picker -------- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 700px) { .template-grid { grid-template-columns: 1fr; } }
.template-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.template-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}
.template-card .head { display: flex; align-items: flex-start; gap: 12px; }
.template-card .ico {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
}
[data-theme="dark"] .template-card .ico { color: var(--accent); }
.template-card .ico svg { width: 17px; height: 17px; }
.template-card .meta { flex: 1; min-width: 0; }
.template-card h4 { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.template-card .sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.template-card .lines {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.template-card .line {
  display: flex; justify-content: space-between; gap: 12px;
  font-variant-numeric: tabular-nums;
}
.template-card .line .name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.template-card .foot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--text-tertiary);
  padding-top: 6px;
}
.template-card .foot strong {
  color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums;
}

/* PDF extraction overlay */
.pdf-extract-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: grid;
  place-items: center;
  border-radius: var(--r-xl);
  z-index: 5;
}
[data-theme="dark"] .pdf-extract-overlay { background: rgba(0,0,0,0.7); }
.pdf-extract-overlay .spinner {
  width: 28px; height: 28px;
  border-radius: 999px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  margin-bottom: 12px;
}
.pdf-extract-overlay .label {
  font-size: 14px; font-weight: 500; color: var(--text);
}
.pdf-extract-overlay .sub {
  font-size: 12.5px; color: var(--text-secondary); margin-top: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------- Send dropdown (Validate · Versenden button) -------- */
.send-dropdown-wrap {
  position: relative;
  /* New stacking context so the dropdown isn't dimmed by any ancestor's
     opacity transition (e.g. .reveal fade-in) — without this the dropdown
     would inherit the parent's effective opacity and show through. */
  isolation: isolate;
}
.send-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-spring);
}
[data-theme="dark"] .send-dropdown { background: #2C2C2E; }
.send-dropdown.is-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}
.send-dropdown button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: background var(--t-fast) var(--ease-out);
}
.send-dropdown button:hover { background: var(--surface-2); }
.send-dropdown .ico {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--accent-strong);
  flex-shrink: 0;
}
[data-theme="dark"] .send-dropdown .ico { color: var(--accent); }
.send-dropdown .ico svg { width: 15px; height: 15px; }
.send-dropdown .title { font-size: 14px; font-weight: 500; }
.send-dropdown .sub   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* -------- Profile dropdown (anchored to avatar) -------- */
.profile-wrap { position: relative; }
.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-spring);
  overflow: hidden;
}
.profile-dropdown.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.profile-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
}
.profile-avatar-lg {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.profile-avatar-lg svg { width: 20px; height: 20px; }
.profile-name { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.profile-email { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.3; word-break: break-all; }
.profile-divider { height: 1px; background: var(--border); }
.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: 0;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  transition: background var(--t-fast) var(--ease-out);
}
.profile-row:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.profile-row-icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.profile-row-icon svg { width: 16px; height: 16px; }
.profile-row-label { flex: 1; text-align: left; font-weight: 500; }
.profile-row-link svg.chev { width: 13px; height: 13px; color: var(--text-tertiary); }
.profile-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px;
  border-radius: 8px;
  gap: 1px;
}
.profile-toggle a, .profile-toggle button {
  background: transparent;
  border: 0;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.profile-toggle a:hover, .profile-toggle button:hover { color: var(--text); text-decoration: none; }
.profile-toggle .is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  cursor: default;
  pointer-events: none;
}
[data-theme="dark"] .profile-toggle .is-active { background: var(--surface-3); }

/* -------- Transaction scope list (Home / Knowledge) -------- */
.scope-list { overflow: hidden; }
.scope-group-header {
  padding: 12px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.scope-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px 16px 22px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background var(--t-fast) var(--ease-out);
}
.scope-row:last-child { border-bottom: 0; }
.scope-row:hover { background: var(--surface-2); }
.scope-row.in-scope::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--green);
}
.scope-meta { flex: 1; min-width: 0; }
.scope-title { font-size: 14.5px; font-weight: 500; letter-spacing: -0.005em; }
.scope-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.scope-row .badge { flex-shrink: 0; }
.scope-row.is-hidden, .scope-group.is-hidden { display: none; }
@media (max-width: 720px) {
  .scope-row { padding: 14px 18px; }
  .scope-row .badge { font-size: 10.5px; }
}

/* -------- Rollout Timeline (regulation roadmap)
   Layout math (so the track is centered on the dots):
     .rollout padding-top: 40px (room for the Heute-pill above the dots)
     .rollout-step has no own padding
     .dot is 28px square -> top at 40px, center at 54px, bottom at 68px
     .rollout-track sits at top: 53px (2px line centered on y=54)
-------- */
.rollout {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 40px 8px 4px;
}
.rollout-track {
  position: absolute;
  top: 53px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  z-index: 0;
}
.rollout-fill {
  position: absolute;
  top: 53px;
  left: 10%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--green) 0%, var(--accent) 100%);
  transition: width 700ms var(--ease-out);
  z-index: 0;
}
.rollout-today {
  position: absolute;
  top: 36px;          /* a few pixels above the dot top edge (40px)  */
  height: 36px;       /* extends from above to just past dot bottom  */
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
  z-index: 0;
}
.rollout-today::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 6px);   /* sits ABOVE the line in the padding area */
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-strong);
  background: var(--surface);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--accent-tint-strong);
  white-space: nowrap;
}
[data-theme="dark"] .rollout-today::after { color: var(--accent); background: var(--surface-elevated); }

.rollout-step {
  text-align: center;
  position: relative;
  padding: 0 6px;
  z-index: 1;
}
.rollout-step .dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  margin: 0 auto 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  transition: transform var(--t-base) var(--ease-spring), background var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
  position: relative;
  z-index: 2;          /* dots sit above the today line */
}
.rollout-step .dot svg { width: 12px; height: 12px; }
.rollout-step.past .dot {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.rollout-step.past .dot svg { color: #fff; }
.rollout-step.next .dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px var(--accent-tint);
}
.rollout-step.next .dot svg { color: #fff; }
.rollout-step.future .dot {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.rollout-step .year {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}
.rollout-step.future .year { color: var(--text-secondary); }
.rollout-step .lbl {
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  letter-spacing: -0.005em;
}
.rollout-step .sub {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.rollout-step.future .lbl,
.rollout-step.future .sub { opacity: 0.7; }
.rollout-step:hover .dot { transform: scale(1.08); }

@media (max-width: 900px) {
  .rollout { grid-template-columns: 1fr 1fr; gap: 16px 8px; padding-top: 12px; }
  .rollout-track, .rollout-fill, .rollout-today { display: none; }
  .rollout-step .dot { margin-bottom: 8px; }
}

/* Language flag — shows CURRENT language, click switches */
.lang-flag {
  width: 30px; height: 30px;
  border-radius: 999px;
  overflow: hidden;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  position: relative;
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease-spring),
              box-shadow var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
  flex-shrink: 0;
}
.lang-flag svg {
  display: block;
  width: 100%; height: 100%;
}
.lang-flag:hover {
  transform: scale(1.08);
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  text-decoration: none;
}
.lang-flag:active { transform: scale(0.94); }
.lang-flag::after {
  /* tiny corner dot showing the OTHER language as a hint on hover */
  content: attr(data-current-lang);
  position: absolute;
  bottom: -22px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--text-tertiary);
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-spring);
}
.lang-flag:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(2px);
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--surface-3);
  display: grid; place-items: center;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-spring), background var(--t-fast) var(--ease-out);
}
.avatar:hover { transform: scale(1.05); background: var(--surface-2); }
.avatar svg { width: 16px; height: 16px; }

.date-picker {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out);
}
.date-picker:hover { background: var(--surface-3); }
.date-picker svg { width: 13px; height: 13px; color: var(--text-tertiary); }

/* -------- Canvas -------- */
.canvas {
  max-width: var(--canvas-max);
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 28px;
}
.page-head h1 { font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.page-head .lede { color: var(--text-secondary); margin-top: 6px; font-size: 15px; max-width: 56ch; }
.page-actions { display: flex; gap: 10px; }

/* -------- Progress breadcrumb (Creator → Validator → Transmission) -------- */
.flow-crumb {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 5px 8px;
  font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.flow-crumb .step {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
  text-decoration: none;
}
.flow-crumb .step:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.flow-crumb .step.done { color: var(--text); }
.flow-crumb .step.done .dot { background: var(--green); }
.flow-crumb .step.current { background: var(--accent-tint); color: var(--accent-strong); }
[data-theme="dark"] .flow-crumb .step.current { color: var(--accent); }
.flow-crumb .step .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--border-strong); }
.flow-crumb .step.current .dot { background: var(--accent); }
.flow-crumb .sep { color: var(--text-quaternary); }
.flow-crumb .sep svg { width: 10px; height: 10px; }

/* -------- Buttons -------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  font-size: 14px; font-weight: 500; letter-spacing: -0.005em;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-spring), box-shadow var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn svg { width: 14px; height: 14px; }

/* Highlighted buttons (primary + gradient alias) share one unified gradient.
   Used for any CTA that should pop: New invoice, Pflichten-Check, file
   upload, Send via email, wizard Next, etc. */
.btn-primary {
  background: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 60%, #AF52DE 100%);
  background-size: 140% 140%;
  background-position: 0% 0%;
  color: #fff;
  border: 0;
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: 0 1px 2px rgba(94,92,230,0.25), inset 0 1px 0 rgba(255,255,255,0.22);
  transition: background-position var(--t-base) var(--ease-out), transform var(--t-fast) var(--ease-spring), box-shadow var(--t-base) var(--ease-out);
}
.btn-primary:hover {
  background-position: 100% 100%;
  box-shadow: 0 2px 8px rgba(94,92,230,0.32), inset 0 1px 0 rgba(255,255,255,0.22);
  color: #fff;
}
[data-theme="dark"] .btn-primary {
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-3); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-tinted {
  background: var(--accent-tint);
  color: var(--accent-strong);
}
[data-theme="dark"] .btn-tinted { color: var(--accent); }
.btn-tinted:hover { background: var(--accent-tint-strong); }

.btn-pill { border-radius: var(--r-pill); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #D70015; }

/* .btn-gradient legacy alias — pulls in the same gradient as .btn-primary
   so any markup still using it stays consistent. */
.btn-gradient {
  background: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 60%, #AF52DE 100%);
  background-size: 140% 140%;
  background-position: 0% 0%;
  color: #fff;
  border: 0;
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: 0 1px 2px rgba(94,92,230,0.25), inset 0 1px 0 rgba(255,255,255,0.22);
  transition: background-position var(--t-base) var(--ease-out), transform var(--t-fast) var(--ease-spring), box-shadow var(--t-base) var(--ease-out);
}
.btn-gradient:hover {
  background-position: 100% 100%;
  box-shadow: 0 2px 8px rgba(94,92,230,0.32), inset 0 1px 0 rgba(255,255,255,0.22);
  color: #fff;
  text-decoration: none;
}
.btn-gradient svg { width: 13px; height: 13px; }

/* -------- Compliance check tile (page-head, right of heading) -------- */
.compliance-tile {
  align-self: stretch;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-decoration: none; color: var(--text);
  cursor: pointer; font-family: inherit;
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
  text-align: left;
  min-width: 280px;
}
.compliance-tile:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  text-decoration: none;
  color: var(--text);
}
/* Default state is "not completed yet" — red, signals action needed */
.compliance-tile .ct-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--red-tint);
  color: var(--red);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.compliance-tile.is-good .ct-icon { background: var(--green-tint); color: var(--green); }
.compliance-tile.is-warn .ct-icon { background: var(--amber-tint); color: var(--amber); }
.compliance-tile.is-bad  .ct-icon { background: var(--red-tint);   color: var(--red); }
.compliance-tile .ct-icon svg { width: 18px; height: 18px; }
.compliance-tile .ct-content { flex: 1; min-width: 0; }
.compliance-tile .ct-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-tertiary);
}
.compliance-tile .ct-status {
  font-size: 15px; font-weight: 600;
  margin-top: 2px;
  letter-spacing: -0.005em;
  color: var(--red);
}
.compliance-tile.is-good .ct-status { color: var(--green); }
.compliance-tile.is-warn .ct-status { color: var(--amber); }
.compliance-tile.is-bad  .ct-status { color: var(--red); }
.compliance-tile .ct-arrow { color: var(--text-tertiary); width: 14px; height: 14px; flex-shrink: 0; transition: transform var(--t-fast) var(--ease-out); }
.compliance-tile:hover .ct-arrow { transform: translateX(2px); }
@media (max-width: 720px) {
  .compliance-tile { width: 100%; min-width: 0; }
}

/* -------- AI Chat · floating action button + chat window -------- */
.ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px; height: 56px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 60%, #AF52DE 100%);
  background-size: 160% 160%;
  background-position: 0% 0%;
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(94,92,230,0.45), inset 0 1px 0 rgba(255,255,255,0.22);
  z-index: 45;
  animation: ai-float 5s ease-in-out infinite, ai-shift 8s ease-in-out infinite;
  transition: transform var(--t-base) var(--ease-spring), box-shadow var(--t-base) var(--ease-out);
}
.ai-chat-fab:hover { box-shadow: 0 12px 32px rgba(94,92,230,0.55), inset 0 1px 0 rgba(255,255,255,0.22); }
.ai-chat-fab:active { transform: scale(0.94); }
.ai-chat-fab svg { width: 24px; height: 24px; color: #fff; }
.ai-chat-fab.is-open { animation: none; }

@keyframes ai-float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-6px) rotate(3deg); }
}
@keyframes ai-shift {
  0%, 100% { background-position: 0% 0%; }
  50%      { background-position: 100% 100%; }
}

.ai-chat-window {
  position: fixed;
  bottom: 96px; right: 24px;
  width: 360px;
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  z-index: 44;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-spring);
}
.ai-chat-window.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.ai-chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.ai-chat-head .badge-ai {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0A84FF, #5E5CE6, #AF52DE);
  color: #fff;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.ai-chat-head .badge-ai svg { width: 16px; height: 16px; }
.ai-chat-head .title { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.ai-chat-head .subtitle { font-size: 11.5px; color: var(--text-secondary); margin-top: 1px; }
.ai-chat-head .close {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-secondary);
  display: grid; place-items: center;
  transition: background var(--t-fast) var(--ease-out);
}
.ai-chat-head .close:hover { background: var(--surface-2); color: var(--text); }
.ai-chat-head .close svg { width: 14px; height: 14px; }

.ai-chat-messages {
  flex: 1; min-height: 280px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  background: var(--canvas);
}
.ai-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
}
.ai-msg.bot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  color: var(--text);
}
.ai-msg.user {
  background: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 60%, #AF52DE 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.ai-msg.typing {
  display: inline-flex; gap: 4px;
  padding: 14px 16px;
}
.ai-msg.typing span {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--text-tertiary);
  animation: ai-dot 1.2s ease-in-out infinite;
}
.ai-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.ai-chat-input {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.ai-chat-input input {
  flex: 1;
  border: 0;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}
.ai-chat-input input:focus { background: var(--surface-3); }
.ai-chat-input button {
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 100%);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-spring);
}
.ai-chat-input button:active { transform: scale(0.92); }
.ai-chat-input button:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-chat-input button svg { width: 16px; height: 16px; transform: translateX(1px); }

@media (max-width: 560px) {
  .ai-chat-window { right: 12px; left: 12px; width: auto; max-height: 80vh; }
  .ai-chat-fab { bottom: 16px; right: 16px; }
}

/* -------- Cards -------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
}
.card-hover { cursor: pointer; }
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.card-flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .actions { display: flex; gap: 6px; }
.card-body { padding: 18px 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }

/* -------- KPI tiles -------- */
.kpi {
  display: flex; flex-direction: column; gap: 10px;
}
.kpi-label {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
}
.kpi-label .ico {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  display: grid; place-items: center;
}
[data-theme="dark"] .kpi-label .ico { color: var(--accent); }
.kpi-label .ico.green { background: var(--green-tint); color: var(--green); }
.kpi-label .ico.amber { background: var(--amber-tint); color: var(--amber); }
.kpi-label .ico.red { background: var(--red-tint); color: var(--red); }
.kpi-label .ico svg { width: 14px; height: 14px; }
.kpi-value {
  font-size: 30px; font-weight: 600; letter-spacing: -0.02em;
  line-height: 1.1;
  display: flex; align-items: baseline; gap: 6px;
}
.kpi-value .unit { font-size: 16px; color: var(--text-secondary); font-weight: 500; }
.kpi-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 500;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--green-tint); color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
}
.kpi-delta.down { background: var(--red-tint); color: var(--red); }
.kpi-delta.neutral { background: var(--surface-2); color: var(--text-secondary); }
.kpi-delta svg { width: 10px; height: 10px; }
.sparkline { flex: 1 1 auto; min-width: 0; max-width: 140px; height: 36px; }

/* -------- Bento grid (Dashboard) -------- */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; }
.span-12 { grid-column: span 12; }
.row-span-2 { grid-row: span 2; }

@media (max-width: 1100px) {
  .span-3 { grid-column: span 6; }
  .span-4, .span-5 { grid-column: span 6; }
  .span-7, .span-8, .span-9 { grid-column: span 12; }
}
@media (max-width: 720px) {
  .bento > * { grid-column: span 12 !important; }
}

/* -------- Status pipeline -------- */
.pipeline {
  display: flex; gap: 6px;
  margin-top: 4px;
}
.pipeline-seg {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-spring);
  display: flex; flex-direction: column; gap: 6px;
  text-align: left;
}
.pipeline-seg:hover { background: var(--surface-3); transform: translateY(-1px); }
.pipeline-seg .lbl { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.pipeline-seg .lbl .swatch { width: 8px; height: 8px; border-radius: 999px; background: var(--text-quaternary); }
.pipeline-seg .num { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.pipeline-seg .delta { font-size: 11px; color: var(--text-tertiary); }
.pipeline-seg.draft .swatch { background: var(--text-quaternary); }
.pipeline-seg.sent .swatch { background: var(--accent); }
.pipeline-seg.viewed .swatch { background: var(--purple); }
.pipeline-seg.paid .swatch { background: var(--green); }

/* -------- Lists / rows -------- */
.row-list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast) var(--ease-out);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row .meta { flex: 1; min-width: 0; }
.row .meta .title { font-size: 14px; font-weight: 500; color: var(--text); }
.row .meta .sub { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.row .amount { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row .badge { flex-shrink: 0; }
.row .avatar-circle {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  flex-shrink: 0;
}

/* -------- Badges / pills -------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  font-size: 11.5px; font-weight: 500;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge svg { width: 10px; height: 10px; }
.badge.green { background: var(--green-tint); color: var(--green); border-color: transparent; }
.badge.amber { background: var(--amber-tint); color: var(--amber); border-color: transparent; }
.badge.red { background: var(--red-tint); color: var(--red); border-color: transparent; }
.badge.blue { background: var(--accent-tint); color: var(--accent-strong); border-color: transparent; }
[data-theme="dark"] .badge.blue { color: var(--accent); }
.badge.purple { background: var(--purple-tint); color: var(--purple); border-color: transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* -------- Inputs / forms -------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.field .hint { font-size: 12px; color: var(--text-tertiary); }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text);
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-quaternary); }
.input:hover, .select:hover, .textarea:hover { background: var(--surface-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.textarea { resize: vertical; min-height: 80px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path stroke='%2386868B' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5 6 7.5l3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 32px;
}

.input-group {
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 10px;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.input-group:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.input-group .prefix, .input-group .suffix {
  color: var(--text-tertiary); font-size: 13px; font-weight: 500;
}
.input-group input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  padding: 9px 8px;
  color: var(--text);
  font-size: 14px;
}

/* segmented control */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: var(--r-md);
  gap: 2px;
}
.segmented button {
  background: transparent;
  border: 0;
  padding: 5px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), inset 0 0 0 1px var(--border);
}
[data-theme="dark"] .segmented button.is-active { background: var(--surface-3); box-shadow: 0 1px 2px rgba(0,0,0,0.4); }

/* toggle (sub-tabs / underline tabs) */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tabs button {
  background: transparent; border: 0;
  padding: 10px 14px;
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color var(--t-fast) var(--ease-out);
}
.tabs button:hover { color: var(--text); }
.tabs button.is-active { color: var(--text); }
.tabs button.is-active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--accent);
  border-radius: 2px;
}

/* -------- Tables -------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  letter-spacing: 0.01em;
}
.table th:first-child { border-top-left-radius: var(--r-md); }
.table th:last-child { border-top-right-radius: var(--r-md); }
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.table tbody tr { transition: background var(--t-fast) var(--ease-out); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* -------- Status banner (Validator) -------- */
.status-banner {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 22px;
  border-radius: var(--r-xl);
  border: 1px solid;
  background: var(--green-tint);
  border-color: transparent;
  color: var(--text);
}
.status-banner .check {
  width: 44px; height: 44px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(52,199,89,0.25);
  flex-shrink: 0;
  animation: pop 360ms var(--ease-spring) backwards;
}
.status-banner .check svg { width: 22px; height: 22px; }
.status-banner h3 { font-size: 17px; font-weight: 600; }
.status-banner p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.status-banner .right { margin-left: auto; display: flex; gap: 8px; }
.status-banner.warn { background: var(--amber-tint); }
.status-banner.warn .check { background: var(--amber); box-shadow: 0 4px 12px rgba(255,159,10,0.25); }
.status-banner.error { background: var(--red-tint); }
.status-banner.error .check { background: var(--red); box-shadow: 0 4px 12px rgba(255,59,48,0.25); }

@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* validation checklist */
.checklist { display: flex; flex-direction: column; }
.checklist-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}
.checklist-row:last-child { border-bottom: 0; }
.checklist-row .ico {
  width: 26px; height: 26px;
  border-radius: 999px;
  display: grid; place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.checklist-row .ico svg { width: 13px; height: 13px; }
.checklist-row.pass .ico { background: var(--green-tint); color: var(--green); }
.checklist-row.warn .ico { background: var(--amber-tint); color: var(--amber); }
.checklist-row.fail .ico { background: var(--red-tint); color: var(--red); }
.checklist-row .meta { flex: 1; }
.checklist-row .meta .title { font-size: 14px; font-weight: 500; }
.checklist-row .meta .sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.checklist-row .meta a { font-size: 12px; }

/* -------- Invoice preview (Creator + Validator) -------- */
.invoice-preview {
  background: #fff;
  color: #111;
  border-radius: var(--r-md);
  padding: 36px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 10px 32px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  border: 1px solid #E5E5EA;
  transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out);
}
[data-theme="dark"] .invoice-preview {
  background: #fff;
  color: #111;
}
.invoice-preview h2 { font-size: 22px; letter-spacing: -0.015em; }
.invoice-preview .meta-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 32px;
  margin: 24px 0;
}
.invoice-preview .meta-grid .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #888; font-weight: 500; margin-bottom: 4px; }
.invoice-preview table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.invoice-preview table th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  color: #888; font-weight: 500; padding: 8px 0; letter-spacing: 0.05em;
  border-bottom: 1px solid #E5E5EA;
}
.invoice-preview table td { padding: 10px 0; border-bottom: 1px solid #F1F1F4; font-variant-numeric: tabular-nums; }
.invoice-preview .totals { margin-top: 18px; margin-left: auto; width: 240px; }
.invoice-preview .totals .line { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.invoice-preview .totals .grand { font-weight: 600; font-size: 15px; border-top: 1px solid #E5E5EA; margin-top: 8px; padding-top: 10px; }
.invoice-preview .logo-stamp {
  width: 40px; height: 40px; border-radius: 9px;
  background: linear-gradient(135deg, #0A84FF 0%, #5E5CE6 100%);
  display: grid; place-items: center; color: #fff;
}

/* -------- Code view -------- */
.code-view {
  background: #0B0B0E;
  color: #E5E5EA;
  border-radius: var(--r-md);
  padding: 18px 20px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  overflow: auto;
  border: 1px solid #2C2C2E;
  position: relative;
  white-space: pre;
}
.code-view .copy-btn {
  position: absolute; top: 12px; right: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: #E5E5EA;
}
.code-view .copy-btn:hover { background: rgba(255,255,255,0.10); }
.code-view .tag { color: #FF7AB6; }
.code-view .attr { color: #FFD479; }
.code-view .str { color: #ACF2E4; }
.code-view .comment { color: #6C6C70; font-style: italic; }

/* -------- Channel cards (Transmission) -------- */
.channel {
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
  cursor: pointer;
  position: relative;
}
.channel:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.channel .ico {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  display: grid; place-items: center;
}
[data-theme="dark"] .channel .ico { color: var(--accent); }
.channel .ico svg { width: 20px; height: 20px; }
.channel h4 { font-size: 15px; font-weight: 600; }
.channel p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; line-height: 1.45; }
.channel .foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 4px; }

/* -------- Timeline (post-send receipt) -------- */
.timeline { display: flex; flex-direction: column; gap: 0; padding: 6px 0; }
.tl-step { display: flex; gap: 14px; position: relative; padding: 10px 0; }
.tl-step::before {
  content: ""; position: absolute; left: 11px; top: 28px; bottom: -6px;
  width: 2px; background: var(--border);
}
.tl-step:last-child::before { display: none; }
.tl-step .dot {
  width: 24px; height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: grid; place-items: center;
  z-index: 1;
  flex-shrink: 0;
}
.tl-step .dot svg { width: 11px; height: 11px; color: var(--text-tertiary); }
.tl-step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.tl-step.done .dot svg { color: #fff; }
.tl-step.current .dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-tint); }
.tl-step.current .dot svg { color: #fff; }
.tl-step .body { padding-top: 2px; }
.tl-step .body .title { font-size: 14px; font-weight: 500; }
.tl-step .body .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* -------- Split (Creator / Validator) -------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.split .sticky { position: sticky; top: calc(var(--topbar-h) + 24px); }

/* form sections */
.form-section { display: flex; flex-direction: column; gap: 16px; padding: 22px; }
.form-section + .form-section { border-top: 1px solid var(--border); }
.form-section h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.full { grid-template-columns: 1fr; }
.hint-inline { color: var(--text-tertiary); font-weight: 400; font-size: 11.5px; }

/* form accordion (Create-Invoice manual mode) */
.form-accordion { border-top: 1px solid var(--border); }
.form-accordion:first-of-type { border-top: 0; }
.form-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 500;
  user-select: none;
  transition: background var(--t-fast) var(--ease-out);
}
.form-accordion > summary::-webkit-details-marker { display: none; }
.form-accordion > summary:hover { background: var(--surface-2); }
.form-accordion > summary .chev {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px;
  color: var(--text-tertiary);
  transition: transform var(--t-fast) var(--ease-out);
}
.form-accordion > summary .chev svg { width: 11px; height: 11px; }
.form-accordion[open] > summary .chev { transform: rotate(90deg); }
.form-accordion > .form-grid { padding: 4px 22px 22px; }
.form-accordion > .line-items { margin-top: 4px; }

/* readonly summary blocks (Payment means, From sender) */
.readonly-block {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.readonly-block .ro-row { display: flex; justify-content: space-between; gap: 16px; }
.readonly-block .ro-row .lbl { color: var(--text-tertiary); font-size: 12.5px; }
.readonly-block .ro-row > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.readonly-block .ro-foot {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}
.readonly-block .ro-foot a { color: var(--accent-strong); }
[data-theme="dark"] .readonly-block .ro-foot a { color: var(--accent); }

/* line items — extended 7-column grid (description / qty / unit / price / vat-cat / total / x) */
.line-items { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.line-item {
  display: grid;
  grid-template-columns: 1fr 80px 110px 110px 28px;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
}
.line-items-x .line-item {
  grid-template-columns: 1.4fr 70px 100px 100px 150px 100px 28px;
}
.line-item-head {
  background: var(--surface-2);
  padding-top: 8px;
  padding-bottom: 8px;
}
.line-item:last-child { border-bottom: 0; }
.line-item input { background: transparent; border: 0; padding: 6px 0; font-size: 14px; color: var(--text); outline: none; }
.line-item input:focus { background: var(--surface-2); padding: 6px 8px; border-radius: 6px; }
.line-item select {
  background: transparent; border: 0; padding: 6px 4px; font-size: 13px; color: var(--text); outline: none;
  font-family: inherit; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  border-radius: 6px;
}
.line-item select:hover { background: var(--surface-2); }
.line-item select:focus { background: var(--surface-2); }
.line-item .remove { width: 24px; height: 24px; border-radius: 6px; background: transparent; border: 0; color: var(--text-tertiary); cursor: pointer; display: grid; place-items: center; }
.line-item .remove:hover { background: var(--red-tint); color: var(--red); }
.line-item .remove svg { width: 12px; height: 12px; }
@media (max-width: 900px) {
  .line-items-x .line-item { grid-template-columns: 1fr 60px 80px 80px 130px 90px 28px; gap: 6px; padding: 10px 14px; }
}

/* sticky action bar */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  position: sticky; bottom: 16px;
}
.action-bar .saved { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.action-bar .saved svg { color: var(--green); width: 14px; height: 14px; }
.action-bar .actions { display: flex; gap: 8px; }

/* -------- Knowledge Hub -------- */
.hub-hero {
  padding: 40px;
  border-radius: var(--r-2xl);
  background: linear-gradient(135deg, var(--accent-tint) 0%, var(--purple-tint) 100%);
  border: 1px solid var(--border);
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px;
  align-items: center;
}
@media (max-width: 1000px) { .hub-hero { grid-template-columns: 1fr; } }
.hub-hero .eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent-strong);
  margin-bottom: 16px;
}
[data-theme="dark"] .hub-hero .eyebrow { color: var(--accent); }
.hub-hero h2 { font-size: 32px; line-height: 1.1; letter-spacing: -0.02em; }
.hub-hero p { color: var(--text-secondary); margin-top: 12px; font-size: 16px; max-width: 52ch; }
.hub-hero .cta { margin-top: 24px; display: flex; gap: 10px; }
.hub-hero .illu {
  aspect-ratio: 4/3; border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  position: relative; overflow: hidden;
}
.readiness {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  margin-top: 0;
}
.readiness-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.readiness-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--green) 100%);
  border-radius: 999px;
  width: 78%;
  animation: grow 1200ms var(--ease-out) backwards;
}
@keyframes grow { from { width: 0; } }

.article-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
}
@media (max-width: 900px) { .article-grid { grid-template-columns: 1fr; } }
.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  cursor: pointer;
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out), border-color var(--t-base) var(--ease-out);
}
.article:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.article .ico {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--accent-strong);
}
[data-theme="dark"] .article .ico { color: var(--accent); }
.article .ico svg { width: 22px; height: 22px; }
.article h4 { font-size: 16px; font-weight: 600; }
.article p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.article .foot { margin-top: auto; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-tertiary); padding-top: 8px; }

/* -------- Slide-over drawer -------- */
.drawer-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease-out);
}
.drawer-mask.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0;
  height: 100vh; width: 480px; max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 51;
  transform: translateX(100%);
  transition: transform var(--t-slow) var(--ease-out);
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-body { flex: 1; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* -------- Empty state -------- */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty .ill {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-tertiary);
}
.empty .ill svg { width: 28px; height: 28px; }
.empty h4 { font-size: 16px; color: var(--text); margin-bottom: 4px; }
.empty p { font-size: 13.5px; max-width: 36ch; margin: 0 auto; }
.empty .cta { margin-top: 20px; }

/* -------- Reveal -------- */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out); }
.reveal.in { opacity: 1; transform: translateY(0); }

/* count-up */
.kpi-value { transition: color var(--t-base) var(--ease-out); }

/* utility */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-right { text-align: right; }
.ml-auto { margin-left: auto; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .canvas { padding: 24px 16px 48px; }
  .topbar { padding: 0 16px; }
  .page-head { flex-direction: column; align-items: flex-start; }
}

/* focus rings */
:focus-visible { outline: none; }
button:focus-visible, a:focus-visible, .nav-item:focus-visible { box-shadow: var(--shadow-focus); border-radius: 8px; }

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
