:root {
  --canvas: #f8f9f7;
  --surface: #ffffff;
  --surface-muted: #f3f5f2;
  --ink: #18181b;
  --muted: #71717a;
  --line: #dde2dc;
  --accent: #1f6f5b;
  --accent-soft: #e4f1ed;
  --amber: #b45309;
  --red: #b42318;
  --sidebar: #211f1a;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.065);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Geist, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
code { font-family: "Geist Mono", "SFMono-Regular", Consolas, monospace; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.demo-shell { min-height: 100dvh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 288px;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.08);
  background: var(--sidebar);
  color: #fff;
  padding: 20px;
}

.brand-card {
  display: block;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 28px;
  background: rgba(255,255,255,0.06);
  padding: 20px;
}
.brand-kicker { display: block; color: #9ad6c6; font-size: 11px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }
.brand-card strong { display: block; margin-top: 18px; font-size: 26px; line-height: 1.02; letter-spacing: -.06em; }
.brand-card small { display: block; margin-top: 12px; color: rgba(255,255,255,.58); line-height: 1.55; }

.side-nav { display: grid; gap: 8px; margin-top: 22px; }
.nav-item {
  min-height: 46px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: rgba(255,255,255,.68);
  padding: 0 14px;
  text-align: left;
  font-weight: 750;
}
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-note { margin-top: 22px; border: 1px solid rgba(255,255,255,.1); border-radius: 22px; background: rgba(255,255,255,.055); padding: 16px; }
.sidebar-note span { color: #9ad6c6; font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.sidebar-note p { margin: 10px 0 0; color: rgba(255,255,255,.58); font-size: 13px; line-height: 1.6; }

.main-shell { padding-left: 288px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  background: rgba(248,249,247,.9);
  padding: 14px 32px;
  backdrop-filter: blur(18px);
}
.tiny-label, .breadcrumb { margin: 0; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.topbar strong { display: block; margin-top: 4px; font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.ghost-link, .mobile-menu, .shop-select { min-height: 40px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 0 13px; font-size: 13px; font-weight: 800; }
.mobile-menu { display: none; color: var(--ink); }

.content { max-width: 1500px; margin: 0 auto; padding: 32px; }
.screen { display: none; }
.screen.active { display: block; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
h1 { margin: 8px 0 0; font-size: clamp(30px, 4vw, 46px); line-height: 1; letter-spacing: -.06em; }
.page-header p:not(.breadcrumb) { max-width: 760px; margin: 12px 0 0; color: #52525b; line-height: 1.65; }
.primary-action, .secondary-action, .command-bar button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 850;
}
.secondary-action { border-color: var(--line); background: var(--surface); color: var(--ink); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.tab { min-height: 38px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); padding: 0 13px; font-weight: 850; }
.tab.active { border-color: rgba(31,111,91,.24); background: var(--accent); color: #fff; }
.settings-tabs { margin-bottom: 16px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-grid article, .panel, .settings-card, .command-bar, .table-wrap, .invoice-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metric-grid article { padding: 18px; }
.metric-grid span, .settings-card span { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.metric-grid strong { display: block; margin-top: 12px; font-family: "Geist Mono", "SFMono-Regular", Consolas, monospace; font-size: 34px; letter-spacing: -.06em; }
.metric-grid small, .settings-card p { display: block; margin-top: 8px; color: #52525b; line-height: 1.55; }

.dashboard-grid, .jobs-layout { display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; margin-top: 16px; }
.panel { padding: 20px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.panel-title h2 { margin: 0; font-size: 18px; letter-spacing: -.035em; }
.panel-title span { color: var(--muted); font-size: 12px; font-weight: 800; }
.flow-rail { display: grid; gap: 12px; margin-top: 18px; }
.flow-rail div { display: grid; grid-template-columns: .45fr 1fr; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-muted); padding: 14px; }
.flow-rail span, .readiness-list small { color: var(--muted); }
.readiness-list { display: grid; gap: 14px; margin-top: 18px; }
.readiness-list div { display: grid; grid-template-columns: 12px 1fr; column-gap: 10px; row-gap: 2px; align-items: center; }
.readiness-list small { grid-column: 2; }
.dot { width: 10px; height: 10px; border-radius: 999px; background: var(--muted); }
.dot.ok { background: var(--accent); } .dot.warn { background: var(--amber); } .dot.off { background: var(--red); }

.command-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; padding: 14px; box-shadow: none; }
.command-bar input, .command-bar select { min-height: 42px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 0 12px; }
.command-bar input { min-width: 260px; flex: 1; }
.table-wrap { overflow-x: auto; border-radius: 20px; box-shadow: none; }
.data-table { width: 100%; min-width: 1080px; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { border-bottom: 1px solid rgba(221,226,220,.72); padding: 14px 16px; text-align: left; white-space: nowrap; }
.data-table td small { display: block; margin-top: 4px; color: var(--muted); }
.data-table th { background: var(--surface-muted); color: #52525b; font-size: 11px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.row-action { min-height: 32px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); padding: 0 10px; font-size: 12px; font-weight: 850; }
.row-action.primary { border-color: transparent; background: var(--accent); color: #fff; }
.action-cell { display: flex; flex-wrap: wrap; gap: 6px; }

.status-pill { display: inline-flex; align-items: center; min-height: 28px; border: 1px solid var(--line); border-radius: 999px; padding: 0 10px; font-size: 12px; font-weight: 850; }
.status-pill.success { border-color: rgba(31,111,91,.22); background: var(--accent-soft); color: #185545; }
.status-pill.warning { border-color: rgba(180,83,9,.24); background: #fff7ed; color: var(--amber); }
.status-pill.danger { border-color: rgba(180,35,24,.2); background: #fff1f2; color: var(--red); }
.status-pill.neutral { background: var(--surface-muted); color: #52525b; }

.invoice-board { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.invoice-card { padding: 18px; box-shadow: none; }
.invoice-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.invoice-card h2 { margin: 0; font-size: 18px; letter-spacing: -.035em; }
.invoice-card p { color: #52525b; line-height: 1.6; }
.invoice-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.invoice-actions .row-action { min-height: 36px; }
.invoice-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.invoice-meta div { border-radius: 14px; background: var(--surface-muted); padding: 12px; }
.invoice-meta span { display: block; color: var(--muted); font-size: 11px; font-weight: 850; text-transform: uppercase; }
.invoice-meta strong { display: block; margin-top: 5px; font-family: "Geist Mono", "SFMono-Regular", Consolas, monospace; }

.attention-list, .job-timeline { display: grid; gap: 12px; margin-top: 16px; }
.attention-item, .job-step { border: 1px solid var(--line); border-radius: 16px; background: var(--surface-muted); padding: 14px; }
.attention-item strong, .job-step strong { display: block; }
.attention-item span, .job-step span { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; }
.job-step { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; }
.job-step code { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; background: var(--sidebar); color: #fff; font-size: 12px; font-weight: 900; }

.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.settings-card { padding: 18px; box-shadow: none; }
.settings-card strong { display: block; margin-top: 10px; font-size: 21px; letter-spacing: -.04em; }
.settings-card.danger { background: #fff8f7; }
.settings-card.danger strong { color: var(--red); }
.mew-gate-grid { margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.form-grid input { min-height: 42px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); color: var(--ink); padding: 0 12px; font-size: 14px; font-weight: 650; letter-spacing: 0; text-transform: none; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; }
.toggle-button { min-height: 38px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-muted); color: var(--ink); padding: 0 14px; font-weight: 850; }
.toggle-button.on { border-color: rgba(31,111,91,.25); background: var(--accent); color: #fff; }
.safety-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 20px; background: #fff8f0; padding: 14px 16px; color: #7c2d12; }
.safety-banner strong { color: #7c2d12; }
.safety-banner.safe { background: var(--accent-soft); color: #185545; }
.safety-banner.safe strong { color: #185545; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.audit-table td { vertical-align: top; white-space: normal; }
.pdf-box, .xml-box { margin-top: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-muted); padding: 16px; }
.pdf-box { min-height: 220px; }
.xml-box pre { overflow: auto; margin: 0; font-size: 12px; line-height: 1.5; }

.detail-panel { position: fixed; inset: 0 0 0 auto; z-index: 40; width: min(480px, 100%); transform: translateX(104%); transition: transform 180ms ease; border-left: 1px solid var(--line); background: var(--surface); padding: 22px; box-shadow: -20px 0 60px rgba(15,23,42,.12); }
.detail-panel.is-open { transform: translateX(0); }
.panel-close { min-height: 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-muted); padding: 0 14px; font-weight: 850; }
.panel-body h2 { margin: 22px 0 10px; font-size: 28px; letter-spacing: -.055em; }
.panel-body p { color: #52525b; line-height: 1.65; }
.panel-body ul { color: #52525b; line-height: 1.8; }
.scrim { position: fixed; inset: 0; z-index: 35; display: none; background: rgba(24,24,27,.28); }
.scrim.is-open { display: block; }

@media (prefers-reduced-motion: reduce) { .detail-panel { transition: none; } }

@media (max-width: 1080px) {
  .metric-grid, .settings-grid, .invoice-board { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .jobs-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-104%); transition: transform 180ms ease; z-index: 30; }
  .sidebar.is-open { transform: translateX(0); }
  .main-shell { padding-left: 0; }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .topbar-actions { display: none; }
  .content { padding: 22px 14px; }
  .page-header { flex-direction: column; }
  .metric-grid, .settings-grid, .invoice-board { grid-template-columns: 1fr; }
  .flow-rail div, .job-step { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
