@font-face {
  font-family: "Ubuntu";
  font-style: normal;
  font-weight: 400;
  src: url("./fonts/Ubuntu-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "Ubuntu";
  font-style: italic;
  font-weight: 400;
  src: url("./fonts/Ubuntu-Italic.ttf") format("truetype");
}

@font-face {
  font-family: "Ubuntu";
  font-style: normal;
  font-weight: 700;
  src: url("./fonts/Ubuntu-Bold.ttf") format("truetype");
}

/* ─── Design tokens ─────────────────────────────────────────── */
:root {
  color-scheme: light;

  /* Surface */
  --bg:               #f2ece2;
  --bg-accent:        #e4dace;
  --surface:          rgba(255, 253, 248, 0.96);
  --surface-strong:   #fffefb;
  --surface-alt:      #f9f5ee;

  /* Lines */
  --line:             rgba(80, 60, 30, 0.10);
  --line-strong:      rgba(80, 60, 30, 0.20);

  /* Text */
  --text:             #1e160a;
  --muted:            #72614e;

  /* Brand */
  --accent:           #a06826;
  --accent-strong:    #7a4c12;
  --accent-soft:      rgba(160, 104, 38, 0.12);

  /* Semantic */
  --danger:           #c0463b;
  --danger-soft:      rgba(192, 70, 59, 0.11);
  --success:          #197a5a;
  --success-soft:     rgba(25, 122, 90, 0.11);
  --warning:          #c4831a;

  /* Shadows */
  --shadow-sm:        0 2px 8px rgba(30, 18, 6, 0.07);
  --shadow:           0 8px 28px rgba(30, 18, 6, 0.10), 0 2px 6px rgba(30, 18, 6, 0.06);
  --shadow-lg:        0 20px 52px rgba(30, 18, 6, 0.13), 0 4px 12px rgba(30, 18, 6, 0.06);
  --shadow-xl:        0 32px 72px rgba(30, 18, 6, 0.16), 0 8px 20px rgba(30, 18, 6, 0.07);

  /* Backgrounds */
  --body-background:
    radial-gradient(ellipse 60% 40% at 0% 0%,   rgba(160, 104, 38, 0.13), transparent),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(100, 64, 18, 0.09), transparent),
    linear-gradient(160deg, #faf6ef 0%, #ede5d5 55%, #f8f4ec 100%);

  --sidebar-background: linear-gradient(175deg, #1a0f04 0%, #3a240e 60%, #2c1a08 100%);
  --sidebar-text: #fff8f0;
  --sidebar-link-bg: rgba(255, 246, 230, 0.05);
  --sidebar-link-border: rgba(230, 195, 130, 0.10);
  --sidebar-link-text: rgba(255, 238, 208, 0.82);

  --hero-background: linear-gradient(145deg, #1e0f04 0%, #7a4c12 60%, #a06828 100%);
  --brand-background: linear-gradient(135deg, #f5d49a, #c07e30);
  --brand-text: #3a240d;

  /* Radii — max 7px across all widgets */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 7px;
  --radius-xl: 7px;
  --radius-2xl: 7px;

  /* Typography */
  --font-body:    "Ubuntu", "Trebuchet MS", sans-serif;
  --font-heading: "Ubuntu", "Trebuchet MS", sans-serif;

  /* Animation */
  --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Theme: Midnight ───────────────────────────────────────── */
:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg:               #090e15;
  --bg-accent:        #101923;
  --surface:          rgba(14, 22, 32, 0.96);
  --surface-strong:   #0c1520;
  --surface-alt:      #111d29;
  --line:             rgba(120, 148, 178, 0.14);
  --line-strong:      rgba(120, 148, 178, 0.26);
  --text:             #e6edf5;
  --muted:            #8fa3b8;
  --accent:           #4a90d9;
  --accent-strong:    #2e6eb8;
  --accent-soft:      rgba(74, 144, 217, 0.14);
  --danger:           #df6b62;
  --danger-soft:      rgba(223, 107, 98, 0.13);
  --success:          #38b38a;
  --success-soft:     rgba(56, 179, 138, 0.13);
  --warning:          #e3a649;
  --shadow-sm:        0 2px 8px rgba(0,0,0,0.24);
  --shadow:           0 8px 28px rgba(0,0,0,0.32), 0 2px 6px rgba(0,0,0,0.20);
  --shadow-lg:        0 20px 52px rgba(0,0,0,0.42), 0 4px 12px rgba(0,0,0,0.22);
  --shadow-xl:        0 32px 72px rgba(0,0,0,0.52), 0 8px 20px rgba(0,0,0,0.24);
  --body-background:
    radial-gradient(ellipse 55% 40% at 0% 0%,    rgba(74, 144, 217, 0.13), transparent),
    radial-gradient(ellipse 45% 35% at 100% 100%, rgba(56, 179, 138, 0.10), transparent),
    linear-gradient(160deg, #07101a 0%, #0d1928 55%, #09121e 100%);
  --sidebar-background: linear-gradient(175deg, #050d14 0%, #0c1927 60%, #071020 100%);
  --sidebar-text: #ecf5ff;
  --sidebar-link-bg: rgba(230, 248, 255, 0.04);
  --sidebar-link-border: rgba(120, 160, 210, 0.10);
  --sidebar-link-text: rgba(220, 238, 255, 0.82);
  --hero-background: linear-gradient(145deg, #060e18 0%, #193255 60%, #2e6eb8 100%);
  --brand-background: linear-gradient(135deg, #1a3556, #4a90d9);
  --brand-text: #eef8ff;
}

/* ─── Theme: Emerald ────────────────────────────────────────── */
:root[data-theme="emerald"] {
  --bg:               #eaf6ef;
  --bg-accent:        #d4ede2;
  --surface:          rgba(250, 255, 252, 0.96);
  --surface-strong:   #ffffff;
  --surface-alt:      #edf8f3;
  --line:             rgba(20, 80, 58, 0.11);
  --line-strong:      rgba(20, 80, 58, 0.21);
  --text:             #12392b;
  --muted:            #587d6f;
  --accent:           #17825f;
  --accent-strong:    #0f6849;
  --accent-soft:      rgba(23, 130, 95, 0.12);
  --danger:           #be5454;
  --danger-soft:      rgba(190, 84, 84, 0.11);
  --success:          #17825f;
  --success-soft:     rgba(23, 130, 95, 0.11);
  --warning:          #c88b2a;
  --body-background:
    radial-gradient(ellipse 60% 40% at 0% 0%,    rgba(23, 130, 95, 0.15), transparent),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(80, 170, 130, 0.10), transparent),
    linear-gradient(160deg, #f6fdf9 0%, #e5f5ed 55%, #f7fcf9 100%);
  --sidebar-background: linear-gradient(175deg, #082d20 0%, #155e44 60%, #0e4a34 100%);
  --sidebar-text: #eafef4;
  --sidebar-link-bg: rgba(244, 255, 249, 0.05);
  --sidebar-link-border: rgba(140, 220, 190, 0.12);
  --sidebar-link-text: rgba(230, 254, 244, 0.84);
  --hero-background: linear-gradient(145deg, #072018 0%, #166048 60%, #209d74 100%);
  --brand-background: linear-gradient(135deg, #bff0d6, #1da876);
  --brand-text: #0d3525;
}

/* ─── Theme: Executive ──────────────────────────────────────── */
:root[data-theme="executive"] {
  --bg:               #eef2f9;
  --bg-accent:        #dce5f2;
  --surface:          rgba(255, 255, 255, 0.96);
  --surface-strong:   #ffffff;
  --surface-alt:      #f4f7fd;
  --line:             rgba(20, 40, 75, 0.11);
  --line-strong:      rgba(20, 40, 75, 0.21);
  --text:             #162840;
  --muted:            #5e748e;
  --accent:           #2960c8;
  --accent-strong:    #1a45a0;
  --accent-soft:      rgba(41, 96, 200, 0.12);
  --danger:           #c45350;
  --danger-soft:      rgba(196, 83, 80, 0.11);
  --success:          #1e7e6c;
  --success-soft:     rgba(30, 126, 108, 0.11);
  --warning:          #cc8a26;
  --body-background:
    radial-gradient(ellipse 60% 40% at 100% 0%,  rgba(41, 96, 200, 0.13), transparent),
    radial-gradient(ellipse 50% 40% at 0% 100%,  rgba(30, 126, 108, 0.10), transparent),
    linear-gradient(160deg, #f6faff 0%, #eaf0f9 55%, #f8fbff 100%);
  --sidebar-background: linear-gradient(175deg, #0d1e3a 0%, #1c3a6a 60%, #152f58 100%);
  --sidebar-text: #eef6ff;
  --sidebar-link-bg: rgba(236, 247, 255, 0.05);
  --sidebar-link-border: rgba(120, 165, 230, 0.12);
  --sidebar-link-text: rgba(225, 242, 255, 0.84);
  --hero-background: linear-gradient(145deg, #0a1830 0%, #1c3a6a 60%, #2960c8 100%);
  --brand-background: linear-gradient(135deg, #d8e8ff, #5a8ee8);
  --brand-text: #152f58;
}

/* ─── Theme: Glass ──────────────────────────────────────────── */
:root[data-theme="glass"] {
  --bg:               #e8f5f3;
  --bg-accent:        #d2ede9;
  --surface:          rgba(250, 255, 254, 0.74);
  --surface-strong:   rgba(255, 255, 255, 0.92);
  --surface-alt:      rgba(234, 250, 248, 0.80);
  --line:             rgba(15, 95, 90, 0.15);
  --line-strong:      rgba(15, 95, 90, 0.28);
  --text:             #0f3038;
  --muted:            #537880;
  --accent:           #0c9c92;
  --accent-strong:    #076e6a;
  --accent-soft:      rgba(12, 156, 146, 0.14);
  --danger:           #c25265;
  --danger-soft:      rgba(194, 82, 101, 0.12);
  --success:          #148665;
  --success-soft:     rgba(20, 134, 101, 0.12);
  --warning:          #be8a2d;
  --shadow:           0 8px 32px rgba(12, 68, 76, 0.15), 0 2px 8px rgba(12, 68, 76, 0.08);
  --shadow-lg:        0 24px 60px rgba(12, 68, 76, 0.20), 0 4px 14px rgba(12, 68, 76, 0.10);
  --body-background:
    linear-gradient(135deg, rgba(255,255,255,.58), rgba(255,255,255,0) 36%),
    radial-gradient(ellipse 55% 45% at 15% 12%, rgba(45, 215, 190, 0.28), transparent),
    radial-gradient(ellipse 45% 40% at 84% 16%, rgba(120, 215, 250, 0.22), transparent),
    linear-gradient(160deg, #ebf7f6 0%, #d5ece9 50%, #f5fafe 100%);
  --sidebar-background: linear-gradient(175deg, rgba(6, 46, 54, 0.92) 0%, rgba(10, 98, 93, 0.84) 60%);
  --sidebar-text: #f0fffd;
  --sidebar-link-bg: rgba(255, 255, 255, 0.09);
  --sidebar-link-border: rgba(200, 255, 250, 0.18);
  --sidebar-link-text: rgba(234, 255, 252, 0.90);
  --hero-background: linear-gradient(145deg, rgba(4, 44, 52, 0.94), rgba(14, 148, 138, 0.80));
  --brand-background: linear-gradient(135deg, rgba(236, 254, 255, 0.94), rgba(18, 188, 168, 0.84));
  --brand-text: #063c40;
}

/* ─── Theme: Fire ───────────────────────────────────────────── */
:root[data-theme="fire"] {
  --bg:               #fff0e5;
  --bg-accent:        #fecfaa;
  --surface:          rgba(255, 250, 244, 0.96);
  --surface-strong:   #fffaf6;
  --surface-alt:      #ffede0;
  --line:             rgba(130, 28, 28, 0.15);
  --line-strong:      rgba(130, 28, 28, 0.28);
  --text:             #2c150c;
  --muted:            #7e4e32;
  --accent:           #da2020;
  --accent-strong:    #981818;
  --accent-soft:      rgba(218, 32, 32, 0.12);
  --danger:           #b81818;
  --danger-soft:      rgba(184, 24, 24, 0.12);
  --success:          #17705a;
  --success-soft:     rgba(23, 112, 90, 0.12);
  --warning:          #f59e0b;
  --shadow:           0 8px 28px rgba(130, 28, 28, 0.14), 0 2px 6px rgba(130, 28, 28, 0.08);
  --shadow-lg:        0 24px 56px rgba(130, 28, 28, 0.20), 0 4px 12px rgba(130, 28, 28, 0.10);
  --body-background:
    radial-gradient(ellipse 55% 45% at 12% 16%, rgba(240, 68, 68, 0.24), transparent),
    radial-gradient(ellipse 45% 38% at 86% 18%, rgba(245, 158, 11, 0.24), transparent),
    linear-gradient(160deg, #fff6ed 0%, #ffddba 50%, #fff8f0 100%);
  --sidebar-background: linear-gradient(175deg, #420c08 0%, #7f1d1d 60%, #6a1212 100%);
  --sidebar-text: #fff6ed;
  --sidebar-link-bg: rgba(255, 237, 213, 0.07);
  --sidebar-link-border: rgba(252, 178, 110, 0.16);
  --sidebar-link-text: rgba(255, 246, 237, 0.90);
  --hero-background: linear-gradient(145deg, #420c08 0%, #991b1b 55%, #da2020 80%, #f59e0b 100%);
  --brand-background: linear-gradient(135deg, #fecba0, #ef4444 60%, #f59e0b);
  --brand-text: #3a1408;
}

/* ─── Theme: Ice ────────────────────────────────────────────── */
:root[data-theme="ice"] {
  --bg:               #e8f8ff;
  --bg-accent:        #d4f0fb;
  --surface:          rgba(248, 253, 255, 0.92);
  --surface-strong:   #ffffff;
  --surface-alt:      #e8f8ff;
  --line:             rgba(10, 118, 148, 0.15);
  --line-strong:      rgba(10, 118, 148, 0.26);
  --text:             #103040;
  --muted:            #4e7282;
  --accent:           #0280c4;
  --accent-strong:    #0164a0;
  --accent-soft:      rgba(2, 128, 196, 0.12);
  --danger:           #be5070;
  --danger-soft:      rgba(190, 80, 112, 0.11);
  --success:          #0d8878;
  --success-soft:     rgba(13, 136, 120, 0.12);
  --warning:          #c28020;
  --shadow:           0 8px 28px rgba(6, 86, 120, 0.12), 0 2px 6px rgba(6, 86, 120, 0.07);
  --shadow-lg:        0 24px 56px rgba(6, 86, 120, 0.16), 0 4px 12px rgba(6, 86, 120, 0.08);
  --body-background:
    linear-gradient(135deg, rgba(255,255,255,.74), rgba(255,255,255,0) 40%),
    radial-gradient(ellipse 55% 45% at 10% 14%, rgba(186, 230, 253, 0.54), transparent),
    radial-gradient(ellipse 45% 38% at 84% 16%, rgba(34, 215, 240, 0.20), transparent),
    linear-gradient(160deg, #f5fcff 0%, #daf0fb 52%, #ffffff 100%);
  --sidebar-background: linear-gradient(175deg, #052e4a 0%, #0c6e94 60%, #095a7c 100%);
  --sidebar-text: #eefbff;
  --sidebar-link-bg: rgba(224, 248, 255, 0.08);
  --sidebar-link-border: rgba(186, 230, 253, 0.22);
  --sidebar-link-text: rgba(232, 249, 255, 0.90);
  --hero-background: linear-gradient(145deg, #042840 0%, #0c6e94 60%, #0280c4 100%);
  --brand-background: linear-gradient(135deg, #e8f8ff, #7ad2fc 52%, #38bdf8);
  --brand-text: #0c3448;
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  background: var(--body-background);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-heading);
  line-height: 1.2;
}

button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

button {
  transition:
    transform .16s var(--ease-out),
    box-shadow .16s var(--ease-out),
    background-color .16s ease,
    border-color .16s ease,
    opacity .16s ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: .52; cursor: not-allowed; transform: none !important; }

.hidden { display: none !important; }
.text-right { text-align: right; }

/* ─── Shell ─────────────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* ─── Eyebrow ───────────────────────────────────────────────── */
.eyebrow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .20em;
  font-weight: 700;
  color: var(--accent);
}

/* ─── Login ─────────────────────────────────────────────────── */
.login-view {
  min-height: calc(100vh - 40px);
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(440px, 1fr);
  gap: 24px;
  align-items: stretch;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(16px) saturate(1.1);
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.login-panel h1 {
  font-size: clamp(1.75rem, 2.4vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -.01em;
}

.lead, .workspace-copy, .panel-head p, .hero-panel p, .summary-note {
  color: var(--muted);
  line-height: 1.68;
  font-size: 14.5px;
}

/* ─── Login art ─────────────────────────────────────────────── */
.login-art {
  background: var(--hero-background);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  color: rgba(255, 248, 238, 0.92);
  padding: 36px;
  display: grid;
  gap: 20px;
  align-content: end;
  position: relative;
  overflow: hidden;
}

.login-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 55% at 100% 0%, rgba(255,255,255,.09), transparent),
    radial-gradient(ellipse 50% 45% at 0% 100%, rgba(255,255,255,.06), transparent);
  pointer-events: none;
}

.login-art::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,.28), rgba(255,255,255,0));
  pointer-events: none;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  position: relative;
}

.preview-card {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: var(--radius-xl);
  padding: 18px;
  display: grid;
  gap: 10px;
  backdrop-filter: blur(8px);
  transition: background .2s ease, border-color .2s ease;
}

.preview-card:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.16);
}

.preview-hero {
  min-height: 220px;
  align-content: end;
  background: rgba(255, 255, 255, 0.05);
}

.preview-tag {
  display: inline-flex;
  width: fit-content;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.preview-card strong {
  font-size: 14px;
  line-height: 1.45;
}

/* ─── Auth form ─────────────────────────────────────────────── */
.auth-form, .field, .compact-field { display: grid; gap: 7px; }

.field span, .compact-field span {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
  font-weight: 700;
}

.input-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.input-action-btn { min-width: 72px; padding-inline: 14px; }

.login-meta-row { display: flex; justify-content: flex-end; }

.text-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-strong);
  transition: color .15s ease;
}
.text-link:hover { color: var(--accent); }

/* ─── Inputs ────────────────────────────────────────────────── */
input, select, textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line-strong);
  padding: 11px 14px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }

/* ─── Shared card surfaces ──────────────────────────────────── */
.connection-card, .status-card, .panel-pill, .mini-stat-card, .summary-card, .detail-block, .detail-summary, .detail-stat-grid > article {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.connection-card, .status-card { padding: 14px 16px; font-size: 14px; }
.connection-card code { font-size: 12.5px; word-break: break-all; }

.status-card { line-height: 1.6; }
.status-card.error { border-color: rgba(192, 70, 59, 0.32); color: var(--danger); background: var(--danger-soft); }

.api-config-card { display: grid; gap: 14px; }
.api-config-card summary {
  display: grid;
  gap: 4px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}
.api-config-card summary::marker { color: var(--accent); }
.api-config-card summary small { color: var(--muted); font-weight: 500; }
.api-config-card[open] summary { margin-bottom: 10px; }
.api-config-grid { margin-bottom: 12px; }
.api-config-actions { margin-bottom: 6px; }
.error-text { color: var(--danger); }

/* ─── Layout helpers ────────────────────────────────────────── */
.login-actions, .workspace-actions, .hero-actions, .detail-actions, .modal-actions, .pager-actions, .toolbar-row, .section-head, .panel-head, .summary-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.login-actions, .modal-actions { justify-content: flex-start; }
.workspace-actions, .toolbar-row, .panel-head, .section-head { flex-wrap: wrap; }

.invoice-filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 180px) auto auto;
  gap: 8px;
  align-items: center;
}

.invoice-filter-row input,
.invoice-filter-row select,
.invoice-filter-row button {
  min-width: 0;
  width: 100%;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.primary-btn, .ghost-btn, .danger-btn, .anchor-btn {
  border-radius: var(--radius-md);
  padding: 10px 18px;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  letter-spacing: .01em;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fffdf8;
  box-shadow: 0 4px 14px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.08);
  border-color: transparent;
}
.primary-btn:hover:not(:disabled) {
  box-shadow: 0 8px 22px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.10);
}

.ghost-btn, .anchor-btn {
  background: rgba(255,255,255,.46);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.ghost-btn:hover:not(:disabled) {
  background: rgba(255,255,255,.72);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.danger-btn {
  background: var(--danger-soft);
  border-color: rgba(192,70,59,.22);
  color: var(--danger);
}
.danger-btn:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}

/* Theme-specific button overrides */
:root[data-theme="glass"] .primary-btn,
:root[data-theme="glass"] .table-btn:not(.danger) {
  background: linear-gradient(135deg, rgba(12,156,146,.96), rgba(6,110,106,.88));
  border-color: rgba(200,255,252,.42);
  box-shadow: 0 6px 20px rgba(12, 118, 110, .22);
}

:root[data-theme="glass"] .ghost-btn,
:root[data-theme="glass"] .anchor-btn,
:root[data-theme="glass"] .chip,
:root[data-theme="glass"] .panel-pill {
  background: rgba(255,255,255,.58);
  border-color: rgba(255,255,255,.52);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.58);
}

:root[data-theme="fire"] .primary-btn,
:root[data-theme="fire"] .table-btn:not(.danger) {
  background: linear-gradient(135deg, #7f1d1d, #da2020 58%, #f59e0b);
  border-color: rgba(252,180,110,.46);
  box-shadow: 0 6px 20px rgba(130, 28, 28, .22);
}

:root[data-theme="fire"] .ghost-btn,
:root[data-theme="fire"] .anchor-btn,
:root[data-theme="fire"] .chip,
:root[data-theme="fire"] .panel-pill {
  background: rgba(255, 236, 212, .66);
  border-color: rgba(248, 110, 110, .32);
  color: #431407;
}

:root[data-theme="ice"] .primary-btn,
:root[data-theme="ice"] .table-btn:not(.danger) {
  background: linear-gradient(135deg, #0164a0, #0280c4 58%, #65e0f8);
  border-color: rgba(186, 230, 253, .66);
  box-shadow: 0 6px 20px rgba(6, 86, 120, .18);
}

:root[data-theme="ice"] .ghost-btn,
:root[data-theme="ice"] .anchor-btn,
:root[data-theme="ice"] .chip,
:root[data-theme="ice"] .panel-pill {
  background: rgba(238, 249, 255, .76);
  border-color: rgba(120, 210, 252, .40);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.76);
}

/* ─── Workspace shell ───────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 40px);
  align-items: start;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-background);
  color: var(--sidebar-text);
  border-radius: var(--radius-2xl);
  border: 1px solid rgba(255,255,255,.08);
  padding: 22px 18px;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 32px 70px rgba(8, 9, 12, 0.28), inset 0 1px 0 rgba(255,255,255,.07);
  isolation: isolate;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 70% 36% at 50% 0%, rgba(255,255,255,.12), transparent),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(255,255,255,.05), transparent);
  pointer-events: none;
  z-index: -1;
}

.sidebar-top { display: grid; gap: 20px; }

/* Brand lockup */
.brand-lockup {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  padding: 4px 2px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  background: var(--brand-background);
  color: var(--brand-text);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.38);
  letter-spacing: -.01em;
  flex-shrink: 0;
}

.brand-copy { display: grid; gap: 4px; }
.brand-copy h2 { margin: 0; font-size: 20px; letter-spacing: .02em; color: #fff; }

.sidebar-brand-note {
  margin: 0;
  color: rgba(255,255,255,.60);
  line-height: 1.5;
  font-size: 12px;
}

.premium-badge {
  display: inline-flex;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.14);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255,255,255,.76);
  font-weight: 700;
}

/* Nav */
.sidebar-nav { display: grid; gap: 4px; }

.nav-btn {
  border-radius: var(--radius-md);
  background: var(--sidebar-link-bg);
  border: 1px solid var(--sidebar-link-border);
  color: var(--sidebar-link-text);
  width: 100%;
  padding: 11px 14px 11px 16px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: none;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .16s var(--ease-out), box-shadow .16s ease;
}

.nav-btn:hover:not(:disabled) { transform: translateY(0) translateX(2px); }

.nav-btn-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.09);
  flex-shrink: 0;
  transition: background .18s ease;
}

.nav-btn-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .82;
}

.nav-btn-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.nav-label { font-weight: 700; font-size: 13.5px; }

.nav-btn small {
  color: rgba(255,255,255,.52);
  line-height: 1.4;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn-featured {
  background: linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.06));
  color: rgba(255,255,255,.96);
  border-color: rgba(255,255,255,.22);
  box-shadow: 0 8px 22px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.14);
  margin-bottom: 4px;
}

.nav-btn-featured .nav-btn-icon {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.18);
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(255,255,255,.14), rgba(255,255,255,.06));
  color: rgba(255,255,255,.96);
  border-color: rgba(255,255,255,.20);
  box-shadow: 0 6px 18px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.10);
}

.nav-btn.active .nav-btn-icon {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.18);
}

.nav-btn.active .nav-btn-icon svg,
.nav-btn-featured .nav-btn-icon svg { opacity: 1; }

/* Active indicator pill */
.nav-btn.active::after,
.nav-btn-featured::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.80);
  box-shadow: 0 0 10px rgba(255,255,255,.40);
}

