/* ============================================================================
   Power Saver Admin · Design System
   Standalone — no Pico, no framework conflicts
   ============================================================================ */

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

/* ============================================================================
   Full Reset — override anything pico may have applied before removal
   ============================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: light;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: #0B1B2B;
  background: #F2F2F2;
  min-height: 100vh;
}

/* Force light mode everywhere — no dark mode */
* { color-scheme: light only; }

/* ============================================================================
   Brand Color Variables
   ============================================================================ */
:root {
  --brand:        #333333;
  --brand-strong: #111111;
  --brand-light:  #F0F0F0;
  --accent:       #555555;
  --accent-soft:  #F0F0F0;
  --positive:     #16A34A;
  --pos-soft:     #DCFCE7;
  --pos-strong:   #047857;
  --warning:      #EF9F27;
  --warn-soft:    #FEF3C7;
  --error:        #E24B4A;
  --error-soft:   #FEE2E2;
  --sun:          #FFB627;

  /* Layout & Surface */
  --page-bg:      #F2F2F2;
  --surface:      #FFFFFF;
  --surface-alt:  #F5F5F5;
  --surface-hover:#EFEFEF;

  /* Text */
  --text:         #0B1B2B;
  --text-muted:   #5A6B82;
  --text-subtle:  #94A3B8;

  /* Borders */
  --border:       #E2E8F0;
  --border-focus: #333333;

  /* Sidebar */
  --sidebar-w:    240px;
  --sb-bg1:       #162533;
  --sb-bg2:       #0D1A24;

  /* Elevation */
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:       0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg:    0 8px 24px rgba(0,0,0,0.09);
  --shadow-xl:    0 16px 48px rgba(0,0,0,0.12);

  /* Tokens */
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --radius-xl:    20px;
  --transition:   180ms ease-out;

  /* Brand gradient (matches Flutter countdown timer) */
  --brand-gradient: #333333;
  --brand-gradient-hover: #111111;
}

/* ============================================================================
   Global Elements
   ============================================================================ */
a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-strong); text-decoration: underline; }

h1, h2, h3, h4 {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.3;
}

p { line-height: 1.6; }

code, kbd {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: #EEF2F7;
  color: #1D4ED8;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #D1D9E6;
}

pre {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: #F5F5F5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================================
   Layout
   ============================================================================ */
.navtoggle { display: none; }

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

/* ============================================================================
   Sidebar
   ============================================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #111111;
  z-index: 200;
  overflow: hidden;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  flex-shrink: 0;
}
.brand-icon { width: 28px; height: 28px; flex-shrink: 0; }
.brand-icon svg { width: 100%; height: 100%; display: block; }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 0.08em; text-transform: uppercase; }

/* App switcher (sits between brand and nav) */
.app-switcher {
  display: flex;
  gap: 4px;
  padding: 10px 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.app-tab {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 6px;
  border-radius: 6px;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
  transition: background 120ms, color 120ms;
}
.app-tab:hover { background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.85); }
.app-tab.is-active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.10) inset;
}

/* Nav */
.sidebar nav {
  flex: 1;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section {
  padding: 12px 8px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.25);
}
/* No extra gap before first section */
.nav-section:first-child { padding-top: 4px; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.55);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}
.sidebar nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
  text-decoration: none;
}
.sidebar nav a.is-active {
  color: #fff;
  background: rgba(255,255,255,0.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}
.sidebar nav a.is-active .nav-icon { color: #fff; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.75; }
.sidebar nav a:hover .nav-icon,
.sidebar nav a.is-active .nav-icon { opacity: 1; }

/* Sidebar footer */
.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.20);
  flex-shrink: 0;
}
.sidebar-foot .who {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  margin-bottom: 4px;
}
.sidebar-foot button.link {
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 6px 12px;
  transition: all var(--transition);
}
.sidebar-foot button.link:hover {
  color: #fff;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.08));
  border-color: rgba(255,255,255,0.25);
}

