/* ═══════════════════════════════════════════════════
   ย่างเนย Dashboard — Liquid Glass UI
   Inspired by iOS 26 / macOS Tahoe
═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Prompt:wght@400;500;600;700;800&display=swap');

:root {
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);

  /* Dark (default) — iOS 26 dark */
  --bg-base: #000000;
  --bg-gradient: radial-gradient(ellipse at top, #1a1d29 0%, #0a0b10 50%, #000000 100%);
  --bg-mesh-1: rgba(255, 149, 0, 0.15);    /* orange accent */
  --bg-mesh-2: rgba(88, 86, 214, 0.12);    /* purple accent */
  --bg-mesh-3: rgba(255, 45, 85, 0.08);    /* pink accent */

  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-hover: rgba(255, 255, 255, 0.09);
  --glass-bg-strong: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-strong: rgba(255, 255, 255, 0.15);
  --glass-highlight: rgba(255, 255, 255, 0.15);

  --text: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.45);
  --text-quaternary: rgba(255, 255, 255, 0.3);

  --accent: #FF9500;           /* iOS orange */
  --accent-dim: #FF9F0A;
  --accent-glow: rgba(255, 149, 0, 0.35);
  --success: #30D158;
  --danger: #FF453A;
  --warning: #FFD60A;
  --info: #0A84FF;

  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
  --radius-xl: 36px;

  --shadow-sm: 0 2px 12px rgba(0,0,0,0.25);
  --shadow: 0 8px 32px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);

  --blur: saturate(180%) blur(30px);
  --blur-strong: saturate(200%) blur(50px);

  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-theme="light"] {
  --bg-base: #F2F2F7;
  --bg-gradient: radial-gradient(ellipse at top, #ffffff 0%, #f5f5f7 50%, #eeeef2 100%);
  --bg-mesh-1: rgba(255, 149, 0, 0.1);
  --bg-mesh-2: rgba(88, 86, 214, 0.08);
  --bg-mesh-3: rgba(255, 45, 85, 0.06);

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-bg-hover: rgba(255, 255, 255, 0.85);
  --glass-bg-strong: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-border-strong: rgba(0, 0, 0, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.9);

  --text: #000000;
  --text-secondary: rgba(0, 0, 0, 0.7);
  --text-tertiary: rgba(0, 0, 0, 0.45);
  --text-quaternary: rgba(0, 0, 0, 0.3);

  --shadow-sm: 0 2px 12px rgba(0,0,0,0.06);
  --shadow: 0 8px 32px rgba(0,0,0,0.08);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg-base);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ═══════════════ Animated Background Mesh ═══════════════ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-gradient);
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(circle at 15% 20%, var(--bg-mesh-1) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, var(--bg-mesh-2) 0%, transparent 40%),
    radial-gradient(circle at 50% 85%, var(--bg-mesh-3) 0%, transparent 45%);
  filter: blur(60px);
  z-index: -1;
  animation: meshFloat 20s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes meshFloat {
  0%   { transform: translate(0, 0) rotate(0deg); }
  50%  { transform: translate(-2%, 1%) rotate(1deg); }
  100% { transform: translate(2%, -2%) rotate(-1deg); }
}

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ═══════════════ LOGIN SCREEN ═══════════════ */
#loginScreen, #changePwdScreen {
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  position: relative;
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.6s var(--spring);
}

.login-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
}

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

.login-logo {
  width: 96px; height: 96px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
  border: 1px solid var(--glass-border-strong);
  border-radius: 28px;
  padding: 14px;
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--shadow-sm);
}
.login-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
[data-theme="dark"] .login-logo img { filter: invert(1) brightness(0.95); }

.login-title {
  text-align: center;
  font-family: 'Prompt', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 6px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 32px;
  letter-spacing: 0.2px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  letter-spacing: 0.3px;
  padding-left: 4px;
}
.field input {
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border-strong);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  transition: all 0.3s var(--ease);
  backdrop-filter: blur(10px);
}
.field input::placeholder { color: var(--text-quaternary); }
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: var(--glass-bg-hover);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%);
  border: none;
  border-radius: 14px;
  padding: 15px;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.2px;
  cursor: pointer;
  margin-top: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 4px 20px var(--accent-glow),
    0 1px 3px rgba(0,0,0,0.2);
  transition: all 0.2s var(--ease);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 8px 28px var(--accent-glow), 0 2px 4px rgba(0,0,0,0.2); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  min-height: 20px;
  margin-top: 4px;
  font-weight: 500;
}

.version-tag {
  position: absolute;
  bottom: calc(24px + var(--sab));
  font-size: 11px;
  color: var(--text-quaternary);
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ═══════════════ TOPBAR (Glass) ═══════════════ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  padding-top: calc(14px + var(--sat));
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--glass-border);
  min-height: calc(64px + var(--sat));
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  object-fit: contain;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  padding: 6px;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
[data-theme="dark"] .topbar-logo { filter: invert(1) brightness(0.9); }

.topbar-title {
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
  line-height: 1.2;
}
.topbar-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; position: relative; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border-strong);
  background: var(--glass-bg-strong);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s var(--spring);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.icon-btn:hover { background: var(--glass-bg-hover); transform: scale(1.05); }
.icon-btn:active { transform: scale(0.95); }

#userBtn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  border: 1px solid rgba(255,255,255,0.2);
  text-transform: uppercase;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 4px 16px var(--accent-glow);
}

.user-menu { position: relative; }
.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--glass-bg);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius);
  min-width: 220px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: dropIn 0.25s var(--spring);
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.user-info {
  padding: 16px 18px;
  border-bottom: 1px solid var(--glass-border);
}
.user-info > div:first-child {
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  letter-spacing: -0.1px;
}
.user-role {
  font-size: 11px;
  color: var(--accent);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.user-dropdown button {
  width: 100%;
  padding: 13px 18px;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}
.user-dropdown button:hover { background: var(--glass-bg-hover); }
.user-dropdown button + button { border-top: 1px solid var(--glass-border); }

/* ═══════════════ SIDEBAR / NAV ═══════════════ */
.sidebar {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding: 12px 16px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: calc(64px + var(--sat));
  z-index: 99;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Brand block (desktop only) */
.sidebar-brand { display: none; }
.nav-section-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s var(--spring);
  backdrop-filter: blur(10px);
  position: relative;
}
.nav-item:hover { background: var(--glass-bg-hover); color: var(--text); transform: translateY(-1px); }
.nav-item.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 4px 16px var(--accent-glow);
}
.nav-item.coming-soon { opacity: 0.45; }
.nav-icon { font-size: 15px; }

/* ═══════════════ MAIN CONTENT ═══════════════ */
.main {
  flex: 1;
  padding: 20px 16px;
  padding-bottom: calc(40px + var(--sab));
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.page {
  animation: pageIn 0.4s var(--ease);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header { margin-bottom: 20px; padding: 0 4px; }
.page-header h2 {
  font-family: 'Prompt', sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1.1;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-top: 6px;
  font-weight: 500;
  letter-spacing: 0.1px;
}

/* ═══════════════ KPI Cards (Glass) ═══════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s var(--spring);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
}

.kpi-card:hover {
  transform: translateY(-2px);
  background: var(--glass-bg-hover);
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.kpi-value {
  font-family: 'Prompt', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.8px;
  line-height: 1.05;
  margin-top: 4px;
}

.kpi-compare {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  flex-wrap: wrap;
}

.kpi-compare .delta {
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 11px;
  backdrop-filter: blur(10px);
}
.kpi-compare .delta.up { color: var(--danger); background: rgba(255,69,58,0.15); }
.kpi-compare .delta.down { color: var(--success); background: rgba(48,209,88,0.15); }
.kpi-compare .delta.neutral { color: var(--text-tertiary); background: var(--glass-bg-strong); }

/* ═══════════════ Chart Card ═══════════════ */
.chart-card {
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.chart-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.chart-header h3 {
  font-family: 'Prompt', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.chart-actions { display: flex; gap: 6px; }
.chip {
  padding: 7px 14px;
  border-radius: 100px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--spring);
  backdrop-filter: blur(10px);
}
.chip:hover { background: var(--glass-bg-hover); }
.chip.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 2px 12px var(--accent-glow);
}

.chart-body { min-height: 280px; }

/* ═══════════════ Status Card ═══════════════ */
.status-card {
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.status-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
}
.status-card h3 {
  font-family: 'Prompt', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: 14px;
}
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.status-item {
  padding: 14px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(10px);
  transition: all 0.25s var(--spring);
}
.status-item:hover { background: var(--glass-bg-hover); transform: translateY(-1px); }
.status-item .label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.4px;
}
.status-item .value {
  font-family: 'Prompt', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.4px;
  color: var(--text);
  margin-top: 4px;
}
.status-item .sub {
  font-size: 10px;
  color: var(--text-quaternary);
  margin-top: 3px;
  font-weight: 500;
}

.loading {
  color: var(--text-tertiary);
  font-size: 13px;
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  font-weight: 500;
}

/* Coming soon */
.coming-soon-box {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-tertiary);
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.coming-soon-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.6;
}
.coming-soon-box h2 {
  font-family: 'Prompt', sans-serif;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.coming-soon-box p { font-size: 14px; font-weight: 500; }

/* ═══════════════ KPI Sparkline ═══════════════ */
.kpi-spark {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 10px;
  height: 28px;
  opacity: 0.55;
  pointer-events: none;
}
.kpi-card { position: relative; padding-bottom: 44px !important; }

/* ═══════════════ Admin Page ═══════════════ */
.admin-sync {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.btn-compact {
  width: auto !important;
  padding: 12px 22px !important;
  font-size: 14px !important;
}
.sync-status {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--glass-border);
}
.data-table tbody td {
  padding: 14px 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--glass-border);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--glass-bg); }
.data-table strong { color: var(--text); font-weight: 700; }

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.role-badge.role-owner { background: rgba(255,149,0,0.15); color: var(--accent); border: 1px solid rgba(255,149,0,0.3); }
.role-badge.role-manager { background: rgba(10,132,255,0.15); color: var(--info); border: 1px solid rgba(10,132,255,0.3); }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.tag.ok { background: rgba(48,209,88,0.15); color: var(--success); }
.tag.warn { background: rgba(255,214,10,0.15); color: var(--warning); }

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 480px;
  overflow-y: auto;
}
.audit-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  transition: background 0.15s ease;
}
.audit-row:hover { background: var(--glass-bg); }
.audit-action {
  font-weight: 700;
  color: var(--text);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
}
.audit-user { color: var(--text-secondary); }
.audit-user .muted { color: var(--text-quaternary); font-size: 10px; }
.audit-time { color: var(--text-tertiary); font-size: 11px; white-space: nowrap; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ═══════════════ MOBILE (< 768px) ═══════════════ */
@media (max-width: 767px) {
  .kpi-value { font-size: 24px; }
  .kpi-card { min-height: 100px; padding: 16px 14px 40px !important; }
  .kpi-spark { height: 22px; bottom: 8px; left: 12px; right: 12px; }
  .page-header h2 { font-size: 26px; }
  .main { padding: 16px 12px; }
  .chart-card { padding: 16px; }
  .status-card { padding: 16px; }
  .chart-header h3 { font-size: 15px; }
  .login-box { padding: 32px 24px; }
  .login-title { font-size: 22px; }
  .audit-row { grid-template-columns: 1fr; gap: 4px; }
  .data-table thead { display: none; }
  .data-table tbody td { display: block; padding: 4px 0; border: none; }
  .data-table tbody tr { display: block; padding: 12px 4px; border-bottom: 1px solid var(--glass-border); }
}

/* ═══════════════ DESKTOP (≥ 768px) ═══════════════ */
@media (min-width: 768px) {
  /* Grid layout: topbar on top, sidebar left, main right */
  #appScreen {
    display: grid;
    grid-template-columns: 248px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "topbar  topbar"
      "sidebar main";
    min-height: 100vh;
  }
  #appScreen .topbar { grid-area: topbar; }
  #appScreen .sidebar {
    grid-area: sidebar;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 20px 14px 28px;
    border-bottom: none;
    border-right: 1px solid var(--glass-border);
    position: sticky;
    top: calc(64px + var(--sat));
    height: calc(100vh - 64px - var(--sat));
    overflow-x: hidden;
    overflow-y: auto;
    width: 248px;
  }
  #appScreen .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 18px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--glass-border);
  }
  #appScreen .sidebar-logo {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    padding: 5px;
    box-shadow: inset 0 1px 0 var(--glass-highlight);
    object-fit: contain;
  }
  [data-theme="dark"] #appScreen .sidebar-logo { filter: invert(1) brightness(0.9); }
  #appScreen .sidebar-brand-title {
    font-family: 'Prompt', sans-serif;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.3px;
    line-height: 1.1;
  }
  #appScreen .sidebar-brand-sub {
    font-size: 11px;
    color: var(--text-tertiary);
    letter-spacing: 0.4px;
    margin-top: 2px;
    font-weight: 500;
  }
  #appScreen .nav-section-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-quaternary);
    padding: 14px 12px 6px;
  }
  #appScreen .main {
    grid-area: main;
    max-width: none;
    width: 100%;
    margin: 0;
  }
  .main-inner, .page { max-width: 1280px; margin: 0 auto; }

  /* Sidebar nav items → vertical rectangular pills */
  #appScreen .sidebar .nav-item {
    width: 100%;
    justify-content: flex-start;
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 14px;
    gap: 12px;
    border: 1px solid transparent;
    background: transparent;
    box-shadow: none;
  }
  #appScreen .sidebar .nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    transition: transform 0.3s var(--spring);
  }
  #appScreen .sidebar .nav-item:hover {
    background: var(--glass-bg-hover);
    transform: none;
  }
  #appScreen .sidebar .nav-item.active {
    background: var(--glass-bg-strong);
    border-color: var(--glass-border-strong);
    color: var(--text);
    box-shadow:
      inset 0 1px 0 var(--glass-highlight),
      0 4px 16px rgba(0,0,0,0.15);
  }
  #appScreen .sidebar .nav-item.active::before {
    transform: translateY(-50%) scaleY(1);
  }
  #appScreen .sidebar .nav-item.active .nav-icon {
    filter: drop-shadow(0 0 8px var(--accent-glow));
  }
  #appScreen .sidebar .nav-icon { font-size: 18px; width: 24px; text-align: center; }

  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .kpi-value { font-size: 32px; }
  .kpi-card { min-height: 130px; padding: 22px 20px; }
  .main { padding: 28px 32px; }
  .topbar-title { font-size: 18px; }
  .status-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .page-header h2 { font-size: 38px; }
}

@media (min-width: 1024px) {
  .chart-body { min-height: 320px; }
  #appScreen { grid-template-columns: 260px 1fr; }
  #appScreen .sidebar { width: 260px; padding: 26px 18px; }
}

/* ═══════════════ Custom scrollbar ═══════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--glass-border-strong);
  border-radius: 100px;
}
::-webkit-scrollbar-thumb:hover { background: var(--glass-highlight); }

/* ═══════════════ FILTER BAR ═══════════════ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.filter-group { display: flex; gap: 6px; align-items: center; }
.filter-btn {
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--spring);
}
.filter-btn:hover { background: var(--glass-bg-hover); color: var(--text); }
.filter-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.date-input, .search-input, .select-input {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--glass-border-strong);
  background: var(--glass-bg-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  backdrop-filter: blur(10px);
  transition: border-color 0.2s ease;
}
.date-input:focus, .search-input:focus, .select-input:focus { border-color: var(--accent); }
.search-input { min-width: 200px; }
.date-sep { color: var(--text-tertiary); font-size: 14px; }
.btn-secondary {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--glass-border-strong);
  background: var(--glass-bg-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s var(--spring);
  backdrop-filter: blur(10px);
}
.btn-secondary:hover { background: var(--glass-bg-hover); transform: translateY(-1px); }

/* ═══════════════ CHART ROW 2-COL ═══════════════ */
.chart-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .chart-row-2 { grid-template-columns: 1fr; } }
.chart-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  background: var(--glass-bg-strong);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}
.chart-badge.danger { background: rgba(255,69,58,0.15); color: var(--danger); border-color: rgba(255,69,58,0.3); }
.chart-badge.success { background: rgba(48,209,88,0.15); color: var(--success); border-color: rgba(48,209,88,0.3); }

/* ═══════════════ ITEMS LIST ═══════════════ */
.items-grid { margin-bottom: 20px; } /* keep selector, wrap container */

.item-list {
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}

.item-row {
  display: grid;
  grid-template-columns: 36px 1fr 52px 100px 110px 24px;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.15s ease;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--glass-bg-hover); }
.item-row:hover .item-row-arrow { color: var(--accent); transform: translateX(2px); }

.item-row-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-quaternary);
  text-align: center;
}
.item-row-info { min-width: 0; }
.item-row-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-row-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-row-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-row-stat { text-align: right; }
.item-row-stat-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}
.item-row-stat-lbl {
  font-size: 10px;
  color: var(--text-quaternary);
  font-weight: 500;
  margin-top: 1px;
}
.item-row-arrow {
  font-size: 18px;
  color: var(--text-quaternary);
  text-align: center;
  transition: all 0.2s var(--spring);
}

@media (max-width: 600px) {
  .item-row {
    grid-template-columns: 28px 1fr 44px 90px 20px;
    gap: 8px;
    padding: 12px 12px;
  }
  /* hide "ต้นทุนรวม" on very small screens — show only ราคา/หน่วย */
  .item-row > .item-row-stat:nth-child(5) { display: none; }
  .item-row-stat-val { font-size: 12px; }
}