.sidebar-link {
  border-radius: var(--radius-md);
  background: var(--sidebar-link-bg);
  border: 1px solid var(--sidebar-link-border);
  color: var(--sidebar-link-text);
  display: block;
  padding: 11px 14px;
  font-size: 14px;
}

.sidebar-heading {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: rgba(255,255,255,.52);
  margin-bottom: 8px;
  font-weight: 700;
}

/* Sidebar footer */
.sidebar-foot { display: grid; gap: 12px; }

.sidebar-session-card {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.sidebar-session-card p {
  margin: 0;
  font-weight: 700;
  color: rgba(255,255,255,.92);
  font-size: 14px;
}

.sidebar-session-meta {
  display: block;
  margin-top: 5px;
  color: rgba(255,255,255,.58);
  line-height: 1.5;
  font-size: 12px;
}

/* ─── Workspace main ────────────────────────────────────────── */
.workspace-main { display: grid; gap: 18px; min-width: 0; }

.workspace-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.workspace-header h1 {
  font-size: 22px;
  letter-spacing: -.01em;
}

/* ─── Notice/Toast ──────────────────────────────────────────── */
.notice {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 9999;
  width: min(400px, calc(100vw - 56px));
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  font-weight: 700;
  font-size: 14px;
  animation: noticeIn .2s var(--ease-out) both;
}
.notice.error { color: var(--danger); border-color: rgba(192,70,59,.26); background: var(--danger-soft); }
.notice.success { color: var(--success); border-color: rgba(25,128,95,.24); background: var(--success-soft); }

@keyframes noticeIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Pages ─────────────────────────────────────────────────── */
.page-section { display: grid; gap: 16px; }

.hero-panel, .panel-card, .metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-panel {
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  background:
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0)),
    var(--surface);
}