/* Sidebar powered-by */
.sidebar-powered {
  padding: 14px 18px 20px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.powered-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  margin-bottom: 10px;
}
.sidebar-powered svg {
  width: 33%;
  height: auto;
  opacity: 0.7;
}

/* ============================================================================
   Main Area
   ============================================================================ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--page-bg);
}

/* ============================================================================
   Topbar
   ============================================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 58px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.hamburger {
  display: none;
  width: 22px;
  height: 22px;
  cursor: pointer;
  color: var(--text-muted);
  margin-right: 12px;
}
.page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.top-right .user { color: var(--text-muted); font-weight: 500; }
.topbar button.link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.topbar button.link:hover {
  color: var(--brand-strong);
  background: linear-gradient(135deg, rgba(0,0,0,0.08), rgba(0,0,0,0.08));
}

/* ============================================================================
   Content Container
   ============================================================================ */
.content {
  flex: 1;
  padding: 28px;
  width: 100%;
}

/* ============================================================================
   Flash Messages
   ============================================================================ */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  animation: slideDown 180ms ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.flash-success { background: var(--pos-soft);  color: var(--pos-strong); border: 1px solid #86EFAC; }
.flash-error   { background: var(--error-soft); color: #991B1B;          border: 1px solid #FCA5A5; }
.flash-warning { background: var(--warn-soft);  color: #92400E;          border: 1px solid #FDE68A; }

/* ============================================================================
   Page Intro Header
   ============================================================================ */
.page-intro {
  margin-bottom: 24px;
}
.page-intro h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.page-intro p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 680px;
}

/* ============================================================================
   Cards
   ============================================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================================
   Metric Cards
   ============================================================================ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand-gradient);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.metric-card.metric-green::before { background: #444444; }
.metric-card.metric-blue::before  { background: #444444; }
.metric-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

/* Highlighted stat cards with glowing effect */
.metric-card.highlight {
  border-color: rgba(0,0,0,0.15);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.05), var(--shadow);
}
.metric-card.highlight::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.01);
  pointer-events: none;
}

/* Green stat cards matching app lava color */
.metric-card.metric-green {
  border-color: rgba(92,255,148,0.3);
}
.metric-card.metric-green:hover {
  box-shadow: 0 0 12px rgba(92,255,148,0.15), var(--shadow);
}
.metric-num {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}
.metric-value {
  font-size: 42px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.04em;
  margin: 12px 0 4px;
}
.metric-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.metric-sub {
  font-size: 12px;
  color: var(--text-subtle);
}

/* ============================================================================
   Two-column grid
   ============================================================================ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ============================================================================
   Activity Feed
   ============================================================================ */
.activity { list-style: none; }
.activity li {
  padding: 10px 0;
  border-bottom: 1px solid #EFEFEF;
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}
.activity li:last-child { border-bottom: none; }
.activity .ts {
  font-size: 11px;
  color: var(--text-subtle);
  font-family: monospace;
  min-width: 0;
}
.activity strong { color: var(--text); font-weight: 600; }
.activity .muted { color: var(--text-muted); }

/* ============================================================================
   Buttons
   ============================================================================ */
.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }

/* Primary button */
.btn.primary {
  background: #222222;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.20);
}
.btn.primary:hover {
  background: #111111;
  box-shadow: 0 4px 14px rgba(0,0,0,0.30);
  transform: translateY(-1px);
}