/* ═══════════════ ITEM DETAIL OVERLAY ═══════════════ */
.detail-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex; align-items: flex-end;
  animation: fadeIn 0.2s ease;
}
@media (min-width: 768px) { .detail-overlay { align-items: center; justify-content: center; } }
.detail-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.35s var(--spring);
}
@media (min-width: 768px) { .detail-panel { max-width: 680px; border-radius: var(--radius-lg); max-height: 80vh; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.detail-title { font-family: 'Prompt', sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.detail-subtitle { font-size: 13px; color: var(--text-tertiary); margin-top: 4px; }
.detail-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .detail-stats { grid-template-columns: repeat(4, 1fr); } }
.kpi-card.mini { padding: 14px 12px; min-height: unset; }
.kpi-card.mini .kpi-value.sm { font-size: 18px !important; }

/* ═══════════════ FORECAST TABLE ═══════════════ */
.forecast-table { font-size: 13px; }
.ft-head, .ft-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; padding: 12px 16px; align-items: center; }
.ft-head { font-size: 11px; font-weight: 700; color: var(--text-quaternary); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--glass-border); }
.ft-row { border-bottom: 1px solid var(--glass-border); color: var(--text-secondary); transition: background 0.15s; }
.ft-row:last-child { border-bottom: none; }
.ft-row:hover { background: var(--glass-bg); }
.ft-name { color: var(--text); font-weight: 600; }

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

/* ═══════════════ DOW HEATMAP (Patterns) ═══════════════ */
.dow-heatmap { padding: 8px 4px; }
.dow-row {
  display: grid;
  grid-template-columns: 60px 1fr 90px 60px;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.dow-row:hover { background: var(--glass-bg); }
.dow-label { font-weight: 700; font-size: 14px; color: var(--text); }
.dow-bar-wrap { height: 28px; background: var(--glass-bg-strong); border-radius: 8px; overflow: hidden; border: 1px solid var(--glass-border); }
.dow-bar {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg,
    rgba(255,149,0, calc(var(--intensity) * 0.006 + 0.3)),
    rgba(255,149,0, calc(var(--intensity) * 0.008 + 0.5))
  );
  transition: width 0.5s var(--spring);
}
.dow-value { font-weight: 700; font-size: 14px; text-align: right; color: var(--text); }
.dow-sub { font-size: 12px; color: var(--text-tertiary); }

/* ═══════════════ TOP DAYS LIST ═══════════════ */
.top-day-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.15s;
}
.top-day-row:last-child { border-bottom: none; }
.top-day-row:hover { background: var(--glass-bg); }
.top-day-rank {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--accent);
  flex-shrink: 0;
}
.top-day-info { flex: 1; }
.top-day-date { font-weight: 600; font-size: 14px; color: var(--text); }
.top-day-guests { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.top-day-sales { font-weight: 800; font-size: 15px; color: var(--text); }

/* ═══════════════ SUPPLIER CARDS ═══════════════ */
.supplier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.supplier-card {
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all 0.25s var(--spring);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.supplier-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 8px 24px rgba(255,149,0,0.12);
}
.supplier-name { font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 6px; line-height: 1.3; }
.supplier-cost { font-family: 'Prompt', sans-serif; font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; margin-bottom: 6px; }
.supplier-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 12px; color: var(--text-tertiary); }
.pct-badge {
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 100px;
  background: rgba(255,149,0,0.15); color: var(--accent); border: 1px solid rgba(255,149,0,0.25);
}
.supplier-bar { height: 6px; background: var(--glass-bg-strong); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.supplier-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-dim)); border-radius: 3px; transition: width 0.6s var(--spring); }
.supplier-footer { font-size: 11px; color: var(--text-quaternary); font-weight: 500; }

/* ═══════════════ HAMBURGER BUTTON ═══════════════ */
.hamburger-btn {
  font-size: 20px;
  display: flex; /* show on mobile */
}
@media (min-width: 768px) {
  .hamburger-btn { display: none; } /* hide on desktop */
}

/* ═══════════════ MOBILE DRAWER ═══════════════ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 400;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.drawer-overlay.open { opacity: 1; }

.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  z-index: 500;
  background: var(--glass-bg);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
  border-right: 1px solid var(--glass-border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s var(--spring);
  overflow-y: auto;
  padding-bottom: calc(32px + var(--sab));
}
.drawer.open { transform: translateX(0); }

@media (min-width: 768px) {
  .drawer, .drawer-overlay { display: none !important; }
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(20px + var(--sat)) 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.drawer-header .icon-btn {
  margin-left: auto;
  flex-shrink: 0;
}
.drawer-header .sidebar-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  padding: 5px;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  object-fit: contain;
  flex-shrink: 0;
}
[data-theme="dark"] .drawer-header .sidebar-logo { filter: invert(1) brightness(0.9); }

.drawer-nav {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.drawer-nav .nav-section-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-quaternary);
  padding: 14px 10px 6px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s var(--spring);
  position: relative;
}
.drawer-item .nav-icon { font-size: 20px; width: 28px; text-align: center; }
.drawer-item:hover {
  background: var(--glass-bg-hover);
  color: var(--text);
}
.drawer-item.active {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-strong);
  color: var(--text);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.drawer-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.drawer-item.active .nav-icon {
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

/* Hide sidebar horizontal pills on mobile (drawer replaces it) */
@media (max-width: 767px) {
  .sidebar { display: none !important; }
}

/* ═══════════════ PROMO TRACKER ═══════════════ */
.promo-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.promo-data-table {
  min-width: 600px;
  width: max-content;
}
.promo-data-table thead th {
  white-space: nowrap;
  font-size: 12px;
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-tertiary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.promo-col-item { color: var(--accent) !important; background: var(--glass-bg-strong); }
.promo-data-table tbody td {
  white-space: nowrap;
  font-size: 13px;
  padding: 9px 10px;
  text-align: right;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-secondary);
}
.promo-data-table tbody td:first-child { text-align: left; font-weight: 600; color: var(--text); }
.promo-data-table tbody tr:hover { background: var(--glass-bg); }
.promo-summary-row td { background: var(--glass-bg-strong); font-weight: 700; color: var(--text) !important; border-top: 2px solid var(--accent); }

.promo-pct-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
}
.promo-pct-badge.pct-green { background: rgba(52,199,89,0.15); color: #34C759; }
.promo-pct-badge.pct-yellow { background: rgba(255,204,0,0.15); color: #FFCC00; }
.promo-pct-badge.pct-red { background: rgba(255,59,48,0.15); color: #FF3B30; }

/* Promo Modal */
.promo-search-box { position: relative; margin-top: 8px; }
.promo-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  max-height: 220px;
  overflow-y: auto;
}
.promo-search-item {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.15s;
}
.promo-search-item:last-child { border-bottom: none; }
.promo-search-item:hover { background: var(--glass-bg-hover); }
.promo-search-th { font-size: 14px; font-weight: 600; color: var(--text); }
.promo-search-en { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.promo-search-no-result { padding: 12px 14px; font-size: 13px; color: var(--text-tertiary); text-align: center; }

.promo-config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  margin-bottom: 6px;
  background: var(--glass-bg-strong);
}
.promo-config-info { display: flex; align-items: center; gap: 8px; }
.promo-config-th { font-size: 14px; font-weight: 600; color: var(--text); }
.promo-config-unit { font-size: 12px; color: var(--text-tertiary); background: var(--glass-bg); padding: 2px 8px; border-radius: 100px; }
.promo-remove-btn {
  background: rgba(255,59,48,0.12);
  border: 1px solid rgba(255,59,48,0.2);
  color: #FF3B30;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.promo-remove-btn:hover { background: rgba(255,59,48,0.25); }
.promo-empty-config { text-align: center; padding: 20px; font-size: 13px; color: var(--text-tertiary); }

/* ═══════════════════════════════════════════════════
   EDITORIAL OVERVIEW (v2) — Yangnoey Daily
═══════════════════════════════════════════════════ */

.editorial {
  --ed-paper: #FAF7F2;
  --ed-paper-2: #F4F0E8;
  --ed-ink: #1A1815;
  --ed-ink-2: #3D3935;
  --ed-ink-3: #6E6862;
  --ed-ink-4: #A29B92;
  --ed-rule: #D9D2C6;
  --ed-rule-2: #B8B0A2;
  --ed-grill: #C73E0F;
  --ed-ember: #F5894F;
  --ed-leaf: #5C7A3E;
  --ed-serif: 'Fraunces','IBM Plex Serif',Georgia,serif;
  --ed-sans: 'Inter','IBM Plex Sans Thai',-apple-system,sans-serif;
  --ed-thai: 'IBM Plex Sans Thai','Prompt',sans-serif;
  --ed-mono: 'JetBrains Mono',ui-monospace,monospace;
  font-family: var(--ed-sans);
  color: var(--ed-ink);
  background: var(--ed-paper);
  position: relative;
  padding: 32px 36px 56px;
  border-radius: 12px;
  font-feature-settings: 'ss01','cv11';
}
.editorial::before {
  content: '';
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(58,30,14,0.025) 0.5px,transparent 0.5px);
  background-size: 3px 3px;
  opacity: 0.6;
  border-radius: inherit;
}
.editorial > * { position: relative; z-index: 1; }

[data-theme=dark] .editorial {
  --ed-paper: #13110E;
  --ed-paper-2: #1B1814;
  --ed-ink: #EDE4D3;
  --ed-ink-2: #C7BBA7;
  --ed-ink-3: #8B8275;
  --ed-ink-4: #5C5547;
  --ed-rule: #2C2722;
  --ed-rule-2: #3D362E;
  --ed-grill: #F5894F;
  --ed-ember: #FFB07A;
  --ed-leaf: #A8C97A;
}

/* Masthead */
.editorial .masthead {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 18px; align-items: end;
  padding-bottom: 14px; border-bottom: 2px solid var(--ed-ink);
  margin-bottom: 4px;
}
.editorial .masthead-left { display: flex; align-items: center; gap: 14px; }
.editorial .masthead-mascot { display: block; flex-shrink: 0; }
.editorial .masthead-title {
  font-family: var(--ed-serif); font-size: 36px; font-weight: 600;
  letter-spacing: -0.035em; line-height: 0.95;
  font-variation-settings: 'opsz' 96;
  color: var(--ed-ink); margin: 0;
}
.editorial .masthead-title em {
  font-style: italic; color: var(--ed-grill);
  font-variation-settings: 'opsz' 96,'wght' 500;
}
.editorial .masthead-mid {
  font-family: var(--ed-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ed-ink-3); text-align: center;
  padding-bottom: 6px;
}
.editorial .masthead-right {
  font-family: var(--ed-mono); font-size: 10px; letter-spacing: 0.1em;
  color: var(--ed-ink-3); text-align: right; padding-bottom: 6px;
  display: flex; flex-direction: column; gap: 3px;
}
.editorial .masthead-right .vol { color: var(--ed-ink-2); font-weight: 500; }
.editorial .masthead-right .page-subtitle { color: var(--ed-ink-3); margin: 0; }

.editorial .rules { height: 1px; background: var(--ed-ink); margin-top: 2px; }
.editorial .rules + .rules { margin-top: 3px; background: var(--ed-ink-3); height: 0.5px; }

/* Kicker */
.editorial .kicker {
  font-family: var(--ed-mono); font-size: 10px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ed-grill); font-weight: 500;
  margin-bottom: 6px; display: flex; align-items: center; gap: 10px;
}
.editorial .kicker::before {
  content: ''; width: 4px; height: 4px;
  background: var(--ed-grill); border-radius: 50%;
}

/* Lead headline */
.editorial .lead {
  padding: 32px 0 28px; border-bottom: 1px solid var(--ed-rule-2);
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 36px; align-items: end;
}
.editorial .lead-meta-label {
  font-family: var(--ed-thai); font-size: 14px; color: var(--ed-ink-2);
  font-weight: 500; margin-top: 6px;
}
.editorial .lead-headline {
  font-family: var(--ed-serif); font-size: 64px; font-weight: 500;
  letter-spacing: -0.045em; line-height: 0.95;
  font-variation-settings: 'opsz' 144;
  font-variant-numeric: tabular-nums lining-nums;
  margin: 6px 0 12px; color: var(--ed-ink);
}
.editorial .lead-delta {
  font-family: var(--ed-mono); font-size: 12px;
}
.editorial .lead-delta .delta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 6px; font-weight: 500;
  font-family: var(--ed-mono);
  background: rgba(92,122,62,0.10); color: var(--ed-leaf);
  border: 1px solid rgba(92,122,62,0.18);
}
.editorial .lead-delta .delta.up {
  background: rgba(199,62,15,0.10); color: var(--ed-grill);
  border-color: rgba(199,62,15,0.22);
}
[data-theme=dark] .editorial .lead-delta .delta {
  background: rgba(168,201,122,0.10); color: var(--ed-leaf);
  border-color: rgba(168,201,122,0.22);
}
[data-theme=dark] .editorial .lead-delta .delta.up {
  background: rgba(245,137,79,0.12); color: var(--ed-ember);
  border-color: rgba(245,137,79,0.28);
}
.editorial .lead-spark { height: 120px; width: 100%; }

/* Ticker */
.editorial .ticker {
  display: grid; grid-template-columns: repeat(3,1fr);
  border-bottom: 1px solid var(--ed-rule-2);
}
.editorial .tk {
  padding: 22px 24px; border-right: 1px solid var(--ed-rule);
  transition: background 0.4s cubic-bezier(0.16,1,0.3,1);
}
.editorial .tk:hover { background: rgba(199,62,15,0.04); }
[data-theme=dark] .editorial .tk:hover { background: rgba(245,137,79,0.05); }
.editorial .tk:last-child { border-right: none; }
.editorial .tk-name {
  font-family: var(--ed-mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ed-ink-3); margin-bottom: 6px;
}
.editorial .tk-val {
  font-family: var(--ed-serif); font-size: 30px; font-weight: 500;
  letter-spacing: -0.03em; line-height: 1;
  font-variation-settings: 'opsz' 72;
  font-variant-numeric: tabular-nums lining-nums; color: var(--ed-ink);
}
.editorial .tk-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; font-size: 11px;
}
.editorial .tk-foot .delta {
  font-family: var(--ed-mono); font-weight: 500;
}
.editorial .tk-foot .delta.up { color: var(--ed-grill); }
.editorial .tk-foot .delta.down { color: var(--ed-leaf); }
.editorial .tk-spark { width: 70px; height: 20px; }

/* Section */
.editorial .sect { padding: 32px 0 0; }
.editorial .sect-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-bottom: 12px; border-bottom: 1px solid var(--ed-ink);
  margin-bottom: 16px; gap: 16px; flex-wrap: wrap;
}
.editorial .sect-title {
  font-family: var(--ed-serif); font-size: 26px; font-weight: 500;
  letter-spacing: -0.025em; font-variation-settings: 'opsz' 36;
  color: var(--ed-ink); margin: 0;
}
.editorial .sect-title em {
  font-style: italic; color: var(--ed-grill);
  font-variation-settings: 'opsz' 36,'wght' 500;
}

/* Filter chips — editorial style override */
.editorial .filt {
  display: inline-flex; align-items: center; gap: 16px;
  font-family: var(--ed-mono); font-size: 11px;
}
.editorial .filt .chip {
  background: none; border: none; padding: 4px 2px;
  font-family: inherit; font-size: inherit; color: var(--ed-ink-3);
  border-bottom: 1px dotted transparent; cursor: pointer;
  transition: all 0.3s; letter-spacing: 0.04em;
}
.editorial .filt .chip.active {
  color: var(--ed-grill); border-bottom-color: var(--ed-grill); font-weight: 500;
}
.editorial .filt .chip:hover:not(.active) { color: var(--ed-ink); }
.editorial .filt .select-input {
  background: transparent; border: 1px solid var(--ed-rule-2);
  color: var(--ed-ink-2); font-family: var(--ed-mono); border-radius: 0;
}

.editorial .fig-host { height: 300px; margin: 0 -6px; }

/* Two-col */
.editorial .two-col {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 48px; padding-top: 32px; align-items: start;
}

/* System status as dossier */
.editorial .dossier {
  font-family: var(--ed-mono); font-size: 12px; line-height: 1.7;
  color: var(--ed-ink-2); margin-top: 12px;
  padding: 16px 20px;
  background: rgba(217,210,198,0.30);
  border-left: 2px solid var(--ed-grill);
  border-radius: 0; display: block;
}
[data-theme=dark] .editorial .dossier {
  background: rgba(44,39,34,0.6);
}
.editorial .dossier > div { padding: 3px 0; }

/* Hide masthead-mid on small screens */
@media (max-width: 720px) {
  .editorial { padding: 20px 16px 40px; }
  .editorial .masthead { grid-template-columns: 1fr; gap: 8px; }
  .editorial .masthead-mid, .editorial .masthead-right { display: none; }
  .editorial .masthead-title { font-size: 24px; }
  .editorial .lead { grid-template-columns: 1fr; gap: 18px; padding: 22px 0; }
  .editorial .lead-headline { font-size: 44px; }
  .editorial .lead-spark { height: 90px; }
  .editorial .ticker { grid-template-columns: 1fr; }
  .editorial .tk { border-right: none; border-bottom: 1px solid var(--ed-rule); }
  .editorial .tk:last-child { border-bottom: none; }
  .editorial .two-col { grid-template-columns: 1fr; gap: 32px; }
  .editorial .sect-title { font-size: 20px; }
}

