/**
 * Project Lab — Design system layer (2026-10)
 *
 * Loads after style.css on every page (see views/_head.php).
 * Redefines the legacy variables (--primary, --gray-*, ...) so existing
 * components pick up the new palette, and adds a light/dark token set
 * driven by html.theme-dark (resolved from the aeo_theme cookie in _head.php).
 *
 * Direction: minimal, flat, neutral zinc palette, single cyan accent,
 * Inter for UI text, JetBrains Mono for code / ids / paths.
 */

/* ---------- Fonts (self-hosted, assets/fonts) ---------- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/Inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/Inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('../fonts/JetBrainsMono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('../fonts/JetBrainsMono-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens: light ---------- */
:root {
    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --bg: #f7f7f8;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --surface-3: #e4e4e7;
    --surface-raised: #ffffff;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #18181b;
    --text-2: #3f3f46;
    --text-muted: #71717a;
    --text-faint: #a1a1aa;

    --accent: #0891b2;
    --accent-strong: #0e7490;
    --accent-soft: #ecfeff;
    --accent-ring: rgba(8, 145, 178, 0.25);

    --surface-inverse: #18181b;   /* dark surfaces (tooltips, dark header bars) stay dark in both themes */
    --surface-inverse-2: #3f3f46;
    --ink: #18181b;          /* primary button surface */
    --ink-hover: #27272a;
    --on-ink: #ffffff;

    --success: #16a34a;
    --success-bg: #ecfdf5;
    --success-text: #15803d;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-text: #b45309;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-text: #b91c1c;
    --info: #0284c7;
    --info-bg: #f0f9ff;
    --info-text: #0369a1;
    --purple: #7c3aed;
    --purple-bg: #f5f3ff;
    --purple-text: #6d28d9;

    /* Legacy aliases used throughout the app */
    --primary: var(--ink);
    --primary-light: var(--accent);
    --gray-50: #fafafa;
    --gray-100: #f4f4f5;
    --gray-200: #e4e4e7;
    --gray-300: #d4d4d8;
    --gray-400: #a1a1aa;
    --gray-500: #71717a;
    --gray-600: #52525b;
    --gray-700: #3f3f46;
    --gray-800: #27272a;
    --gray-900: #18181b;
    --error-bg: var(--danger-bg);
    --error-text: var(--danger-text);
    --bg-primary: var(--surface);
    --bg-secondary: var(--bg);
    --bg-tertiary: var(--surface-2);
    --text-primary: var(--text);
    --text-secondary: var(--text-2);
    --border-color: var(--border);
    --card-bg: var(--surface);
    --card-border: var(--border);
    --input-bg: var(--surface);
    --input-border: var(--border-strong);
    --input-focus-border: var(--accent);
    --table-header-bg: var(--surface-2);
    --table-row-hover: var(--surface-2);
    --table-border: var(--border);
    --modal-bg: var(--surface-raised);
    --modal-overlay: rgba(9, 9, 11, 0.55);
    --code-bg: var(--surface-2);

    /* Variables referenced by page-level styles with light fallbacks */
    --bg-muted: var(--surface-2);
    --bg-hover: var(--surface-2);
    --bg-card: var(--surface);
    --bg-active: var(--accent-soft);
    --text-color: var(--text);
    --primary-color: var(--accent);
    --primary-dark: var(--accent-strong);
    --metric-bg: var(--surface-2);
    --info-border: color-mix(in srgb, var(--info) 35%, transparent);
    --hover-bg: var(--surface-2);
    --card-header-bg: var(--surface-2);
    --btn-secondary-bg: var(--surface-2);
    --btn-secondary-hover: var(--surface-3);
    --selected-bg: var(--accent-soft);

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 2px rgba(9, 9, 11, 0.04);
    --shadow-lg: 0 12px 32px -8px rgba(9, 9, 11, 0.18), 0 2px 6px rgba(9, 9, 11, 0.06);
    --nav-h: 56px;

    color-scheme: light;
}

