@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-alt: #F3F2EF;
  --border: #E2E0DA;
  --border-light: #ECEAE5;
  --text: #1A1917;
  --text-secondary: #6B6860;
  --text-tertiary: #9B9790;
  --accent: #2C5F8A;
  --accent-light: #E8F0F7;
  --accent-muted: #4A7FA8;
  --accent-hover: #1E4A6E;
  --highlight: #D4740A;
  --highlight-bg: #FDF5EC;
  --highlight-hover: #B5620A;
  --green: #2D7A4F;
  --green-bg: #EDF7F1;
  --red: #C53030;
  --red-bg: #FFF5F5;
  --row-hover: rgba(44, 95, 138, 0.04);
  --input-bg: #FFFFFF;
  --input-border: #D4D2CC;
  --shadow-sm: 0 1px 3px rgba(26,25,23,0.06);
  --shadow-md: 0 4px 12px rgba(26,25,23,0.08);
  --nav-bg: #1A1917;
  --nav-text: #D4D2CC;
  --nav-active: #FFFFFF;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1E1E1C; --surface-alt: #252523;
    --border: #333330; --border-light: #2A2A27;
    --text: #EAEAE7; --text-secondary: #A0A098; --text-tertiary: #706E68;
    --accent: #6AACDE; --accent-light: #1A2A38; --accent-muted: #5090BC; --accent-hover: #8AC4EE;
    --highlight: #E8952A; --highlight-bg: #2A2218; --highlight-hover: #F0A540;
    --green: #5ABF80; --green-bg: #1A2A20;
    --red: #FC8181; --red-bg: #2A1A1A;
    --row-hover: rgba(106,172,222,0.06);
    --input-bg: #252523; --input-border: #444440;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2); --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --nav-bg: #0E0E0D; --nav-text: #706E68; --nav-active: #EAEAE7;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1E1E1C; --surface-alt: #252523;
  --border: #333330; --border-light: #2A2A27;
  --text: #EAEAE7; --text-secondary: #A0A098; --text-tertiary: #706E68;
  --accent: #6AACDE; --accent-light: #1A2A38; --accent-muted: #5090BC; --accent-hover: #8AC4EE;
  --highlight: #E8952A; --highlight-bg: #2A2218; --highlight-hover: #F0A540;
  --green: #5ABF80; --green-bg: #1A2A20;
  --red: #FC8181; --red-bg: #2A1A1A;
  --row-hover: rgba(106,172,222,0.06);
  --input-bg: #252523; --input-border: #444440;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2); --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --nav-bg: #0E0E0D; --nav-text: #706E68; --nav-active: #EAEAE7;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── App shell ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand h1 {
  font-size: 1.125rem; font-weight: 700; color: var(--nav-active);
  letter-spacing: -0.02em;
}
.sidebar-brand span { font-size: 0.6875rem; color: var(--nav-text); }

.sidebar-nav { flex: 1; padding: 0.75rem 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 1rem; color: var(--nav-text);
  font-size: 0.8125rem; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar-nav a:hover { color: var(--nav-active); background: rgba(255,255,255,0.04); }
.sidebar-nav a.active {
  color: var(--nav-active); background: rgba(255,255,255,0.06);
  border-left-color: var(--accent);
}
.sidebar-nav a svg { width: 18px; height: 18px; opacity: 0.6; }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.75rem;
}
.sidebar-footer a { color: var(--nav-text); }
.sidebar-footer a:hover { color: var(--red); }

.main-content {
  flex: 1; margin-left: 220px;
  padding: 2rem 2.5rem 4rem;
  max-width: 1100px;
}

/* ── Mobile nav ── */
.mobile-nav {
  display: none; position: fixed; top: 0; left: 0; right: 0;
  background: var(--nav-bg); color: var(--nav-active);
  padding: 0.75rem 1rem; z-index: 101;
  align-items: center; justify-content: space-between;
}
.mobile-nav h1 { font-size: 1rem; font-weight: 700; }
.hamburger { background: none; border: none; color: var(--nav-active); cursor: pointer; padding: 0.25rem; }
.hamburger svg { width: 24px; height: 24px; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .mobile-nav { display: flex; }
  .main-content { margin-left: 0; padding: 4rem 1rem 3rem; }
}

/* ── Page header ── */
.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem;
}
.page-header h2 {
  font-size: 1.375rem; font-weight: 700;
  letter-spacing: -0.02em;
}
.page-header p { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 0.125rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 1rem; border-radius: 5px;
  font-family: inherit; font-size: 0.8125rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.15s; text-decoration: none;
  line-height: 1.3;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-highlight { background: var(--highlight); color: #fff; }
.btn-highlight:hover { background: var(--highlight-hover); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.75rem; }
.btn-ghost { background: transparent; border: none; color: var(--text-secondary); padding: 0.375rem; }
.btn-ghost:hover { color: var(--accent); }

/* ── KPI tiles ── */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 0.625rem; margin-bottom: 2rem; }
.kpi { background: var(--surface); border: 1px solid var(--border-light); border-radius: 6px; padding: 0.875rem; box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); margin-bottom: 0.125rem; }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 1.5rem; font-weight: 500; color: var(--accent); line-height: 1.1; }
.kpi.accent { background: var(--accent); border-color: var(--accent); }
.kpi.accent .kpi-label { color: rgba(255,255,255,0.7); }
.kpi.accent .kpi-value { color: #fff; }
.kpi.green { background: var(--green); border-color: var(--green); }
.kpi.green .kpi-label { color: rgba(255,255,255,0.7); }
.kpi.green .kpi-value { color: #fff; }

/* ── Section headings ── */
.section-title {
  font-size: 1rem; font-weight: 600; margin: 2rem 0 0.75rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.section-title::before {
  content: ''; width: 3px; height: 1rem;
  background: var(--accent); border-radius: 2px; flex-shrink: 0;
}
.section-title.orange::before { background: var(--highlight); }
.section-title.green::before { background: var(--green); }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: 6px; box-shadow: var(--shadow-sm);
  background: var(--surface); margin-bottom: 1.5rem;
}
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.8125rem; }
thead th {
  background: var(--surface-alt); font-size: 0.625rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary);
  padding: 0.5rem 0.75rem; text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; white-space: nowrap;
}
thead th.num { text-align: right; }
tbody td { padding: 0.4375rem 0.75rem; border-bottom: 1px solid var(--border-light); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }
td.item-name { font-weight: 500; }
td.num {
  text-align: right; font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem; color: var(--text-secondary);
}
td.num.has-val { color: var(--text); }
td.note-text { font-size: 0.75rem; color: var(--text-tertiary); font-style: italic; }