.hero-panel h3 {
  font-size: 20px;
  letter-spacing: -.01em;
  margin-top: 5px;
}

.panel-card { padding: 24px; }

/* ─── Metrics ───────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 22px 20px 20px;
  display: grid;
  gap: 8px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.52), rgba(255,255,255,0)),
    var(--surface);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 75%);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 68%);
  pointer-events: none;
}

.metric-card span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong { font-size: 26px; line-height: 1.1; letter-spacing: -.01em; }
.metric-card small { line-height: 1.5; color: var(--muted); font-size: 12.5px; }
.mini-stat-card span { font-size: 11px; text-transform: uppercase; letter-spacing: .10em; color: var(--muted); font-weight: 700; }
.mini-stat-card strong { font-size: 24px; line-height: 1.1; }

.accent-card {
  background: var(--hero-background);
  color: rgba(255, 250, 244, .95);
  border-color: transparent;
}
.accent-card span, .accent-card small { color: rgba(255,255,255,.72); }
.accent-card::before { background: linear-gradient(90deg, rgba(255,255,255,.88), rgba(255,255,255,0)); }
.accent-card::after  { background: radial-gradient(circle, rgba(255,255,255,.16), transparent 68%); }

/* ─── Widget grid ───────────────────────────────────────────── */
.widget-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.overview-widget {
  position: relative;
  overflow: hidden;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.58), rgba(255,255,255,0)),
    var(--surface);
}