/* ═══════════════════════════════════════════════════
   EDITORIAL CHROME — sidebar + topbar + login (v2)
═══════════════════════════════════════════════════ */

/* Editorial design tokens at root so chrome can use too */
:root {
  --ed2-paper: #FAF7F2;
  --ed2-paper-2: #F4F0E8;
  --ed2-ink: #1A1815;
  --ed2-ink-2: #3D3935;
  --ed2-ink-3: #6E6862;
  --ed2-ink-4: #A29B92;
  --ed2-rule: #D9D2C6;
  --ed2-rule-2: #B8B0A2;
  --ed2-grill: #C73E0F;
  --ed2-ember: #F5894F;
  --ed2-serif: 'Fraunces','IBM Plex Serif',Georgia,serif;
  --ed2-sans: 'Inter','IBM Plex Sans Thai','Prompt',-apple-system,sans-serif;
  --ed2-mono: 'JetBrains Mono',ui-monospace,monospace;
}
[data-theme=dark] {
  --ed2-paper: #13110E;
  --ed2-paper-2: #1B1814;
  --ed2-ink: #EDE4D3;
  --ed2-ink-2: #C7BBA7;
  --ed2-ink-3: #8B8275;
  --ed2-ink-4: #5C5547;
  --ed2-rule: #2C2722;
  --ed2-rule-2: #3D362E;
  --ed2-grill: #F5894F;
  --ed2-ember: #FFB07A;
}

body { font-family: var(--ed2-sans); }
body { background: var(--ed2-paper); color: var(--ed2-ink); }

/* Grain texture across whole app */
#appScreen::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(58,30,14,0.025) 0.5px,transparent 0.5px);
  background-size: 3px 3px; opacity: 0.6;
}
[data-theme=dark] #appScreen::before {
  background-image: radial-gradient(rgba(237,228,211,0.025) 0.5px,transparent 0.5px);
  opacity: 0.7;
}

/* ── SIDEBAR ── */
#appScreen .sidebar {
  background: var(--ed2-paper) !important;
  border-right: 1px solid var(--ed2-rule);
  padding: 28px 22px;
  width: 240px;
  backdrop-filter: none;
}
#appScreen .sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 22px; margin-bottom: 22px;
  border-bottom: 1px solid var(--ed2-ink);
  position: relative;
}
#appScreen .sidebar-brand::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -4px;
  height: 0.5px; background: var(--ed2-ink-3);
}
#appScreen .sidebar-logo {
  width: 38px; height: 38px; filter: none !important;
}
#appScreen .sidebar-brand-text { display: flex; flex-direction: column; }
#appScreen .sidebar-brand-title {
  font-family: var(--ed2-serif); font-size: 18px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--ed2-ink);
  font-variation-settings: 'opsz' 36;
}
#appScreen .sidebar-brand-sub {
  font-family: var(--ed2-mono); font-size: 9px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ed2-ink-3); margin-top: 2px;
}

#appScreen .nav-section-label {
  font-family: var(--ed2-mono) !important; font-size: 9px !important;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ed2-grill) !important; font-weight: 500;
  padding: 18px 0 8px; margin: 0; display: flex; align-items: center; gap: 8px;
}
#appScreen .nav-section-label::before {
  content: ''; width: 4px; height: 4px; background: var(--ed2-grill); border-radius: 50%;
}

#appScreen .nav-item, #appScreen .drawer-item {
  background: transparent !important; border: none !important;
  border-radius: 0 !important;
  padding: 9px 0 !important; margin: 0 !important;
  font-family: var(--ed2-sans) !important; font-size: 13px !important;
  color: var(--ed2-ink-2) !important; font-weight: 400 !important;
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: color 0.25s, padding-left 0.3s cubic-bezier(0.16,1,0.3,1);
  position: relative; width: 100%; text-align: left;
}
#appScreen .nav-item .nav-icon, #appScreen .drawer-item .nav-icon {
  font-size: 14px; opacity: 0.7; filter: grayscale(0.4);
  transition: opacity 0.25s;
}
#appScreen .nav-item:hover, #appScreen .drawer-item:hover {
  color: var(--ed2-ink) !important; padding-left: 4px !important;
}
#appScreen .nav-item:hover .nav-icon { opacity: 1; filter: none; }
#appScreen .nav-item.active, #appScreen .drawer-item.active {
  color: var(--ed2-grill) !important; font-weight: 500 !important;
}
#appScreen .nav-item.active::before, #appScreen .drawer-item.active::before {
  content: ''; position: absolute; left: -22px; top: 50%;
  transform: translateY(-50%); width: 3px; height: 14px;
  background: var(--ed2-grill);
}
#appScreen .nav-item.active .nav-icon { opacity: 1; filter: none; }

/* ── TOPBAR ── */
#appScreen .topbar {
  background: var(--ed2-paper) !important; backdrop-filter: none !important;
  border-bottom: 1px solid var(--ed2-rule) !important;
  padding: 10px 24px !important;
  min-height: 52px;
}
#appScreen .topbar-logo { display: none; }
#appScreen .topbar-title {
  font-family: var(--ed2-serif); font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ed2-ink);
}
#appScreen .topbar-title::after {
  content: ' · '; color: var(--ed2-ink-4);
}
#appScreen .topbar-subtitle {
  display: inline; font-family: var(--ed2-mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ed2-ink-3);
  vertical-align: 1px;
}
#appScreen .icon-btn {
  background: transparent !important; border: 1px solid var(--ed2-rule) !important;
  border-radius: 6px !important; color: var(--ed2-ink-2) !important;
  font-size: 14px !important;
  transition: all 0.25s;
}
#appScreen .icon-btn:hover {
  border-color: var(--ed2-grill) !important; color: var(--ed2-grill) !important;
}
#appScreen #userBtn { font-family: var(--ed2-mono); font-weight: 500; }

#appScreen .user-dropdown {
  background: var(--ed2-paper) !important; border: 1px solid var(--ed2-ink-3) !important;
  border-radius: 0 !important; padding: 4px !important;
  box-shadow: 4px 4px 0 var(--ed2-rule);
}
#appScreen .user-info {
  font-family: var(--ed2-mono); font-size: 11px;
  border-bottom: 1px dotted var(--ed2-rule) !important;
  color: var(--ed2-ink-2);
}
#appScreen .user-role {
  font-family: var(--ed2-mono); text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ed2-grill); font-size: 9px;
}
#appScreen .user-dropdown button {
  font-family: var(--ed2-sans); border-radius: 0 !important;
  color: var(--ed2-ink-2);
}
#appScreen .user-dropdown button:hover {
  background: var(--ed2-paper-2) !important; color: var(--ed2-grill);
}

/* ── LOGIN ── */
#loginScreen {
  background: var(--ed2-paper) !important; position: relative;
}
#loginScreen::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(58,30,14,0.025) 0.5px,transparent 0.5px);
  background-size: 3px 3px; opacity: 0.6;
}
[data-theme=dark] #loginScreen::before {
  background-image: radial-gradient(rgba(237,228,211,0.025) 0.5px,transparent 0.5px);
}
.login-box {
  background: transparent !important; border: none !important;
  box-shadow: none !important; padding: 48px 40px !important;
  position: relative; z-index: 1;
}
.login-box::before {
  content: ''; display: block;
  border-top: 2px solid var(--ed2-ink);
  border-bottom: 1px solid var(--ed2-ink-3);
  margin-bottom: 28px; padding-top: 3px;
}
.login-logo img {
  width: 64px !important; height: 64px !important;
  filter: none !important;
}
.login-title {
  font-family: var(--ed2-serif) !important; font-size: 32px !important;
  font-weight: 600 !important; letter-spacing: -0.03em !important;
  color: var(--ed2-ink) !important; margin-top: 18px !important;
  font-variation-settings: 'opsz' 72;
}
.login-subtitle {
  font-family: var(--ed2-mono) !important; font-size: 10px !important;
  letter-spacing: 0.18em !important; text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important; margin-top: 6px !important;
}
.login-form .field label {
  font-family: var(--ed2-mono) !important; font-size: 10px !important;
  letter-spacing: 0.14em !important; text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
}
.login-form input {
  background: transparent !important;
  border: none !important; border-bottom: 1px solid var(--ed2-rule-2) !important;
  border-radius: 0 !important; padding: 10px 0 !important;
  font-family: var(--ed2-sans) !important; font-size: 15px !important;
  color: var(--ed2-ink) !important;
  transition: border-color 0.3s;
}
.login-form input:focus {
  outline: none !important; border-bottom-color: var(--ed2-grill) !important;
}
.login-form button[type=submit] {
  background: var(--ed2-ink) !important; color: var(--ed2-paper) !important;
  border-radius: 0 !important;
  font-family: var(--ed2-mono) !important; font-size: 11px !important;
  letter-spacing: 0.14em !important; text-transform: uppercase !important;
  font-weight: 500 !important; padding: 14px 22px !important;
  border: none !important;
  transition: background 0.3s;
}
.login-form button[type=submit]:hover {
  background: var(--ed2-grill) !important;
}

/* Drawer (mobile) */
#mobileDrawer {
  background: var(--ed2-paper) !important;
  border-right: 1px solid var(--ed2-ink) !important;
}
#mobileDrawer .drawer-header {
  border-bottom: 1px solid var(--ed2-ink) !important;
  padding: 22px 20px !important;
}
#mobileDrawer .sidebar-logo { filter: none !important; }

/* Page header for non-editorial pages — quick consistency */
.page-header h2 {
  font-family: var(--ed2-serif) !important; font-weight: 600;
  letter-spacing: -0.03em; color: var(--ed2-ink);
  font-variation-settings: 'opsz' 72;
}
.page-subtitle {
  font-family: var(--ed2-mono) !important; font-size: 10px !important;
  letter-spacing: 0.14em !important; text-transform: uppercase;
  color: var(--ed2-ink-3) !important;
}

/* Cards, charts on non-editorial pages — soften to paper feel */
.chart-card, .status-card, .kpi-card {
  background: var(--ed2-paper-2) !important;
  border: 1px solid var(--ed2-rule) !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}
[data-theme=dark] .chart-card,
[data-theme=dark] .status-card,
[data-theme=dark] .kpi-card { background: var(--ed2-paper-2) !important; }

/* Editorial section sits flush on paper bg — remove inner card chrome */
.editorial {
  background: transparent !important;
  border-radius: 0 !important;
  padding: 24px 32px 56px !important;
}
.editorial::before { display: none; }


/* ═══════════════════════════════════════════════════
   ICONS + THEME TOGGLE (v2 custom)
═══════════════════════════════════════════════════ */

/* Generic SVG icon — inherits color & font-size */
svg.nav-icon, svg.ico {
  width: 16px; height: 16px;
  flex-shrink: 0;
  display: inline-block; vertical-align: middle;
  color: inherit; fill: none;
}
#appScreen .nav-item svg.nav-icon,
#appScreen .drawer-item svg.nav-icon {
  width: 16px; height: 16px;
  color: var(--ed2-ink-3);
  transition: color 0.25s, transform 0.3s cubic-bezier(0.16,1,0.3,1);
  opacity: 1; filter: none !important;
}
#appScreen .nav-item:hover svg.nav-icon,
#appScreen .drawer-item:hover svg.nav-icon {
  color: var(--ed2-ink); transform: translateX(1px);
}
#appScreen .nav-item.active svg.nav-icon,
#appScreen .drawer-item.active svg.nav-icon {
  color: var(--ed2-grill);
}

#appScreen .icon-btn svg.ico {
  width: 16px; height: 16px; color: inherit;
}

/* ── Theme Toggle Pill — Glass v2 ── */
.theme-pill {
  position: relative;
  width: 60px; height: 30px;
  border-radius: 100px;
  background: linear-gradient(180deg, rgba(58,30,14,0.06), rgba(58,30,14,0.12));
  border: 1px solid var(--ed2-rule-2);
  cursor: pointer;
  padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: space-between;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), inset 0 -1px 2px rgba(58,30,14,0.06);
  transition: background 0.5s cubic-bezier(0.16,1,0.3,1),
              border-color 0.3s,
              box-shadow 0.3s;
  -webkit-tap-highlight-color: transparent;
}
[data-theme="dark"] .theme-pill {
  background: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.55));
  border-color: var(--ed2-rule-2);
  box-shadow: inset 0 1px 0 rgba(245,137,79,0.08), inset 0 -1px 2px rgba(0,0,0,0.4);
}
.theme-pill:hover { border-color: var(--ed2-grill); }

.theme-pill .theme-icon {
  width: 14px; height: 14px;
  position: relative; z-index: 1;
  fill: none;
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.16,1,0.3,1), color 0.4s;
}
.theme-pill .theme-icon-sun {
  color: var(--ed2-grill);
  opacity: 1;
}
.theme-pill .theme-icon-moon {
  color: var(--ed2-ink-3);
  opacity: 0.45;
}
[data-theme="dark"] .theme-pill .theme-icon-sun {
  color: var(--ed2-ink-3);
  opacity: 0.45;
}
[data-theme="dark"] .theme-pill .theme-icon-moon {
  color: var(--ed2-ember);
  opacity: 1;
}

.theme-pill .theme-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFFFFF, #F4F0E8);
  border: 1px solid rgba(58,30,14,0.18);
  box-shadow:
    0 1px 2px rgba(58,30,14,0.18),
    0 2px 6px rgba(58,30,14,0.12),
    inset 0 1px 0 rgba(255,255,255,0.9);
  transform: translateX(0);
  transition: transform 0.55s cubic-bezier(0.34,1.56,0.64,1),
              background 0.4s,
              border-color 0.3s,
              box-shadow 0.3s;
  z-index: 2;
  pointer-events: none;
}
[data-theme="dark"] .theme-pill .theme-thumb {
  transform: translateX(30px);
  background: linear-gradient(180deg, #2A2520, #13110E);
  border-color: rgba(245,137,79,0.35);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.5),
    0 2px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(245,137,79,0.25);
}

.theme-pill:active .theme-thumb {
  width: 26px;
  transition: transform 0.5s cubic-bezier(0.34,1.56,0.64,1),
              width 0.15s ease-out,
              background 0.4s, border-color 0.3s, box-shadow 0.3s;
}

@supports (backdrop-filter: blur(10px)) {
  .theme-pill { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
}

/* ═══════════════════════════════════════════════════
   SUPPLIER RANKING (editorial leaderboard)
═══════════════════════════════════════════════════ */

.editorial #supplierChart { padding: 8px 0; min-height: auto; }
.editorial .rank { display: flex; flex-direction: column; gap: 0; }
.editorial .rank-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 14px 16px;
  align-items: baseline;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--ed2-rule);
  transition: opacity 0.3s, padding-left 0.3s cubic-bezier(0.16,1,0.3,1);
  cursor: default;
}
.editorial .rank-row:hover { padding-left: 4px; }
.editorial .rank-row:hover .rank-fill { filter: brightness(1.05); }
.editorial .rank-row:last-of-type { border-bottom: none; }

.editorial .rank-n {
  font-family: var(--ed2-serif);
  font-size: 22px; font-weight: 500; font-style: italic;
  color: var(--ed2-ink-4);
  line-height: 1;
  font-variation-settings: 'opsz' 36;
  font-variant-numeric: tabular-nums;
  grid-row: span 2;
}
.editorial .rank-row.rank-top .rank-n { color: var(--ed2-grill); }

.editorial .rank-name {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-size: 14px; font-weight: 500;
  color: var(--ed2-ink); letter-spacing: -0.005em;
  align-self: end;
  word-break: break-word;
}

.editorial .rank-val {
  font-family: var(--ed2-serif);
  font-size: 15px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ed2-ink);
  text-align: right;
  line-height: 1.1;
  align-self: end;
}
.editorial .rank-val .pct {
  display: block;
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  margin-top: 3px;
  font-weight: 400;
  letter-spacing: 0.06em;
}

.editorial .rank-bar {
  grid-column: 2 / 4;
  height: 2px;
  background: var(--ed2-rule);
  position: relative;
  margin-top: 8px;
}
.editorial .rank-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ed2-ink-3);
  transform-origin: left;
  animation: rankBarIn 1.2s cubic-bezier(0.16,1,0.3,1) both;
}
.editorial .rank-row.rank-top .rank-fill {
  background: var(--ed2-grill);
  box-shadow: 0 0 12px rgba(199,62,15,0.18);
}
[data-theme=dark] .editorial .rank-row.rank-top .rank-fill {
  box-shadow: 0 0 14px rgba(245,137,79,0.30);
}
.editorial .rank-row:nth-child(1) .rank-fill { animation-delay: 0.05s; }
.editorial .rank-row:nth-child(2) .rank-fill { animation-delay: 0.12s; }
.editorial .rank-row:nth-child(3) .rank-fill { animation-delay: 0.19s; }
.editorial .rank-row:nth-child(4) .rank-fill { animation-delay: 0.26s; }
.editorial .rank-row:nth-child(5) .rank-fill { animation-delay: 0.33s; }
.editorial .rank-row:nth-child(6) .rank-fill { animation-delay: 0.4s; }
.editorial .rank-row:nth-child(7) .rank-fill { animation-delay: 0.47s; }
.editorial .rank-row:nth-child(8) .rank-fill { animation-delay: 0.54s; }
@keyframes rankBarIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.editorial .rank-foot {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  color: var(--ed2-ink-3);
  text-transform: uppercase;
  padding-top: 14px;
  margin-top: 8px;
  border-top: 1px dotted var(--ed2-rule-2);
  text-align: right;
}
.editorial .rank-foot b {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-weight: 500;
  color: var(--ed2-ink);
  font-size: 12px;
  text-transform: none;
  letter-spacing: -0.01em;
}

