/* ============================================================
   TLclaw Design System — Theme Tokens & Global Styles
   The Lad Collective Internal Marketing Platform
   ============================================================

   Brand reference:
   - Prairie Sand (TLC accent): #963d20
   - Cedar (TLC dark):          #3b1a13
   - Montserrat (headings)
   - Inter (UI text)

   Design philosophy:
   Premium restraint. Warm neutrals. Editorial hierarchy.
   "A bedding brand's marketing OS" — not cold SaaS, not loud startup.
   ============================================================ */

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

/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
    /* --- Typography --- */
    --font-heading: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

    /* Font weights */
    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;

    /* Font sizes — modular scale (1.2 ratio) */
    --text-xs: 0.694rem;    /* 11px */
    --text-sm: 0.833rem;    /* 13px */
    --text-base: 1rem;      /* 16px */
    --text-md: 1.125rem;    /* 18px */
    --text-lg: 1.35rem;     /* 21.6px */
    --text-xl: 1.62rem;     /* 26px */
    --text-2xl: 1.944rem;   /* 31px */
    --text-3xl: 2.4rem;     /* 38px */
    --text-stat: 2.8rem;    /* 45px — for metric cards */

    /* Line heights */
    --leading-tight: 1.2;
    --leading-snug: 1.35;
    --leading-normal: 1.5;
    --leading-relaxed: 1.65;

    /* Letter spacing */
    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;
    --tracking-wider: 0.06em;

    /* --- Colors: Surfaces --- */
    --color-page-bg: #FAF8F5;           /* warm linen */
    --color-surface: #FFFFFF;            /* card/panel white */
    --color-surface-elevated: #FFFFFF;   /* modals, dropdowns */
    --color-surface-subtle: #F5F0EB;    /* secondary surface, sidebar bg */
    --color-surface-hover: #F0EBE4;     /* row hover, subtle interaction */
    --color-surface-active: #EBE4DC;    /* pressed state */
    --color-sidebar-bg: #2C2320;        /* warm dark charcoal */
    --color-sidebar-hover: #3D322E;     /* sidebar item hover */
    --color-sidebar-active: #4A3D38;    /* sidebar active item bg */

    /* --- Colors: Text --- */
    --color-text-primary: #2C2320;       /* warm charcoal — main body text */
    --color-text-secondary: #7A6E66;     /* stone — secondary, helper text */
    --color-text-tertiary: #A89E96;      /* muted taupe — timestamps, meta */
    --color-text-inverse: #FAF8F5;       /* text on dark surfaces */
    --color-text-inverse-secondary: #C4B8AE; /* secondary text on dark surfaces */
    --color-text-link: #8B3A1E;          /* darker prairie sand for links */

    /* --- Colors: Brand & Accent --- */
    --color-primary: #963D20;            /* prairie sand — TLC brand accent */
    --color-primary-hover: #7D3319;      /* darker prairie sand */
    --color-primary-subtle: #F5E8E2;     /* light terracotta wash */
    --color-primary-light: #EDD5CB;      /* selected row, light accent bg */

    /* --- Colors: Semantic States --- */
    --color-success: #5B7F5E;            /* eucalyptus green */
    --color-success-bg: #EEF4EE;         /* light sage background */
    --color-success-text: #3D5C3F;       /* readable dark green */

    --color-warning: #C48832;            /* warm amber/ochre */
    --color-warning-bg: #FBF3E4;         /* light amber wash */
    --color-warning-text: #8A5F1F;       /* readable dark amber */

    --color-danger: #B94A48;             /* muted terracotta-red */
    --color-danger-bg: #FAECEB;          /* light red wash */
    --color-danger-text: #8C3533;        /* readable dark red */

    --color-info: #6B8BA4;              /* dusty blue-grey */
    --color-info-bg: #EDF2F6;           /* light blue-grey wash */
    --color-info-text: #4A6A82;         /* readable blue-grey */

    /* --- Colors: Borders & Dividers --- */
    --color-border: #E5DDD4;            /* warm sand border */
    --color-border-subtle: #EDE7E0;     /* very subtle divider */
    --color-border-strong: #C4B8AE;     /* emphasized border */
    --color-focus-ring: rgba(150, 61, 32, 0.35); /* TLC brand focus ring */

    /* --- Spacing 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 */
    --space-16: 4rem;      /* 64px */

    /* --- Radius --- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* --- Shadows --- */
    --shadow-xs: 0 1px 2px rgba(44, 35, 32, 0.04);
    --shadow-sm: 0 1px 3px rgba(44, 35, 32, 0.06), 0 1px 2px rgba(44, 35, 32, 0.04);
    --shadow-md: 0 4px 6px rgba(44, 35, 32, 0.05), 0 2px 4px rgba(44, 35, 32, 0.03);
    --shadow-lg: 0 10px 15px rgba(44, 35, 32, 0.06), 0 4px 6px rgba(44, 35, 32, 0.03);
    --shadow-xl: 0 20px 25px rgba(44, 35, 32, 0.08), 0 8px 10px rgba(44, 35, 32, 0.04);

    /* --- Transitions --- */
    --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 120ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;

    /* --- Layout --- */
    --sidebar-width: 240px;
    --content-max-width: 1120px;
    --header-height: 64px;
}


