@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&display=swap');
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --rk-navy: #0A1628;
  --rk-navy-mid: #162844;
  --rk-navy-light: #1E3550;
  --rk-teal: #1A3A3A;
  --rk-teal-deep: #0F2B2B;
  --rk-gold: #C5A258;
  --rk-gold-light: #D4B97A;
  --rk-gold-pale: #F0E6CE;
  --rk-gold-muted: rgba(197,162,88,0.15);
  --rk-gold-border: rgba(197,162,88,0.35);
  --rk-cream: #FAF8F4;
  --rk-cream-dark: #F3EFE7;
  --rk-slate: #4A5568;
  --rk-light: #E8E4DD;
  --rk-text: #1E293B;
  --rk-text-muted: #64748b;
  --rk-white: #FFFFFF;
  --rk-serif: 'Cormorant Garamond', Georgia, serif;
  --rk-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --progress-anim-dur: 2.8s;
  --progress-anim-ease: ease-in-out;

  /* Theme tokens — light */
  --bg-page: var(--rk-cream);
  --bg-card: var(--rk-white);
  --bg-card-alt: #FDFCFA;
  --bg-cat-row: var(--rk-cream-dark);
  --bg-table: var(--rk-white);
  --bg-tabs: var(--rk-white);
  --bg-header-row: var(--rk-cream);
  --border-gold: var(--rk-gold-border);
  --border-row: rgba(197,162,88,0.08);
  --text-primary: var(--rk-text);
  --text-secondary: var(--rk-text-muted);
  --text-cat: var(--rk-navy);
  --stat-num-color: var(--rk-navy);
  --input-focus-bg: rgba(197,162,88,0.04);
  --drag-over-bg: rgba(197,162,88,0.15);
  --modal-overlay: rgba(10,22,40,0.6);
  --tab-text: #1e293b;
  --progress-track: var(--rk-cream-dark);
  --mini-bar-track: var(--rk-cream-dark);
}

[data-theme="dark"] {
  --bg-page: #0C1219;
  --bg-card: #141D2B;
  --bg-card-alt: #172033;
  --bg-cat-row: #1A2436;
  --bg-table: #111923;
  --bg-tabs: #111923;
  --bg-header-row: #1A2436;
  --border-gold: rgba(197,162,88,0.25);
  --border-row: rgba(197,162,88,0.06);
  --text-primary: #E2DDD5;
  --text-secondary: #8A9BB0;
  --text-cat: var(--rk-gold-light);
  --stat-num-color: var(--rk-gold-light);
  --input-focus-bg: rgba(197,162,88,0.08);
  --drag-over-bg: rgba(197,162,88,0.12);
  --modal-overlay: rgba(0,0,0,0.7);
  --tab-text: #E2DDD5;
  --progress-track: #1A2436;
  --mini-bar-track: #1A2436;
  --rk-gold-muted: rgba(197,162,88,0.1);
}

body { font-family: var(--rk-sans); background: var(--bg-page); color: var(--text-primary); padding: 10px; transition: background 0.3s, color 0.3s; }
.wrap { max-width: min(1720px, calc(100vw - 20px)); margin: 0 auto; }