/* === Overlap fixes for overview === */
.editorial .lead { gap: 36px; }
.editorial .lead-spark { 
  height: 100px; 
  width: 100%;
  margin-top: auto;
  position: relative;
  z-index: 0;
}
.editorial .lead-r { 
  display: flex; 
  flex-direction: column; 
  align-self: stretch;
  justify-content: flex-end;
  min-width: 0;
}
.editorial .sect-head { 
  flex-wrap: wrap; 
  row-gap: 12px;
}
.editorial .sect-title { line-height: 1.1; }
.editorial .filt { 
  flex-wrap: wrap; 
  row-gap: 6px;
}
.editorial .lead-headline { 
  word-break: keep-all; 
  overflow-wrap: break-word;
}

/* ApexCharts trend tooltip / labels — keep within bounds */
.editorial .fig-host .apexcharts-canvas { overflow: visible; }
.editorial .fig-host .apexcharts-tooltip {
  font-family: var(--ed2-sans) !important;
  background: var(--ed2-paper) !important;
  border: 1px solid var(--ed2-ink-3) !important;
  border-radius: 0 !important;
  box-shadow: 2px 2px 0 var(--ed2-rule) !important;
  color: var(--ed2-ink) !important;
}
[data-theme=dark] .editorial .fig-host .apexcharts-tooltip {
  background: var(--ed2-paper-2) !important;
  border-color: var(--ed2-rule-2) !important;
  color: var(--ed2-ink) !important;
}
.editorial .fig-host .apexcharts-xaxistooltip,
.editorial .fig-host .apexcharts-yaxistooltip { display: none !important; }


/* === Editorial: hide ticker sparklines (visual noise) === */
.editorial .tk .kpi-spark { display: none !important; }
.editorial .tk-foot { 
  justify-content: flex-start;
  gap: 12px;
  padding-top: 10px;
  margin-top: 8px;
  border-top: 1px dotted var(--ed2-rule);
}

/* Compact delta pill in editorial */
.editorial .kpi-compare {
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.editorial .kpi-compare .delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 4px;
  font-family: var(--ed2-mono);
  font-weight: 500;
  font-size: 11px;
  border: 1px solid currentColor;
  background: transparent;
}
.editorial .kpi-compare .delta.down { color: var(--ed2-leaf, #5C7A3E); }
.editorial .kpi-compare .delta.up { color: var(--ed2-grill); }
.editorial .kpi-compare .delta.neutral { color: var(--ed2-ink-3); }

/* Lead delta — slightly bigger */
.editorial .lead .kpi-compare {
  font-size: 12px;
  margin-top: 4px;
}
.editorial .lead .kpi-compare .delta {
  font-size: 12px;
  padding: 5px 11px;
}

/* Make sure lead-spark sits as a backdrop, not in the text flow */
.editorial .lead { position: relative; }
.editorial .lead-r { 
  position: relative; 
  align-self: stretch;
  display: flex; 
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 4px;
}
.editorial .lead-spark { 
  position: relative;
  z-index: 0;
  height: 110px;
  pointer-events: none;
}


/* === User button — minimal circular, no harsh border === */
#appScreen .icon-btn.user-btn {
  width: 32px; height: 32px;
  border-radius: 50% !important;
  border: 1px solid var(--ed2-rule-2) !important;
  background: transparent !important;
  color: var(--ed2-ink-2) !important;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
  box-shadow: none !important;
}
#appScreen .icon-btn.user-btn svg.ico {
  width: 16px; height: 16px;
  color: inherit;
}
#appScreen .icon-btn.user-btn:hover {
  border-color: var(--ed2-grill) !important;
  color: var(--ed2-grill) !important;
  background: transparent !important;
  transform: scale(1.05);
}

/* sr-only — visually hidden but still readable by screen readers */
.sr-only {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}

/* Minimize hamburger + close + theme-toggle a touch */
#appScreen .icon-btn.hamburger-btn,
#appScreen .icon-btn#drawerCloseBtn {
  width: 32px; height: 32px;
  border-radius: 6px !important;
}

/* Topbar right cluster spacing */
#appScreen .topbar-right { gap: 10px !important; }


/* === Editorial delta — no border, pure typographic === */
.editorial .kpi-compare .delta,
.editorial .lead .kpi-compare .delta {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.editorial .kpi-compare .delta.down { color: var(--ed2-leaf, #5C7A3E); }
.editorial .kpi-compare .delta.up { color: var(--ed2-grill); }
.editorial .kpi-compare .delta.neutral { color: var(--ed2-ink-3); }

[data-theme="dark"] .editorial .kpi-compare .delta.down { color: #A8C97A; }
[data-theme="dark"] .editorial .kpi-compare .delta.up { color: var(--ed2-ember); }


/* ═══════════════════════════════════════════════════
   System status — editorial dossier (clean, no nested cards)
═══════════════════════════════════════════════════ */

.editorial .dossier {
  background: transparent !important;
  border-left: 2px solid var(--ed2-grill) !important;
  padding: 8px 0 8px 20px !important;
  margin-top: 12px;
  display: flex; flex-direction: column;
  font-family: var(--ed2-mono);
  color: var(--ed2-ink-2);
}

/* Each status item — dotted leader row */
.editorial .dossier .status-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 12px 0;
  border: none !important;
  background: transparent !important;
  border-radius: 0 !important;
  border-bottom: 1px solid var(--ed2-rule) !important;
}
.editorial .dossier .status-item:last-child { border-bottom: none !important; }

.editorial .dossier .status-item .label {
  font-family: var(--ed2-mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.10em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
  font-weight: 400 !important;
  margin: 0 !important;
}
.editorial .dossier .status-item .label::after {
  content: ' ';
}
/* Dotted leader between label and value */
.editorial .dossier .status-item::before {
  content: '';
  border-bottom: 1px dotted var(--ed2-rule-2);
  align-self: end;
  margin-bottom: 4px;
  height: 1px;
  grid-column: 2;
}
.editorial .dossier .status-item .value {
  font-family: var(--ed2-serif) !important;
  font-size: 18px !important;
  font-weight: 500 !important;
  letter-spacing: -0.02em !important;
  font-variation-settings: 'opsz' 36 !important;
  font-variant-numeric: tabular-nums lining-nums !important;
  color: var(--ed2-ink) !important;
  text-align: right !important;
  line-height: 1.1 !important;
  margin: 0 !important;
  white-space: nowrap;
}
.editorial .dossier .status-item .sub {
  display: block !important;
  grid-column: 1 / -1 !important;
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  color: var(--ed2-ink-4) !important;
  letter-spacing: 0.04em !important;
  margin-top: 4px !important;
  text-align: right !important;
}

/* Last-sync value is timestamp — keep slim */
.editorial .dossier .status-item .value[style*=font-size:12px] {
  font-size: 14px !important;
  font-family: var(--ed2-mono) !important;
  font-variation-settings: normal !important;
  letter-spacing: 0.02em !important;
}


/* ═══════════════════════════════════════════════════
   COST PAGE — editorial sub layout
═══════════════════════════════════════════════════ */

/* Sub-page masthead (smaller than overview masthead, no mascot) */
.editorial.editorial-sub .page-masthead {
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ed2-ink);
}
.editorial.editorial-sub .page-title {
  font-family: var(--ed2-serif);
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variation-settings: 'opsz' 96;
  color: var(--ed2-ink);
  margin: 4px 0 10px;
}
.editorial.editorial-sub .page-title em {
  font-style: italic;
  color: var(--ed2-grill);
  font-variation-settings: 'opsz' 96,'wght' 500;
}
.editorial.editorial-sub .page-lede {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ed2-ink-3);
  line-height: 1.5;
  max-width: 640px;
  font-variation-settings: 'opsz' 18;
}

/* Filter row */
.editorial .filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 20px 0;
  border-bottom: 1px solid var(--ed2-rule);
  flex-wrap: wrap;
  row-gap: 12px;
}
.editorial .filter-row .filt-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-3);
}

/* Date input minimal */
.editorial .date-input {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--ed2-rule-2) !important;
  border-radius: 0 !important;
  font-family: var(--ed2-mono) !important;
  font-size: 11px !important;
  color: var(--ed2-ink-2) !important;
  padding: 4px 4px !important;
  letter-spacing: 0.04em;
  outline: none !important;
}
.editorial .date-input:focus { border-bottom-color: var(--ed2-grill) !important; }
.editorial .date-sep { color: var(--ed2-ink-4); font-family: var(--ed2-mono); font-size: 11px; }

/* Buttons: minimal */
.editorial .btn-min {
  background: var(--ed2-ink) !important;
  color: var(--ed2-paper) !important;
  border: 1px solid var(--ed2-ink) !important;
  border-radius: 0 !important;
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  font-weight: 500 !important;
  padding: 7px 14px !important;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
  text-decoration: none !important;
}
.editorial .btn-min:hover {
  background: var(--ed2-grill) !important;
  border-color: var(--ed2-grill) !important;
}
.editorial .btn-min-out {
  background: transparent !important;
  color: var(--ed2-ink-2) !important;
  border-color: var(--ed2-rule-2) !important;
}
.editorial .btn-min-out:hover {
  color: var(--ed2-grill) !important;
  border-color: var(--ed2-grill) !important;
  background: transparent !important;
}

/* Cost summary lead — extremes column on right */
.editorial .cost-summary {
  padding: 32px 0 28px;
  border-bottom: 1px solid var(--ed2-rule-2);
}
.editorial .cost-extremes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--ed2-mono);
  font-size: 11px;
  border-top: 1px solid var(--ed2-rule);
  padding-top: 14px;
}
.editorial .cost-extremes .extreme {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--ed2-rule);
}
.editorial .cost-extremes .extreme:last-child { border-bottom: none; }
.editorial .cost-extremes .extreme-lbl {
  color: var(--ed2-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-size: 10px;
}
.editorial .cost-extremes .extreme-val {
  font-family: var(--ed2-serif);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ed2-ink);
  letter-spacing: -0.01em;
}
.editorial .cost-meta-mono {
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.04em;
}

/* Restyle filter-btn (chip) inside cost — already inherits .editorial .filt .chip */
.editorial .filt .filter-btn { /* inherits chip */ }

/* Hide old btn-secondary / search-input chrome that we replaced */
.editorial.editorial-sub .chart-card,
.editorial.editorial-sub .status-card,
.editorial.editorial-sub .kpi-card { 
  background: transparent !important; 
  border: none !important; 
  padding: 0 !important;
}
.editorial.editorial-sub .chart-header { display: none; }
.editorial.editorial-sub .chart-body { padding: 0 !important; min-height: auto; }

/* Cost daily chart sect-head font */
.editorial.editorial-sub .sect-head .kicker { margin-bottom: 4px; }


/* ═══════════════════════════════════════════════════
   ITEMS PAGE — editorial table layout
═══════════════════════════════════════════════════ */

.editorial .search-wrap {
  position: relative; flex: 1; max-width: 320px;
  display: flex; align-items: center;
}
.editorial .search-wrap .search-ico {
  position: absolute; left: 4px;
  width: 14px; height: 14px;
  color: var(--ed2-ink-3); pointer-events: none;
}
.editorial .search-input {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--ed2-rule-2) !important;
  border-radius: 0 !important;
  padding: 8px 0 8px 26px !important;
  font-family: var(--ed2-sans) !important;
  font-size: 14px !important;
  color: var(--ed2-ink) !important;
  width: 100%; outline: none !important;
}
.editorial .search-input::placeholder {
  color: var(--ed2-ink-3);
  font-style: italic;
  font-family: var(--ed2-serif);
}
.editorial .search-input:focus { border-bottom-color: var(--ed2-grill) !important; }

.editorial .plain-select {
  -webkit-appearance: none !important;
  appearance: none !important;
  background-color: transparent !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236E6862' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 6 8 10 12 6'/></svg>") !important;
  background-position: 100% 50% !important;
  background-repeat: no-repeat !important;
  background-size: 12px 12px !important;
  border: none !important; border-radius: 0 !important;
  color: var(--ed2-ink-2) !important;
  font-family: var(--ed2-mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.04em !important;
  padding: 4px 22px 4px 0 !important;
  cursor: pointer; outline: none !important;
}
[data-theme="dark"] .editorial .plain-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238B8275' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 6 8 10 12 6'/></svg>") !important;
}

.editorial .items-table-head {
  display: grid;
  grid-template-columns: 36px 1fr 80px 110px 130px 24px;
  gap: 16px;
  padding: 14px 8px 10px;
  margin-top: 18px;
  border-bottom: 1px solid var(--ed2-ink);
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  font-weight: 500;
}
.editorial .items-table-head .col-price,
.editorial .items-table-head .col-total { text-align: right; }

.editorial #itemsGrid { display: block; padding: 0 !important; background: none !important; }
.editorial .item-list { display: flex; flex-direction: column; }

.editorial .item-row {
  display: grid !important;
  grid-template-columns: 36px 1fr 80px 110px 130px 24px;
  gap: 16px !important;
  align-items: baseline;
  padding: 16px 8px !important;
  border-bottom: 1px solid var(--ed2-rule) !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: padding-left 0.3s cubic-bezier(0.16,1,0.3,1), background 0.25s;
}
.editorial .item-row:hover {
  padding-left: 14px !important;
  background: rgba(199,62,15,0.03) !important;
}
[data-theme="dark"] .editorial .item-row:hover {
  background: rgba(245,137,79,0.05) !important;
}
.editorial .item-row:hover .item-row-arrow {
  color: var(--ed2-grill); transform: translateX(2px);
}

.editorial .item-row-num {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--ed2-ink-4);
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'opsz' 36;
  line-height: 1;
}
.editorial .item-row-info { min-width: 0; }
.editorial .item-row-name {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-size: 14px; font-weight: 500;
  color: var(--ed2-ink); letter-spacing: -0.005em;
  word-break: break-word;
}
.editorial .item-row-sub {
  font-family: var(--ed2-mono);
  font-size: 10px; color: var(--ed2-ink-3);
  margin-top: 3px; letter-spacing: 0.02em;
}
.editorial .item-row-unit {
  font-family: var(--ed2-mono); font-size: 11px;
  color: var(--ed2-ink-2); letter-spacing: 0.04em;
}
.editorial .item-row-stat {
  text-align: right;
  font-family: var(--ed2-serif);
  font-size: 15px; font-weight: 500;
  color: var(--ed2-ink);
  font-variant-numeric: tabular-nums;
}
.editorial .item-row-stat .item-row-stat-lbl { display: none; }
.editorial .item-row-arrow {
  color: var(--ed2-ink-4);
  font-family: var(--ed2-serif);
  font-size: 20px; text-align: right;
  transition: color 0.25s, transform 0.3s cubic-bezier(0.16,1,0.3,1);
  line-height: 1;
}

.editorial .empty, .editorial .loading {
  padding: 32px; text-align: center;
  font-family: var(--ed2-serif);
  font-style: italic; color: var(--ed2-ink-3);
}

/* Detail overlay */
.editorial .detail-overlay {
  background: rgba(58, 30, 14, 0.45) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
[data-theme="dark"] .editorial .detail-overlay {
  background: rgba(0, 0, 0, 0.6) !important;
}
.editorial .detail-panel {
  background: var(--ed2-paper) !important;
  border: 1px solid var(--ed2-ink) !important;
  border-radius: 0 !important;
  padding: 40px 44px !important;
  box-shadow: 8px 8px 0 var(--ed2-rule-2) !important;
  max-width: 880px !important;
  position: relative;
}
.editorial .detail-panel::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(58,30,14,0.025) 0.5px,transparent 0.5px);
  background-size: 3px 3px; opacity: 0.6;
}
.editorial .detail-panel > * { position: relative; z-index: 1; }
.editorial .detail-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 24px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ed2-ink);
}
.editorial .detail-header > div:first-child { flex: 1; min-width: 0; }
.editorial .detail-title {
  font-family: var(--ed2-serif);
  font-size: 32px; font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ed2-ink);
  font-variation-settings: 'opsz' 72;
  line-height: 1; margin: 6px 0;
}
.editorial .detail-subtitle {
  font-family: var(--ed2-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
}
.editorial .detail-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 28px;
  padding: 24px 0;
  border-bottom: 1px solid var(--ed2-rule);
}
.editorial .detail-stats .kpi-card {
  background: transparent !important;
  border: none !important;
  padding: 0 0 8px !important;
  display: flex; justify-content: space-between;
  align-items: baseline; gap: 10px;
  border-bottom: 1px dotted var(--ed2-rule-2) !important;
  border-radius: 0 !important;
}
.editorial .detail-stats .kpi-label {
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
  margin: 0 !important;
}
.editorial .detail-stats .kpi-value {
  font-family: var(--ed2-serif) !important;
  font-size: 18px !important;
  font-weight: 500 !important;
  letter-spacing: -0.02em !important;
  color: var(--ed2-ink) !important;
  font-variant-numeric: tabular-nums !important;
  text-align: right;
}
.editorial .detail-chart-sect { padding-top: 28px !important; }
.editorial .items-filter { align-items: center; padding: 18px 0; }