/* ============================================================
   RESET / BASE OVERRIDES
   Override Pico CSS defaults with our design system
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: var(--leading-normal);
    color: var(--color-text-primary);
    background-color: var(--color-page-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    background-color: var(--color-page-bg);
}


/* ============================================================
   APP SHELL — Sidebar + Content Layout
   ============================================================ */

.app-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--color-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: var(--space-6) var(--space-5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand h1 {
    font-family: var(--font-heading);
    font-size: var(--text-md);
    font-weight: var(--weight-bold);
    color: var(--color-text-inverse);
    margin: 0;
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
}

.sidebar-brand .brand-subtitle {
    font-size: var(--text-xs);
    color: var(--color-text-inverse-secondary);
    margin: var(--space-1) 0 0 0;
    font-weight: var(--weight-normal);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

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

.sidebar-section {
    margin-bottom: var(--space-4);
}

.sidebar-section-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-inverse-secondary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    padding: var(--space-2) var(--space-3) var(--space-2);
    margin: 0;
}

.sidebar-link {
    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-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-inverse-secondary);
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-default);
}

.sidebar-link:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-text-inverse);
}

.sidebar-link[aria-current="page"],
.sidebar-link.active {
    background: var(--color-sidebar-active);
    color: var(--color-text-inverse);
    font-weight: var(--weight-semibold);
}

.sidebar-link .nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    flex-shrink: 0;
}

.sidebar-link[aria-current="page"] .nav-icon,
.sidebar-link.active .nav-icon,
.sidebar-link:hover .nav-icon {
    opacity: 1;
}

.sidebar-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: auto;
}

.sidebar-footer small {
    font-size: var(--text-xs);
    color: var(--color-text-inverse-secondary);
}


/* --- Main Content Area --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-header {
    padding: var(--space-6) var(--space-8);
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-surface);
}

.content-header h1 {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--color-text-primary);
    margin: 0;
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
}

.content-header p {
    color: var(--color-text-secondary);
    margin: var(--space-1) 0 0 0;
    font-size: var(--text-sm);
}

.content-body {
    padding: var(--space-8);
    flex: 1;
    max-width: var(--content-max-width);
}

.content-footer {
    padding: var(--space-4) var(--space-8);
    border-top: 1px solid var(--color-border-subtle);
    margin-top: auto;
}

.content-footer small {
    color: var(--color-text-tertiary);
    font-size: var(--text-xs);
}


/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-text-primary);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
    margin: 0 0 var(--space-4) 0;
}

h1 { font-size: var(--text-2xl); font-weight: var(--weight-bold); }
h2 { font-size: var(--text-xl); font-weight: var(--weight-bold); }
h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
h4 { font-size: var(--text-md); font-weight: var(--weight-semibold); }

p {
    color: var(--color-text-secondary);
    line-height: var(--leading-relaxed);
    margin: 0 0 var(--space-4) 0;
}

a {
    color: var(--color-text-link);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-default);
}

a:hover {
    color: var(--color-primary);
}

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--color-surface-subtle);
    color: var(--color-text-primary);
    padding: 0.125em 0.375em;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-subtle);
}

small, .text-sm {
    font-size: var(--text-sm);
}

.text-xs {
    font-size: var(--text-xs);
}

.text-secondary {
    color: var(--color-text-secondary);
}

.text-tertiary {
    color: var(--color-text-tertiary);
}


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

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: box-shadow var(--duration-normal) var(--ease-default);
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--color-border-subtle);
}

.card-header h3 {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    margin: 0;
}

.card-header p {
    margin: var(--space-1) 0 0 0;
    font-size: var(--text-sm);
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--color-border-subtle);
    background: var(--color-surface-subtle);
}

/* Stat cards — metric display */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    box-shadow: var(--shadow-xs);
}

.stat-card .stat-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    margin: 0 0 var(--space-2) 0;
}

.stat-card .stat-value {
    font-family: var(--font-heading);
    font-size: var(--text-stat);
    font-weight: var(--weight-extrabold);
    color: var(--color-text-primary);
    line-height: 1;
    margin: 0;
    letter-spacing: var(--tracking-tight);
}

