/**
 * Riterly App — Design System
 * Version: 2.0 — April 2026
 * Source: docs/branding/design-system/riterly-design-system.css
 * Cross-reference: BRAND_VISUALS.md, BRAND_VOICE.md
 *
 * THREE CONTEXTS:
 *   Context 1 — Marketing site (not covered here)
 *   Context 2 — App UI (dashboard, kanban, settings, admin overview)
 *   Context 3 — Editor environment (always dark, deep teal)
 *
 * TOKEN ARCHITECTURE:
 *   1. Brand tokens   — raw palette, defined once, never used directly in components
 *   2. Semantic tokens — usage-based layer, the ONLY layer components reference
 *   3. Compat aliases  — old token names forwarded to semantic layer (backward compat)
 */

/* ══════════════════════════════════════════════════════════════════════════════
   1. BRAND TOKENS — raw palette, never used in components
   ══════════════════════════════════════════════════════════════════════════════ */
:root {
  /* Primary teal palette — from BRAND_VISUALS.md */
  --brand-deep:        #04342C;   /* Hero backgrounds, nav, editor env */
  --brand-teal:        #0F6E56;   /* Secondary surfaces, action hover */
  --brand-mid:         #1D9E75;   /* CTAs, primary buttons, positive status */
  --brand-light:       #9FE1CB;   /* Subheads on dark, secondary links on dark */

  /* Neutral palette */
  --brand-off-white:   #F1EFE8;   /* Light mode page background */
  --brand-stone:       #D3D1C7;   /* Body text on dark, muted surfaces */
  --brand-near-black:  #2C2C2A;   /* Primary text on light */
  --brand-charcoal:    #5F5E5A;   /* Secondary text, captions, metadata */

  /* Status palette — defined once here, consumed via semantic tokens */
  --brand-success-bg:      #E1F5EE;
  --brand-success-text:    #085041;
  --brand-warning-bg:      #FEF3C7;
  --brand-warning-text:    #92400E;
  --brand-warning-fill:    #F59E0B;
  --brand-danger-bg:       #FEE2E2;
  --brand-danger-text:     #991B1B;
  --brand-danger-fill:     #EF4444;
}

/* ══════════════════════════════════════════════════════════════════════════════
   2. SEMANTIC TOKENS — components use ONLY these
   ══════════════════════════════════════════════════════════════════════════════ */