/* ── Header ── */
.header {
  background: linear-gradient(165deg, var(--rk-teal-deep) 0%, var(--rk-teal) 40%, var(--rk-navy-mid) 100%);
  padding: 28px 32px;
  margin-bottom: 20px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(197,162,88,0.015) 0px, rgba(197,162,88,0.015) 1px, transparent 1px, transparent 40px),
              repeating-linear-gradient(0deg, rgba(197,162,88,0.015) 0px, rgba(197,162,88,0.015) 1px, transparent 1px, transparent 40px);
  pointer-events: none;
}
.header::after {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 350px; height: 100%;
  background: radial-gradient(circle at 80% 30%, rgba(197,162,88,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.header-left { display: flex; flex-direction: column; gap: 14px; min-width: 260px; z-index: 1; }

/* ── Logo ── */
.logo-block { display: flex; flex-direction: column; gap: 2px; }
.logo-main {
  font-family: var(--rk-serif);
  font-size: 28px;
  font-weight: 500;
  color: var(--rk-gold);
  letter-spacing: 6px;
  text-transform: uppercase;
  line-height: 1.1;
}
.logo-sub {
  font-family: var(--rk-sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--rk-gold-light);
  letter-spacing: 5.5px;
  text-transform: uppercase;
  opacity: 0.85;
  padding-left: 2px;
}

.projected-delivery { font-size: 12px; color: rgba(255,255,255,0.55); margin-top: 6px; }
.projected-delivery strong { color: var(--rk-gold-light); font-weight: 500; }

.header-main { z-index: 1; flex: 1; min-width: 300px; }
.header h1 {
  font-family: var(--rk-serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.3;
  border-left: 3px solid var(--rk-gold);
  padding-left: 16px;
  color: #fff;
}
.header p { margin-top: 8px; font-size: 11px; opacity: 0.45; letter-spacing: 1.5px; text-transform: uppercase; padding-left: 19px; }
.save-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 6px; padding-left: 19px; }
.save-dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; display: inline-block; }

.header-actions { display: flex; gap: 8px; align-self: flex-start; z-index: 1; }
.btn-header-icon {
  width: 36px; height: 36px;
  border: 1px solid rgba(197,162,88,0.3);
  border-radius: 4px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; transition: all 0.2s;
}
.btn-header-icon:hover { background: rgba(197,162,88,0.12); color: #fff; border-color: var(--rk-gold); }
.btn-header-icon svg { width: 16px; height: 16px; }
.btn-header-icon.reset { color: #fca5a5; }
.btn-header-icon.theme-toggle { color: var(--rk-gold-light); font-size: 16px; }

/* ── Stats ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-top: 3px solid var(--rk-gold);
  padding: 16px 18px;
  transition: background 0.3s, border-color 0.3s;
}
.stat-label {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.stat-value { font-size: 22px; font-weight: 700; font-family: var(--rk-sans); }

/* ── Progress ── */
.progress-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  padding: 14px 18px;
  margin-bottom: 16px;
  transition: background 0.3s;
}
.progress-header { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.progress-bar { background: var(--progress-track); border-radius: 2px; height: 8px; overflow: hidden; transition: background 0.3s; }
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }

@keyframes progressGradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.progress-fill, .mini-fill {
  background-size: 200% 100%;
  animation: progressGradientShift var(--progress-anim-dur) var(--progress-anim-ease) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .progress-fill, .mini-fill { animation: none !important; }
}

/* ── Table ── */
.table-wrap {
  background: var(--bg-table);
  border: 1px solid var(--border-gold);
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 360px);
  position: relative;
  transition: background 0.3s, border-color 0.3s;
  scrollbar-gutter: stable;
  padding-right: 0px;
}
.row {
  display: grid;
  grid-template-columns: minmax(280px,2.1fr) minmax(150px,1fr) minmax(210px,1.05fr) 76px 132px 142px minmax(420px,2.7fr) 84px;
  align-items: center;
  padding: 0 16px;
  min-height: 38px;
  position: relative;
}
.row::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, var(--border-row), rgba(197,162,88,0.18), var(--border-row));
}
.row-header {
  background: var(--bg-header-row);
  border-bottom: 2px solid var(--border-gold);
  min-height: 42px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-primary);
  position: sticky; top: 54px; z-index: 3;
  transition: background 0.3s;
}
.row-cat {
  background: var(--bg-cat-row) !important;
  border-top: 1px solid var(--border-gold);
  border-bottom: 1px solid var(--border-gold);
  cursor: default;
  transition: background 0.3s, opacity 0.15s;
}
.row-item {
  border-bottom: 1px solid var(--border-row);
  align-items: start; padding-top: 6px; padding-bottom: 6px;
  background: var(--bg-card) !important;
  transition: background 0.3s;
}
.row-item:nth-child(even) { background: var(--bg-card-alt) !important; }