.stat-card .stat-value.danger {
    color: var(--color-danger);
}

.stat-card .stat-meta {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    margin: var(--space-2) 0 0 0;
}

/* Stat grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}


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

.data-table-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    margin: 0;
}

thead {
    background: var(--color-surface-subtle);
    border-bottom: 1px solid var(--color-border);
}

thead th {
    padding: var(--space-3) var(--space-5);
    font-weight: var(--weight-semibold);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    text-align: left;
    white-space: nowrap;
    border: none;
}

tbody td {
    padding: var(--space-4) var(--space-5);
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: middle;
    border-left: none;
    border-right: none;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background var(--duration-fast) var(--ease-default);
}

tbody tr:hover {
    background: var(--color-surface-hover);
}

/* Cell variants */
td strong {
    font-weight: var(--weight-semibold);
    color: var(--color-text-primary);
}

td small {
    display: block;
    color: var(--color-text-tertiary);
    margin-top: 2px;
}

td code {
    font-size: var(--text-xs);
}


/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    line-height: 1.6;
    white-space: nowrap;
}

/* Status badges */
.badge-active {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge-paused {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.badge-draft {
    background: var(--color-surface-subtle);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.badge-scheduled {
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.badge-sending {
    background: var(--color-primary-subtle);
    color: var(--color-primary);
}

.badge-sent {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge-cancelled {
    background: var(--color-surface-subtle);
    color: var(--color-text-tertiary);
    border: 1px solid var(--color-border);
}

/* Step type badges */
.badge-delay {
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.badge-email {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge-condition {
    background: #F3ECF8;
    color: #6B4C8A;
}

/* Suppression badges */
.badge-suppressed {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.badge-clear {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

/* Refresh mode badges */
.badge-realtime {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge-batch {
    background: var(--color-surface-subtle);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}


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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-md);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-normal);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--duration-fast) var(--ease-default);
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* Primary */
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: #fff;
}

/* Secondary */
.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-strong);
    color: var(--color-text-primary);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
}

/* Small variant */
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}


/* ============================================================
   FORM INPUTS
   ============================================================ */

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-default);
    outline: none;
}

.form-input::placeholder {
    color: var(--color-text-tertiary);
}

.form-input:hover {
    border-color: var(--color-border-strong);
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
}

.form-group {
    margin-bottom: var(--space-5);
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    margin-top: var(--space-1);
}

/* Input with inline button */
.input-group {
    display: flex;
    gap: var(--space-2);
}

.input-group .form-input {
    flex: 1;
}


/* ============================================================
   FLOW STEP LIST
   ============================================================ */

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

.step-item {
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--color-border-strong);
    transition: box-shadow var(--duration-fast) var(--ease-default);
}

.step-item:hover {
    box-shadow: var(--shadow-sm);
}

.step-item.step-delay {
    border-left-color: var(--color-info);
}

.step-item.step-email {
    border-left-color: var(--color-success);
}

.step-item.step-condition {
    border-left-color: #8B6BAE;
}

.step-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.step-number {
    font-weight: var(--weight-semibold);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    min-width: 1.5em;
}

.step-details {
    margin-top: var(--space-2);
    padding-left: calc(1.5em + var(--space-3));
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}


/* ============================================================
   DETAILS / COLLAPSIBLE SECTIONS
   ============================================================ */

.section-collapsible {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    overflow: hidden;
}

.section-collapsible summary {
    padding: var(--space-4) var(--space-5);
    font-weight: var(--weight-semibold);
    font-size: var(--text-base);
    color: var(--color-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    list-style: none;
    transition: background var(--duration-fast) var(--ease-default);
}

.section-collapsible summary:hover {
    background: var(--color-surface-hover);
}

.section-collapsible summary::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--color-text-tertiary);
    border-bottom: 2px solid var(--color-text-tertiary);
    transform: rotate(-45deg);
    transition: transform var(--duration-fast) var(--ease-default);
}

.section-collapsible[open] summary::after {
    transform: rotate(45deg);
}

.section-collapsible summary::-webkit-details-marker {
    display: none;
}

.section-collapsible .section-body {
    padding: 0 var(--space-5) var(--space-5);
}


/* ============================================================
   SUPPRESSION RESULT
   ============================================================ */

.suppression-result {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    margin-top: var(--space-4);
}

.suppression-result.is-suppressed {
    background: var(--color-warning-bg);
    border: 1px solid #E8D5B0;
}

.suppression-result.is-clear {
    background: var(--color-success-bg);
    border: 1px solid #C5DBC6;
}