@media (max-width: 760px) {
  .editorial .items-table-head .col-unit,
  .editorial .items-table-head .col-price,
  .editorial .item-row-unit,
  .editorial .item-row .item-row-stat:first-of-type { display: none; }
  .editorial .items-table-head { grid-template-columns: 30px 1fr 110px 20px; gap: 12px; }
  .editorial .item-row { grid-template-columns: 30px 1fr 110px 20px !important; gap: 12px !important; }
  .editorial .detail-panel { padding: 28px 22px !important; }
  .editorial .detail-title { font-size: 24px; }
  .editorial .detail-stats { grid-template-columns: 1fr; }
}

/* === Detail panel — restore scroll + scale-in animation === */
.editorial .detail-panel {
  max-height: 88vh !important;
  overflow-y: auto !important;
  width: 100% !important;
  animation: editorialPanelIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
}
@keyframes editorialPanelIn {
  from { opacity: 0; transform: scale(0.96) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Custom scrollbar inside editorial modal */
.editorial .detail-panel::-webkit-scrollbar { width: 6px; }
.editorial .detail-panel::-webkit-scrollbar-track { background: transparent; }
.editorial .detail-panel::-webkit-scrollbar-thumb {
  background: var(--ed2-rule-2); border-radius: 0;
}
.editorial .detail-panel::-webkit-scrollbar-thumb:hover { background: var(--ed2-grill); }

/* On mobile: slide up from bottom like iOS sheet */
@media (max-width: 768px) {
  .editorial .detail-overlay { align-items: flex-end !important; }
  .editorial .detail-panel {
    max-height: 92vh !important;
    border-radius: 12px 12px 0 0 !important;
    animation: editorialPanelSlide 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
  }
  @keyframes editorialPanelSlide {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* === FIX: detail-overlay must stay fixed despite .editorial > * relative === */
.editorial .detail-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.editorial .detail-overlay.hidden { display: none !important; }

@media (max-width: 768px) {
  .editorial .detail-overlay { align-items: flex-end !important; }
}

/* === Unit cell — strip pill, plain mono uppercase === */
.editorial .item-row-unit {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.16em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
  text-align: left;
  white-space: nowrap;
}

/* Detail panel — also strip unit pills if any */
.editorial .detail-subtitle .badge,
.editorial .item-badge,
.editorial .unit-badge {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  font-family: var(--ed2-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* === Remove outer page-section frame (no card-look) === */
.editorial {
  background: transparent !important;
  border-radius: 0 !important;
  padding: 28px 36px 60px !important;
  box-shadow: none !important;
}
.editorial::before { display: none !important; }

/* Body provides the paper texture instead — push it slightly */
body { background: var(--ed2-paper) !important; }
#appScreen { background: transparent !important; }

@media (max-width: 720px) {
  .editorial { padding: 20px 18px 48px !important; }
}

/* === FORCE: month-picker + all selects inside .editorial — highest specificity, kills any leftover === */
.editorial select.select-input,
.editorial select.month-picker,
.editorial select.plain-select,
.editorial #itemsMonthPicker,
.editorial #costMonthPicker,
.editorial #fcMonthPicker,
.editorial #overviewMonthPicker,
.editorial #itemCategoryFilter,
.editorial #itemSort {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-color: transparent !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 1px dotted transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  color: var(--ed2-ink-2) !important;
  font-family: var(--ed2-mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.04em !important;
  padding: 4px 22px 4px 0 !important;
  cursor: pointer;
  outline: none !important;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236E6862' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 6 8 10 12 6'/></svg>") !important;
  background-position: 100% 50% !important;
  background-repeat: no-repeat !important;
  background-size: 12px 12px !important;
  min-width: 0 !important;
}

/* Month picker specifically — calendar icon on left */
.editorial select.month-picker,
.editorial #itemsMonthPicker,
.editorial #costMonthPicker,
.editorial #fcMonthPicker,
.editorial #overviewMonthPicker {
  padding-left: 22px !important;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236E6862' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='3.5' width='12' height='10'/><line x1='2' y1='6.5' x2='14' y2='6.5'/><line x1='5' y1='2' x2='5' y2='4.5'/><line x1='11' y1='2' x2='11' y2='4.5'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236E6862' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 6 8 10 12 6'/></svg>") !important;
  background-position: 0 50%, 100% 50% !important;
  background-size: 14px 14px, 12px 12px !important;
}

[data-theme="dark"] .editorial select.select-input,
[data-theme="dark"] .editorial select.plain-select,
[data-theme="dark"] .editorial select.month-picker {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238B8275' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 6 8 10 12 6'/></svg>") !important;
}
[data-theme="dark"] .editorial select.month-picker,
[data-theme="dark"] .editorial #itemsMonthPicker,
[data-theme="dark"] .editorial #costMonthPicker,
[data-theme="dark"] .editorial #overviewMonthPicker {
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238B8275' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='3.5' width='12' height='10'/><line x1='2' y1='6.5' x2='14' y2='6.5'/><line x1='5' y1='2' x2='5' y2='4.5'/><line x1='11' y1='2' x2='11' y2='4.5'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238B8275' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 6 8 10 12 6'/></svg>") !important;
}

.editorial select:focus { border-bottom-color: var(--ed2-grill) !important; }
.editorial select option {
  background: var(--ed2-paper) !important;
  color: var(--ed2-ink) !important;
}

/* === Strip the big rounded frame around items list === */
.editorial .item-list,
.editorial #itemsGrid .item-list,
.editorial.editorial-sub .item-list {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
}
.editorial #itemsGrid {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* ═══════════════════════════════════════════════════
   PATTERNS PAGE — editorial DOW heatmap + top days
═══════════════════════════════════════════════════ */

/* DOW heatmap as editorial table rows */
.editorial #patSalesHeatmap { padding: 16px 0 0; }
.editorial .dow-heatmap {
  display: flex; flex-direction: column;
}
.editorial .dow-row {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 18px;
  align-items: baseline;
  padding: 14px 4px 10px;
  border-bottom: 1px solid var(--ed2-rule);
  transition: padding-left 0.3s cubic-bezier(0.16,1,0.3,1);
}
.editorial .dow-row:hover { padding-left: 8px; }
.editorial .dow-row:hover .dow-bar { filter: brightness(1.1); }
.editorial .dow-row:last-child { border-bottom: none; }

.editorial .dow-label {
  font-family: var(--ed2-serif);
  font-size: 18px;
  font-style: italic;
  color: var(--ed2-ink);
  font-variation-settings: 'opsz' 36;
  letter-spacing: -0.01em;
}
.editorial .dow-bar-wrap {
  position: relative;
  height: 2px;
  background: var(--ed2-rule);
  align-self: center;
  margin-top: 8px;
  grid-row: 2;
  grid-column: 1 / 3;
}
.editorial .dow-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ed2-ink-3);
  transform-origin: left;
  animation: dowBarIn 1.2s cubic-bezier(0.16,1,0.3,1) both;
}
.editorial .dow-row:first-child .dow-bar { background: var(--ed2-grill); }
@keyframes dowBarIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.editorial .dow-value {
  font-family: var(--ed2-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ed2-ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  letter-spacing: -0.01em;
}
.editorial .dow-sub {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.06em;
  text-align: right;
  white-space: nowrap;
}

/* Best/Worst days — editorial ranking style */
.editorial #patBestDays,
.editorial #patWorstDays {
  display: flex; flex-direction: column;
  margin-top: 12px;
}
.editorial .top-day-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 14px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--ed2-rule);
  background: transparent !important;
  border-radius: 0 !important;
  transition: padding-left 0.3s cubic-bezier(0.16,1,0.3,1);
}
.editorial .top-day-row:hover { padding-left: 6px; }
.editorial .top-day-row:last-child { border-bottom: none; }
.editorial .top-day-rank {
  font-family: var(--ed2-serif);
  font-size: 22px;
  font-style: italic;
  font-weight: 500;
  color: var(--ed2-ink-4);
  font-variation-settings: 'opsz' 36;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}
.editorial #patBestDays .top-day-row:first-child .top-day-rank { color: var(--ed2-grill); }
.editorial #patWorstDays .top-day-row:first-child .top-day-rank { color: var(--ed2-leaf, #5C7A3E); }
.editorial .top-day-date {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-size: 14px;
  font-weight: 500;
  color: var(--ed2-ink);
  letter-spacing: -0.005em;
}
.editorial .top-day-date .muted {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  margin-left: 6px;
}
.editorial .top-day-guests {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  margin-top: 3px;
  letter-spacing: 0.04em;
}
.editorial .top-day-sales {
  font-family: var(--ed2-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ed2-ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  letter-spacing: -0.01em;
}

/* === DOW stats summary — editorial 3-column ticker === */
.editorial .dow-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--ed2-rule-2);
  border-bottom: 1px solid var(--ed2-rule-2);
  margin-bottom: 20px;
}
.editorial .dow-stat {
  padding: 18px 22px;
  border-right: 1px solid var(--ed2-rule);
  transition: background 0.3s;
}
.editorial .dow-stat:last-child { border-right: none; }
.editorial .dow-stat:hover { background: rgba(199,62,15,0.03); }
[data-theme="dark"] .editorial .dow-stat:hover { background: rgba(245,137,79,0.04); }
.editorial .dow-stat-lbl {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  margin-bottom: 8px;
}
.editorial .dow-stat-val {
  font-family: var(--ed2-serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 48;
  color: var(--ed2-ink);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.editorial .dow-stat:first-child .dow-stat-val { color: var(--ed2-grill); font-style: italic; }
.editorial .dow-stat:nth-child(2) .dow-stat-val { color: var(--ed2-leaf, #5C7A3E); font-style: italic; }
.editorial .dow-stat-sub {
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-3);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

@media (max-width: 720px) {
  .editorial .dow-stats { grid-template-columns: 1fr; }
  .editorial .dow-stat { border-right: none; border-bottom: 1px solid var(--ed2-rule); }
  .editorial .dow-stat:last-child { border-bottom: none; }
}

/* === Semantic color fix: best = green (good), worst = red (bad) === */
.editorial .dow-stat:first-child .dow-stat-val {
  color: var(--ed2-leaf, #5C7A3E) !important;
  font-style: italic;
}
.editorial .dow-stat:nth-child(2) .dow-stat-val {
  color: var(--ed2-grill) !important;
  font-style: italic;
}
[data-theme="dark"] .editorial .dow-stat:first-child .dow-stat-val {
  color: #A8C97A !important;
}
[data-theme="dark"] .editorial .dow-stat:nth-child(2) .dow-stat-val {
  color: var(--ed2-ember) !important;
}

/* Bar color of #1 day (best) in DOW heatmap — green */
.editorial .dow-row:first-child .dow-bar {
  background: var(--ed2-leaf, #5C7A3E) !important;
}
[data-theme="dark"] .editorial .dow-row:first-child .dow-bar {
  background: #A8C97A !important;
}

/* Best/Worst days ranking — same convention */
.editorial #patBestDays .top-day-row:first-child .top-day-rank {
  color: var(--ed2-leaf, #5C7A3E) !important;
}
.editorial #patWorstDays .top-day-row:first-child .top-day-rank {
  color: var(--ed2-grill) !important;
}
[data-theme="dark"] .editorial #patBestDays .top-day-row:first-child .top-day-rank {
  color: #A8C97A !important;
}
[data-theme="dark"] .editorial #patWorstDays .top-day-row:first-child .top-day-rank {
  color: var(--ed2-ember) !important;
}

/* ═══════════════════════════════════════════════════
   PATTERNS v2 — Margin DOW + DOW×Month + Anomalies
═══════════════════════════════════════════════════ */

/* DOW table head — column labels */
.editorial .dow-table-head {
  display: grid;
  grid-template-columns: 60px 1.1fr 1fr 0.9fr 1fr 0.9fr;
  gap: 14px;
  padding: 14px 4px 10px;
  margin-top: 12px;
  border-bottom: 1px solid var(--ed2-ink);
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  font-weight: 500;
}
.editorial .dow-table-head .col-sales,
.editorial .dow-table-head .col-cost,
.editorial .dow-table-head .col-margin,
.editorial .dow-table-head .col-bill,
.editorial .dow-table-head .col-guests { text-align: right; }

/* New row layout with cells */
.editorial .dow-row-v2 {
  display: grid;
  grid-template-columns: 60px 1.1fr 1fr 0.9fr 1fr 0.9fr;
  gap: 14px;
  padding: 14px 4px 10px;
  border-bottom: 1px solid var(--ed2-rule);
}
.editorial .dow-row-v2:last-child { border-bottom: none; }
.editorial .dow-cell {
  font-family: var(--ed2-serif);
  font-size: 15px;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ed2-ink);
  letter-spacing: -0.01em;
}
.editorial .dow-cell .cn-suffix {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.06em;
  font-weight: 400;
}
.editorial .dow-margin.margin-good { color: var(--ed2-leaf, #5C7A3E); font-style: italic; }
.editorial .dow-margin.margin-ok { color: var(--ed2-ink); }
.editorial .dow-margin.margin-low { color: var(--ed2-grill); font-style: italic; }
[data-theme="dark"] .editorial .dow-margin.margin-good { color: #A8C97A; }
[data-theme="dark"] .editorial .dow-margin.margin-low { color: var(--ed2-ember); }

.editorial .dow-bar-wrap-v2 {
  grid-column: 1 / -1;
  height: 2px;
  background: var(--ed2-rule);
  position: relative;
  margin-top: 6px;
}
.editorial .dow-row-v2 .dow-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ed2-ink-3);
  transform-origin: left;
  animation: dowBarIn 1.2s cubic-bezier(0.16,1,0.3,1) both;
}
.editorial .dow-row-v2:first-of-type .dow-bar { background: var(--ed2-leaf, #5C7A3E); }
[data-theme="dark"] .editorial .dow-row-v2:first-of-type .dow-bar { background: #A8C97A; }

/* DOW × Month heatmap */
.editorial .dmh-wrap {
  margin-top: 14px;
  padding: 8px 0;
}
.editorial .dmh-head,
.editorial .dmh-row {
  display: grid;
  grid-template-columns: 36px repeat(var(--dmh-cols, 6), 1fr);
  gap: 4px;
}
.editorial .dmh-head {
  margin-bottom: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ed2-ink);
}
.editorial .dmh-col-h {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  text-align: center;
}
.editorial .dmh-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.editorial .dmh-row {
  align-items: center;
}
.editorial .dmh-cell-lbl {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ed2-ink-3);
  text-align: right;
  padding-right: 6px;
}
.editorial .dmh-cell {
  aspect-ratio: 1 / 1;
  background: var(--ed2-grill);
  opacity: var(--int, 0.1);
  border-radius: 2px;
  cursor: default;
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1), opacity 0.2s;
  min-height: 18px;
}
.editorial .dmh-cell:hover {
  transform: scale(1.15);
  opacity: 1 !important;
}
.editorial .dmh-cell.dmh-empty {
  background: var(--ed2-rule);
  opacity: 0.4;
}
[data-theme="dark"] .editorial .dmh-cell { background: var(--ed2-ember); }
[data-theme="dark"] .editorial .dmh-cell.dmh-empty { background: var(--ed2-rule-2); opacity: 0.5; }

.editorial .dmh-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
}
.editorial .dmh-legend-bar {
  width: 90px;
  height: 8px;
  background: linear-gradient(to right, color-mix(in srgb, var(--ed2-grill) 12%, transparent), var(--ed2-grill));
  border-radius: 2px;
}
[data-theme="dark"] .editorial .dmh-legend-bar {
  background: linear-gradient(to right, color-mix(in srgb, var(--ed2-ember) 12%, transparent), var(--ed2-ember));
}
.editorial .dmh-empty-note {
  font-family: var(--ed2-serif);
  font-style: italic;
  color: var(--ed2-ink-3);
  padding: 18px;
  text-align: center;
}

/* Anomalies — editorial callouts */
.editorial .anom-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
}
.editorial .anom-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: baseline;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--ed2-rule);
}
.editorial .anom-row:last-child { border-bottom: none; }
.editorial .anom-date {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-size: 14px;
  font-weight: 500;
  color: var(--ed2-ink);
}
.editorial .anom-dow {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  margin-left: 6px;
}
.editorial .anom-sales {
  font-family: var(--ed2-serif);
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ed2-ink);
  text-align: right;
  letter-spacing: -0.01em;
}
.editorial .anom-delta {
  font-family: var(--ed2-mono);
  font-size: 12px;
  font-weight: 500;
  text-align: right;
  letter-spacing: 0.04em;
}
.editorial .anom-row.anom-up .anom-delta { color: var(--ed2-leaf, #5C7A3E); }
.editorial .anom-row.anom-down .anom-delta { color: var(--ed2-grill); }
[data-theme="dark"] .editorial .anom-row.anom-up .anom-delta { color: #A8C97A; }
[data-theme="dark"] .editorial .anom-row.anom-down .anom-delta { color: var(--ed2-ember); }
.editorial .anom-z {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-4);
  margin-left: 4px;
}
.editorial .anom-vs {
  grid-column: 1 / -1;
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.editorial .sect-sub {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ed2-ink-3);
  margin-top: 4px;
  font-variation-settings: 'opsz' 14;
}

@media (max-width: 760px) {
  .editorial .dow-table-head,
  .editorial .dow-row-v2 {
    grid-template-columns: 50px 1fr 1fr;
    font-size: 13px;
  }
  .editorial .col-cost, .editorial .col-bill, .editorial .col-guests,
  .editorial .dow-cost, .editorial .dow-bill, .editorial .dow-guests { display: none; }
  .editorial .dmh-head, .editorial .dmh-row {
    grid-template-columns: 28px repeat(auto-fit, minmax(20px, 1fr));
  }
}

/* === Shrink DOW×Month heatmap cells === */
.editorial .dmh-wrap {
  margin-top: 14px;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.editorial .dmh-head,
.editorial .dmh-row {
  display: grid;
  grid-template-columns: 28px repeat(var(--dmh-cols, 18), 22px);
  gap: 3px;
  width: auto;
}
.editorial .dmh-head { margin-bottom: 4px; padding-bottom: 6px; }
.editorial .dmh-cell-lbl {
  font-size: 11px;
  font-style: italic;
  padding-right: 4px;
}
.editorial .dmh-col-h {
  font-size: 9px;
  letter-spacing: 0.08em;
}
.editorial .dmh-cell {
  width: 22px;
  height: 22px;
  min-height: 22px;
  aspect-ratio: auto;
  border-radius: 2px;
}
.editorial .dmh-body { gap: 3px; }
.editorial .dmh-legend {
  margin-top: 14px;
  font-size: 9px;
}
.editorial .dmh-legend-bar { width: 70px; height: 6px; }

/* === Stretch DOW×Month heatmap to full width, bigger cells === */
.editorial .dmh-wrap {
  margin-top: 14px;
  padding: 8px 0;
  display: block;
}
.editorial .dmh-head,
.editorial .dmh-row {
  display: grid;
  grid-template-columns: 50px repeat(var(--dmh-cols, 6), minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.editorial .dmh-head {
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ed2-ink);
}
.editorial .dmh-cell-lbl {
  font-family: var(--ed2-serif);
  font-size: 16px;
  font-style: italic;
  color: var(--ed2-ink-3);
  text-align: right;
  padding-right: 8px;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 24;
}
.editorial .dmh-col-h {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  text-align: center;
  padding: 4px 0;
}
.editorial .dmh-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.editorial .dmh-cell {
  aspect-ratio: 1.4 / 1;
  width: 100%;
  height: auto;
  min-height: 38px;
  background: var(--ed2-grill);
  opacity: var(--int, 0.1);
  border-radius: 3px;
  cursor: default;
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1), opacity 0.2s;
  position: relative;
}
.editorial .dmh-cell:hover {
  transform: scale(1.04);
  opacity: 1 !important;
}
[data-theme="dark"] .editorial .dmh-cell { background: var(--ed2-ember); }
.editorial .dmh-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
}
.editorial .dmh-legend-bar { width: 120px; height: 8px; }

/* DOW row label first column larger */
.editorial .dmh-row:hover .dmh-cell-lbl { color: var(--ed2-ink); }

@media (max-width: 760px) {
  .editorial .dmh-head,
  .editorial .dmh-row {
    grid-template-columns: 36px repeat(var(--dmh-cols, 6), minmax(0, 1fr));
    gap: 4px;
  }
  .editorial .dmh-cell { min-height: 28px; aspect-ratio: 1 / 1; }
  .editorial .dmh-cell-lbl { font-size: 13px; padding-right: 4px; }
}

/* === DOW×Month — smaller cells (final size) === */
.editorial .dmh-head,
.editorial .dmh-row {
  grid-template-columns: 40px repeat(var(--dmh-cols, 6), minmax(0, 1fr));
  gap: 6px !important;
}
.editorial .dmh-cell-lbl {
  font-size: 13px !important;
  padding-right: 6px !important;
}
.editorial .dmh-col-h {
  font-size: 9px !important;
  letter-spacing: 0.12em !important;
}
.editorial .dmh-cell {
  aspect-ratio: auto !important;
  height: 24px !important;
  min-height: 24px !important;
  border-radius: 2px !important;
}
.editorial .dmh-body { gap: 6px !important; }
.editorial .dmh-legend { font-size: 9px !important; }
.editorial .dmh-legend-bar { width: 90px !important; height: 6px !important; }

@media (max-width: 760px) {
  .editorial .dmh-cell { height: 20px !important; min-height: 20px !important; }
  .editorial .dmh-cell-lbl { font-size: 11px !important; }
}

/* ═══════════════════════════════════════════════════
   SUPPLIERS PAGE — editorial ranking + items table
═══════════════════════════════════════════════════ */

/* Supplier cards container — strip glass */
.editorial #supplierCards {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 12px 0 0 !important;
  display: block !important;
}
.editorial .supplier-grid { display: block !important; }

/* Supplier rank row — clickable, similar to cost ranking */
.editorial .supplier-rank-row {
  cursor: pointer;
}
.editorial .supplier-rank-row:hover { padding-left: 4px; }
.editorial .supplier-rank-row:hover .rank-fill { filter: brightness(1.1); }
.editorial .rank-name-sub {
  display: block;
  font-family: var(--ed2-mono);
  font-weight: 400;
  font-size: 10px;
  color: var(--ed2-ink-3);
  margin-top: 3px;
  letter-spacing: 0.04em;
}

/* Items table inside supplier drill-down */
.editorial .supp-items-head {
  display: grid;
  grid-template-columns: 30px 1fr 70px 100px 100px 140px;
  gap: 14px;
}
.editorial .supp-items-list { display: block; }
.editorial .supp-item-row {
  display: grid !important;
  grid-template-columns: 30px 1fr 70px 100px 100px 140px !important;
  gap: 14px !important;
  align-items: baseline;
  padding: 14px 4px 10px !important;
  border-bottom: 1px solid var(--ed2-rule) !important;
  cursor: default;
}
.editorial .supp-item-row:hover {
  padding-left: 4px !important;
  background: transparent !important;
}
.editorial .supp-item-row .row-pct {
  display: block;
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  margin-top: 3px;
  letter-spacing: 0.04em;
}
.editorial .supp-bar {
  grid-column: 1 / -1;
  height: 2px;
  background: var(--ed2-rule);
  margin-top: 6px;
  position: relative;
}
.editorial .supp-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ed2-ink-3);
  animation: rankBarIn 1s cubic-bezier(0.16,1,0.3,1) both;
  transform-origin: left;
}