.overview-widget::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 100% 0%, var(--accent-soft), transparent);
  pointer-events: none;
}

.overview-widget::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,.70), rgba(255,255,255,0));
}

.widget-recent::before   { background: radial-gradient(ellipse at 100% 0%, rgba(47,99,199,.10), transparent); }
.widget-collection::before{ background: radial-gradient(ellipse at 100% 0%, rgba(25,128,95,.10), transparent); }
.widget-customers::before { background: radial-gradient(ellipse at 100% 0%, rgba(155,108,47,.10), transparent); }
.widget-inventory::before { background: radial-gradient(ellipse at 100% 0%, rgba(197,133,30,.12), transparent); }

/* ─── Tables ────────────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.data-table { width: 100%; border-collapse: collapse; min-width: 820px; }

.data-table th, .data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
  background: var(--surface-alt);
  font-weight: 700;
}

.data-table tbody tr {
  transition: background .12s ease;
}

.data-table tbody tr:hover {
  background: rgba(160, 104, 38, 0.04);
}

.table-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.table-btn, .chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.chip.success { color: var(--success); background: var(--success-soft); border-color: rgba(25,128,95,.22); }
.chip.warning { color: var(--warning); background: rgba(196,131,26,.10); border-color: rgba(196,131,26,.22); }
.chip.danger  { color: var(--danger);  background: var(--danger-soft);  border-color: rgba(192,70,59,.22); }
.chip.info    { color: var(--accent);  background: var(--accent-soft);  border-color: rgba(160,104,38,.22); }

/* ─── Empty & pager ─────────────────────────────────────────── */
.empty-state, .detail-empty {
  padding: 36px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.pager-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--muted);
}

/* ─── Stack / list rows ─────────────────────────────────────── */
.stack-list, .line-items, .dynamic-list { display: grid; gap: 10px; }

.stack-row, .line-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255,255,255,.38), rgba(255,255,255,0)),
    var(--surface-alt);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.38);
  font-size: 14px;
}

.stack-row strong:first-child { font-size: 14.5px; }
.stack-row strong:last-child  { color: var(--title, var(--text)); }
.stack-row small, .stack-meta { color: var(--muted); display: block; margin-top: 3px; line-height: 1.5; font-size: 12.5px; }

/* ─── Detail panel ──────────────────────────────────────────── */
.detail-panel { align-self: start; }
.detail-content { display: grid; gap: 12px; }

.detail-summary {
  padding: 14px 16px;
  display: grid;
  gap: 7px;
}
.detail-summary strong { font-size: 20px; }

.detail-block {
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}
.detail-block-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.detail-actions { flex-wrap: wrap; }

.mini-stat-card, .detail-stat-grid > article {
  padding: 14px 16px;
  display: grid;
  gap: 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.38), rgba(255,255,255,0)),
    var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.38);
}