:root {
  /* ── Page & surfaces ─────────────────────────────────────────────────────── */
  --color-bg-page:         var(--brand-off-white);
  --color-bg-surface:      #FFFFFF;                    /* Card / panel lift on off-white page */
  --color-bg-nav:          var(--brand-deep);
  --color-bg-header:       rgba(241, 239, 232, 0.40);  /* Section-block and table headers */
  --color-bg-table-head:   rgba(241, 239, 232, 0.25);  /* Table <thead> cells */
  --color-bg-kanban:       rgba(44,  44,  42,  0.04);  /* Kanban column background */

  /* ── Text ────────────────────────────────────────────────────────────────── */
  --color-text-primary:    var(--brand-near-black);
  --color-text-secondary:  var(--brand-charcoal);
  --color-text-muted:      var(--brand-stone);
  --color-text-on-dark:    var(--brand-off-white);
  --color-text-accent:     var(--brand-deep);           /* Page titles, cost values */
  --color-text-link:       var(--brand-mid);

  /* ── Borders ─────────────────────────────────────────────────────────────── */
  --color-border-subtle:   rgba(44, 44, 42, 0.08);     /* Default component border */
  --color-border-default:  rgba(44, 44, 42, 0.15);     /* Stronger border when needed */
  --color-border-warm:     var(--brand-stone);          /* Chips, inputs, count badges */
  --color-border-row:      rgba(44, 44, 42, 0.05);     /* Table row separator */

  /* ── Actions ─────────────────────────────────────────────────────────────── */
  --color-action-primary:       var(--brand-mid);
  --color-action-primary-hover: var(--brand-teal);
  --color-action-text:          var(--brand-off-white); /* Text on filled action elements */

  /* ── Navigation overlays (on deep teal surfaces) ─────────────────────────── */
  --color-nav-text:        rgba(241, 239, 232, 0.60);  /* Default nav link text */
  --color-nav-text-active: var(--brand-off-white);      /* Active nav link text */
  --color-nav-icon:        rgba(159, 225, 203, 0.50);  /* Default nav icon */
  --color-nav-icon-active: var(--brand-light);
  --color-nav-label:       rgba(159, 225, 203, 0.30);  /* Sidebar section labels */
  --color-nav-border:      rgba(159, 225, 203, 0.06);  /* Sidebar outer edge */
  --color-nav-divider:     rgba(159, 225, 203, 0.07);  /* Sidebar internal dividers */
  --color-nav-hover:       rgba(159, 225, 203, 0.08);  /* Nav item hover bg */
  --color-nav-active:      rgba(159, 225, 203, 0.14);  /* Nav item active bg */
  --color-nav-tint:        rgba(159, 225, 203, 0.15);  /* Topbar user border, trial bar */
  --color-nav-dim:         rgba(241, 239, 232, 0.10);  /* Topbar hairline divider */

  /* ── Interactive states ──────────────────────────────────────────────────── */
  --color-row-hover:       rgba(29, 158, 117, 0.025);  /* Table row hover */
  --color-surface-hover:   rgba(241, 239, 232, 0.50);  /* Collapsible header hover */

  /* ── Status ──────────────────────────────────────────────────────────────── */
  --color-status-success-bg:   var(--brand-success-bg);
  --color-status-success-text: var(--brand-success-text);
  --color-status-success-fill: var(--brand-mid);
  --color-status-warning-bg:   var(--brand-warning-bg);
  --color-status-warning-text: var(--brand-warning-text);
  --color-status-warning-fill: var(--brand-warning-fill);
  --color-status-danger-bg:    var(--brand-danger-bg);
  --color-status-danger-text:  var(--brand-danger-text);
  --color-status-danger-fill:  var(--brand-danger-fill);
}

/* ══════════════════════════════════════════════════════════════════════════════
   3. BACKWARD COMPATIBILITY ALIASES
   Old token names forwarded to the semantic layer.
   Twig template <style> blocks and page-specific CSS continue to work unchanged.
   ══════════════════════════════════════════════════════════════════════════════ */
:root {
  --color-teal-deep:    var(--brand-deep);
  --color-teal-mid:     var(--brand-teal);
  --color-teal-brand:   var(--color-action-primary);
  --color-teal-light:   var(--brand-light);
  --color-off-white:    var(--brand-off-white);
  --color-warm-mid:     var(--color-border-warm);
  --color-stone:        var(--brand-stone);
  --color-ink:          var(--color-text-primary);
  --color-charcoal:     var(--color-text-secondary);
  --color-success-bg:   var(--color-status-success-bg);
  --color-success-text: var(--color-status-success-text);
  --color-warning-bg:   var(--color-status-warning-bg);
  --color-warning-text: var(--color-status-warning-text);
  --color-danger-bg:    var(--color-status-danger-bg);
  --color-danger-text:  var(--color-status-danger-text);
  --color-surface:      var(--color-bg-surface);
  --color-border:       var(--color-border-subtle);
  --color-border-strong:var(--color-border-default);

  /* Sidebar tokens — kept as aliases; sidebar components now use nav tokens */
  --sidebar-bg:         var(--color-bg-nav);
  --sidebar-hover:      var(--color-nav-hover);
  --sidebar-active:     var(--color-nav-active);
  --sidebar-text:       var(--color-nav-text);
  --sidebar-text-active:var(--color-nav-text-active);
  --sidebar-icon:       var(--color-nav-icon);
  --sidebar-icon-active:var(--color-nav-icon-active);
  --topbar-bg:          var(--color-bg-nav);
}