tr.total-row td {
  background: var(--accent-light); font-weight: 600;
  border-top: 2px solid var(--accent); color: var(--accent); border-bottom: none;
}
tr.subtotal-row td {
  background: var(--surface-alt); font-weight: 600;
  border-top: 1px solid var(--border);
}
tr.section-row td {
  background: var(--accent-light); font-weight: 600;
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent-muted); padding: 0.375rem 0.75rem;
}

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 0.25rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.form-control {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--input-border); border-radius: 5px;
  background: var(--input-bg); color: var(--text);
  font-family: inherit; font-size: 0.875rem;
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

input.edit-inline {
  width: 75px; padding: 0.2rem 0.375rem;
  border: 1px solid var(--input-border); border-radius: 3px;
  background: var(--input-bg); color: var(--text);
  font-family: 'JetBrains Mono', monospace; font-size: 0.75rem;
  text-align: right; font-variant-numeric: tabular-nums;
}
input.edit-inline:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 6px; padding: 1.25rem; box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 0.75rem; margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}
.card-header h3 { font-size: 0.9375rem; font-weight: 600; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; margin-bottom: 1.5rem; border-bottom: 2px solid var(--border); }
.tab-btn {
  padding: 0.625rem 1.25rem; font-size: 0.8125rem; font-weight: 600;
  color: var(--text-secondary); cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  font-family: inherit; transition: all 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Status badges ── */
.badge {
  display: inline-block; font-family: 'JetBrains Mono', monospace;
  font-size: 0.625rem; font-weight: 500;
  padding: 0.125rem 0.5rem; border-radius: 3px;
}
.badge-draft { background: var(--surface-alt); color: var(--text-secondary); }
.badge-sent { background: var(--accent-light); color: var(--accent); }
.badge-accepted { background: var(--green-bg); color: var(--green); }
.badge-refused { background: var(--red-bg); color: var(--red); }
.badge-info { background: var(--highlight-bg); color: var(--highlight); }

/* ── Flash messages ── */
.flash {
  padding: 0.625rem 1rem; border-radius: 5px;
  margin-bottom: 1rem; font-size: 0.8125rem; font-weight: 500;
}
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

/* ── Room cards (synthesis) ── */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 0.625rem; margin-bottom: 1rem; }
.room-card { background: var(--surface); border: 1px solid var(--border-light); border-radius: 6px; padding: 0.875rem 1rem; box-shadow: var(--shadow-sm); }
.room-card h3 { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.625rem; padding-bottom: 0.375rem; border-bottom: 1px solid var(--border-light); }
.room-card .cat-label { font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-muted); margin-bottom: 0.125rem; }
.room-card ul { list-style: none; margin-bottom: 0.625rem; }
.room-card li { font-size: 0.75rem; color: var(--text-secondary); padding: 0.0625rem 0; display: flex; align-items: baseline; gap: 0.375rem; }
.room-card li::before { content: '\00B7'; color: var(--text-tertiary); font-weight: 700; }
.room-card .room-note { font-size: 0.6875rem; font-style: italic; color: var(--text-tertiary); margin-bottom: 0.5rem; }

/* ── Grand total banner ── */
.grand-total {
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: 8px; padding: 1.25rem 1.5rem; margin: 2rem 0;
  box-shadow: var(--shadow-md);
}
.grand-total h3 { margin-bottom: 0.75rem; font-size: 1rem; font-weight: 700; color: var(--accent); }
.gt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 0.75rem; }
.gt-label { font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); }
.gt-val { font-family: 'JetBrains Mono', monospace; font-size: 1.25rem; font-weight: 600; color: var(--text); }
.gt-main .gt-val { font-size: 1.5rem; color: var(--accent); }

/* ── Login page ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 2rem; width: 100%; max-width: 360px;
  box-shadow: var(--shadow-md);
}
.login-card h1 {
  font-size: 1.25rem; font-weight: 700; margin-bottom: 0.25rem;
  text-align: center;
}
.login-card .subtitle {
  text-align: center; font-size: 0.8125rem; color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* ── Accordion ── */
.accordion-toggle {
  width: 100%; background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0; color: var(--text); font-family: inherit;
}
.accordion-toggle svg { transition: transform 0.2s; width: 16px; height: 16px; color: var(--text-tertiary); }
.accordion-toggle.open svg { transform: rotate(180deg); }
.accordion-body { overflow: hidden; }
.accordion-body.collapsed { display: none; }

/* ── Utility ── */
.mono { font-family: 'JetBrains Mono', monospace; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-row { display: flex; align-items: center; gap: 0.5rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ── Print ── */
@media print {
  .sidebar, .mobile-nav { display: none !important; }
  .main-content { margin-left: 0; padding: 0; }
  .btn { display: none !important; }
}
