/* ============================================================
   BuildFlow CMS  -  Design System
   Porcelain + Champagne Gold theme (light, premium)
   ============================================================ */

:root {
  /* Soft indigo accents - light UI, never obsidian */
  --navy-950: #3f4a70;
  --navy-900: #4d5982;
  --navy-800: #5b6690;
  --navy-700: #55618c;
  --navy-600: #6d78a0;
  --navy-500: #8a93b6;

  /* Champagne gold accents */
  --amber-50: #fdf9f0;
  --amber-100: #faf1de;
  --amber-200: #f4e6c8;
  --amber-300: #ecd7a6;
  --amber-400: #dcb96a;
  --amber-500: #cda54f;
  --amber-600: #ad8738;
  --amber-700: #8b6a2b;

  --ink: #38322a;
  --text: #625c4f;
  --muted: #7d7666;
  --faint: #a49c8a;
  --line: #ece7dc;
  --line-soft: #f4f0e8;
  --bg: #faf8f3;
  --bg-soft: #fdfbf7;
  --card: #ffffff;

  --green-500: #3fae7f;
  --green-600: #2f8e66;
  --green-50: #edf9f2;
  --red-500: #e4695e;
  --red-600: #cd5448;
  --red-50: #fdf1ef;
  --blue-500: #4d74d4;
  --blue-50: #eef3fd;
  --violet-500: #8b79e3;
  --violet-50: #f4f1fe;
  --teal-500: #4aa6a1;
  --teal-50: #ecfafa;

  /* Chart series - muted, expensive looking */
  --c1: #cda54f;
  --c2: #7c8cc2;
  --c3: #4aa6a1;
  --c4: #5aa77f;
  --c5: #a596dd;
  --c6: #e0896f;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;

  --shadow-xs: 0 1px 2px rgba(84, 74, 55, .05);
  --shadow-sm: 0 1px 2px rgba(84, 74, 55, .05), 0 6px 16px -8px rgba(84, 74, 55, .14);
  --shadow-md: 0 2px 4px rgba(84, 74, 55, .05), 0 16px 36px -20px rgba(84, 74, 55, .28);
  --shadow-lg: 0 30px 70px -30px rgba(74, 66, 48, .42);

  --sidebar-w: 264px;
  --topbar-h: 68px;

  --font: "Manrope", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Fraunces", "Playfair Display", Georgia, "Times New Roman", serif;
  --mono: "SFMono-Regular", ui-monospace, "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(1000px 460px at 94% -8%, rgba(220, 185, 106, .16), transparent 60%),
    radial-gradient(820px 420px at -8% 10%, rgba(124, 140, 194, .12), transparent 62%),
    linear-gradient(180deg, #fbf9f5 0%, #f7f4ee 100%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.015em;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ============================ LAYOUT ============================ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------------------------- SIDEBAR --------------------------- */

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(178deg, #fffdf9 0%, #fdfaf3 48%, #f8f3e8 100%);
  color: var(--text);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 60;
  border-right: 1px solid var(--line);
  box-shadow: inset -14px 0 24px -22px rgba(84, 74, 55, .5);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 16px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--amber-300), var(--amber-500));
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px -8px rgba(220, 185, 106, .75), inset 0 1px 0 rgba(255, 255, 255, .6);
  flex: none;
}

.brand-name {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -.015em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--amber-600);
  font-weight: 700;
  margin-top: 3px;
}

.nav-scroll {
  overflow-y: auto;
  padding: 6px 12px 18px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(173, 135, 56, .32) transparent;
}

.nav-scroll::-webkit-scrollbar { width: 6px; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(173, 135, 56, .30); border-radius: 8px; }

.nav-label {
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #a29880;
  font-weight: 700;
  padding: 16px 12px 7px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 11px;
  color: #7c7566;
  font-size: 13.4px;
  font-weight: 500;
  position: relative;
  margin-bottom: 2px;
  transition: background .16s ease, color .16s ease;
  cursor: pointer;
}