/* ── Form elements ── */
.cell-input, textarea.cell-input.item, textarea.cell-input.owner, textarea.cell-input.notes {
  border: none; background: transparent;
  font-size: 12px !important; color: var(--text-secondary) !important;
  font-family: var(--rk-sans);
  width: 100%; padding: 4px 0; outline: none;
}
.cell-input:focus, textarea:focus, input[type="date"]:focus {
  border-bottom: 2px solid var(--rk-gold) !important;
  background: var(--input-focus-bg);
}
.cell-input.cat-name { font-weight: 600; color: var(--text-cat) !important; font-size: 13px !important; }
textarea.cell-input.notes, textarea.cell-input.owner {
  resize: none; overflow: hidden; min-height: 26px; height: 26px;
  line-height: 1.4; vertical-align: top; padding: 4px 2px;
  font-family: inherit; white-space: pre-wrap; word-break: break-word; display: block; width: 100%;
  transition: height 0.15s ease;
}
input[type="date"] { border: none; background: transparent; font-size: 12px; color: var(--text-secondary); width: 100%; padding: 4px 0; outline: none; text-align: center; }
[data-theme="dark"] input[type="date"] { color-scheme: dark; }

select.status {
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--border-gold);
  border-radius: 2px;
  padding: 4px 10px;
  cursor: pointer; width: auto; max-width: 100%; white-space: nowrap; outline: none;
}

/* ── Status tabs ── */
.status-tabs {
  display: flex; flex-wrap: nowrap; gap: 8px;
  padding: 12px;
  position: sticky; top: 0; z-index: 4;
  background: var(--bg-tabs);
  border-bottom: 1px solid var(--border-gold);
  overflow-x: auto; white-space: nowrap;
  transition: background 0.3s;
  justify-content: center;
  align-items: center;
}
.status-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: 2px;
  border: 1px solid var(--border-gold);
  cursor: pointer;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.03em;
  transition: all .18s ease;
  user-select: none;
  flex: 0 0 auto;
  color: var(--tab-text);
}
.status-tab:hover { transform: translateY(-1px); }
.status-tab.active { border-color: var(--rk-gold) !important; box-shadow: 0 0 0 1px var(--rk-gold) inset; }
.tab-count { background: rgba(0,0,0,.1); border-radius: 2px; padding: 1px 6px; font-size: 10px; font-weight: 700; }
[data-theme="dark"] .tab-count { background: rgba(255,255,255,.08); }
.tab-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 28px; border-radius: 2px;
  border: 1px solid var(--border-gold);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer; transition: all .18s ease; flex: 0 0 auto;
}
.tab-icon-btn:hover { border-color: var(--rk-gold); }
.tab-icon-btn.active { box-shadow: 0 0 0 1px var(--rk-gold) inset; border-color: var(--rk-gold); }