/* Secondary button - subtle gradient */
.btn.secondary {
  background: linear-gradient(135deg, #F2F2F2, #EAEAEA);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.btn.secondary:hover {
  background: linear-gradient(135deg, #EAEAEA, #E0E8EB);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Danger button - solid red */
.btn.danger {
  background: var(--error);
  color: #fff;
  box-shadow: 0 2px 8px rgba(226,75,74,0.3);
}
.btn.danger:hover {
  background: #C53030;
  box-shadow: 0 4px 12px rgba(226,75,74,0.4);
  transform: translateY(-1px);
}

/* Success button - solid green */
.btn.success {
  background: var(--positive);
  color: #fff;
  box-shadow: 0 2px 8px rgba(22,163,74,0.3);
}
.btn.success:hover {
  background: #047857;
  box-shadow: 0 4px 12px rgba(22,163,74,0.4);
  transform: translateY(-1px);
}

.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.large { padding: 12px 24px; font-size: 15px; font-weight: 600; }
.btn svg { flex-shrink: 0; }

/* ============================================================================
   Page Actions Bar (index pages)
   ============================================================================ */
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-actions-left h2 {
  font-size: 20px;
  margin-bottom: 2px;
}
.page-actions-left p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ============================================================================
   Filter Bar
   ============================================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-bar select,
.filter-bar input[type="search"],
.filter-bar input[type="text"] {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.filter-bar select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6B82' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.filter-bar select:focus,
.filter-bar input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.15);
}

/* Focus states with gradient accent */
.filter-bar select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232EA8A0' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* ============================================================================
   Data Table
   ============================================================================ */
.data-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead th {
  background: #F7F7F7;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 13px 16px;
  color: var(--text);
  border-bottom: 1px solid #EFEFEF;
  background: #fff;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #F5F5F5; }
.data-table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.data-table a { color: var(--brand); font-weight: 500; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* ============================================================================
   Badges
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-draft    { background: #EFEFEF;  color: #475569;  border: 1px solid #CBD5E1; }
.badge-active   { background: linear-gradient(135deg, rgba(92,255,148,0.15), rgba(77,224,128,0.1));  color: #166534;  border: 1px solid rgba(92,255,148,0.4); }
.badge-paused   { background: #FEF3C7;  color: #92400E;  border: 1px solid #FDE68A; }
.badge-expired  { background: #FEE2E2;  color: #991B1B;  border: 1px solid #FCA5A5; }
.badge-archived { background: #EFEFEF;  color: #64748B;  border: 1px solid #CBD5E1; }
.badge-sent     { background: #DBEAFE;  color: #1E40AF;  border: 1px solid #BFDBFE; }
.badge-type     { background: #F0F0F0; color: #444; border: 1px solid #D0D0D0; }
.badge-create   { background: linear-gradient(135deg, rgba(92,255,148,0.15), rgba(77,224,128,0.1));  color: #166534;  border: 1px solid rgba(92,255,148,0.4); }
.badge-update   { background: #DBEAFE;  color: #1E40AF;  border: 1px solid #BFDBFE; }
.badge-delete   { background: #FEE2E2;  color: #991B1B;  border: 1px solid #FCA5A5; }

/* ============================================================================
   Pagination
   ============================================================================ */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 20px;
  justify-content: center;
}
.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.pagination a:hover { background: var(--surface-hover); box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.pagination a.is-current {
  background: #222222;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.20);
}

/* ============================================================================
   Form Layout — Sections-based
   ============================================================================ */
.edit-form { max-width: 1100px; }

/* Section card used inside the form */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.form-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  background: #F7F7F7;
  border-bottom: 1px solid var(--border);
}
.form-section-header h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.form-section-header p {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 1px;
}
.form-section-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Grid layouts for fields inside sections */
.fields-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.fields-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* Individual field */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field label .optional {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-subtle);
  background: var(--surface-alt);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* All form inputs */
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="url"],
.field input[type="email"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6B82' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.15), inset 0 1px 2px rgba(0,0,0,0.02);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-subtle); }
.field textarea { resize: vertical; min-height: 100px; }

/* Help text under fields */
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}
.field-hint code { font-size: 11px; }
.field-hint strong { color: var(--text); }

/* Char counter */
.char-counter {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-subtle);
  text-align: right;
}

/* Checkbox */
.field-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.field-checkbox:hover {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(0,0,0,0.05), rgba(0,0,0,0.05));
}
.field-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--brand);
  cursor: pointer;
}
.field-checkbox:has(input:checked) {
  border-color: rgba(0,0,0,0.4);
  background: linear-gradient(135deg, rgba(0,0,0,0.08), rgba(0,0,0,0.08));
}
.field-checkbox-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.field-checkbox-text span { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ID display (non-editable) */
.id-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
}
.id-display code { background: none; border: none; padding: 0; font-size: 13px; color: var(--accent); font-weight: 600; }

/* Performance stats row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.stat-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
}
.stat-box .stat-num {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.stat-box .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Form sticky footer actions */
.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 50;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.95));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 -28px -28px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}

/* ============================================================================
   LEGACY FORM HELPERS (kept for .targeting section)
   ============================================================================ */
.edit-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
}

.targeting {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.targeting summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  background: #F7F7F7;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.targeting summary::-webkit-details-marker { display: none; }
.targeting summary::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235A6B82' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--transition);
}
details[open] .targeting summary::before,
.targeting[open] summary::before { transform: rotate(180deg); }

.targeting-body {
  padding: 20px 22px;
}
.target-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.target-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.target-grid label small { font-weight: 400; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.target-grid input,
.target-grid select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.target-grid select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6B82' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.target-grid input:focus,
.target-grid select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.15), inset 0 1px 2px rgba(0,0,0,0.02);
}
.target-grid small code { font-size: 11px; }

/* ============================================================================
   Dashboard — section headers, card title rows, inset tables, empty states
   ============================================================================ */

/* Section divider label above two-col groups */
.dash-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.dash-section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-live  { background: linear-gradient(135deg, #5CFF94, #4DE080); box-shadow: 0 0 0 2px rgba(92,255,148,0.25); }
.dot-draft { background: linear-gradient(135deg, #F59E0B, #EF9F27);  box-shadow: 0 0 0 2px rgba(239,159,39,0.2); }
.dot-perf  { background: #333;   box-shadow: 0 0 0 2px rgba(0,0,0,0.15); }
.dash-section-sub {
  font-weight: 400;
  color: var(--text-muted);
}
.dash-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 9999px;
  background: var(--warn-soft);
  color: #92400E;
  border: 1px solid #FDE68A;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* Card title + action in same row */
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title-row .card-title { margin: 0; }

/* Tables inset inside cards (no outer border/shadow — card provides it) */
.inset-table { border-radius: 0; }
.inset-table thead th { background: #F7F7F7; }
.inset-table tbody tr:last-child td { border-bottom: none; }
/* Remove top margin from first inset row */
.inset-table thead th:first-child { border-radius: 0; }

/* Activate button — solid gradient green */
.activate-btn {
  color: #fff !important;
  border: none !important;
  background: linear-gradient(135deg, #5CFF94, #4DE080) !important;
  box-shadow: 0 2px 8px rgba(92,255,148,0.3);
}
.activate-btn:hover {
  background: linear-gradient(135deg, #4DE080, #3DC070) !important;
  box-shadow: 0 4px 12px rgba(92,255,148,0.4);
  transform: translateY(-1px);
}

/* Empty state inside a card */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 13px; line-height: 1.6; margin: 0; }

/* ============================================================================
   Settings Page
   ============================================================================ */
.settings-rows { display: flex; flex-direction: column; }

.setting-row {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
  padding: 20px 24px;
  border-bottom: 1px solid #EFEFEF;
  transition: background var(--transition);
}
.setting-row:last-child { border-bottom: none; }
.setting-row:hover { background: #FAFCFE; }

.setting-key {
  display: inline-block;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #1D4ED8;
  background: #EEF2FF;
  border: 1px solid #C7D2FE;
  padding: 3px 9px;
  border-radius: 5px;
  margin-bottom: 8px;
}
.setting-description {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.setting-control { display: flex; flex-direction: column; gap: 8px; }
.setting-input-row { display: flex; gap: 10px; align-items: center; }
.setting-input-row input[type="text"] {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.setting-input-row input[type="text"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.15), inset 0 1px 2px rgba(0,0,0,0.02);
}
.setting-meta {
  font-size: 12px;
  color: var(--text-subtle);
}

/* ============================================================================
   Analytics Page
   ============================================================================ */
.analytics-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.range-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.range-label select {
  height: 36px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6B82' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.range-label select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.12);
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  min-height: 320px;
  position: relative;
}
.chart-card canvas {
  width: 100% !important;
}

/* Category filter rows */
.cat-filter-row {
  transition: opacity 180ms ease, background 180ms ease;
}
.cat-filter-row:hover {
  background: var(--surface-hover) !important;
  opacity: 1 !important;
}
.cat-filter-row td:first-child::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 180ms ease;
}
.cat-filter-row.is-selected td:first-child::after {
  opacity: 1;
}

/* Numeric cells in analytics table */
.num-cell {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  color: var(--text);
}
.ctr-cell {
  text-align: right;
  font-weight: 700;
  font-size: 13px;
  color: #4DE080;
}

/* ============================================================================
   Hint / Help Text (legacy areas)
   ============================================================================ */
.hint, small.hint {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.55;
  margin-top: 4px;
}
.hint code { font-size: 11px; }
.hint strong { color: var(--text); }
.hint p { margin: 4px 0; }
.hint ol, .hint ul { margin: 4px 0 4px 18px; padding: 0; }
.hint .warning {
  display: block;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--warn-soft);
  color: #92400E;
  border-radius: var(--radius-sm);
  border: 1px solid #FDE68A;
  font-size: 12px;
}

/* Generic muted text */
.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* ============================================================================
   Login Page
   ============================================================================ */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ECECEC 0%, #F2F2F2 60%, #F0F0F0 100%);
}
.login-body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 25%, rgba(0,0,0,0.12) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 75%, rgba(0,0,0,0.08) 0%, transparent 55%);
  pointer-events: none;
}
.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
}
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-brand-icon { width: 38px; height: 38px; }
.login-brand h1 { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}
.login-card label span { display: block; margin-bottom: 5px; }
.login-card input {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.login-card input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.15);
}
.login-card input::placeholder { color: var(--text-subtle); }
.login-card button.primary {
  width: 100%;
  padding: 12px;
  background: var(--brand-gradient);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transition: all var(--transition);
}
.login-card button.primary:hover {
  background: var(--brand-gradient-hover);
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
  transform: translateY(-1px);
}
.login-error {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--error-soft);
  color: #991B1B;
  border-radius: var(--radius);
  border: 1px solid #FCA5A5;
  font-size: 14px;
  text-align: center;
}

.login-hint {
  margin-top: 16px;
  font-size: 13px;
  text-align: center;
  color: var(--text-subtle);
}
.login-hint a { color: var(--text-subtle); }

/* ============================================================================
   Audit Log
   ============================================================================ */
.audit-diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
  min-width: 400px;
}
.audit-diff > div {
  min-width: 0;
}
.audit-diff pre {
  font-size: 11px;
  line-height: 1.5;
  padding: 12px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.diff-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 4px;
}
details.audit-details summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.3);
  background: var(--brand-light);
  transition: all var(--transition);
}
details.audit-details summary::-webkit-details-marker { display: none; }
details.audit-details summary:hover { background: rgba(0,0,0,0.15); }
details.audit-details[open] {
  padding: 8px 0;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 1024px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col     { grid-template-columns: 1fr; }
  .fields-grid-2, .fields-grid-3 { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; }
  .setting-row .setting-key { display: inline-block; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 220ms ease-out;
  }
  .navtoggle:checked ~ .layout .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; align-items: center; justify-content: center; }

  .content { padding: 16px; }
  .topbar { padding: 0 16px; }

  .metric-grid { grid-template-columns: 1fr; }
  .target-grid { grid-template-columns: 1fr; }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .edit-grid   { grid-template-columns: 1fr; }

  .form-actions { padding: 12px 16px; margin: 0 -16px -16px; }

  .data-table-wrapper { margin: 0 -16px; border-radius: 0; border-left: none; border-right: none; }
}