.nav-item svg { flex: none; opacity: .85; }

.nav-item:hover {
  background: rgba(220, 185, 106, .14);
  color: var(--ink);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(220, 185, 106, .30), rgba(220, 185, 106, .07));
  color: var(--ink);
  font-weight: 700;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--amber-400), var(--amber-600));
  box-shadow: 0 0 10px rgba(220, 185, 106, .65);
}

.nav-item.active svg { color: var(--amber-600); opacity: 1; }


.sidebar-foot {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.side-logout {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 11.3px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.side-logout:hover {
  background: var(--amber-50);
  border-color: var(--amber-200);
  color: var(--amber-700);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-500);
  box-shadow: 0 0 0 3px rgba(63, 174, 127, .18);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(63, 174, 127, .18); }
  50% { box-shadow: 0 0 0 6px rgba(63, 174, 127, .05); }
}

/* ---------------------------- TOPBAR ---------------------------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.hamburger {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}

.crumb b { color: var(--ink); font-weight: 700; }
.crumb .sep { color: var(--faint); }

.topbar > .crumb + .icon-btn { margin-left: auto; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text);
  position: relative;
  transition: .16s;
}

.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }

.badge-dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--red-500);
  border: 1.5px solid #fff;
  border-radius: 50%;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--amber-300), var(--amber-500));
  color: #4a3a15;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55);
}

.user-meta { line-height: 1.15; }
.user-meta .u-name { font-size: 12.8px; font-weight: 700; color: var(--ink); }
.user-meta .u-role { font-size: 10.5px; color: var(--muted); }

/* ---------------------------- PAGE ------------------------------ */

.page {
  padding: 26px 26px 44px;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  animation: fadeUp .3s ease;
}

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

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -.025em;
  color: var(--ink);
}

.page-sub {
  color: var(--muted);
  font-size: 13.4px;
  margin-top: 5px;
  max-width: 68ch;
}

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================ BUTTONS ============================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.4px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s ease, background .16s, box-shadow .16s, border-color .16s;
  background: var(--bg-soft);
  color: var(--text);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #e3c483, #cda54f);
  color: #33250b;
  border-color: rgba(173, 135, 56, .5);
  box-shadow: 0 6px 16px -8px rgba(220, 185, 106, .85), inset 0 1px 0 rgba(255, 255, 255, .55);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #ecd297, #d3ad59);
  box-shadow: 0 10px 22px -10px rgba(220, 185, 106, .95);
}