/* ---------- Tokens: dark ---------- */
html.theme-dark {
    --bg: #09090b;
    --surface: #111114;
    --surface-2: #18181b;
    --surface-3: #27272a;
    --surface-raised: #18181b;
    --border: #232326;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #d4d4d8;
    --text-muted: #a1a1aa;
    --text-faint: #71717a;

    --accent: #22d3ee;
    --accent-strong: #67e8f9;
    --accent-soft: rgba(34, 211, 238, 0.10);
    --accent-ring: rgba(34, 211, 238, 0.30);

    --surface-inverse: #27272a;
    --surface-inverse-2: #3f3f46;
    --ink: #fafafa;
    --ink-hover: #e4e4e7;
    --on-ink: #09090b;

    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.12);
    --success-text: #4ade80;
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --warning-text: #fbbf24;
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --danger-text: #f87171;
    --info: #38bdf8;
    --info-bg: rgba(56, 189, 248, 0.12);
    --info-text: #38bdf8;
    --purple: #a78bfa;
    --purple-bg: rgba(167, 139, 250, 0.12);
    --purple-text: #a78bfa;

    /* --primary is used as a *background* under white text in page styles; keep it a mid tone in dark */
    --primary: #0e7490;
    --primary-light: #22d3ee;

    --gray-50: #121215;
    --gray-100: #18181b;
    --gray-200: #27272a;
    --gray-300: #3f3f46;
    --gray-400: #71717a;
    --gray-500: #a1a1aa;
    --gray-600: #c4c4cc;
    --gray-700: #d4d4d8;
    --gray-800: #e4e4e7;
    --gray-900: #fafafa;
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.4);

    color-scheme: dark;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -0.015em; }