/* ══════════════════════════════════════════════════════════════════════════════
   4. LAYOUT, TYPOGRAPHY, SPACING, SHAPE & EFFECT TOKENS
   ══════════════════════════════════════════════════════════════════════════════ */
:root {
  /* Layout */
  --sidebar-width:  220px;
  --topbar-height:  52px;

  /* Typography */
  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-sans:  'Inter', system-ui, sans-serif;
  --font-mono:  'DM Mono', 'Fira Code', 'Courier New', monospace;

  /* Type scale — UI (App Context 2, 1rem = 16px base) */
  --text-2xs:      0.625rem;    /* 10px — avatars, compact badges */
  --text-xs:       0.6875rem;   /* 11px — labels, metadata */
  --text-sm:       0.75rem;     /* 12px — table content, secondary */
  --text-base:     0.8125rem;   /* 13px — body, UI default */
  --text-md:       0.875rem;    /* 14px — slightly elevated body */
  --text-lg:       1rem;        /* 16px — section headings */
  --text-xl:       1.25rem;     /* 20px — page titles (sans) */
  --text-display:  2rem;        /* 32px — stat values */
  --text-serif-lg: 1.5rem;      /* 24px — page titles (serif) */

  /* Logo-specific sizing — not general typography */
  --text-logo-mark: 1.6rem;
  --text-logo-name: 0.82rem;

  /* Spacing — strict 4px scale */
  --space-1:  0.25rem;   /* 4px  */
  --space-2:  0.5rem;    /* 8px  */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   10px;
  --radius-xl:   12px;
  --radius-pill: 100px;

  /* Shadows — tinted with brand deep teal */
  --shadow-sm: 0 1px 3px  rgba(4, 52, 44, 0.06);
  --shadow-md: 0 4px 16px rgba(4, 52, 44, 0.08);
  --shadow-lg: 0 8px 32px rgba(4, 52, 44, 0.12);

  /* Transitions */
  --transition: 0.15s ease;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESET
   ══════════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg-page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── SEMANTIC TEXT ROLES ───────────────────────────────────────────────────── */
.text-heading {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1.4;
}
.text-body {
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--color-text-primary);
  line-height: 1.6;
}
.text-label {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.text-meta {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
}

/* ── APP SHELL ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}
.app-shell.admin {
  grid-template-columns: 1fr;
  grid-template-areas:
    "topbar"
    "main";
}

/* ── TOP BAR ───────────────────────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  background: var(--color-bg-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--color-nav-divider);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-logo {
  display: flex;
  align-items: baseline;
  text-decoration: none;
  line-height: 1;
  gap: 0;
}
.logo-R {
  font-family: 'Trajan Pro', Georgia, serif;
  font-size: var(--text-logo-mark);
  font-weight: 400;
  color: var(--color-text-on-dark);
  line-height: 1;
  letter-spacing: -0.01em;
}
.logo-iterly {
  font-family: var(--font-sans);
  font-size: var(--text-logo-name);
  font-weight: 400;
  color: var(--brand-light);
  letter-spacing: 0.04em;
  position: relative;
  top: -0.28rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.topbar-link {
  font-size: var(--text-sm);
  color: var(--color-nav-text);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.topbar-link:hover { color: var(--brand-light); background: var(--color-nav-hover); }

.topbar-divider {
  width: 1px;
  height: 14px;
  background: var(--color-nav-dim);
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-nav-tint);
  background: var(--color-nav-hover);
  text-decoration: none;
  transition: background var(--transition);
}
.topbar-user:hover { background: var(--color-nav-active); }
.topbar-user-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--color-action-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--color-action-text);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.topbar-user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-on-dark);
}

/* Admin context badge in topbar */
.topbar-admin-badge {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--brand-light);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── SIDEBAR ───────────────────────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  background: var(--color-bg-nav);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-nav-border);
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
}

.sidebar-section {
  padding: var(--space-6) 0 var(--space-4);
}
.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--color-nav-divider);
  padding-top: var(--space-4);
}