.summary-note {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.42);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.38);
  font-size: 13.5px;
}

/* ─── Split shell ───────────────────────────────────────────── */
.split-shell { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .9fr); gap: 14px; }
.collection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.theme-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.field-wide { grid-column: 1 / -1; }
.settings-shell { align-items: start; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

/* ─── Panel head ────────────────────────────────────────────── */
.panel-head { justify-content: space-between; }
.panel-head h4 { font-size: 17px; letter-spacing: -.01em; }
.panel-head > div { display: grid; gap: 3px; }
.section-head { justify-content: space-between; padding-bottom: 6px; border-bottom: 1px solid var(--line); }

.panel-pill {
  padding: 6px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .10em;
  font-weight: 700;
}

/* ─── Modal ─────────────────────────────────────────────────── */
.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 14, 22, 0.62);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  width: min(740px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(20px);
  padding: 28px;
  animation: modalIn .22s var(--ease-out) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-wide { width: min(1020px, calc(100vw - 32px)); }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h4 { font-size: 18px; letter-spacing: -.01em; }
.modal-body { display: grid; gap: 16px; }
.workspace-form-body { display: grid; gap: 16px; }
.form-section { display: grid; gap: 12px; }

.dynamic-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.dynamic-item-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

/* ─── Quantity field + embedded multiplier ──────────────────── */
.qty-wrap { display: grid; }

.qty-input-row {
  position: relative;
  display: flex;
}

.qty-input-row input[type="number"] {
  flex: 1;
  padding-right: 38px;
}

.qty-wrap--on .qty-input-row input[type="number"] {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* The × toggle embedded in the right edge of the input */
.qty-mult-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-radius .15s;
  z-index: 1;
}
.qty-mult-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-50%); /* cancel global button lift — keeps absolute position */
}
.qty-wrap--on .qty-mult-toggle {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
}
.qty-wrap--on .qty-mult-toggle:hover {
  background: var(--accent-strong);
  transform: translateY(-50%);
}

/* Panel that appears below the input */
.qty-mult-panel {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  flex-wrap: wrap;
}

.qmp-sym {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
  opacity: .65;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
}

.qmp-val,
.qmp-lbl {
  padding: 4px 7px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1.5px solid var(--line-strong);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.qmp-val { width: 62px; }
.qmp-lbl { width: 70px; }
.qmp-val:focus,
.qmp-lbl:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.qmp-val::-webkit-inner-spin-button,
.qmp-val::-webkit-outer-spin-button { opacity: 0; }
.qmp-val:hover::-webkit-inner-spin-button,
.qmp-val:hover::-webkit-outer-spin-button { opacity: .5; }

.qmp-divider {
  flex: 1;
  min-width: 4px;
}

.qmp-eq {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  opacity: .65;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
}

.qmp-result {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-strong);
  flex-shrink: 0;
  min-width: 20px;
  letter-spacing: -.01em;
}

.payment-detail-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.summary-card {
  padding: 16px 18px;
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
}