/* Supplier items card section header */
.editorial #supplierItemsCard .sect-head {
  align-items: center;
}
.editorial #supplierItemsTitle em {
  font-style: italic;
  color: var(--ed2-grill);
  font-weight: 500;
}

@media (max-width: 760px) {
  .editorial .supp-items-head .col-unit,
  .editorial .supp-items-head .col-used,
  .editorial .supp-item-row .item-row-unit,
  .editorial .supp-item-row .item-row-stat:nth-child(5) { display: none; }
  .editorial .supp-items-head,
  .editorial .supp-item-row { grid-template-columns: 26px 1fr 100px 130px !important; gap: 12px !important; }
}

/* === Supplier ranking — 2-3 columns grid (more compact) === */
.editorial #supplierCards .rank {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0 32px;
  border-top: 1px solid var(--ed2-rule);
  padding-top: 4px;
}
.editorial .supplier-rank-row {
  border-bottom: 1px solid var(--ed2-rule);
  padding: 14px 4px 12px !important;
}
.editorial #supplierCards .rank-foot {
  grid-column: 1 / -1;
  padding-top: 14px;
  margin-top: 12px;
}
.editorial .supplier-rank-row .rank-bar {
  grid-column: 1 / -1;
  margin-top: 6px;
}
.editorial .supplier-rank-row .rank-name {
  font-size: 13px !important;
}
.editorial .supplier-rank-row .rank-name-sub {
  font-size: 9px !important;
  margin-top: 2px !important;
}
.editorial .supplier-rank-row .rank-val {
  font-size: 14px !important;
}
.editorial .supplier-rank-row .rank-val .pct {
  font-size: 9px !important;
  margin-top: 2px !important;
}
.editorial .supplier-rank-row .rank-n {
  font-size: 18px !important;
}

@media (max-width: 760px) {
  .editorial #supplierCards .rank {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* ═══════════════════════════════════════════════════
   FOOD COST PAGE — editorial KPI lead
═══════════════════════════════════════════════════ */

.editorial .fc-summary {
  padding: 32px 0 28px;
  border-bottom: 1px solid var(--ed2-rule-2);
}
.editorial .fc-lead {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 36px;
  align-items: end;
}
.editorial .lead-headline-suffix {
  font-size: 0.55em;
  color: var(--ed2-ink-3);
  margin-left: 2px;
  font-weight: 400;
  font-style: italic;
}
.editorial .lead-headline.fc-good { color: var(--ed2-leaf, #5C7A3E); }
.editorial .lead-headline.fc-warn { color: var(--ed2-grill); }
.editorial .lead-headline.fc-bad { color: #B91C1C; }
[data-theme="dark"] .editorial .lead-headline.fc-good { color: #A8C97A; }
[data-theme="dark"] .editorial .lead-headline.fc-warn { color: var(--ed2-ember); }
[data-theme="dark"] .editorial .lead-headline.fc-bad { color: #F87171; }

.editorial .fc-status {
  font-family: var(--ed2-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 0;
}
.editorial .fc-status.fc-good { color: var(--ed2-leaf, #5C7A3E); }
.editorial .fc-status.fc-warn { color: var(--ed2-grill); }
.editorial .fc-status.fc-bad { color: #B91C1C; }
[data-theme="dark"] .editorial .fc-status.fc-good { color: #A8C97A; }
[data-theme="dark"] .editorial .fc-status.fc-warn { color: var(--ed2-ember); }
[data-theme="dark"] .editorial .fc-status.fc-bad { color: #F87171; }

@media (max-width: 720px) {
  .editorial .fc-lead { grid-template-columns: 1fr; gap: 18px; }
}

/* ═══════════════════════════════════════════════════
   PROMO PAGE — editorial chrome + KPI overrides
═══════════════════════════════════════════════════ */

/* Promo KPI grids — flatten to editorial dotted leader */
.editorial #promoKpiGrid,
.editorial #shrimpKpiCards,
.editorial #customerMixCard .kpi-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
  gap: 0 32px !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 24px 0 !important;
  border-top: 1px solid var(--ed2-rule-2) !important;
  border-bottom: 1px solid var(--ed2-rule-2) !important;
  margin: 20px 0 !important;
}

.editorial #promoKpiGrid .kpi-card,
.editorial #shrimpKpiCards .kpi-card,
.editorial #customerMixCard .kpi-card {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 6px 0 !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--ed2-rule);
  padding-right: 24px !important;
  margin-right: 8px;
}
.editorial #promoKpiGrid .kpi-card:last-child,
.editorial #shrimpKpiCards .kpi-card:last-child,
.editorial #customerMixCard .kpi-card:last-child {
  border-right: none;
}

.editorial #promoKpiGrid .kpi-label,
.editorial #shrimpKpiCards .kpi-label,
.editorial #customerMixCard .kpi-label {
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
}
.editorial #promoKpiGrid .kpi-value,
.editorial #shrimpKpiCards .kpi-value,
.editorial #customerMixCard .kpi-value {
  font-family: var(--ed2-serif) !important;
  font-size: 26px !important;
  font-weight: 500 !important;
  letter-spacing: -0.025em !important;
  font-variation-settings: 'opsz' 48 !important;
  color: var(--ed2-ink) !important;
  font-variant-numeric: tabular-nums lining-nums !important;
  line-height: 1.05 !important;
}

/* Period label */
.editorial .promo-period-lbl {
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.06em;
}

/* Charts/cards — strip background, add editorial section spacing */
.editorial #promoChartCard,
.editorial #promoCpgChartCard,
.editorial #promoTableCard,
.editorial #customerMixCard,
.editorial #shrimpReconCard {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 24px 0 0 !important;
  box-shadow: none !important;
  margin-top: 20px !important;
}
.editorial #promoChartCard .chart-header,
.editorial #promoCpgChartCard .chart-header,
.editorial #promoTableCard .chart-header,
.editorial #customerMixCard .chart-header,
.editorial #shrimpReconCard .chart-header {
  display: flex !important;
  padding-bottom: 12px !important;
  border-bottom: 1px solid var(--ed2-ink) !important;
  margin-bottom: 16px;
  align-items: center;
  justify-content: space-between;
}
.editorial #promoChartCard h3,
.editorial #promoCpgChartCard h3,
.editorial #promoTableCard h3,
.editorial #customerMixCard h3,
.editorial #shrimpReconCard h3 {
  font-family: var(--ed2-serif) !important;
  font-size: 22px !important;
  font-weight: 500 !important;
  letter-spacing: -0.025em !important;
  color: var(--ed2-ink) !important;
  font-variation-settings: 'opsz' 36 !important;
  margin: 0 !important;
}

/* Data tables editorial */
.editorial .data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--ed2-sans);
  font-size: 13px;
}
.editorial .data-table thead th {
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
  text-align: left;
  padding: 12px 8px !important;
  border-bottom: 1px solid var(--ed2-ink) !important;
  font-weight: 500 !important;
  background: transparent !important;
}
.editorial .data-table tbody td {
  padding: 12px 8px !important;
  border-bottom: 1px solid var(--ed2-rule) !important;
  color: var(--ed2-ink) !important;
  font-variant-numeric: tabular-nums;
  background: transparent !important;
}
.editorial .data-table tbody tr:hover td {
  background: rgba(199,62,15,0.03) !important;
}
[data-theme="dark"] .editorial .data-table tbody tr:hover td {
  background: rgba(245,137,79,0.04) !important;
}
.editorial .promo-table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

/* Promo modal — editorial paper */
.editorial-promo-modal {} /* placeholder */
#promoModal .detail-panel,
#reconSettingsModal .detail-panel {
  background: var(--ed2-paper) !important;
  border: 1px solid var(--ed2-ink) !important;
  border-radius: 0 !important;
  box-shadow: 8px 8px 0 var(--ed2-rule-2) !important;
  font-family: var(--ed2-sans);
  color: var(--ed2-ink);
  position: relative;
}
#promoModal .detail-panel::before,
#reconSettingsModal .detail-panel::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(58,30,14,0.025) 0.5px,transparent 0.5px);
  background-size: 3px 3px; opacity: 0.6;
}
#promoModal .detail-panel > *,
#reconSettingsModal .detail-panel > * { position: relative; z-index: 1; }
#promoModal .detail-title,
#reconSettingsModal .detail-title {
  font-family: var(--ed2-serif) !important;
  font-size: 24px !important;
  font-weight: 600 !important;
  letter-spacing: -0.025em !important;
  color: var(--ed2-ink) !important;
  font-variation-settings: 'opsz' 48 !important;
}
#promoModal .detail-subtitle,
#reconSettingsModal .detail-subtitle {
  font-family: var(--ed2-mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.10em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
}
#promoModal .detail-header,
#reconSettingsModal .detail-header {
  border-bottom: 2px solid var(--ed2-ink) !important;
  padding-bottom: 14px !important;
}

@media (max-width: 760px) {
  .editorial #promoKpiGrid,
  .editorial #shrimpKpiCards,
  .editorial #customerMixCard .kpi-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0 !important;
  }
  .editorial #promoKpiGrid .kpi-card,
  .editorial #shrimpKpiCards .kpi-card,
  .editorial #customerMixCard .kpi-card {
    border-right: none;
    border-bottom: 1px solid var(--ed2-rule);
    padding: 10px 14px !important;
    margin-right: 0;
  }
}

/* === Tighten promo KPI grid spacing — multiple grids shouldn't double-pad === */
.editorial #promoKpiGrid,
.editorial #shrimpKpiCards,
.editorial #customerMixCard .kpi-grid {
  padding: 14px 0 !important;
  margin: 4px 0 !important;
  border-top: 1px solid var(--ed2-rule) !important;
  border-bottom: none !important;
}
/* Last KPI grid in stack gets bottom border to close */
.editorial #shrimpKpiCards {
  border-bottom: 1px solid var(--ed2-rule) !important;
  margin-bottom: 12px !important;
}
.editorial #customerMixCard .kpi-grid {
  border-bottom: 1px solid var(--ed2-rule) !important;
}

/* When #shrimpKpiCards is hidden, #promoKpiGrid needs bottom border */
.editorial #promoKpiGrid:not(:has(+ #shrimpKpiCards[style*="display:none"])) ~ #shrimpKpiCards {
  /* fallback */
}

.editorial #promoKpiGrid .kpi-card,
.editorial #shrimpKpiCards .kpi-card,
.editorial #customerMixCard .kpi-card {
  padding: 4px 18px 4px 0 !important;
  margin-right: 0 !important;
}
.editorial #promoKpiGrid .kpi-value,
.editorial #shrimpKpiCards .kpi-value,
.editorial #customerMixCard .kpi-value {
  font-size: 24px !important;
  margin-top: 2px;
}
.editorial #promoKpiGrid .kpi-label,
.editorial #shrimpKpiCards .kpi-label,
.editorial #customerMixCard .kpi-label {
  font-size: 9px !important;
}

/* Sub label inside shrimp KPI ("ตัว/คนที่เลือกโปร · 5,517 คน") */
.editorial #shrimpKpiCards .kpi-sub,
.editorial #promoKpiGrid .kpi-sub {
  font-family: var(--ed2-mono) !important;
  font-size: 9px !important;
  color: var(--ed2-ink-4) !important;
  letter-spacing: 0.04em !important;
  margin-top: 4px;
}