.btn-dark {
  background: linear-gradient(180deg, #a1813f, #8b6a2b);
  color: #fffbf1;
  border-color: #8b6a2b;
  box-shadow: 0 6px 16px -9px rgba(139, 106, 43, .8), inset 0 1px 0 rgba(255, 255, 255, .28);
}

.btn-dark:hover { background: linear-gradient(180deg, #97773a, #7f6027); }

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost:hover { background: var(--bg-soft); border-color: #dcd7cc; }

.btn-soft {
  background: var(--amber-50);
  color: var(--amber-700);
  border-color: var(--amber-100);
}

.btn-soft:hover { background: var(--amber-100); }

.btn-danger {
  background: var(--red-50);
  color: var(--red-600);
  border-color: #f9d8d2;
}

.btn-danger:hover { background: #fbe6e1; }

.btn-sm { height: 32px; padding: 0 11px; font-size: 12.6px; border-radius: 8px; }
.btn-xs { height: 27px; padding: 0 9px; font-size: 11.8px; border-radius: 7px; gap: 5px; }
.btn-icon { width: 32px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.link-btn {
  background: none;
  border: none;
  color: var(--blue-500);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover { text-decoration: underline; }

/* ============================ CARDS ============================= */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 20px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.card-title {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
}

.card-title .hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.card-body { padding: 20px; }
.card-body.tight { padding: 14px 16px; }
.card-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fdfbf7;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ------------------------ STAT / KPI CARDS ---------------------- */

.grid { display: grid; gap: 16px; }

/* Grid items default to an automatic minimum size of min-content, so a wide
   table or chart inside a card can stretch the whole track (and the page)
   past the viewport on phones. opt out explicitly. */
.grid > * { min-width: 0; }

.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-1 { grid-template-columns: 1fr 1fr; }
.g-3-2 { grid-template-columns: 3fr 2fr; }

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 17px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -34px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 185, 106, .12), transparent 70%);
  pointer-events: none;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.stat-label {
  font-size: 11.6px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-ico {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: none;
}

.stat-ico.amber { background: var(--amber-50); color: var(--amber-600); }
.stat-ico.navy { background: #eef1f7; color: var(--navy-700); }
.stat-ico.green { background: var(--green-50); color: var(--green-600); }
.stat-ico.red { background: var(--red-50); color: var(--red-600); }
.stat-ico.blue { background: var(--blue-50); color: var(--blue-500); }
.stat-ico.violet { background: var(--violet-50); color: var(--violet-500); }
.stat-ico.teal { background: var(--teal-50); color: var(--teal-500); }

.stat-value {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.02em;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
}

.stat-value.sm { font-size: 20px; }

.stat-foot {
  margin-top: 7px;
  font-size: 12.2px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  font-size: 11.6px;
  padding: 1.5px 6px;
  border-radius: 6px;
}

.trend.up { background: var(--green-50); color: var(--green-600); }
.trend.down { background: var(--red-50); color: var(--red-600); }
.trend.flat { background: #f3f0e8; color: var(--muted); }

/* ============================ TABLES ============================ */

.table-wrap { overflow-x: auto; }

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.2px;
  min-width: 720px;
}

.table thead th {
  text-align: left;
  font-size: 11.2px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  background: #fbf9f4;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.table tbody td {
  padding: 12.5px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr { transition: background .13s; }
.table tbody tr:hover { background: #fdfcf9; }
.table tbody tr:last-child td { border-bottom: none; }

.table td.num, .table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

.table .cell-strong { font-weight: 700; color: var(--ink); }
.table .cell-sub { font-size: 11.6px; color: var(--muted); margin-top: 2px; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

.row-btn {
  width: 29px;
  height: 29px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  transition: .14s;
}

.row-btn:hover { background: var(--bg-soft); color: var(--ink); border-color: #dcd7cc; }
.row-btn.danger:hover { background: var(--red-50); color: var(--red-600); border-color: #f9d8d2; }
.row-btn.view:hover { background: var(--blue-50); color: var(--blue-500); border-color: #dde7fb; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.6px;
  color: var(--muted);
  flex-wrap: wrap;
}

/* ============================ BADGES ============================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.4px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .85;
}

.badge.plain::before { display: none; }

.badge-green { background: var(--green-50); color: var(--green-600); border-color: #d7f0e3; }
.badge-amber { background: var(--amber-50); color: var(--amber-700); border-color: #f4e6c8; }
.badge-red { background: var(--red-50); color: var(--red-600); border-color: #f9d8d2; }
.badge-blue { background: var(--blue-50); color: var(--blue-500); border-color: #dde7fb; }
.badge-violet { background: var(--violet-50); color: var(--violet-500); border-color: #e6e0fb; }
.badge-teal { background: var(--teal-50); color: var(--teal-500); border-color: #d5f0ef; }
.badge-slate { background: #f4f1e9; color: #6b6455; border-color: #e7e1d4; }

.badge-lg { padding: 5px 12px; font-size: 12.4px; }

/* ============================ FORMS ============================= */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 16px;
}

.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }

.field label {
  font-size: 12.4px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 5px;
}

.field label .req { color: var(--red-500); font-weight: 800; }
.field label .opt { color: var(--faint); font-weight: 500; font-size: 11px; }

.control {
  height: 39px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-size: 13.4px;
}

textarea.control {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.55;
}

select.control {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d7666' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
  cursor: pointer;
}

.control::placeholder { color: var(--faint); }

.control:hover { border-color: #dcd7cc; }

.control:focus {
  border-color: var(--amber-400);
  box-shadow: 0 0 0 4px rgba(220, 185, 106, .15);
  background: #fff;
}

.control.invalid {
  border-color: var(--red-500);
  background: #fef8f6;
  animation: shake .3s ease;
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.field-err { font-size: 11.6px; color: var(--red-600); font-weight: 600; display: none; }
.field.has-err .field-err { display: block; }

.field-hint { font-size: 11.4px; color: var(--muted); }

.input-group {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

.input-group:focus-within {
  border-color: var(--amber-400);
  box-shadow: 0 0 0 4px rgba(220, 185, 106, .15);
}

.input-group .prefix {
  display: grid;
  place-items: center;
  padding: 0 11px;
  background: #fbf9f4;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.input-group .control {
  border: none;
  border-radius: 0;
  box-shadow: none !important;
}

.input-group .suffix {
  display: grid;
  place-items: center;
  padding: 0 11px;
  background: #fbf9f4;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.2px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.check-row input[type="checkbox"], .check-row input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: var(--amber-500);
  cursor: pointer;
}

/* file upload */
.drop-zone {
  border: 1.6px dashed #ded7c8;
  border-radius: 12px;
  background: #fdfbf7;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: .16s;
  color: var(--muted);
  font-size: 12.6px;
}

.drop-zone:hover, .drop-zone.drag {
  border-color: var(--amber-400);
  background: var(--amber-50);
  color: var(--amber-700);
}

.drop-zone strong { color: var(--ink); }

.file-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fbf9f4;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 12.4px;
  margin-top: 8px;
}

.file-chip .fc-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fc-size { color: var(--muted); margin-left: auto; font-size: 11.4px; white-space: nowrap; }

.file-chip .fc-x {
  border: none; background: none; cursor: pointer; color: var(--red-500);
  display: grid; place-items: center; padding: 2px; border-radius: 6px;
}
.file-chip .fc-x:hover { background: var(--red-50); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f2eee4;
}

.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .ph-x {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 6px;
  background: rgba(74, 66, 48, .78); color: #fff; border: none;
  display: grid; place-items: center; cursor: pointer; font-size: 11px;
}

/* ============================ MODAL ============================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(72, 64, 48, .46);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 46px 18px;
  z-index: 200;
  overflow-y: auto;
  opacity: 0;
  animation: fadeIn .18s ease forwards;
}

@keyframes fadeIn { to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow-lg);
  transform: translateY(-14px) scale(.985);
  opacity: 0;
  animation: popIn .22s cubic-bezier(.2, .9, .3, 1.2) forwards;
  margin-bottom: 40px;
}

@keyframes popIn {
  to { transform: none; opacity: 1; }
}

.modal.sm { max-width: 440px; }
.modal.lg { max-width: 860px; }
.modal.xl { max-width: 1080px; }

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

.modal-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--ink); letter-spacing: -.015em; }
.modal-sub { font-size: 12.8px; color: var(--muted); margin-top: 3px; }

.modal-x {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; color: var(--muted); display: grid; place-items: center;
}
.modal-x:hover { background: var(--bg-soft); color: var(--ink); }

.modal-body { padding: 20px 22px; }
.modal-body.flush { padding: 0; }

.modal-foot {
  padding: 15px 22px;
  border-top: 1px solid var(--line-soft);
  background: #fdfbf7;
  border-radius: 0 0 18px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-foot.split { justify-content: space-between; }

/* ============================ TOAST ============================= */

.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green-500);
  border-radius: 12px;
  padding: 12px 15px;
  box-shadow: var(--shadow-md);
  animation: slideIn .28s cubic-bezier(.2, .9, .3, 1.1);
  font-size: 13.2px;
}

.toast.out { animation: slideOut .25s ease forwards; }

@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(30px); } }

.toast .t-ico { flex: none; margin-top: 1px; }
.toast.success { border-left-color: var(--green-500); }
.toast.success .t-ico { color: var(--green-600); }
.toast.error { border-left-color: var(--red-500); }
.toast.error .t-ico { color: var(--red-600); }
.toast.info { border-left-color: var(--blue-500); }
.toast.info .t-ico { color: var(--blue-500); }
.toast.warn { border-left-color: var(--amber-500); }
.toast.warn .t-ico { color: var(--amber-600); }

.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 700; color: var(--ink); font-size: 13.2px; }
.toast .t-msg { color: var(--muted); font-size: 12.6px; margin-top: 1px; }
.toast .t-x { border: none; background: none; cursor: pointer; color: var(--faint); padding: 2px; }
.toast .t-x:hover { color: var(--ink); }

/* ============================ MISC ============================== */

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.filters .control { height: 36px; font-size: 13px; width: auto; min-width: 138px; }
.filters .search-box { position: relative; flex: 1; min-width: 190px; }
.filters .search-box .control { width: 100%; padding-left: 34px; }
.filters .search-box svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint);
}
.filters .spacer { flex: 1; }

/* Label + input pairs stay one unit, so a tight filter bar can never split a
   date label away from its input (desktop) and the pair can stack cleanly
   (phones). Spacing matches the surrounding filter gap, so the desktop
   layout is unchanged. */
.filters > .filter-pair {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search-box { position: relative; }
.search-box svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint);
}
.search-box input { padding-left: 36px; }

.progress {
  height: 8px;
  background: #efe9de;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  min-width: 70px;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--amber-400), var(--amber-500));
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}

.progress.green > span { background: linear-gradient(90deg, #6cc79c, var(--green-500)); }
.progress.red > span { background: linear-gradient(90deg, #ef9488, var(--red-500)); }
.progress.blue > span { background: linear-gradient(90deg, #85a1ea, var(--blue-500)); }
.progress.navy > span { background: linear-gradient(90deg, #9aa6c9, var(--navy-700)); }
.progress.sm { height: 6px; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.2px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.progress-row .progress { flex: 1; }

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}

.empty .e-ico {
  width: 56px; height: 56px; margin: 0 auto 13px;
  border-radius: 16px; background: var(--bg-soft);
  display: grid; place-items: center; color: var(--faint);
  border: 1px solid var(--line);
}

.empty h4 { font-size: 15.5px; margin-bottom: 5px; }
.empty p { font-size: 13px; margin: 0 auto; max-width: 44ch; }

.divider { height: 1px; background: var(--line-soft); margin: 16px 0; }

.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; font-size: 13.2px; }
.kv + .kv { border-top: 1px dashed var(--line); }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; color: var(--ink); text-align: right; }
.kv.total { font-size: 15px; }
.kv.total .v { color: var(--amber-700); }

.section-label {
  font-size: 11.4px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 4px 0 12px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

.tabs {
  display: flex;
  gap: 5px;
  border-bottom: 1.5px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  padding: 9px 15px;
  font-size: 13.2px;
  font-weight: 600;
  color: var(--muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  white-space: nowrap;
  transition: .15s;
}

.tab:hover { color: var(--ink); }
.tab.active { color: var(--amber-700); border-bottom-color: var(--amber-500); font-weight: 700; }

.alert {
  display: flex;
  gap: 11px;
  padding: 12px 15px;
  border-radius: 12px;
  font-size: 13px;
  align-items: flex-start;
  border: 1px solid;
}

.alert-amber { background: var(--amber-50); border-color: #f4e6c8; color: var(--amber-700); }
.alert-red { background: var(--red-50); border-color: #f9d8d2; color: var(--red-600); }
.alert-green { background: var(--green-50); border-color: #d7f0e3; color: var(--green-600); }
.alert-blue { background: var(--blue-50); border-color: #dde7fb; color: var(--blue-500); }
.alert b { color: inherit; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.2px; color: var(--muted); }
.legend .lg { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; }

.chart-box { width: 100%; position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }

.chart-tip {
  position: absolute;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 11.6px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 8px;
  pointer-events: none;
  transform: translate(-50%, -118%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .14s;
  z-index: 5;
  box-shadow: var(--shadow-md);
}

.chart-tip.on { opacity: 1; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat-strip .ss {
  background: #fff;
  padding: 13px 16px;
}
.stat-strip .ss .k { font-size: 11.2px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.stat-strip .ss .v { font-size: 19px; font-weight: 800; color: var(--ink); margin-top: 3px; font-variant-numeric: tabular-nums; }

.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.text-right { text-align: right; } .text-center { text-align: center; }
.text-green { color: var(--green-600); } .text-red { color: var(--red-600); }
.text-amber { color: var(--amber-700); } .text-muted { color: var(--muted); }
.text-ink { color: var(--ink); } .text-blue { color: var(--blue-500); }
.fw-700 { font-weight: 700; } .fw-800 { font-weight: 800; }
.fs-12 { font-size: 12px; } .fs-11 { font-size: 11.4px; } .fs-16 { font-size: 16px; }
.mono { font-family: var(--mono); font-size: 12.4px; }
.nowrap { white-space: nowrap; }
.flex { display: flex; } .flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-center { display: flex; align-items: center; gap: 9px; }
.gap-6 { gap: 6px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; }
.hide { display: none !important; }

/* view detail layout inside modal */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 22px;
}

.detail-grid .d-item {
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 13.2px;
}

.detail-grid .d-item .d-k { color: var(--muted); font-weight: 600; flex: none; }
.detail-grid .d-item .d-v { color: var(--ink); font-weight: 700; text-align: right; word-break: break-word; }
.detail-grid .d-item .d-v .d-empty { color: var(--faint); font-weight: 600; }
.detail-grid .d-item.full { grid-column: 1 / -1; }
.detail-grid .d-item.full.inline { justify-content: flex-start; gap: 10px; }
.detail-grid .d-item.full.inline .d-v { text-align: left; }

/* sidebar overlay on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(72, 64, 48, .42);
  z-index: 55;
}

/* ======================= RESPONSIVE ===================== */

@media (max-width: 1320px) {
  .g-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1140px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3-2, .g-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: none;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar-overlay { display: block; }
  .hamburger { display: inline-flex; }
}

@media (max-width: 860px) {
  .g-5, .g-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .user-meta { display: none; }
  .user-chip { padding: 4px; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .g-2, .g-3, .g-4, .g-5, .g-6, .g-1-1 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .field.span-2, .field.span-3 { grid-column: span 1; }
  .page-title { font-size: 21px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .modal-backdrop { padding: 16px 10px; }
  .stat-value { font-size: 22px; }
  .crumb .sep, .crumb .root { display: none; }
}

/* ==================== PHONE (<=640px) POLISH ==================== */

@media (max-width: 640px) {

  /* KPI / stat rows stay 2-up so the page is not an endless scroll.
     Nested card grids (e.g. document cards) keep the single column. */
  .page > .grid.g-4,
  .page > .grid.g-5,
  .page > .grid.g-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .stat { padding: 13px 13px 14px; }
  .stat::after { width: 76px; height: 76px; right: -26px; top: -26px; }
  .stat-top { margin-bottom: 8px; gap: 6px; }
  .stat-label { font-size: 10.4px; letter-spacing: .05em; }
  .stat-ico { width: 30px; height: 30px; border-radius: 9px; }
  .stat-value { font-size: 20px; }
  .stat-value.sm { font-size: 17px; }
  .stat-foot { font-size: 11.4px; margin-top: 6px; }

  /* Filter bars become a 2-column grid: labels stay next to their input */
  .filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: center;
    padding: 12px;
  }
  .filters .search-box { grid-column: 1 / -1; min-width: 0; }
  .filters .spacer { display: none; }
  .filters .control,
  .filters select.control { width: 100%; min-width: 0; }
  .filters > span { text-align: right; font-size: 11.6px; }
  .filters > .filter-pair {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }
  .filters > .filter-pair > span { font-size: 11.6px; }
  .filters > .filter-pair > .control { width: 100%; min-width: 0; }
  .filters > .btn { width: 100%; }

  /* Tables: tighter cells so more columns fit before you swipe */
  table.table { font-size: 12.6px; }
  .table thead th { padding: 10px 12px; font-size: 10.6px; }
  .table tbody td { padding: 11px 12px; }
  .table .actions { gap: 5px; }

  /* Donut / sparkline SVGs keep their intrinsic size instead of
     stretching across the whole card */
  .chart-box > svg[width] {
    display: block;
    width: min(100%, 220px);
    height: auto;
    margin: 0 auto;
  }

  /* Horizontal bar rows wrap their label/value instead of overflowing */
  .chart-box .flex-between { flex-wrap: wrap; row-gap: 2px; }
  .chart-box .flex-between > span { min-width: 0; }

  /* Long page titles never push the topbar actions off-screen */
  .crumb { overflow: hidden; }
  .crumb b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Modal actions use the full width of the sheet */
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot.split .btn { flex: 0 1 auto; }

  /* Card heads keep the title and the action on one readable line */
  .card-head { padding: 14px 15px; gap: 8px; }
  .card-body { padding: 15px; }
  .card-title { font-size: 14.4px; }
  .card-title .hint { font-size: 11.4px; }

  /* Detail rows inside modals stay readable */
  .detail-grid .d-item { font-size: 12.6px; gap: 10px; }

  .toast-stack { left: 12px; right: 12px; max-width: none; top: 12px; }
}

/* ==================== SEARCHABLE DROPDOWN ==================== */

.sdd { position: relative; min-width: 0; }

/* the native select stays as the value source, just hidden */
.sdd .sdd-native {
  position: absolute;
  left: 0; top: 0;
  width: 1px; height: 1px;
  opacity: 0;
  padding: 0; margin: 0; border: 0;
  pointer-events: none;
}

.sdd-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  background: #fff;
}

.sdd-val {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: var(--ink);
}

.sdd-trigger.is-empty .sdd-val { color: var(--faint); font-weight: 500; }

.sdd-caret {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--faint);
  transition: transform .18s ease;
}

.sdd-trigger:hover .sdd-caret { color: var(--text); }
.sdd.open .sdd-caret { transform: rotate(-180deg); }

.sdd-menu {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  z-index: 130;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: none;
}

.sdd.open .sdd-menu { display: block; animation: fadeUp .16s ease; }
.sdd-menu.sdd-up { top: auto; bottom: calc(100% + 6px); }

.sdd-search { position: relative; margin-bottom: 6px; }

.sdd-search > svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.sdd-q {
  width: 100%; height: 40px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 11px;
  padding: 0 12px 0 36px;
  color: var(--ink);
  font-size: 13.6px;
  outline: none;
  transition: .16s;
}

.sdd-q:focus {
  background: #fff;
  border-color: var(--amber-400);
  box-shadow: 0 0 0 4px rgba(220, 185, 106, .14);
}

.sdd-q::placeholder { color: var(--faint); }

.sdd-list {
  max-height: 238px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.sdd-list::-webkit-scrollbar { width: 6px; }
.sdd-list::-webkit-scrollbar-thumb { background: #e6e0d3; border-radius: 8px; }

.sdd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.sdd-item:hover { background: var(--bg-soft); color: var(--ink); }
.sdd-item.is-head { font-weight: 700; color: var(--ink); font-size: 13.6px; }
.sdd-item.is-sel { background: var(--amber-50); color: var(--amber-700); font-weight: 700; }

.sdd-lab {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sdd-acts { display: flex; gap: 2px; flex: none; }

.sdd-act {
  width: 28px; height: 28px;
  padding: 0; border: 0; background: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .14s;
}

.sdd-act.ed { color: #5b6791; }
.sdd-act.ed:hover { background: #eef0f7; }
.sdd-act.rm { color: var(--red-500); }
.sdd-act.rm:hover { background: var(--red-50); }

.sdd-none {
  padding: 14px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12.6px;
}

.sdd-add {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
  padding: 10px 8px;
  border: 0;
  border-top: 1px dashed var(--line);
  background: none;
  color: var(--blue-500);
  font-size: 13.4px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 0 0 9px 9px;
}

.sdd-add:hover { background: var(--blue-50); }

@media (max-width: 640px) {
  .sdd-list { max-height: 44vh; }
  .sdd-item { padding: 11px 8px; }
  .sdd-act { width: 32px; height: 32px; }
}

/* ==================== PREMIUM CARD SYSTEM ==================== */

/* gold accent tick on every card header */
.card-title::before {
  content: "";
  flex: none;
  width: 3px;
  height: 15px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--amber-400), var(--amber-600));
  box-shadow: 0 0 0 3px rgba(220, 185, 106, .16);
}

.card-head { background: linear-gradient(180deg, #fffefb 0%, #fdfcfa 100%); }

.stat {
  background: linear-gradient(180deg, #ffffff 0%, #fdfcf9 100%);
  border-color: var(--line);
}

/* gold hairline across the top of every KPI card */
.stat::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--amber-400) 0%, rgba(220, 185, 106, 0) 72%);
}

.stat:hover { border-color: var(--amber-200); box-shadow: var(--shadow-md); }

.stat-strip { box-shadow: var(--shadow-xs); }
.stat-strip .ss { transition: background .16s ease; }
.stat-strip .ss:hover { background: var(--amber-50); }
.stat-strip .ss .v { letter-spacing: -.01em; }

/* ------------------------ record cards ------------------------ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
  padding: 18px;
}

.rec-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #fdfcf9 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.rec-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--amber-400), var(--amber-600));
  opacity: 0;
  transition: opacity .18s ease;
}

.rec-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--amber-200);
}

.rec-card:hover::before, .rec-card.is-live::before { opacity: 1; }

.rec-head { display: flex; align-items: flex-start; gap: 11px; }

.rec-ico {
  width: 40px; height: 40px;
  border-radius: 12px;
  flex: none;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--amber-50), var(--amber-100));
  border: 1px solid var(--amber-200);
  color: var(--amber-700);
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: .02em;
}

.rec-title { flex: 1 1 auto; min-width: 0; }

.rec-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rec-sub {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-top: 3px;
  font-size: 12.2px;
  color: var(--muted);
}

.rec-sub > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-sub svg { flex: none; color: var(--faint); }
.rec-head > .badge { flex: none; margin-top: 2px; }

.rec-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  overflow: hidden;
}

.rec-card .fact {
  background: #fff;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fact .k {
  font-size: 10.4px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

.fact .v {
  font-size: 13.4px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rec-block { display: flex; flex-direction: column; gap: 7px; }

.rec-label {
  font-size: 10.6px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.chip {
  display: inline-block;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 12.2px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.chip svg { vertical-align: -2px; margin-right: 4px; color: var(--faint); }

.chip-more {
  background: var(--amber-50);
  border-color: var(--amber-200);
  color: var(--amber-700);
}

.rec-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
}

.rec-foot .row-btn { box-shadow: none; }

.rec-foot > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .card-grid { padding: 14px; gap: 12px; }
  .rec-card { padding: 14px; gap: 11px; }
  .rec-name { font-size: 14.4px; }
  .card-title::before { height: 13px; }
}

/* ---- responsive column priority: same col-hN class on th + td, column hides as screen narrows ---- */
@media (max-width: 1320px) { .table .col-h1 { display: none; } }
@media (max-width: 1140px) { .table .col-h2 { display: none; } }
@media (max-width: 1024px) { .table .col-h3 { display: none; } }
@media (max-width: 860px)  { .table .col-h4 { display: none; } }
@media (max-width: 640px)  { .table .col-h5 { display: none; } }