@media (max-width: 480px) {
  .login-card { margin: 16px; padding: 24px; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   Template expressions help panel + preview output
   ============================================================================ */
.template-help .targeting-body { padding-top: 12px; }
.template-help h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.template-help .data-table { margin-top: 4px; margin-bottom: 8px; }
.template-help code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color: var(--text);
}

.example-block {
  margin-top: 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.example-label {
  padding: 8px 14px;
  background: #eef3f9;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.example-code {
  padding: 12px 14px;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
}

.rules-callout {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef9e7;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 12px;
  color: #78350f;
  line-height: 1.6;
}
.rules-callout strong { display: block; margin-bottom: 6px; color: #713f12; }
.rules-callout ul { margin: 0; padding-left: 18px; }
.rules-callout li { margin-bottom: 4px; }
.rules-callout code {
  background: rgba(255, 255, 255, 0.7);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: #713f12;
}

/* ----- preview output ----- */
.preview-out {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.55;
}
.preview-out.ok {
  background: linear-gradient(135deg, rgba(92,255,148,0.12), rgba(77,224,128,0.08));
  border: 1px solid rgba(92,255,148,0.4);
  color: #064e3b;
}
.preview-out.ok .preview-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  color: #047857;
}
.preview-out.ok .preview-body { color: #065f46; }
.preview-out.err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
}
.preview-out.err strong { display: block; margin-bottom: 4px; font-family: 'Inter', sans-serif; font-size: 13px; }
.preview-out .preview-row { margin-top: 6px; }
.preview-out .preview-row-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

/* ── Colour swatch & picker ─────────────────────────────────── */
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1.5px solid #ddd;
  flex-shrink: 0;
}

/* Native color input styling */
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}
input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 6px;
}