.sidebar-label {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-nav-label);
  padding: 0 var(--space-5);
  margin-bottom: var(--space-2);
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: 0 var(--space-3);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-nav-text);
  font-size: var(--text-sm);
  font-weight: 400;
  transition: color var(--transition), background var(--transition);
  letter-spacing: 0.01em;
}
.sidebar-nav a:hover {
  color: var(--color-nav-text-active);
  background: var(--color-nav-hover);
}
.sidebar-nav a.active {
  color: var(--color-nav-text-active);
  background: var(--color-nav-active);
  font-weight: 500;
}
.sidebar-nav a.active .nav-icon { color: var(--color-nav-icon-active); }

.sidebar-nav .nav-link-disabled {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--color-nav-text);
  letter-spacing: 0.01em;
  opacity: 0.4;
  cursor: default;
  user-select: none;
  pointer-events: none;
}
.sidebar-nav .nav-link-disabled .nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--color-nav-icon);
}

.nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--color-nav-icon);
  transition: color var(--transition);
}
.nav-icon svg {
  width: 100%; height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-action-primary);
  color: var(--color-action-text);
  font-size: var(--text-2xs);
  font-weight: 500;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
  line-height: 1.6;
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--color-nav-divider);
}

/* ── SIDEBAR TRIAL WIDGET ──────────────────────────────────────────────────── */
.sidebar-trial {
  background: var(--color-nav-hover);
  border: 1px solid var(--color-nav-active);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.sidebar-trial-label {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-nav-icon);
  margin-bottom: var(--space-1);
}
.sidebar-trial-days {
  font-size: var(--text-sm);
  color: var(--color-text-on-dark);
  font-weight: 500;
  margin-bottom: var(--space-1);
}
.sidebar-trial-bar {
  height: 3px;
  background: var(--color-nav-tint);
  border-radius: 2px;
  margin-bottom: var(--space-3);
  overflow: hidden;
}
.sidebar-trial-bar-fill {
  height: 100%;
  background: var(--color-action-primary);
  border-radius: 2px;
}
.sidebar-trial-link {
  font-size: var(--text-xs);
  color: var(--brand-light);
  text-decoration: none;
  font-weight: 500;
}
.sidebar-trial-link:hover { text-decoration: underline; }