h1 { font-weight: 650; }
h2, h3 { font-weight: 600; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
code, kbd, pre, samp, .mono, .url-path { font-family: var(--font-mono); font-size: 0.92em; }
code, .url-path { background: var(--code-bg); color: var(--text-2); border-radius: 4px; padding: 1px 5px; }
pre { background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; overflow: auto; }
hr { border: 0; border-top: 1px solid var(--border); }
::selection { background: var(--accent-ring); }
::placeholder { color: var(--text-faint); opacity: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Thin, neutral scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Layout ---------- */
.container { max-width: 1440px; padding: 28px 28px 48px; }
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.page-header-actions { margin-bottom: 20px; }
.back-link { background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); width: 34px; height: 34px; }
.back-link:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Navigation (flat top bar) ---------- */
.main-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(1.4) blur(8px);
    -webkit-backdrop-filter: saturate(1.4) blur(8px);
}
html.theme-dark .main-nav { background: rgba(17, 17, 20, 0.92); }
.nav-container { max-width: 1440px; min-height: var(--nav-h); padding: 0 20px; gap: 10px; }
.nav-brand { flex-shrink: 0; }
.nav-brand a { white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-brand .brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--ink); color: var(--on-ink);
}
.nav-brand .brand-mark svg { width: 18px; height: 18px; stroke: currentColor; }
.brand-aeo, .brand-generator { font-size: 15px !important; letter-spacing: -0.01em; }
.brand-aeo { color: var(--text); font-weight: 650; }
.brand-generator { color: var(--text-muted); font-weight: 450; margin-left: 0; }
.nav-menu { gap: 2px; flex-shrink: 0; }
.nav-menu .nav-item,
.nav-item {
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 11px;
    border-radius: var(--radius);
    gap: 7px;
    white-space: nowrap;
    flex-shrink: 0;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active,
.nav-dropdown-toggle.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-icon { color: var(--text-muted); }
.nav-icon svg { stroke: currentColor; width: 17px; height: 17px; }
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { color: var(--accent); }
.nav-item.active .nav-icon svg,
.nav-dropdown-toggle.active .nav-icon svg,
.nav-dropdown-toggle.active .nav-chevron svg { stroke: currentColor; }
.nav-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.nav-badge { background: var(--danger); color: #fff; font-size: 10.5px; }
.nav-item.active .nav-badge { background: var(--danger); color: #fff; }
.nav-count { display: inline-flex; align-items: center; border-radius: 999px; padding: 1px 6px; font-size: 10.5px; font-weight: 650; line-height: 1.5; font-variant-numeric: tabular-nums; }
.nav-count-amber { background: var(--warning-bg); color: var(--warning-text); }
.nav-count-green { background: var(--success-bg); color: var(--success-text); }
.nav-item.active .nav-count-green { background: var(--success-bg); color: var(--success-text); }
.nav-user { gap: 8px; flex-shrink: 0; }
.user-name { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
@media (max-width: 1280px) { .user-name { display: none; } }
@media (max-width: 1150px) { .nav-search { display: none !important; } }

/* Dropdowns */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle { background: none; border: none; cursor: pointer; font-family: inherit; }
.nav-dropdown-toggle .nav-chevron { display: flex; align-items: center; margin-left: 0; transition: transform 0.2s ease; color: var(--text-faint); }
.nav-dropdown-toggle .nav-chevron svg { stroke: currentColor; width: 13px; height: 13px; }
.nav-dropdown:hover .nav-dropdown-toggle .nav-chevron,
.nav-dropdown.open .nav-dropdown-toggle .nav-chevron { transform: rotate(180deg); }
.nav-dropdown-menu {
    position: absolute; top: 100%; left: 0; min-width: 208px;
    background: var(--surface-raised); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: all 0.16s ease; z-index: 1000; margin-top: 6px;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-dropdown-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    color: var(--text-2); text-decoration: none; font-size: 13.5px; font-weight: 500;
    border-radius: var(--radius-sm); transition: all 0.12s ease;
}
.nav-dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.nav-dropdown-item.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav-dropdown-item .nav-icon { opacity: 1; color: var(--text-muted); }
.nav-dropdown-item:hover .nav-icon, .nav-dropdown-item.active .nav-icon { color: var(--accent); }
.nav-dropdown-item .nav-icon svg { stroke: currentColor; }
.nav-dropdown-item .nav-badge { margin-left: auto; }
.nav-dropdown-divider { height: 1px; background: var(--border); margin: 6px 4px; }
.nav-version-badge { margin-left: auto; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }

/* Master search */
.nav-search { position: relative; flex: 1 1 160px; max-width: 300px; min-width: 140px; margin: 0 4px 0 auto; }
.nav-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; color: var(--text-faint); pointer-events: none; }
.nav-search-input {
    width: 100%; height: 34px; padding: 0 34px 0 32px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font-size: 13px; font-family: inherit; outline: none;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.nav-search-input::placeholder { color: var(--text-faint); }
.nav-search-input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.nav-search-input::-webkit-search-cancel-button { display: none; }
.nav-search-kbd {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    font-size: 11px; font-family: var(--font-mono); padding: 1px 6px; border-radius: 4px;
    background: var(--surface); color: var(--text-faint); border: 1px solid var(--border); pointer-events: none; line-height: 1.4;
}
.nav-search:focus-within .nav-search-kbd { display: none; }
.nav-search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 380px; max-width: 520px; max-height: 70vh; overflow-y: auto;
    background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 1100; padding: 6px;
}
.nav-search-empty, .nav-search-loading, .nav-search-error { padding: 12px 12px; font-size: 13px; color: var(--text-muted); }
.nav-search-error { color: var(--danger-text); }
.nav-search-group-label { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }
.nav-search-item { display: block; padding: 8px 10px; text-decoration: none; color: inherit; border-radius: var(--radius-sm); border-left: 0; cursor: pointer; }
.nav-search-item:hover, .nav-search-item.active { background: var(--surface-2); border-left-color: transparent; }
.nav-search-item-title { font-size: 13.5px; font-weight: 550; color: var(--text); line-height: 1.3; }
.nav-search-item-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-search-item mark { background: var(--accent-soft); color: var(--accent); padding: 0 1px; border-radius: 2px; }
@media (max-width: 900px) { .nav-search { display: none; } }

/* Theme toggle + icon buttons in the nav */
.nav-iconbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius); border: 1px solid transparent;
    background: transparent; color: var(--text-muted); cursor: pointer; transition: all 0.12s ease;
}
.nav-iconbtn:hover { background: var(--surface-2); color: var(--text); }
.nav-iconbtn svg { width: 17px; height: 17px; stroke: currentColor; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
html.theme-dark .theme-toggle .icon-sun { display: inline; }
html.theme-dark .theme-toggle .icon-moon { display: none; }
.nav-logout { color: var(--text-2); }

@media (max-width: 768px) {
    .nav-container { flex-wrap: wrap; padding: 10px 14px; }
    .nav-menu { order: 3; width: 100%; justify-content: flex-start; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
    .nav-item { min-height: 40px; }
}

/* Staging ribbon */
.env-ribbon {
    display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 6px;
    background: var(--warning-bg); color: var(--warning-text); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}

/* Scroll to top */
.scroll-to-top {
    position: fixed; bottom: 24px; right: 24px; width: 40px; height: 40px; border-radius: 10px;
    background: var(--surface-raised); color: var(--text-2); border: 1px solid var(--border); cursor: pointer;
    display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(8px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease, background 0.2s ease; z-index: 9997;
}
.scroll-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.scroll-to-top:hover { background: var(--surface-2); color: var(--text); transform: translateY(-2px); }

/* ---------- Cards ---------- */
.card, .stat-card, .stat-card-enhanced, .detail-card, .metric-card, .int-card, .settings-subcard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: none;
}
.card-header, .detail-card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3, .detail-card-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.card-body, .detail-card-body { padding: 18px; }
.section-header { background: var(--surface); border-color: var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.section-header.collapsed { border-radius: var(--radius-lg); }
.section-header:hover { background: var(--surface-2); }
.section-content { background: var(--surface); border-color: var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.section-header h2, .section-header h3 { color: var(--text); }

/* Stats */
.stat-card { padding: 18px 16px; }
.stat-value, .stat-card-enhanced .stat-value, .metric-value { color: var(--text); font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-value { font-size: 28px; }
.stat-label, .stat-card-enhanced .stat-label, .metric-label { color: var(--text-muted) !important; font-size: 11px; font-weight: 550; letter-spacing: 0.06em; }
.stat-card-enhanced:hover { box-shadow: none; border-color: var(--border-strong); }
.stat-card-enhanced .stat-change.positive { color: var(--success-text); background: var(--success-bg); }
.stat-card-enhanced .stat-change.negative { color: var(--danger-text); background: var(--danger-bg); }
.stat-card-enhanced .stat-change.neutral { color: var(--text-muted); background: var(--surface-2); }

/* Section headings (uppercase eyebrow style used on dashboard) */
.section-heading, .section-divider-with-label span { color: var(--text-faint); font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.section-divider, .section-divider-with-label::before, .section-divider-with-label::after { background: var(--border); }

/* Property cards / logos */
.property-item { background: var(--surface-2); border-radius: var(--radius); }
.property-logo-placeholder, .property-logo-placeholder-lg { background: var(--surface-3); color: var(--text-2); }
.properties-grid { gap: 16px; }
.article-item, .schedule-item { border-color: var(--border); }
.article-title, .article-title-link, .schedule-title { color: var(--text); }
.article-title:hover, .article-title-link:hover { color: var(--accent); }
.article-meta, .schedule-meta, .detail-label { color: var(--text-muted); }
.schedule-date { background: var(--accent-soft); }
.date-day { color: var(--accent); }
.date-month { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
    gap: 7px;
    padding: 0 14px;
    height: 36px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1;
    border-radius: var(--radius);
    border: 1px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
    letter-spacing: -0.005em;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); color: var(--on-ink); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-outline { background: transparent; color: var(--text-2); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-2); color: var(--text); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(0.94); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(0.94); }
html.theme-dark .btn-success, html.theme-dark .btn-danger { color: #09090b; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-strong); }
html.theme-dark .btn-accent { color: #09090b; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm); }
.btn-link { background: none; border: none; color: var(--accent); padding: 0; height: auto; }

/* ---------- Forms ---------- */
.form-group label, label { font-weight: 500; color: var(--text-2); font-size: 13px; }
.form-control, .form-select, select, textarea, input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"] {
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.form-control:focus, .form-select:focus, select:focus, textarea:focus, input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.form-control:disabled, input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-muted); }
select.form-control, .form-select, select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 34px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.form-hint, .form-text, .help-text { color: var(--text-muted); font-size: 12px; }
.form-actions { border-color: var(--border); }
.form-required { color: var(--danger); }
.filter-form .form-control { width: auto; }
/* Nav search keeps its icon/kbd padding (declared after the generic input rules above) */
.nav-search .nav-search-input { height: 34px; padding: 0 34px 0 32px; border-radius: var(--radius); }
.nav-search .nav-search-input:focus { box-shadow: 0 0 0 3px var(--accent-ring); }

/* ---------- Tables ---------- */
table th, table td, .data-table th, .data-table td { border-color: var(--border); padding: 11px 14px; }
table th, .data-table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
table td, .data-table td { color: var(--text-2); font-variant-numeric: tabular-nums; }
table tbody tr:hover, .data-table tr:hover td { background: var(--surface-2); }
.table-wrapper { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; background: var(--surface); }
.table-wrapper table th:first-child { border-top-left-radius: var(--radius-lg); }
.table-wrapper table th:last-child { border-top-right-radius: var(--radius-lg); }
.table-wrapper table tr:last-child td { border-bottom: 0; }
.card > table, .card-body > .table-wrapper { border: 0; border-radius: 0; }

/* ---------- Badges / pills ---------- */
.badge, .status-badge, .chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; font-size: 11px; font-weight: 600; border-radius: 999px;
    letter-spacing: 0.03em; line-height: 1.5; border: 1px solid transparent;
}
.badge-draft, .badge-inactive, .badge-secondary { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.badge-review { background: var(--warning-bg); color: var(--warning-text); }
.badge-approved { background: var(--info-bg); color: var(--info-text); }
.badge-scheduled { background: var(--purple-bg); color: var(--purple-text); }
.badge-published, .badge-active, .badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-failed, .badge-danger, .badge-error { background: var(--danger-bg); color: var(--danger-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-primary { background: var(--accent-soft); color: var(--accent); }

/* Status dots used across dashboard / health */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--text-faint); }
.dot-green { background: var(--success); }
.dot-red { background: var(--danger); }
.dot-yellow { background: var(--warning); }
.dot-gray { background: var(--text-faint); }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); border: 1px solid; font-size: 13.5px; }
.alert-success { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success-text); }
.alert-error, .alert-danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger-text); }
.alert-warning { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning-text); }
.alert-info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--info-text); }