/* === Shrimp recon per-item card — editorial paper style === */
.editorial #shrimpReconBody > div {
  background: transparent !important;
  border-radius: 0 !important;
  padding: 18px 0 18px 0 !important;
  border-bottom: 1px solid var(--ed2-rule) !important;
  margin-bottom: 0 !important;
}
.editorial #shrimpReconBody > div:last-child { border-bottom: none !important; }
.editorial #shrimpReconBody h4 {
  font-family: var(--ed2-serif) !important;
  font-size: 20px !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em !important;
  color: var(--ed2-ink) !important;
  font-variation-settings: 'opsz' 36 !important;
  margin: 0 !important;
}
.editorial #shrimpReconBody h4 span {
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.10em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
  font-weight: 400 !important;
}
.editorial #shrimpReconBody [style*='color:#FF9500'] {
  color: var(--ed2-grill) !important;
}

/* ═══════════════════════════════════════════════════
   FORECAST + PROMO IMPACT — editorial chrome
═══════════════════════════════════════════════════ */

/* Forecast summary KPIs — editorial ticker */
.editorial .fcast-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-top: 1px solid var(--ed2-rule-2);
  border-bottom: 1px solid var(--ed2-rule-2);
  padding: 20px 0;
  margin: 24px 0 8px;
  gap: 0;
}
.editorial .fcast-summary .kpi-card {
  background: transparent !important;
  border: none !important;
  border-right: 1px solid var(--ed2-rule) !important;
  border-radius: 0 !important;
  padding: 6px 24px 6px 0 !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.editorial .fcast-summary .kpi-card:last-child { border-right: none !important; }
.editorial .fcast-summary .kpi-label {
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
}
.editorial .fcast-summary .kpi-value {
  font-family: var(--ed2-serif) !important;
  font-size: 28px !important;
  font-weight: 500 !important;
  letter-spacing: -0.025em !important;
  font-variation-settings: 'opsz' 48 !important;
  color: var(--ed2-ink) !important;
  font-variant-numeric: tabular-nums lining-nums !important;
  line-height: 1.05 !important;
}
.editorial .fcast-summary .kpi-compare {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.04em;
}

/* Trend badge */
.editorial .fcast-badge {
  font-family: var(--ed2-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 6px 12px;
  border: 1px solid var(--ed2-rule-2);
  border-radius: 0;
  color: var(--ed2-ink-2);
}
.editorial .fcast-badge.danger {
  color: var(--ed2-grill);
  border-color: var(--ed2-grill);
}
.editorial .fcast-badge.success {
  color: var(--ed2-leaf, #5C7A3E);
  border-color: var(--ed2-leaf, #5C7A3E);
}
[data-theme="dark"] .editorial .fcast-badge.danger {
  color: var(--ed2-ember);
  border-color: var(--ed2-ember);
}
[data-theme="dark"] .editorial .fcast-badge.success {
  color: #A8C97A;
  border-color: #A8C97A;
}

/* Forecast items table */
.editorial #fcastItemsList .forecast-table {
  background: transparent;
  display: flex;
  flex-direction: column;
}
.editorial #fcastItemsList .ft-head {
  display: grid;
  grid-template-columns: 1fr 130px 100px 130px;
  gap: 14px;
  padding: 12px 4px 10px;
  border-bottom: 1px solid var(--ed2-ink);
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  font-weight: 500;
}
.editorial #fcastItemsList .ft-head span:nth-child(2),
.editorial #fcastItemsList .ft-head span:nth-child(4) { text-align: right; }
.editorial #fcastItemsList .ft-row {
  display: grid;
  grid-template-columns: 1fr 130px 100px 130px;
  gap: 14px;
  padding: 14px 4px 10px;
  align-items: baseline;
  border-bottom: 1px solid var(--ed2-rule);
  background: transparent !important;
}
.editorial #fcastItemsList .ft-name {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-size: 14px;
  color: var(--ed2-ink);
  font-weight: 500;
}
.editorial #fcastItemsList .ft-stat {
  font-family: var(--ed2-serif);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ed2-ink);
  text-align: right;
}
.editorial #fcastItemsList .ft-trend {
  font-family: var(--ed2-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.editorial #fcastItemsList .ft-trend.up { color: var(--ed2-grill); }
.editorial #fcastItemsList .ft-trend.down { color: var(--ed2-leaf, #5C7A3E); }
[data-theme="dark"] .editorial #fcastItemsList .ft-trend.up { color: var(--ed2-ember); }
[data-theme="dark"] .editorial #fcastItemsList .ft-trend.down { color: #A8C97A; }

/* Promo Impact — filter range groups */
.editorial .pi-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
}
.editorial .filt-pi {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
}
.editorial .pi-range-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ed2-mono);
  font-size: 11px;
}
.editorial .pi-range-lbl {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  font-weight: 500;
}
.editorial .pi-range-note {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ed2-ink-3);
  margin-top: 8px;
  font-variation-settings: 'opsz' 14;
}

/* Promo Impact verdict + KPIs */
.editorial #piVerdict {
  margin: 24px 0;
  padding: 18px 22px;
  border-left: 3px solid var(--ed2-grill);
  background: rgba(199,62,15,0.04);
  font-family: var(--ed2-serif);
  font-size: 16px;
  font-style: italic;
  color: var(--ed2-ink);
  font-variation-settings: 'opsz' 18;
}
[data-theme="dark"] .editorial #piVerdict {
  background: rgba(245,137,79,0.06);
  border-left-color: var(--ed2-ember);
}

.editorial .pi-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 18px 0;
  border-top: 1px solid var(--ed2-rule-2);
  border-bottom: 1px solid var(--ed2-rule-2);
  margin-bottom: 16px;
  gap: 0;
}
.editorial .pi-kpi-grid .kpi-card {
  background: transparent !important;
  border: none !important;
  border-right: 1px solid var(--ed2-rule) !important;
  border-radius: 0 !important;
  padding: 6px 22px 6px 0 !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.editorial .pi-kpi-grid .kpi-card:last-child { border-right: none !important; }
.editorial .pi-kpi-grid .kpi-label {
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
}
.editorial .pi-kpi-grid .kpi-value {
  font-family: var(--ed2-serif) !important;
  font-size: 26px !important;
  font-weight: 500 !important;
  letter-spacing: -0.025em !important;
  font-variation-settings: 'opsz' 48 !important;
  color: var(--ed2-ink) !important;
  font-variant-numeric: tabular-nums !important;
}
.editorial .pi-kpi-grid .kpi-compare {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ed2-ink-3);
}

/* PromoImpact recommendations */
.editorial .pi-recs {
  font-family: var(--ed2-serif);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ed2-ink-2);
  font-variation-settings: 'opsz' 16;
  padding: 8px 0;
}

@media (max-width: 760px) {
  .editorial .filt-pi { flex-direction: column; align-items: stretch; gap: 12px; }
  .editorial .pi-kpi-grid,
  .editorial .fcast-summary { grid-template-columns: 1fr 1fr; }
  .editorial .pi-kpi-grid .kpi-card,
  .editorial .fcast-summary .kpi-card { border-right: none; border-bottom: 1px solid var(--ed2-rule); padding-bottom: 12px !important; }
  .editorial #fcastItemsList .ft-head,
  .editorial #fcastItemsList .ft-row { grid-template-columns: 1fr 100px 110px; gap: 10px; }
  .editorial #fcastItemsList .ft-head span:nth-child(3),
  .editorial #fcastItemsList .ft-row > *:nth-child(3) { display: none; }
}

/* ═══════════════════════════════════════════════════
   PROMO IMPACT — polish (delta colors, table, recs)
═══════════════════════════════════════════════════ */

/* Verdict — refined */
.editorial #piVerdict {
  margin: 24px 0;
  padding: 22px 24px;
  border: 1px solid var(--ed2-ink);
  border-left: 3px solid var(--ed2-grill);
  background: var(--ed2-paper-2);
  font-family: var(--ed2-serif);
  font-size: 16px;
  font-style: italic;
  color: var(--ed2-ink);
  line-height: 1.55;
  font-variation-settings: 'opsz' 18;
  position: relative;
}
.editorial #piVerdict::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(58,30,14,0.025) 0.5px,transparent 0.5px);
  background-size: 3px 3px; opacity: 0.5;
}
.editorial #piVerdict > * { position: relative; }
.editorial #piVerdict strong,
.editorial #piVerdict b {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-style: normal;
  font-weight: 600;
  color: var(--ed2-grill);
}
[data-theme="dark"] .editorial #piVerdict {
  background: var(--ed2-paper-2);
  border-color: var(--ed2-rule-2);
  border-left-color: var(--ed2-ember);
}
[data-theme="dark"] .editorial #piVerdict strong,
[data-theme="dark"] .editorial #piVerdict b { color: var(--ed2-ember); }

/* Semantic delta classes — work everywhere */
.editorial .delta-good {
  color: var(--ed2-leaf, #5C7A3E) !important;
  font-family: var(--ed2-mono) !important;
  font-weight: 500 !important;
}
.editorial .delta-bad {
  color: var(--ed2-grill) !important;
  font-family: var(--ed2-mono) !important;
  font-weight: 500 !important;
}
.editorial .delta-flat {
  color: var(--ed2-ink-3) !important;
  font-family: var(--ed2-mono) !important;
  font-weight: 500 !important;
}
[data-theme="dark"] .editorial .delta-good { color: #A8C97A !important; }
[data-theme="dark"] .editorial .delta-bad { color: var(--ed2-ember) !important; }

/* Data table — numeric cells alignment */
.editorial .data-table .num {
  font-family: var(--ed2-mono) !important;
  font-variant-numeric: tabular-nums !important;
  text-align: right !important;
}

/* Top items table — refined typography */
.editorial #piTopItemsBody td .ti-rank {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 17px;
  color: var(--ed2-ink-4);
  font-variation-settings: 'opsz' 24;
}
.editorial #piTopItemsBody td .ti-name {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-weight: 500;
  display: block;
  color: var(--ed2-ink);
}
.editorial #piTopItemsBody td .ti-unit {
  font-family: var(--ed2-mono);
  font-size: 9px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 3px;
  display: block;
}
.editorial #piTopItemsBody tr:first-child td .ti-rank { color: var(--ed2-grill); }

/* PI KPI delta values — apply semantic color from data */
.editorial .pi-kpi-grid .kpi-value > span {
  font: inherit;
}

/* Recommendations — editorial numbered list */
.editorial .pi-recs {
  font-family: var(--ed2-serif);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ed2-ink-2);
  font-variation-settings: 'opsz' 16;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.editorial .pi-rec-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--ed2-rule);
  align-items: baseline;
  background: transparent !important;
}
.editorial .pi-rec-item:last-child { border-bottom: none; }
.editorial .pi-rec-n {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 22px;
  font-weight: 500;
  color: var(--ed2-grill);
  font-variation-settings: 'opsz' 36;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.editorial .pi-rec-text {
  font-family: var(--ed2-serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ed2-ink-2);
  font-variation-settings: 'opsz' 16;
}
.editorial .pi-rec-empty {
  font-family: var(--ed2-serif);
  font-style: italic;
  color: var(--ed2-ink-3);
  padding: 18px 4px;
}

/* PI KPI deltas may contain inline color from JS — override with semantic class */
.editorial .pi-kpi-grid .kpi-value [style*="color:"] {
  color: inherit !important;
}
.editorial .pi-kpi-grid .kpi-value {
  position: relative;
}

/* === Verdict box — clean editorial pull-quote === */
.editorial .pi-verdict {
  margin: 24px 0;
  padding: 22px 28px;
  background: var(--ed2-paper-2);
  border: 1px solid var(--ed2-ink);
  border-left-width: 3px;
  position: relative;
}
.editorial .pi-verdict.verdict-good {
  border-left-color: var(--ed2-leaf, #5C7A3E);
}
.editorial .pi-verdict.verdict-bad {
  border-left-color: var(--ed2-grill);
}
.editorial .pi-verdict.verdict-flat {
  border-left-color: var(--ed2-ink-3);
}
[data-theme="dark"] .editorial .pi-verdict.verdict-good { border-left-color: #A8C97A; }
[data-theme="dark"] .editorial .pi-verdict.verdict-bad { border-left-color: var(--ed2-ember); }

.editorial .pi-verdict::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(58,30,14,0.025) 0.5px,transparent 0.5px);
  background-size: 3px 3px; opacity: 0.4;
}
.editorial .pi-verdict > * { position: relative; z-index: 1; }

.editorial .pi-verdict-kicker {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  margin-bottom: 8px;
  font-weight: 500;
}
.editorial .pi-verdict-text {
  font-family: var(--ed2-serif);
  font-size: 19px;
  font-weight: 500;
  font-style: italic;
  color: var(--ed2-ink);
  line-height: 1.45;
  letter-spacing: -0.005em;
  font-variation-settings: 'opsz' 24;
}
.editorial .pi-verdict.verdict-good .pi-verdict-text {
  color: var(--ed2-leaf, #5C7A3E);
}
.editorial .pi-verdict.verdict-bad .pi-verdict-text {
  color: var(--ed2-grill);
}
[data-theme="dark"] .editorial .pi-verdict.verdict-good .pi-verdict-text { color: #A8C97A; }
[data-theme="dark"] .editorial .pi-verdict.verdict-bad .pi-verdict-text { color: var(--ed2-ember); }

/* ═══════════════════════════════════════════════════
   ADMIN PAGE — editorial chrome for system controls
═══════════════════════════════════════════════════ */

/* Sync status message */
.editorial .sync-status {
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.04em;
  padding: 12px 0;
  margin-top: 8px;
}
.editorial .sync-status:empty { display: none; }

.editorial .admin-sync-info {
  margin-top: 16px;
}

/* Status grid inside admin sync info — same dossier style */
.editorial .admin-sync-info .status-item {
  display: grid !important;
  grid-template-columns: auto 1fr auto !important;
  gap: 10px;
  padding: 10px 0 !important;
  border-bottom: 1px solid var(--ed2-rule) !important;
  background: transparent !important;
  border-radius: 0 !important;
}
.editorial .admin-sync-info .status-item:last-child { border-bottom: none !important; }

/* Users table — editorial */
.editorial #usersTable {
  margin-top: 12px;
  background: transparent !important;
  padding: 0 !important;
}
.editorial #usersTable table,
.editorial #usersTable .users-table-inner {
  width: 100%;
  border-collapse: collapse;
}
.editorial #usersTable .user-row {
  display: grid;
  grid-template-columns: 40px 1fr 110px 110px 80px;
  gap: 14px;
  padding: 14px 4px;
  align-items: baseline;
  border-bottom: 1px solid var(--ed2-rule);
  background: transparent !important;
  font-family: var(--ed2-sans);
}
.editorial #usersTable .user-row.header,
.editorial #usersTable .users-head {
  font-family: var(--ed2-mono) !important;
  font-size: 10px !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed2-ink-3) !important;
  padding: 12px 4px !important;
  border-bottom: 1px solid var(--ed2-ink) !important;
  font-weight: 500 !important;
}
.editorial #usersTable .user-avatar,
.editorial #usersTable .user-init {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--ed2-rule-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ed2-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ed2-ink-2);
}
.editorial #usersTable .user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ed2-ink);
}
.editorial #usersTable .user-username {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.editorial #usersTable .user-role-pill {
  font-family: var(--ed2-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid var(--ed2-rule-2);
  border-radius: 0;
  color: var(--ed2-ink-2);
  background: transparent;
  display: inline-block;
}
.editorial #usersTable .user-role-pill.owner {
  color: var(--ed2-grill);
  border-color: var(--ed2-grill);
}
[data-theme="dark"] .editorial #usersTable .user-role-pill.owner {
  color: var(--ed2-ember);
  border-color: var(--ed2-ember);
}

/* Audit log list */
.editorial .audit-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  background: transparent !important;
  padding: 0 !important;
}
.editorial .audit-list .audit-row {
  display: grid;
  grid-template-columns: 140px 100px 1fr auto;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--ed2-rule);
  align-items: baseline;
  font-family: var(--ed2-sans);
  background: transparent !important;
}
.editorial .audit-list .audit-row:last-child { border-bottom: none; }
.editorial .audit-list .audit-time {
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.04em;
}
.editorial .audit-list .audit-user {
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-2);
  letter-spacing: 0.04em;
}
.editorial .audit-list .audit-action {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-size: 13px;
  color: var(--ed2-ink);
}
.editorial .audit-list .audit-ip {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-4);
  letter-spacing: 0.04em;
}

/* Admin sect-head — button on right of header */
.editorial #page-admin .sect-head {
  align-items: flex-end;
}
.editorial #page-admin .sect-head .btn-min {
  flex-shrink: 0;
}

@media (max-width: 760px) {
  .editorial #usersTable .user-row {
    grid-template-columns: 32px 1fr 80px;
    gap: 10px;
  }
  .editorial #usersTable .user-row > *:nth-child(4),
  .editorial #usersTable .user-row > *:nth-child(5) { display: none; }
  .editorial .audit-list .audit-row {
    grid-template-columns: 110px 1fr;
    gap: 8px;
  }
  .editorial .audit-list .audit-user,
  .editorial .audit-list .audit-ip { display: none; }
}

/* === PI page — preset UX + methodology === */

/* Custom date range — collapsible */
.editorial .pi-custom-range {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--ed2-rule);
  align-items: center;
}
.editorial .pi-custom-range[hidden] { display: none !important; }
.editorial .pi-range-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ed2-mono);
  font-size: 11px;
}
.editorial .pi-range-lbl {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  font-weight: 500;
}