.suppression-result.is-error {
    background: var(--color-surface-subtle);
    border: 1px solid var(--color-border);
}


/* ============================================================
   BACK LINK
   ============================================================ */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
    text-decoration: none;
    margin-top: var(--space-6);
    transition: color var(--duration-fast) var(--ease-default);
}

.back-link:hover {
    color: var(--color-primary);
}


/* ============================================================
   EMPTY STATES
   ============================================================ */

.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-8);
    color: var(--color-text-secondary);
}

.empty-state h3 {
    font-family: var(--font-heading);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
}

.empty-state p {
    font-size: var(--text-sm);
    max-width: 360px;
    margin: 0 auto;
}


/* ============================================================
   UTILITIES
   ============================================================ */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

/* Danger button */
.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}

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

/* Alert messages */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid #C5DBC6;
}

.alert-error {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
    border: 1px solid #E8C5C4;
}

/* Page subtitle */
.page-subtitle {
    margin: var(--space-1) 0 0 0;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

/* HTMX loading indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline;
}


/* ============================================================
   MOBILE HEADER & OVERLAY (hidden on desktop)
   ============================================================ */

.mobile-header {
    display: none;
}

.sidebar-overlay {
    display: none;
}


/* ============================================================
   RESPONSIVE — MOBILE (max-width: 768px)
   ============================================================ */

@media (max-width: 768px) {

    /* Mobile top bar */
    .mobile-header {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--color-sidebar-bg);
        padding: 0 var(--space-4);
        z-index: 200;
    }

    .mobile-menu-btn {
        background: none;
        border: none;
        color: var(--color-text-inverse);
        cursor: pointer;
        padding: var(--space-2);
        border-radius: var(--radius-md);
    }

    .mobile-menu-btn:hover {
        background: var(--color-sidebar-hover);
    }

    .mobile-brand {
        font-family: var(--font-heading);
        font-size: var(--text-md);
        font-weight: var(--weight-bold);
        color: var(--color-text-inverse);
    }

    /* Sidebar becomes off-canvas drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--duration-slow) var(--ease-default);
        top: 0;
        z-index: 300;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Dark overlay behind sidebar */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 250;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--duration-slow) var(--ease-default);
    }

    .sidebar.open ~ .sidebar-overlay,
    .sidebar.open + .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    /* Main content fills full width, offset for mobile header */
    .main-content {
        margin-left: 0;
        padding-top: 56px;
    }

    .content-header {
        padding: var(--space-4) var(--space-4);
    }

    .content-header h1 {
        font-size: var(--text-xl);
    }

    .content-body {
        padding: var(--space-4);
    }

    .content-footer {
        padding: var(--space-3) var(--space-4);
    }

    /* Cards — remove horizontal overflow for small screens */
    .card {
        padding: var(--space-4);
    }

    /* Stats grid — single column on phone */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    .stat-card .stat-value {
        font-size: var(--text-2xl);
    }

    /* Tables — horizontal scroll */
    .data-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Forms — stack inputs */
    .input-group {
        flex-direction: column;
    }

    /* Step list — tighter padding */
    .step-item {
        padding: var(--space-3) var(--space-4);
    }

    .step-details {
        padding-left: 0;
    }

    .template-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ===== Template Gallery ===== */

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-5);
}

.template-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.template-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(44, 35, 32, 0.08);
}

.template-card-preview {
    display: block;
    text-decoration: none;
}

.template-card-thumbnail {
    height: 180px;
    background: linear-gradient(135deg, #f5f0ec 0%, #ece5df 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--color-border);
}

.template-card-body {
    padding: var(--space-4);
}

.template-card-name {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--color-text-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 4px;
}

.template-card-name:hover {
    color: var(--color-primary);
}

.template-card-meta {
    line-height: 1.4;
}

.template-card-actions {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: var(--space-2);
}

.btn-sm {
    font-size: var(--text-xs);
    padding: 4px 10px;
}

.text-danger {
    color: var(--color-danger) !important;
}

/* ===== Starter Template Gallery ===== */

.starter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-5);
}

.starter-card {
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.starter-card:hover,
.starter-card.selected {
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(150, 61, 32, 0.12);
}

.starter-card.selected {
    border-width: 2px;
}

.starter-card-preview {
    height: 160px;
    background: linear-gradient(135deg, #f5f0ec 0%, #ece5df 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--color-border);
    font-size: 2.5rem;
}

.starter-card-body {
    padding: var(--space-4);
}

.starter-card-body h3 {
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: 600;
    margin: 0 0 4px;
}

.starter-card-body p {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin: 0;
}