/* ---------- Tabs ---------- */
.performance-tabs-enhanced, .tabs-pill { background: var(--surface-2); border-radius: 10px; }
.performance-tabs-enhanced .tab-link { color: var(--text-muted); }
.performance-tabs-enhanced .tab-link:hover { color: var(--text); background: transparent; }
.performance-tabs-enhanced .tab-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
html.theme-dark .performance-tabs-enhanced .tab-link.active { background: var(--surface-3); }

/* ---------- Modals / dropdowns (generic) ---------- */
.modal, .seo-modal, .modal-content { background: var(--modal-bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-overlay, .seo-modal-overlay { background: var(--modal-overlay); }
.modal-header, .modal-footer { border-color: var(--border); }
.dropdown-menu { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }
.dropdown-item:hover { background: var(--surface-2); }

/* ---------- Misc / utilities ---------- */
.text-muted, .text-secondary, .card-meta, .filter-label { color: var(--text-muted) !important; }
.empty-state { color: var(--text-muted); }
.empty-state svg { color: var(--text-faint); }
.spinner { border-color: var(--border); border-top-color: var(--accent); }
.url-cell .url-text { color: var(--accent); }
.url-cell .url-tooltip { background: var(--ink); color: var(--on-ink); }
.url-cell .url-tooltip::before { border-bottom-color: var(--ink); }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 11px; color: var(--text-2); }
.tabular { font-variant-numeric: tabular-nums; }

/* Chart canvases keep their own colours; just soften the frame in dark mode */
html.theme-dark .chart-container { filter: none; }
html.theme-dark img.property-logo, html.theme-dark img.property-logo-lg { background: #fff; padding: 3px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