/* ── ADMIN SUBNAV ──────────────────────────────────────────────────────────── */
.admin-subnav {
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  height: 44px;
  gap: var(--space-1);
  position: sticky;
  top: var(--topbar-height);
  z-index: 50;
}
.admin-subnav a {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 0 var(--space-4);
  height: 44px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.admin-subnav a:hover { color: var(--color-text-primary); }
.admin-subnav a.active {
  color: var(--color-action-primary);
  font-weight: 500;
  border-bottom-color: var(--color-action-primary);
}

/* ── MAIN CONTENT ──────────────────────────────────────────────────────────── */
.main-content {
  grid-area: main;
  padding: var(--space-8) var(--space-8) var(--space-12);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.main-content.admin {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ── APP FOOTER ────────────────────────────────────────────────────────────── */
.app-footer {
  margin-top: auto;
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  flex-shrink: 0;
}
.app-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}
.app-footer a:hover { color: var(--color-text-primary); }

/* ── PAGE HEADER ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.page-title {
  font-family: var(--font-serif);
  font-size: var(--text-serif-lg);
  font-weight: 400;
  color: var(--color-text-accent);
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}
.page-title-sub {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-secondary);
  letter-spacing: 0.01em;
}

/* ── SECTION LABEL ─────────────────────────────────────────────────────────── */
.section-label {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.section-label::before {
  content: '';
  width: 3px; height: 12px;
  background: var(--color-action-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── STAT CARDS ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }

.stat-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--color-action-primary);
  opacity: 0.4;
}
.stat-card.accent::before  { opacity: 1; }
.stat-card.warning::before { background: var(--color-status-warning-fill); opacity: 1; }
.stat-card.danger::before  { background: var(--color-status-danger-fill);  opacity: 1; }

.stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-icon {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  background: var(--color-status-success-bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg {
  width: 12px; height: 12px;
  stroke: var(--color-status-success-text);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stat-icon.warning          { background: var(--color-status-warning-bg); }
.stat-icon.warning svg      { stroke: var(--color-status-warning-text); }
.stat-icon.danger           { background: var(--color-status-danger-bg); }
.stat-icon.danger svg       { stroke: var(--color-status-danger-text); }

.stat-value {
  font-family: var(--font-serif);
  font-size: var(--text-display);
  font-weight: 400;
  color: var(--color-text-accent);
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-value.danger  { color: var(--color-status-danger-text); }
.stat-value.warning { color: var(--color-status-warning-text); }

.stat-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* ── SECTION BLOCK (tables, lists) ────────────────────────────────────────── */
.section-block {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.section-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-bg-header);
}
.section-block-title {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.section-block-title::before {
  content: '';
  width: 3px; height: 12px;
  background: var(--color-action-primary);
  border-radius: 2px;
}
.section-block-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-bg-page);
  border: 1px solid var(--color-border-warm);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
}

/* ── TABLES ────────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  padding: var(--space-3) var(--space-6);
  text-align: left;
  background: var(--color-bg-table-head);
  border-bottom: 1px solid var(--color-border-subtle);
}
thead th.right { text-align: right; }
tbody tr {
  border-bottom: 1px solid var(--color-border-row);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--color-row-hover); }
tbody td {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  vertical-align: middle;
}
tbody td.right { text-align: right; }
tbody td.muted { color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
tbody td.cost  { font-weight: 500; color: var(--color-text-accent); font-variant-numeric: tabular-nums; text-align: right; }

/* ── BUTTONS ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-action-primary);
  color: var(--color-action-text);
}
.btn-primary:hover {
  background: var(--color-action-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  color: var(--color-action-text);
}
.btn-ghost {
  background: transparent;
  color: var(--color-action-primary);
  border: 1px solid var(--color-action-primary);
}
.btn-ghost:hover { background: var(--color-status-success-bg); }
.btn-sm { font-size: var(--text-xs); padding: var(--space-1) var(--space-3); }

/* ── CHIPS / TAGS ──────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
}
.chip::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chip-success { background: var(--color-status-success-bg); color: var(--color-status-success-text); }
.chip-success::before { background: var(--color-status-success-fill); }
.chip-warning { background: var(--color-status-warning-bg); color: var(--color-status-warning-text); }
.chip-warning::before { background: var(--color-status-warning-fill); }
.chip-danger  { background: var(--color-status-danger-bg);  color: var(--color-status-danger-text); }
.chip-danger::before  { background: var(--color-status-danger-fill); }
.chip-neutral { background: var(--color-bg-page); color: var(--color-text-secondary); border: 1px solid var(--color-border-warm); }
.chip-neutral::before { background: var(--color-text-muted); }

/* ── CODE / OPERATION NAMES ────────────────────────────────────────────────── */
.op-name {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-status-success-text);
  background: var(--color-status-success-bg);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* ── COST BAR ──────────────────────────────────────────────────────────────── */
.cost-bar-wrap { display: flex; align-items: center; gap: var(--space-3); justify-content: flex-end; }
.cost-bar { height: 4px; border-radius: 2px; background: var(--color-status-success-bg); position: relative; overflow: hidden; width: 60px; flex-shrink: 0; }
.cost-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--color-action-primary); }

/* ── STATUS PANEL ──────────────────────────────────────────────────────────── */
.status-panel {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
}
.status-panel .chip { flex-shrink: 0; }
.status-panel a {
  color: var(--color-text-link);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm);
}
.status-panel a:hover { text-decoration: underline; }

/* Modifier: constrained width for single-line registration mode panels */
.status-panel--narrow { max-width: 520px; }

/* Text and action elements within a status panel */
.status-panel-text {
  color: var(--color-text-secondary);
  font-size: var(--text-base);
}
.status-panel-action {
  margin-left: auto;
  white-space: nowrap;
}

/* ── KANBAN ────────────────────────────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  align-items: start;
}
.kanban-col {
  background: var(--color-bg-kanban);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-subtle);
  overflow: hidden;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border-subtle);
}
.kanban-col-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-primary);
}
.kanban-col-count {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  background: var(--color-bg-page);
  border: 1px solid var(--color-border-warm);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500;
}
.kanban-col-body {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 120px;
}
.kanban-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

/* Kanban card */
.kcard {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
  position: relative;
}
.kcard:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kcard-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1.4;
  margin-bottom: var(--space-2);
  padding-right: var(--space-5);
}
.kcard-excerpt {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kcard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.kcard-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.kcard-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.kcard-action {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-action-primary);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-status-success-bg);
  transition: background var(--transition);
}
.kcard-action:hover { background: var(--brand-light); color: var(--color-text-accent); }
.kcard-close {
  position: absolute;
  top: var(--space-3); right: var(--space-3);
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid var(--color-border-warm);
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  font-size: var(--text-2xs);
  transition: background var(--transition), color var(--transition);
}
.kcard-close:hover { background: var(--color-status-danger-bg); color: var(--color-status-danger-text); border-color: transparent; }