/* Range note — readable summary */
.editorial .pi-range-note {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 0;
  font-family: var(--ed2-mono);
  font-size: 12px;
  margin: 0;
}
.editorial .pi-range-note:empty { display: none; }
.editorial .pi-rn-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  align-items: baseline;
}
.editorial .pi-rn-k {
  color: var(--ed2-ink-3);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-size: 10px;
}
.editorial .pi-rn-v {
  color: var(--ed2-ink);
  font-family: var(--ed2-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* Methodology — editorial numbered list */
.editorial .pi-methodology {
  margin-top: 36px;
  padding-top: 32px;
  border-top: 1px solid var(--ed2-rule-2);
}
.editorial .pi-method-list {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
}
.editorial .pi-method-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 18px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--ed2-rule);
  align-items: baseline;
}
.editorial .pi-method-row:last-child { border-bottom: none; }
.editorial .pi-method-n {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 26px;
  font-weight: 500;
  color: var(--ed2-grill);
  font-variation-settings: 'opsz' 36;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.editorial .pi-method-title {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-weight: 600;
  font-size: 15px;
  color: var(--ed2-ink);
  margin-bottom: 6px;
  letter-spacing: -0.005em;
}
.editorial .pi-method-desc {
  font-family: var(--ed2-serif);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ed2-ink-2);
  font-variation-settings: 'opsz' 16;
}
.editorial .pi-method-desc code {
  font-family: var(--ed2-mono);
  font-size: 11px;
  background: var(--ed2-paper-2);
  padding: 1px 6px;
  color: var(--ed2-grill);
  letter-spacing: 0.02em;
}
[data-theme="dark"] .editorial .pi-method-desc code {
  color: var(--ed2-ember);
}

/* Preset chip — small refinement */
.editorial .pi-preset-btn {
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════
   FULL IMPACT ANALYSIS — 6-angle cards + hero
═══════════════════════════════════════════════════ */

.editorial .pi-full-impact { margin-top: 40px; padding-top: 36px; border-top: 1px solid var(--ed2-rule-2); }

.editorial .fi-content { margin-top: 14px; }

.editorial .fi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0;
  border-top: 1px solid var(--ed2-rule);
}

.editorial .fi-card {
  padding: 22px 26px 20px;
  border-right: 1px solid var(--ed2-rule);
  border-bottom: 1px solid var(--ed2-rule);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: background 0.25s;
}
.editorial .fi-card:hover { background: rgba(199,62,15,0.02); }
[data-theme="dark"] .editorial .fi-card:hover { background: rgba(245,137,79,0.03); }

.editorial .fi-card-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.editorial .fi-n {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 26px;
  font-weight: 500;
  color: var(--ed2-ink-4);
  font-variation-settings: 'opsz' 36;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  flex-shrink: 0;
}
.editorial .fi-title {
  font-family: var(--ed2-serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ed2-ink);
  font-variation-settings: 'opsz' 24;
}

.editorial .fi-big {
  font-family: var(--ed2-serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.03em;
  font-variation-settings: 'opsz' 48;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.editorial .fi-big.good { color: var(--ed2-leaf, #5C7A3E); font-style: italic; }
.editorial .fi-big.bad { color: var(--ed2-grill); font-style: italic; }
.editorial .fi-big.flat { color: var(--ed2-ink-3); }
[data-theme="dark"] .editorial .fi-big.good { color: #A8C97A; }
[data-theme="dark"] .editorial .fi-big.bad { color: var(--ed2-ember); }

.editorial .fi-rows {
  display: flex;
  flex-direction: column;
  padding-top: 6px;
  border-top: 1px dotted var(--ed2-rule);
}
.editorial .fi-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  font-family: var(--ed2-mono);
  font-size: 12px;
  color: var(--ed2-ink-2);
  letter-spacing: 0.02em;
}
.editorial .fi-row.total {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--ed2-rule);
  font-weight: 500;
  color: var(--ed2-ink);
}
.editorial .fi-row span:first-child { color: var(--ed2-ink-3); }
.editorial .fi-row .good { color: var(--ed2-leaf, #5C7A3E); }
.editorial .fi-row .bad { color: var(--ed2-grill); }
.editorial .fi-row .flat { color: var(--ed2-ink-3); }
[data-theme="dark"] .editorial .fi-row .good { color: #A8C97A; }
[data-theme="dark"] .editorial .fi-row .bad { color: var(--ed2-ember); }

.editorial .fi-foot {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ed2-ink-3);
  padding-top: 8px;
  border-top: 1px dotted var(--ed2-rule);
  font-variation-settings: 'opsz' 14;
}
.editorial .fi-foot b {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-style: normal;
  font-weight: 600;
  color: var(--ed2-ink);
}
.editorial .fi-foot .good { color: var(--ed2-leaf, #5C7A3E); font-style: normal; font-family: var(--ed2-mono); }
.editorial .fi-foot .bad { color: var(--ed2-grill); font-style: normal; font-family: var(--ed2-mono); }
[data-theme="dark"] .editorial .fi-foot .good { color: #A8C97A; }
[data-theme="dark"] .editorial .fi-foot .bad { color: var(--ed2-ember); }

/* NW-adjusted card — different layout */
.editorial .fi-card-nw .fi-nw-row {
  padding: 8px 0;
  border-bottom: 1px dotted var(--ed2-rule);
}
.editorial .fi-card-nw .fi-nw-row:last-of-type { border-bottom: none; }
.editorial .fi-nw-name {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-weight: 500;
  font-size: 14px;
  color: var(--ed2-ink);
  margin-bottom: 6px;
}
.editorial .fi-nw-pct {
  font-family: var(--ed2-mono);
  font-size: 9px;
  letter-spacing: 0.10em;
  color: var(--ed2-grill);
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid currentColor;
}
[data-theme="dark"] .editorial .fi-nw-pct { color: var(--ed2-ember); }
.editorial .fi-nw-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.editorial .fi-nw-stats > div {
  display: flex;
  justify-content: space-between;
  font-family: var(--ed2-mono);
  font-size: 11px;
}
.editorial .fi-nw-stats .lbl {
  color: var(--ed2-ink-3);
  letter-spacing: 0.04em;
}
.editorial .fi-nw-stats .val {
  color: var(--ed2-ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.editorial .fi-nw-stats .val.grill { color: var(--ed2-grill); }
[data-theme="dark"] .editorial .fi-nw-stats .val.grill { color: var(--ed2-ember); }
.editorial .fi-empty-small {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 12px;
  color: var(--ed2-ink-3);
  padding: 14px 0;
}

/* Hero — Net Real Impact (full-width banner) */
.editorial .fi-hero {
  margin-top: 24px;
  padding: 32px 36px;
  background: var(--ed2-paper-2);
  border: 1px solid var(--ed2-ink);
  border-left-width: 4px;
  position: relative;
  text-align: center;
}
.editorial .fi-hero.good { border-left-color: var(--ed2-leaf, #5C7A3E); }
.editorial .fi-hero.bad { border-left-color: var(--ed2-grill); }
.editorial .fi-hero.flat { border-left-color: var(--ed2-ink-3); }
[data-theme="dark"] .editorial .fi-hero.good { border-left-color: #A8C97A; }
[data-theme="dark"] .editorial .fi-hero.bad { border-left-color: var(--ed2-ember); }

.editorial .fi-hero::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(58,30,14,0.025) 0.5px,transparent 0.5px);
  background-size: 3px 3px; opacity: 0.5;
}
.editorial .fi-hero > * { position: relative; z-index: 1; }

.editorial .fi-hero-kicker {
  font-family: var(--ed2-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  font-weight: 500;
  margin-bottom: 12px;
}

.editorial .fi-hero-num {
  font-family: var(--ed2-serif);
  font-size: 64px;
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1;
  font-variation-settings: 'opsz' 144;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--ed2-ink);
}
.editorial .fi-hero.good .fi-hero-num { color: var(--ed2-leaf, #5C7A3E); font-style: italic; }
.editorial .fi-hero.bad .fi-hero-num { color: var(--ed2-grill); font-style: italic; }
[data-theme="dark"] .editorial .fi-hero.good .fi-hero-num { color: #A8C97A; }
[data-theme="dark"] .editorial .fi-hero.bad .fi-hero-num { color: var(--ed2-ember); }

.editorial .fi-hero-unit {
  font-size: 0.4em;
  color: var(--ed2-ink-3);
  font-weight: 400;
  font-style: italic;
  margin-left: 4px;
  -webkit-text-fill-color: var(--ed2-ink-3);
}
.editorial .fi-hero-month {
  font-family: var(--ed2-mono);
  font-size: 12px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.06em;
  margin-top: 8px;
}
.editorial .fi-hero-text {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 17px;
  color: var(--ed2-ink-2);
  margin-top: 18px;
  font-variation-settings: 'opsz' 20;
}
.editorial .fi-hero-formula {
  font-family: var(--ed2-mono);
  font-size: 11px;
  color: var(--ed2-ink-4);
  margin-top: 12px;
  letter-spacing: 0.04em;
  padding-top: 12px;
  border-top: 1px dotted var(--ed2-rule);
}

@media (max-width: 760px) {
  .editorial .fi-grid { grid-template-columns: 1fr; }
  .editorial .fi-card { border-right: none; padding: 20px 18px; }
  .editorial .fi-hero { padding: 24px 18px; }
  .editorial .fi-hero-num { font-size: 44px; }
}

.editorial .pi-rn-meta {
  font-family: var(--ed2-mono);
  font-size: 10px;
  color: var(--ed2-ink-3);
  margin-left: 4px;
  letter-spacing: 0.04em;
}
.editorial .pi-rn-meta b {
  font-weight: 600;
  color: var(--ed2-ink);
}
.editorial .pi-rn-row.pi-rn-note {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dotted var(--ed2-rule);
}
.editorial .pi-rn-row.pi-rn-note em {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 11px;
  color: var(--ed2-ink-3);
  line-height: 1.5;
}

.editorial .pi-round-lbl {
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  font-weight: 500;
}
.editorial .pi-round-select {
  min-width: 260px;
}

/* === Low-sample warning hero === */
.editorial .fi-hero-warn {
  margin-top: 24px;
  padding: 32px 36px;
  background: var(--ed2-paper-2);
  border: 2px solid var(--ed2-grill);
  border-left-width: 4px;
  position: relative;
  text-align: left;
}
[data-theme="dark"] .editorial .fi-hero-warn {
  border-color: var(--ed2-ember);
}
.editorial .fi-hero-warn::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(199,62,15,0.05) 0.5px,transparent 0.5px);
  background-size: 3px 3px; opacity: 0.6;
}
.editorial .fi-hero-warn > * { position: relative; z-index: 1; }

.editorial .fi-hero-warn .fi-hero-kicker {
  color: var(--ed2-grill);
  font-weight: 600;
  margin-bottom: 14px;
}
[data-theme="dark"] .editorial .fi-hero-warn .fi-hero-kicker {
  color: var(--ed2-ember);
}
.editorial .fi-hero-warn-title {
  font-family: var(--ed2-serif);
  font-size: 36px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.03em;
  font-variation-settings: 'opsz' 72;
  color: var(--ed2-grill);
  line-height: 1.05;
}
[data-theme="dark"] .editorial .fi-hero-warn-title {
  color: var(--ed2-ember);
}
.editorial .fi-hero-warn-body {
  font-family: var(--ed2-serif);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ed2-ink-2);
  margin: 16px 0;
  font-variation-settings: 'opsz' 18;
}
.editorial .fi-hero-warn-body b {
  font-family: var(--ed2-thai, var(--ed2-sans));
  font-weight: 600;
  color: var(--ed2-ink);
}
.editorial .fi-hero-warn-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--ed2-rule);
  border-bottom: 1px solid var(--ed2-rule);
  margin: 14px 0;
}
.editorial .fi-warn-stat {
  padding: 14px 0;
  border-right: 1px solid var(--ed2-rule);
  text-align: center;
}
.editorial .fi-warn-stat:last-child { border-right: none; }
.editorial .fi-warn-stat .lbl {
  display: block;
  font-family: var(--ed2-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ed2-ink-3);
  margin-bottom: 6px;
}
.editorial .fi-warn-stat .val {
  display: block;
  font-family: var(--ed2-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ed2-ink);
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'opsz' 36;
}
.editorial .fi-hero-warn-foot {
  font-family: var(--ed2-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ed2-ink-3);
  margin-top: 12px;
  font-variation-settings: 'opsz' 14;
}
.editorial .fi-hero-warn-foot b {
  font-family: var(--ed2-mono);
  font-style: normal;
  font-weight: 500;
  color: var(--ed2-grill);
  font-size: 12px;
}
[data-theme="dark"] .editorial .fi-hero-warn-foot b { color: var(--ed2-ember); }
.editorial .fi-hero-text em {
  font-family: var(--ed2-mono);
  font-style: normal;
  font-size: 11px;
  color: var(--ed2-ink-3);
  letter-spacing: 0.06em;
  margin-left: 4px;
}

/* === Bigger sidebar mascot logo === */
#appScreen .sidebar-logo {
  width: 56px !important;
  height: 56px !important;
}
#appScreen .sidebar-brand {
  gap: 14px !important;
  align-items: center !important;
}
#appScreen .sidebar-brand-title {
  font-size: 22px !important;
}
#appScreen .sidebar-brand-sub {
  font-size: 10px !important;
}

/* Mobile drawer logo too */
#mobileDrawer .sidebar-logo {
  width: 52px !important;
  height: 52px !important;
}
#mobileDrawer .drawer-header {
  gap: 14px;
}

/* === Strip ALL frame/bg from sidebar mascot, even bigger === */
#appScreen .sidebar-logo,
#mobileDrawer .sidebar-logo,
.drawer-header .sidebar-logo {
  width: 72px !important;
  height: 72px !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  filter: none !important;
}
[data-theme="dark"] #appScreen .sidebar-logo,
[data-theme="dark"] #mobileDrawer .sidebar-logo,
[data-theme="dark"] .drawer-header .sidebar-logo {
  filter: none !important;
}

#appScreen .sidebar-brand {
  gap: 14px !important;
  align-items: center !important;
}
#appScreen .sidebar-brand-title { font-size: 24px !important; }
#appScreen .sidebar-brand-sub { font-size: 11px !important; }

/* ═══════════════════════════════════════════════════
   GEIST FONT FOR NUMBERS (everything numeric)
═══════════════════════════════════════════════════ */
:root {
  --ed2-num: 'Geist', 'Inter', -apple-system, system-ui, sans-serif;
}

/* All numeric displays use Geist — keep Fraunces only for titles + italic accents */
.editorial .lead-headline,
.editorial .tk-val,
.editorial .kpi-value,
.editorial .extreme-val,
.editorial .rank-val,
.editorial .rank-n,
.editorial .dow-label,
.editorial .dow-value,
.editorial .dow-stat-val,
.editorial .dow-cell,
.editorial .top-day-sales,
.editorial .top-day-rank,
.editorial .item-row-num,
.editorial .item-row-stat,
.editorial .anom-sales,
.editorial .donut-val,
.editorial .fi-big,
.editorial .fi-n,
.editorial .fi-hero-num,
.editorial .ft-stat,
.editorial .fi-warn-stat .val,
.editorial #fcastItemsList .ft-stat {
  font-family: var(--ed2-num) !important;
}

/* Preserve italic + color on rank #1 (still feel personality) */
.editorial .rank-row.rank-top .rank-n,
.editorial .dow-row:first-of-type .dow-label,
.editorial .top-day-row:first-child .top-day-rank,
.editorial .item-row .item-row-num,
.editorial .anom-row .anom-sales,
.editorial .fi-n {
  font-style: italic;
  font-weight: 500;
}

/* Lead headline — slightly tighter letter-spacing with Geist */
.editorial .lead-headline {
  letter-spacing: -0.04em !important;
  font-weight: 600 !important;
}

/* Tabular nums for everything numeric — single source */
.editorial .lead-headline,
.editorial .tk-val,
.editorial .kpi-value,
.editorial .extreme-val,
.editorial .rank-val,
.editorial .dow-value,
.editorial .dow-stat-val,
.editorial .top-day-sales,
.editorial .item-row-stat,
.editorial .anom-sales,
.editorial .fi-big,
.editorial .fi-hero-num {
  font-variant-numeric: tabular-nums lining-nums !important;
}

/* ── Bill Analysis cards ──────────────────────────────────── */
.bill-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.bill-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.bill-rank { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.bill-date { font-size: 12px; color: var(--text-tertiary); }
.bill-card-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.bill-card-stats b { color: var(--text-primary); font-size: 15px; }
.bill-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.bill-breakdown-item {
  background: var(--chip-bg, rgba(199,62,15,0.08));
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
}

/* ── Bill per-category stat ──────────────────────────────── */
.bill-cat-stat {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 140px;
  flex: 1;
}
.bill-cat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.bill-cat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.bill-cat-value span { font-size: 13px; font-weight: 400; color: var(--text-secondary); }
.bill-cat-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}
.bill-breakdown-item.per-guest {
  background: var(--chip-bg-alt, rgba(92,122,62,0.10));
  color: var(--text-secondary);
}
.bill-guests { color: var(--text-tertiary); font-size: 12px; }

.sect-sub-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.bill-rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 6px;
  flex-shrink: 0;
}