/* ============================================================================
   Phone mockup preview
   ============================================================================ */
.phone-mockup-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.phone-mockup-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-subtle, #8896AB);
}
.phone-mockup {
  position: relative;
  width: 218px;
  height: 440px;
  background: url('/images/phone_mockup.svg') no-repeat top center / contain;
  flex-shrink: 0;
}
.phone-content {
  position: absolute;
  top: 191px;
  left: 15px;
  width: 192px;
  height: 196px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
}

/* ============================================================================
   Reminder card preview (matches Flutter _card() styling)
   ============================================================================ */
.reminder-preview-card {
  position: relative;
  padding: 10px;
  border-radius: 11px;
  border: 1px solid #BFDBFE;
  margin-bottom: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}
.rpc-dismiss {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 12px;
  color: rgba(90,107,130,0.5);
  cursor: default;
}
.rpc-inner {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.rpc-image {
  width: 32px;
  height: 32px;
  border-radius: 5px;
  object-fit: contain;
  flex-shrink: 0;
}
.rpc-content { flex: 1; min-width: 0; }
.rpc-title {
  font-size: 8px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 2px;
  padding-right: 14px;
}
.rpc-body {
  font-size: 7px;
  font-weight: 400;
  line-height: 1.5;
  color: #5A6B82;
}
.rpc-link {
  font-size: 6px;
  font-weight: 600;
  text-decoration: underline;
  margin-top: 3px;
}

/* Full-size preview (used on test status / edit page) */
.reminder-preview-card.full-size {
  padding: 16px;
  border-radius: 18px;
  margin-bottom: 12px;
  max-width: 400px;
}
.full-size .rpc-image { width: 56px; height: 56px; border-radius: 8px; }
.full-size .rpc-inner { gap: 12px; }
.full-size .rpc-title { font-size: 13px; margin-bottom: 4px; }
.full-size .rpc-body { font-size: 12px; }
.full-size .rpc-link { font-size: 11px; margin-top: 8px; }
.full-size .rpc-dismiss { font-size: 16px; top: 8px; right: 12px; }

/* ============================================================================
   Status badges for new workflow stages
   ============================================================================ */
.badge-test { color: #1e40af; background: #dbeafe; }
.badge-debug_deploy { color: #92400e; background: #fef3c7; }
.badge-sent { color: #047857; background: #ecfdf5; }

/* ============================================================================
   Status-grouped workflow sections (reminders/notifications list)
   ============================================================================ */
.workflow-section {
  margin-bottom: 24px;
}
.workflow-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.workflow-header .count-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  color: inherit;
}
.wh-draft        { background: #f1f5f9; color: #475569; }
.wh-test         { background: #fee2e2; color: #dc2626; }
.wh-debug_deploy { background: #fef9c3; color: #ca8a04; }
.wh-active       { background: #dcfce7; color: #16a34a; }
.wh-paused       { background: #fff7ed; color: #9a3412; }
.wh-expired      { background: #fef2f2; color: #991b1b; }
.wh-archived     { background: #f1f5f9; color: #64748b; }
.wh-sent         { background: #ecfdf5; color: #047857; }

.workflow-body {
  padding: 12px 0;
}
.workflow-hint {
  font-size: 12px;
  color: var(--text-muted, #8896AB);
  margin-bottom: 12px;
  padding: 0 4px;
}

/* ============================================================================
   Dashboard branded header banner
   ============================================================================ */
.dash-banner {
  background: var(--brand-gradient);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.15);
}
.dash-banner::after {
  content: '';
  position: absolute;
  top: -40%; right: -10%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,0.10) 0%, transparent 70%);
  pointer-events: none;
}
.dash-banner h1 {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.dash-banner p {
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 500;
  margin: 0;
}

/* ============================================================================
   Dashboard metrics enhancements
   ============================================================================ */
.metric-grid-6 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card .metric-delta {
  font-size: 11px;
  margin-top: 4px;
  font-weight: 500;
}
.metric-delta.up { color: #4DE080; font-weight: 600; }
.metric-delta.down { color: #DC2626; }
.metric-delta.neutral { color: var(--text-muted, #8896AB); }

.stacked-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
  background: #f1f5f9;
}
.stacked-bar span {
  display: block;
  height: 100%;
  min-width: 2px;
}
.sb-draft { background: #94a3b8; }
.sb-test { background: #3b82f6; }
.sb-debug_deploy { background: #f59e0b; }
.sb-active { background: linear-gradient(135deg, #5CFF94, #4DE080); }
.sb-paused { background: #f97316; }
.sb-expired { background: #ef4444; }
.sb-archived { background: #64748b; }
.sb-sent { background: linear-gradient(135deg, #5CFF94, #4DE080); }

.stacked-bar-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted, #8896AB);
}
.stacked-bar-legend span::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.sbl-draft::before { background: #94a3b8; }
.sbl-test::before { background: #3b82f6; }
.sbl-debug_deploy::before { background: #f59e0b; }
.sbl-active::before { background: linear-gradient(135deg, #5CFF94, #4DE080); }
.sbl-paused::before { background: #f97316; }

.dash-phone-col {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  margin-bottom: 28px;
}
.dash-phone-col .card { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .metric-grid-6 { grid-template-columns: 1fr 1fr; }
  .dash-phone-col { flex-direction: column; }
}
@media (max-width: 600px) {
  .metric-grid-6 { grid-template-columns: 1fr; }
}

/* ============================================================================
   Two-column split: left content + right phone preview
   ============================================================================ */
.dash-split {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}
.dash-left {
  flex: 1;
  min-width: 0;
}
.dash-right {
  /* width set by phone scale selector */
  flex-shrink: 0;
  position: sticky;
  top: 80px;
}
@media (max-width: 1100px) {
  .dash-split { flex-direction: column; }
  .dash-right { position: static; }
}

/* ============================================================================
   Large phone mockup (right column)
   ============================================================================ */
.phone-preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
/* Phone size controlled by JS via inline width/height.
   Base: 218×440 (0.5x SVG). Scales: 0.5x=218, 1x=436, 2x=872, 3x=1308.
   Size selector persists to localStorage. Default is 2x. */
.phone-mockup-large {
  width: 436px;  /* overridden by JS */
  height: 880px;
}
.phone-content-large {
  top: 43.5%;
  left: 6.65%;
  width: 88.1%;
  height: 44.4%;
  padding: 2.3%;
  container-type: inline-size;
}
.phone-content-large .reminder-preview-card {
  padding: 3.8%;
  border-radius: clamp(8px, 4cqi, 18px);
  margin-bottom: 2%;
}
.phone-content-large .rpc-title { font-size: clamp(6px, 3.4cqi, 14px); margin-bottom: 1%; }
.phone-content-large .rpc-body { font-size: clamp(5px, 3cqi, 12px); line-height: 1.5; }
.phone-content-large .rpc-link { font-size: clamp(4px, 2.6cqi, 11px); margin-top: 1.5%; }
.phone-content-large .rpc-image { width: 13%; height: auto; aspect-ratio: 1; border-radius: clamp(4px, 2cqi, 8px); }
.phone-content-large .rpc-dismiss { font-size: clamp(6px, 3.5cqi, 16px); top: 2%; right: 2%; }
.phone-content-large .rpc-inner { gap: 2.5%; }
.phone-content-large .rpc-error-badge { font-size: clamp(4px, 2cqi, 9px); }

.phone-card-wrap { position: relative; }
.phone-card-status-dot {
  position: absolute;
  top: 4px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 1;
  border: 1.5px solid #fff;
}
.status-dot-test { background: #3b82f6; }
.status-dot-debug_deploy { background: #f59e0b; }
.status-dot-active { background: #16a34a; }
.status-dot-inline {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 2px 0 8px;
  vertical-align: middle;
}

.phone-caption {
  font-size: 11px;
  color: var(--text-subtle, #8896AB);
  text-align: center;
}
.phone-empty {
  text-align: center;
  padding: 60px 12px;
  font-size: 11px;
  color: var(--text-subtle, #8896AB);
}

/* ============================================================================
   Template error styling in card preview
   ============================================================================ */
.tpl-error {
  color: #DC2626 !important;
  background: #FEF2F2;
  padding: 0 3px;
  border-radius: 3px;
  border-bottom: 2px solid #DC2626;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  cursor: help;
}
.tpl-resolved {
  font-weight: 600;
}
.rpc-error-badge {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 6px;
  font-weight: 700;
  text-transform: uppercase;
  color: #DC2626;
  background: #FEF2F2;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: .03em;
}
.reminder-preview-card.has-errors {
  box-shadow: 0 0 0 2px #FCA5A5;
}
.tpl-warn {
  font-size: 11px;
  color: #DC2626;
  font-weight: 600;
  margin-top: 2px;
}

/* ============================================================================
   Mock value editor
   ============================================================================ */
/* ============================================================================
   Modal
   ============================================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
}
.modal-overlay.is-open {
  display: flex;
}
.modal-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.modal-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mock-editor {
  margin-top: 16px;
}
.mock-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mock-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-subtle, #8896AB);
  margin-bottom: 4px;
}
.mock-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.mock-row label {
  flex: 1;
  min-width: 0;
}
.mock-row label code {
  font-size: 11px;
}
.mock-row input {
  padding: 4px 6px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  text-align: right;
}
.mock-unit {
  font-size: 10px;
  color: var(--text-muted, #8896AB);
  width: 30px;
}

/* Phone size selector */
.phone-size-selector {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 8px;
}
.phone-size-btn {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border, #E5E9EF);
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted, #8896AB);
  transition: all 0.15s;
}
.phone-size-btn:hover { border-color: #333; color: #333; }
.phone-size-btn.is-active {
  background: #222;
  border-color: #222;
  color: #fff;
}