/* ── TIME FILTER ───────────────────────────────────────────────────────────── */
.time-filter {
  display: flex;
  align-items: center;
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  gap: var(--space-1);
  width: fit-content;
  margin-bottom: var(--space-6);
}
.tf-btn {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color var(--transition), background var(--transition);
}
.tf-btn:hover { color: var(--color-text-primary); background: var(--color-bg-page); }
.tf-btn.active { background: var(--color-action-primary); color: var(--color-action-text); font-weight: 500; }

/* ── USER AVATAR ───────────────────────────────────────────────────────────── */
.user-cell { display: flex; align-items: center; gap: var(--space-3); }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--color-text-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--brand-light);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.user-name  { font-weight: 500; color: var(--color-text-accent); font-size: var(--text-sm); }
.user-email { font-size: var(--text-xs); color: var(--color-text-secondary); }

/* ── COLLAPSIBLE ───────────────────────────────────────────────────────────── */
.collapsible-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.collapsible-header:hover { background: var(--color-surface-hover); }
.collapsible-icon {
  width: 18px; height: 18px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-page);
  border: 1px solid var(--color-border-warm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.collapsible-icon svg {
  width: 9px; height: 9px;
  stroke: var(--color-text-secondary);
  fill: none; stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform var(--transition);
}
.collapsible-header.open .collapsible-icon svg { transform: rotate(90deg); }
.collapsible-title {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.collapsible-meta { margin-left: auto; font-size: var(--text-xs); color: var(--color-text-muted); }

/* ── SCROLLBAR ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-warm); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ── ANIMATIONS ────────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-fade-up  { opacity: 0; animation: fadeUp 0.4s ease forwards; }
.anim-delay-1  { animation-delay: 0.05s; }
.anim-delay-2  { animation-delay: 0.10s; }
.anim-delay-3  { animation-delay: 0.15s; }
.anim-delay-4  { animation-delay: 0.20s; }
.anim-delay-5  { animation-delay: 0.25s; }
.anim-delay-6  { animation-delay: 0.30s; }

/* ── NARROW SCREEN FALLBACK ────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .app-shell { display: none !important; }
  .narrow-screen-fallback { display: flex !important; }
}
.narrow-screen-fallback {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-bg-nav);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-8);
  text-align: center;
  z-index: 9999;
}
.narrow-screen-fallback .topbar-logo { margin-bottom: var(--space-2); }
.narrow-screen-fallback p {
  font-size: var(--text-base);
  color: var(--color-text-on-dark);
  max-width: 320px;
  line-height: 1.7;
  opacity: 0.85;
}