.include-toggle { display: flex; align-items: center; justify-content: center; }
.include-toggle input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--rk-gold); cursor: pointer; }
.include-toggle input[type="checkbox"]:focus { outline: 2px solid rgba(197,162,88,0.6); outline-offset: 2px; }
.action-stack { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

/* ── Buttons & badges ── */
.btn-icon { background: none; border: none; cursor: pointer; padding: 2px; display: flex; align-items: center; }
.btn-icon.add { color: var(--rk-gold); }
.btn-icon.del { color: #cbd5e1; }
.btn-icon.del:hover { color: #ef4444; }
.btn-icon.del-cat { color: #dc2626; }
.btn-icon.toggle { color: var(--text-secondary); }
.cat-actions { display: flex; gap: 2px; }

.mini-bar { background: var(--mini-bar-track); border-radius: 2px; height: 14px; overflow: hidden; position: relative; transition: background 0.3s; }
.mini-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

.btn-add-cat {
  display: flex; align-items: center; gap: 6px;
  margin: 16px 0;
  background: none;
  border: 1px dashed var(--border-gold);
  padding: 12px 20px;
  cursor: pointer;
  color: var(--rk-gold);
  font-size: 12px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  width: 100%; justify-content: center;
  transition: all 0.2s;
}
.btn-add-cat:hover { border-color: var(--rk-gold); background: var(--rk-gold-muted); }

.cat-avg-date { font-size: 11px; color: var(--text-secondary) !important; font-weight: 600; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 3px; width: 100%; text-align: center; }
.cat-avg-date .avg-label { font-size: 10px; color: var(--text-secondary); font-weight: 500; }

.drag-handle, .drag-handle-item { cursor: grab; color: var(--border-gold); display: flex; align-items: center; padding: 0 2px; }
.drag-handle:active, .drag-handle-item:active { cursor: grabbing; }
.drag-handle svg, .drag-handle-item svg { width: 14px; height: 14px; }
.row-cat.dragging, .row-item.dragging { opacity: 0.4; }
.row-cat.drag-over, .row-item.drag-over {
  background: var(--drag-over-bg) !important;
  box-shadow: inset 3px 0 0 var(--rk-gold);
}

.icon { width: 16px; height: 16px; vertical-align: middle; }
.icon-sm { width: 14px; height: 14px; }

input[type="date"].empty::-webkit-datetime-edit-fields-wrapper { display: none; }
input[type="date"].empty::before { content: "--"; color: #94a3b8; }
input[type="date"].empty::-webkit-calendar-picker-indicator { opacity: 0.4; }
.date-warning { background: #fef3c7 !important; border-bottom: 2px solid #f59e0b !important; font-weight: 700; }
[data-theme="dark"] .date-warning { background: rgba(245,158,11,0.15) !important; }

/* ── Modal ── */
#confirm-modal-overlay { display: none; position: fixed; inset: 0; z-index: 1000; background: var(--modal-overlay); backdrop-filter: blur(3px); align-items: center; justify-content: center; }
#confirm-modal-overlay.active { display: flex; }
#confirm-modal {
  background: var(--bg-card); padding: 36px 32px 28px; max-width: 400px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center; animation: modal-in 0.18s ease;
  border-top: 3px solid var(--rk-gold);
  color: var(--text-primary);
}
@keyframes modal-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#confirm-modal .modal-icon { font-size: 32px; margin-bottom: 12px; }
#confirm-modal h3 { font-family: var(--rk-serif); font-size: 20px; font-weight: 500; color: var(--text-primary); margin-bottom: 8px; }
#confirm-modal p { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; line-height: 1.5; }
#confirm-modal .modal-btns { display: flex; gap: 10px; justify-content: center; }
#confirm-modal .btn-cancel { padding: 9px 22px; border-radius: 2px; border: 1px solid var(--border-gold); background: var(--bg-card); color: var(--text-secondary); font-size: 12px; font-weight: 600; cursor: pointer; letter-spacing: 0.5px; }
#confirm-modal .btn-cancel:hover { background: var(--bg-cat-row); }
#confirm-modal .btn-confirm-del { padding: 9px 22px; border-radius: 2px; border: none; background: #ef4444; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; letter-spacing: 0.5px; }
#confirm-modal .btn-confirm-del:hover { background: #dc2626; }
#confirm-modal .btn-confirm-reset { padding: 9px 22px; border-radius: 2px; border: none; background: var(--rk-gold); color: var(--rk-navy); font-size: 12px; font-weight: 600; cursor: pointer; letter-spacing: 0.5px; }
#confirm-modal .btn-confirm-reset:hover { background: var(--rk-gold-light); }

/* ── Gold divider ── */
.gold-divider { height: 3px; background: linear-gradient(90deg, var(--rk-gold), var(--rk-gold-light), var(--rk-gold)); margin-bottom: 20px; }

/* ── Dark mode status pill adjustments ── */
[data-theme="dark"] select.status { border-color: rgba(197,162,88,0.2); }

/* ── Scrollbar styling (dark mode) ── */
[data-theme="dark"] .table-wrap { scrollbar-width: thin; scrollbar-color: rgba(197,162,88,0.55) rgba(26,36,54,0.92); }
[data-theme="dark"] .table-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
[data-theme="dark"] .table-wrap::-webkit-scrollbar-track { background: #1A2436; }
[data-theme="dark"] .table-wrap::-webkit-scrollbar-thumb { background: rgba(197,162,88,0.45); border-radius: 8px; border: 2px solid #1A2436; }
[data-theme="dark"] .table-wrap::-webkit-scrollbar-thumb:hover { background: rgba(197,162,88,0.65); }