.summary-row { justify-content: space-between; font-size: 14px; }
.summary-row.total {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.summary-row strong { font-size: inherit; }

/* ─── Wizard ────────────────────────────────────────────────── */
.wizard-shell { display: grid; gap: 16px; }

.wizard-progress {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}

.wizard-step:hover { border-color: var(--line-strong); color: var(--text); }

.wizard-step.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.wizard-step.complete {
  background: var(--success-soft);
  border-color: rgba(25,128,95,.24);
  color: var(--success);
}

.wizard-step-index {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.wizard-step.active .wizard-step-index {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.wizard-step.complete .wizard-step-index {
  background: var(--success);
  color: #fff;
  border-color: transparent;
}

.wizard-step-copy { display: grid; gap: 2px; }
.wizard-step-copy small { color: var(--muted); line-height: 1.4; font-size: 11px; }
.wizard-step.active .wizard-step-copy small { color: var(--muted); }

.wizard-panel { display: grid; gap: 14px; }

.wizard-split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, .8fr);
  gap: 14px;
  align-items: start;
}

.wizard-aside { align-self: start; }

.compact-summary-grid { grid-template-columns: 1fr; margin-bottom: 7px; }

.wizard-actions { justify-content: flex-end; }
.invoice-workspace-hero { align-items: center; }
.invoice-workspace-card { padding: 24px; }

/* ─── Settings ──────────────────────────────────────────────── */
.section-head h5 { font-size: 15px; }

.logo-settings-shell {
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.logo-preview-card {
  min-height: 170px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  display: grid;
  place-items: center;
  padding: 18px;
}

.logo-preview-empty {
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
  font-size: 13px;
}

.logo-settings-actions { display: grid; gap: 12px; }

#settingsLogoPreviewImage {
  max-width: 100%;
  max-height: 130px;
  object-fit: contain;
}

/* ─── Template chooser ──────────────────────────────────────── */
.template-choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.template-choice-card {
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: var(--surface-alt);
  padding: 12px;
  display: grid;
  gap: 9px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.template-choice-card:hover { border-color: var(--line-strong); }

.template-choice-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.template-choice-swatch {
  height: 110px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 10px;
  display: grid;
  gap: 7px;
  align-content: start;
}

.template-swatch-bar   { display: block; width: 100%; height: 7px; border-radius: 999px; background: currentColor; opacity: .9; }
.template-swatch-panel { display: block; width: 46%; height: 26px; border-radius: var(--radius-sm); border: 1px solid currentColor; opacity: .5; }
.template-swatch-lines { display: block; width: 100%; height: 40px; border-radius: var(--radius-sm); border: 1px dashed currentColor; opacity: .32; }

.template-choice-classic   { background: linear-gradient(180deg, #ffffff, #f8fafc); color: #2563eb; }
.template-choice-executive { background: linear-gradient(180deg, #0f172a, #1f2937); color: #dbeafe; }
.template-choice-studio    { background: linear-gradient(180deg, #fffdf8, #f7efe2); color: #b45309; }
.template-choice-watermark { background: linear-gradient(180deg, #f5fffd, #e0f4f1); color: #0f766e; }
.template-choice-glass { background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(255,255,255,.46)), linear-gradient(180deg, #ecfeff, #d4f4ee); color: #0f9f95; }
.template-choice-fire  { background: radial-gradient(circle at 18% 18%, rgba(245,158,11,.3), transparent 34%), linear-gradient(180deg, #451a03, #991b1b 58%, #ffedd5); color: #fed7aa; }
.template-choice-ice   { background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(186,230,253,.7)), linear-gradient(180deg, #f8fdff, #dff3ff); color: #0284c7; }

.watermark-settings-shell {
  display: grid;
  grid-template-columns: minmax(200px, .62fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.watermark-preview-card {
  min-height: 150px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

#settingsWatermarkPreviewImage { max-width: 100%; max-height: 120px; object-fit: contain; opacity: .60; }

/* ─── Toggle card ───────────────────────────────────────────── */
.toggle-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  padding: 14px;
  display: grid;
  gap: 7px;
  transition: border-color .15s ease;
}

.toggle-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.toggle-card.disabled { opacity: .58; }

.account-security-card { margin-top: 16px; }
.two-factor-channel-actions { flex-wrap: wrap; }

.checkbox-row { display: flex; gap: 9px; align-items: center; font-weight: 700; font-size: 14px; }
.checkbox-row input { width: 17px; height: 17px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }

/* ─── Review ────────────────────────────────────────────────── */
.review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.review-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  padding: 14px;
  display: grid;
  gap: 7px;
}

.review-card span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
  font-weight: 700;
}

.invoice-review-shell { display: grid; gap: 16px; }

.invoice-review-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .75fr);
  gap: 14px;
  align-items: start;
}

.invoice-review-summary { align-self: stretch; }
.invoice-review-summary .summary-row { padding-block: 3px; }
.invoice-review-preview { padding: 18px; gap: 16px; }
.invoice-preview-toolbar { display: grid; gap: 7px; }

.native-preview-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.native-invoice-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,255,255,.94));
  padding: 24px;
  overflow: auto;
  display: flex;
  justify-content: center;
  min-height: 640px;
}

.invoice-review-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.invoice-review-controls > .form-section { grid-column: 1 / -1; }

/* ─── Stamp & signature ─────────────────────────────────────── */
.stamp-settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  padding: 16px;
}

.stamp-upload-grid, .stamp-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stamp-preview-card {
  min-height: 120px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 7px;
  place-items: center;
  text-align: center;
}

.stamp-preview-card span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 700;
}

.stamp-preview-card img {
  max-width: 100%;
  max-height: 76px;
  object-fit: contain;
}

.signature-draw-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px;
  display: grid;
  gap: 10px;
}

#signatureDrawCanvas {
  width: 100%;
  height: 190px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.96);
  touch-action: none;
  cursor: crosshair;
}

.stamp-actions { justify-content: flex-end; }

/* ─── Theme grid ────────────────────────────────────────────── */
.theme-card {
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--line);
  background: var(--surface-alt);
  padding: 16px;
  display: grid;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.theme-card:hover { border-color: var(--line-strong); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-card strong { font-size: 14px; }
.theme-card small { color: var(--muted); font-size: 12.5px; }

.theme-swatch {
  height: 100px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,.16);
}

.theme-linen     { background: linear-gradient(135deg, #fff8ef 0%, #d9ba8d 100%); }
.theme-midnight  { background: linear-gradient(135deg, #101922 0%, #4282c4 100%); }
.theme-emerald   { background: linear-gradient(135deg, #eff9f3 0%, #19805f 100%); }
.theme-executive { background: linear-gradient(135deg, #f6f9ff 0%, #406dcd 100%); }
.theme-glass {
  background:
    linear-gradient(135deg, rgba(255,255,255,.75), rgba(255,255,255,.18)),
    radial-gradient(circle at 18% 16%, rgba(45,212,191,.52), transparent 28%),
    linear-gradient(135deg, #ecfeff 0%, #8ddfd7 100%);
}
.theme-fire {
  background:
    radial-gradient(circle at 20% 18%, #fbbf24, transparent 24%),
    linear-gradient(135deg, #431407 0%, #dc2626 48%, #f97316 100%);
}
.theme-ice {
  background:
    linear-gradient(135deg, rgba(255,255,255,.92), rgba(255,255,255,.16)),
    radial-gradient(circle at 18% 16%, #bae6fd, transparent 30%),
    linear-gradient(135deg, #f8fdff 0%, #38bdf8 100%);
}

/* ─── Floating theme dock ───────────────────────────────────── */
/* ─── Header theme picker ───────────────────────────────────── */
.hdr-theme-wrap { position: relative; }

.hdr-theme-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.hdr-theme-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  transform: none; /* no lift — just a clean state change */
}

.hdr-theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(0,0,0,.12);
  flex-shrink: 0;
}

.hdr-theme-chevron {
  opacity: .5;
  flex-shrink: 0;
  transition: transform .15s;
}
.hdr-theme-btn[aria-expanded="true"] .hdr-theme-chevron {
  transform: rotate(180deg);
}

.hdr-theme-drop {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  width: max-content;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(12px);
  padding: 8px;
  display: grid;
  gap: 6px;
  z-index: 200;
  animation: noticeIn .14s var(--ease-out) both;
}

#hdrThemeOptions {
  display: flex;
  gap: 5px;
}

.hdr-theme-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 5px;
  width: 54px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  text-align: center;
  transition: background .12s, border-color .12s, color .12s;
}
.hdr-theme-opt:hover {
  background: var(--surface-alt);
  transform: none;
}
.hdr-theme-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.hdr-theme-opt .theme-swatch {
  width: 100%;
  height: 28px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.hdr-theme-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.hdr-theme-studio-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: color .12s, background .12s;
}
.hdr-theme-studio-btn:hover {
  color: var(--accent);
  background: var(--surface-alt);
  transform: none;
}

/* Hide the old floating dock */
.floating-theme-dock {
  display: none !important;
}

.floating-theme-button {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: grid;
  place-items: center;
  padding: 8px;
  cursor: pointer;
  transition: box-shadow .18s ease, transform .16s var(--ease-out);
}

.floating-theme-button:hover { box-shadow: var(--shadow-xl); }
.floating-theme-button img { width: 32px; height: 32px; object-fit: contain; }

.floating-theme-panel {
  width: min(272px, calc(100vw - 48px));
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(16px);
  padding: 14px;
  display: grid;
  gap: 10px;
  animation: noticeIn .18s var(--ease-out) both;
}

.floating-theme-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.floating-theme-options { display: grid; gap: 6px; }

.floating-theme-option {
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  padding: 8px;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.floating-theme-option:hover { border-color: var(--line-strong); }
.floating-theme-option.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.floating-theme-option .theme-swatch { height: 30px; border-radius: var(--radius-sm); }

/* ─── Native invoice sheet ──────────────────────────────────── */
.native-invoice-sheet {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(100%, 1100px);
  min-width: 860px;
  margin: 0 auto;
  padding: 28px;
  color: var(--text);
  border: 1px var(--border-style, solid) var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(255,255,255,.98)), var(--sheet);
  box-shadow: 0 20px 48px rgba(0,0,0,.07);
}

.native-invoice-sheet > *:not(.native-watermark-image):not(.native-paid-badge-image) {
  position: relative;
  z-index: 1;
}

.native-watermark-image {
  position: absolute;
  top: 30%;
  left: 18%;
  width: 64%;
  max-height: 44%;
  object-fit: contain;
  opacity: .09;
  z-index: 0;
  pointer-events: none;
}

.native-paid-badge-image {
  position: absolute;
  top: auto;
  right: auto;
  left: 28px;
  bottom: 28px;
  width: 128px;
  height: auto;
  object-fit: contain;
  z-index: 3;
  opacity: .92;
  transform: rotate(-8deg);
  filter: drop-shadow(0 8px 14px rgba(15,23,42,.14));
  pointer-events: none;
}

.native-invoice-header,
.native-parties-grid,
.native-bottom-grid {
  display: grid;
  gap: 12px;
}

.native-invoice-header,
.native-bottom-grid { grid-template-columns: minmax(0, 1.3fr) minmax(250px, .8fr); align-items: start; }
.native-bottom-grid-totals-only { grid-template-columns: minmax(0, 1.3fr) minmax(250px, .8fr); }
.native-bottom-grid-totals-only .native-total-card { grid-column: 2; }
.native-parties-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.native-invoice-brand { display: grid; gap: 7px; }

.native-brand-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.native-brand-copy-block { display: grid; gap: 5px; }

.native-logo-box { width: 148px; height: 148px; border: 0; border-radius: 0; background: transparent; display: grid; place-items: center; padding: 0; }
.native-logo-image { max-width: 100%; max-height: 100%; object-fit: contain; }

.native-brand-kicker,
.native-party-card span,
.native-summary-card span,
.native-copy-card span,
.native-payment-type {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 700;
}

.native-brand-copy { color: var(--muted); line-height: 1.6; }

.native-invoice-brand h3,
.native-meta-number,
.native-grand-total,
.native-grand-total strong { color: var(--title); }

.native-meta-card,
.native-party-card,
.native-summary-card,
.native-line-card,
.native-copy-card,
.native-total-card,
.native-payment-card {
  border: 1px var(--border-style, solid) var(--line);
  border-radius: var(--radius-sm);
  background: var(--sheet);
}

.native-meta-card,
.native-party-card,
.native-summary-card,
.native-copy-card,
.native-total-card,
.native-payment-card { padding: 14px 16px; }

.native-meta-card { display: grid; gap: 9px; text-align: right; }
.native-meta-title { color: var(--accent); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; }
.native-meta-number { font-size: 26px; line-height: 1; font-family: var(--font-heading); }

.native-status-badge {
  justify-self: end;
  display: inline-flex;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.native-party-card,
.native-summary-card,
.native-total-card { display: grid; gap: 9px; }

.native-summary-card > div,
.native-total-card > div { display: flex; justify-content: space-between; gap: 12px; }

.native-line-card { padding: 0; overflow: hidden; }

.native-line-table { width: 100%; border-collapse: collapse; table-layout: fixed; }

.native-line-table th, .native-line-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.native-line-table th {
  background: var(--surface-alt);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  text-align: left;
}

.native-line-table col.native-col-index     { width: 7%; }
.native-line-table col.native-col-description { width: 43%; }
.native-line-table col.native-col-qty         { width: 12%; }
.native-line-table col.native-col-unit        { width: 19%; }
.native-line-table col.native-col-amount      { width: 19%; }

.native-line-table th.native-col-index, .native-line-table td.native-col-index { text-align: center; }
.native-line-table th.native-col-description, .native-line-table td.native-col-description { text-align: left; }
.native-line-table th.native-col-qty, .native-line-table td.native-col-qty,
.native-line-table th.native-col-unit, .native-line-table td.native-col-unit,
.native-line-table th.native-col-amount, .native-line-table td.native-col-amount { text-align: right; }

.native-line-table td.native-col-qty,
.native-line-table td.native-col-unit,
.native-line-table td.native-col-amount { white-space: nowrap; }

.native-line-meta { margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.native-table-empty { padding: 20px; color: var(--muted); text-align: center; }

.native-notes-stack, .native-payment-grid { display: grid; gap: 10px; }
.native-payment-section { width: 100%; }
.native-payment-grid { width: 100%; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.native-payment-card { min-width: 0; }
.native-empty-note { color: var(--muted); }
.native-copy-value { line-height: 1.7; font-weight: 600; }

.native-payment-table { width: 100%; border-collapse: collapse; margin-top: 5px; }
.native-payment-table td { padding: 4px 0; font-size: 11.5px; vertical-align: top; }
.native-payment-table td:first-child { color: var(--muted); }
.native-payment-table td:last-child { text-align: right; font-weight: 700; }

/* ─── Invoice template variants ─────────────────────────────── */
.native-template-executive .native-invoice-header {
  background: #0f172a;
  border-radius: var(--radius-md);
  padding: 18px;
}

.native-template-executive .native-brand-kicker,
.native-template-executive .native-brand-copy,
.native-template-executive .native-invoice-brand h3,
.native-template-executive .native-meta-title,
.native-template-executive .native-meta-number { color: #f8fafc; }

.native-template-executive .native-meta-card {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.18);
}

.native-template-executive .native-status-badge {
  color: #f8fafc;
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.12);
}

.native-template-executive .native-line-table th { background: #e8eef8; }

.native-invoice-sheet.native-template-studio { border-top: 9px solid var(--accent); }
.native-template-studio .native-invoice-header { border-bottom: 1px dashed var(--line); padding-bottom: 14px; }
.native-template-studio .native-line-table th { background: #f6efe4; }
.native-template-studio .native-copy-card,
.native-template-studio .native-payment-card,
.native-template-studio .native-party-card,
.native-template-studio .native-summary-card,
.native-template-studio .native-total-card { background: #fffdf8; }

.native-invoice-sheet.native-template-glass {
  background: linear-gradient(135deg, rgba(255,255,255,.88), rgba(255,255,255,.64)), linear-gradient(180deg, #fbfffe, #eaf8f6);
  box-shadow: 0 28px 60px rgba(12,66,76,.16), inset 0 1px 0 rgba(255,255,255,.72);
}

.native-template-glass .native-invoice-header {
  padding: 18px;
  border: 1px solid rgba(165, 220, 215, .70);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255,255,255,.72), rgba(208,244,240,.50));
}

.native-template-glass .native-meta-card,
.native-template-glass .native-party-card,
.native-template-glass .native-summary-card,
.native-template-glass .native-copy-card,
.native-template-glass .native-payment-card,
.native-template-glass .native-total-card,
.native-template-glass .native-line-card {
  background: rgba(255,255,255,.74);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.80);
  backdrop-filter: blur(12px);
}

.native-invoice-sheet.native-template-fire {
  border-top: 9px solid var(--accent);
  background: radial-gradient(circle at 12% 8%, rgba(245,158,11,.14), transparent 28%), linear-gradient(180deg, #fff9f2, #fff0e0);
}

.native-template-fire .native-invoice-header {
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #451a03, #991b1b 58%, #dc2626);
}

.native-template-fire .native-brand-copy,
.native-template-fire .native-invoice-brand h3,
.native-template-fire .native-meta-title,
.native-template-fire .native-meta-number { color: #fff7ed; }

.native-template-fire .native-meta-card { background: rgba(255,255,255,.08); border-color: rgba(254,215,170,.28); }

.native-template-fire .native-status-badge {
  color: #fff7ed;
  border-color: rgba(254,215,170,.28);
  background: rgba(254,215,170,.14);
}

.native-template-fire .native-line-table th { background: #ffead5; color: #7c2d12; }

.native-invoice-sheet.native-template-ice {
  background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(255,255,255,.76)), linear-gradient(180deg, #f8fdff, #eaf8ff);
  box-shadow: 0 24px 52px rgba(6,86,120,.12);
}

.native-template-ice .native-invoice-header {
  padding: 18px;
  border: 1px solid rgba(186,230,253,.76);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(240,249,255,.96), rgba(186,230,253,.62));
}

.native-template-ice .native-meta-card,
.native-template-ice .native-party-card,
.native-template-ice .native-summary-card,
.native-template-ice .native-copy-card,
.native-template-ice .native-payment-card,
.native-template-ice .native-total-card,
.native-template-ice .native-line-card { border-color: rgba(10,116,144,.16); }

.native-template-ice .native-line-table th { background: #e0f2fe; }

.native-grand-total {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--accent);
  font-size: 17px;
}

.native-invoice-footer {
  padding-top: 4px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11.5px;
  border-top: 1px solid var(--line);
}

/* ─── Stamp / signature placement ───────────────────────────── */
.native-stamp-section {
  padding: 50px;
  display: flex;
  justify-content: flex-end;
}

.native-stamp-block {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  justify-items: end;
  text-align: right;
}

.native-stamp-names {
  display: grid;
  gap: 6px;
  width: 100%;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.native-stamp-names div { display: flex; justify-content: space-between; gap: 12px; }
.native-stamp-names span { color: var(--muted); font-weight: 700; }
.native-stamp-names strong { color: var(--title); }

.native-stamp-images {
  position: relative;
  width: min(310px, 100%);
  height: 210px;
  pointer-events: none;
}

.native-signature-image {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 2;
  max-width: 56%;
  max-height: 38%;
  object-fit: contain;
  transform: translate(-50%, -50%);
}

.native-stamp-image {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

/* ─── Theme-specific glass/fire/ice card tweaks ─────────────── */
:root[data-theme="glass"] .login-panel,
:root[data-theme="glass"] .panel-card,
:root[data-theme="glass"] .hero-panel,
:root[data-theme="glass"] .metric-card,
:root[data-theme="glass"] .workspace-header,
:root[data-theme="glass"] .modal-dialog {
  border-color: rgba(255,255,255,.40);
  box-shadow: 0 24px 64px rgba(10,76,88,.18), inset 0 1px 0 rgba(255,255,255,.52);
  backdrop-filter: blur(22px) saturate(1.18);
}

:root[data-theme="glass"] .table-wrap,
:root[data-theme="glass"] .review-card,
:root[data-theme="glass"] .native-preview-card,
:root[data-theme="glass"] .mini-stat-card,
:root[data-theme="glass"] .summary-card,
:root[data-theme="glass"] .detail-block {
  border-color: rgba(255,255,255,.50);
  background: rgba(255,255,255,.56);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.54);
}

:root[data-theme="fire"] .hero-panel, :root[data-theme="fire"] .login-art {
  box-shadow: 0 28px 70px rgba(130,28,28,.24);
}

:root[data-theme="fire"] .panel-card,
:root[data-theme="fire"] .metric-card,
:root[data-theme="fire"] .workspace-header,
:root[data-theme="fire"] .table-wrap,
:root[data-theme="fire"] .review-card,
:root[data-theme="fire"] .native-preview-card,
:root[data-theme="fire"] .mini-stat-card,
:root[data-theme="fire"] .summary-card,
:root[data-theme="fire"] .detail-block {
  border-color: rgba(240,68,68,.26);
  background:
    radial-gradient(circle at 0 0, rgba(245,158,11,.10), transparent 34%),
    var(--surface);
}

:root[data-theme="fire"] .table-wrap,
:root[data-theme="fire"] .empty-state,
:root[data-theme="fire"] .panel-pill { border-style: dashed; }

:root[data-theme="fire"] .data-table th {
  background: linear-gradient(135deg, rgba(130,28,28,.10), rgba(245,158,11,.16));
  color: #7f1d1d;
}

:root[data-theme="ice"] .login-panel,
:root[data-theme="ice"] .panel-card,
:root[data-theme="ice"] .hero-panel,
:root[data-theme="ice"] .metric-card,
:root[data-theme="ice"] .workspace-header,
:root[data-theme="ice"] .modal-dialog {
  border-color: rgba(186,230,253,.52);
  box-shadow: 0 24px 56px rgba(6,86,120,.14), inset 0 1px 0 rgba(255,255,255,.64);
  backdrop-filter: blur(18px) saturate(1.08);
}

:root[data-theme="ice"] .table-wrap,
:root[data-theme="ice"] .review-card,
:root[data-theme="ice"] .native-preview-card,
:root[data-theme="ice"] .mini-stat-card,
:root[data-theme="ice"] .summary-card,
:root[data-theme="ice"] .detail-block {
  border-color: rgba(120,210,252,.40);
  background: linear-gradient(135deg, rgba(255,255,255,.84), rgba(224,242,254,.64)), var(--surface);
}

:root[data-theme="ice"] .table-wrap,
:root[data-theme="ice"] .empty-state,
:root[data-theme="ice"] .panel-pill { border-style: dotted; }

:root[data-theme="ice"] .data-table th {
  background: linear-gradient(135deg, rgba(240,249,255,.96), rgba(186,230,253,.74));
  color: #075985;
}

/* ─── Background texture overlays ───────────────────────────── */
:root[data-theme="glass"] body::before,
:root[data-theme="fire"] body::before,
:root[data-theme="ice"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .34;
}

:root[data-theme="glass"] body::before {
  background-image: radial-gradient(rgba(12,156,146,.18) 1px, transparent 1px);
  background-size: 22px 22px;
}

:root[data-theme="fire"] body::before {
  background-image:
    linear-gradient(120deg, rgba(218,32,32,.07), transparent 42%),
    radial-gradient(rgba(130,28,28,.22) 1px, transparent 1px);
  background-size: auto, 20px 20px;
}

:root[data-theme="ice"] body::before {
  background-image:
    linear-gradient(135deg, rgba(255,255,255,.42), transparent 38%),
    radial-gradient(rgba(2,128,196,.20) 1px, transparent 1px);
  background-size: auto, 18px 18px;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .metrics-grid    { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .theme-grid      { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wizard-progress { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .workspace          { grid-template-columns: 1fr; }
  .split-shell, .widget-grid, .login-view, .wizard-split { grid-template-columns: 1fr; }
  .settings-grid      { grid-template-columns: 1fr; }
  .invoice-review-overview, .invoice-review-controls { grid-template-columns: 1fr; }
  .logo-settings-shell, .watermark-settings-shell { grid-template-columns: 1fr; }
  .stamp-upload-grid, .stamp-preview-grid { grid-template-columns: 1fr; }
  .native-stamp-section { padding: 24px 0; }
  .native-stamp-block { justify-items: stretch; text-align: left; }
  .native-stamp-images { align-self: start; }
  .template-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { position: static; top: auto; max-height: none; overflow: visible; }
  .native-invoice-header, .native-parties-grid, .native-bottom-grid { grid-template-columns: 1fr; }
  .native-bottom-grid-totals-only .native-total-card { grid-column: auto; }
  .native-meta-card { text-align: left; }
  .native-status-badge { justify-self: start; }
  .native-payment-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); overflow: visible; }
  .wizard-progress { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { padding: 12px; }
  .workspace-header, .hero-panel, .panel-card, .metric-card, .login-panel, .login-art, .modal-dialog { padding: 16px; }
  .metrics-grid, .form-grid, .detail-stat-grid, .collection-grid, .theme-grid, .review-grid, .wizard-progress { grid-template-columns: 1fr; }
  .invoice-filter-row { grid-template-columns: 1fr; }
  .dynamic-item-grid, .payment-detail-grid { grid-template-columns: 1fr; }
  .data-table { min-width: 760px; }
  .workspace-actions { align-items: stretch; }
  .native-invoice-preview { padding: 10px; }
  .native-invoice-sheet { min-width: 680px; padding: 16px; }
  .native-brand-head { grid-template-columns: 1fr; }
  .native-payment-grid { grid-template-columns: 1fr; }
  .floating-theme-dock { right: 16px; bottom: 16px; }
  .wizard-progress { grid-template-columns: 1fr; }
  .template-choice-grid { grid-template-columns: 1fr; }
}

/* ─── Polish & micro-details ────────────────────────────────── */

/* Subtle scrollbar styling */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.32); }

/* Workspace header border accent */
.workspace-header::after {
  content: none;
}

/* Compact field layout for workspace header controls */
.compact-field {
  display: grid;
  gap: 5px;
  min-width: 120px;
}

.compact-field span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 700;
}

.compact-field input,
.compact-field select {
  padding: 8px 10px;
  font-size: 13px;
}

/* Panel pill refinement */
.panel-pill { border-radius: var(--radius-sm); }

/* Table btn hover */
.table-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* Toolbar row spacing */
.toolbar-row {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

/* payment method row */
.payment-method-row { align-items: center; }

/* section-head spacing */
.section-head {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

/* stack-meta utility */
.stack-meta { color: var(--muted); font-size: 12.5px; line-height: 1.55; display: block; }

/* Section head title size */
.section-head h4 { font-size: 16px; }
.section-head h5 { font-size: 14px; }

/* Smooth page-section entry */
.page-section:not(.hidden) { animation: pageFadeIn .22s var(--ease-out) both; }

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hero panel headline spacing */
.hero-panel h3 { font-size: 19px; margin-top: 4px; }
.hero-panel .eyebrow { margin-bottom: 2px; }

/* Metric accent card text */
.accent-card strong { font-size: 28px; }

/* Login panel eyebrow */
.login-panel .eyebrow { font-size: 11px; }

/* Connection card summary text */
#apiConfigSummary { font-size: 11.5px; }

/* Better modal close button */
.modal-head .ghost-btn { flex-shrink: 0; }

/* Wizard nav active badge pulse */
@keyframes activePulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255,255,255,.36); }
  50%       { box-shadow: 0 0 18px rgba(255,255,255,.56); }
}
.nav-btn.active::after { animation: activePulse 2.4s ease infinite; }

/* Input file styling tweak */
input[type="file"] {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

/* Number inputs — remove spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity: 1; }

/* Hover rows in stack list */
.stack-row { transition: border-color .12s ease, background .12s ease; }
.stack-row:hover { border-color: var(--accent); }

/* Panel card inner gap reset for nested sections */
.panel-card .form-section + .form-section { margin-top: 4px; }

/* Danger btn in sidebar matches a more refined look */
#logoutButton {
  border-radius: var(--radius-md);
  font-size: 14px;
  padding: 10px 16px;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .16s var(--ease-out);
}

/* Status pill for invoice workspace */
.panel-pill#invoiceWorkspaceStatusPill {
  font-size: 12px;
  border-radius: var(--radius-sm);
}
