/* === DESIGN TOKENS === */
:root {
  /* Brand */
  --brand: #D42027;
  --brand-hover: #b01b20;
  /* Surfaces */
  --surface-base: #f4f5f7;
  --surface-raised: #ffffff;
  --surface-overlay: #ffffff;
  /* Text */
  --text-primary: #1c2024;
  --text-secondary: #5f6b7a;
  --text-muted: #8b95a5;
  /* Borders */
  --border: #e1e4e8;
  --border-focus: rgba(212,32,39,0.4);
  /* Status — semantic, colorblind-safe (always paired with icon) */
  --status-pass: #1a7f37;
  --status-pass-bg: #dafbe1;
  --status-fail: #cf222e;
  --status-fail-bg: #ffebe9;
  --status-broken: #9a6700;
  --status-broken-bg: #fff8c5;
  --status-skip: #57606a;
  --status-skip-bg: #eaeef2;
  /* Accent */
  --accent-info: #0969da;
  --accent-info-bg: #ddf4ff;
  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  /* Type */
  --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  /* Transitions */
  --transition-fast: 0.12s ease;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-base: #0d1117;
    --surface-raised: #161b22;
    --surface-overlay: #1c2128;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border: #30363d;
    --border-focus: rgba(212,32,39,0.5);
    --status-pass: #3fb950;
    --status-pass-bg: #0d2818;
    --status-fail: #f85149;
    --status-fail-bg: #3d1117;
    --status-broken: #d29922;
    --status-broken-bg: #2e1800;
    --status-skip: #8b949e;
    --status-skip-bg: #21262d;
    --accent-info: #58a6ff;
    --accent-info-bg: #0d2240;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  }
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); background: var(--surface-base); color: var(--text-primary); min-height: 100vh; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* === LAYOUT === */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 220px; flex-shrink: 0; background: var(--surface-raised); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; transition: width 0.2s ease; }
.sidebar-toggle { display: flex; align-items: center; justify-content: center; width: 100%; height: 40px; border: none; background: transparent; cursor: pointer; color: var(--text-secondary); font-size: 18px; border-bottom: 1px solid var(--border); transition: background var(--transition-fast); flex-shrink: 0; }
.sidebar-toggle:hover { background: var(--surface-base); }
.sidebar-label { transition: opacity 0.2s ease; white-space: nowrap; }
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-label { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-user-info { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 14px 0; }
.sidebar.collapsed .sidebar-toggle-icon::after { content: "\25B6"; }
.sidebar:not(.collapsed) .sidebar-toggle-icon::after { content: "\25C0"; }
.sidebar-toggle-icon { font-size: 0; }
.sidebar-nav { flex: 1; padding: var(--space-lg) 0; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 10px var(--space-lg); font-size: 14px; font-weight: 500; color: var(--text-primary); text-decoration: none; border-left: 3px solid transparent; transition: background var(--transition-fast), border-color var(--transition-fast); }
.sidebar-item:hover { background: var(--surface-base); text-decoration: none; }
.sidebar-item.active { background: var(--surface-base); border-left-color: var(--brand); color: var(--brand); font-weight: 600; }
.sidebar-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-user { border-top: 1px solid var(--border); padding: 14px var(--space-md); display: flex; align-items: center; gap: 10px; }
.sidebar-user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; }
.sidebar-user-email { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-content { flex: 1; min-width: 0; overflow-x: hidden; }
.container { max-width: 1100px; margin: 0 auto; padding: var(--space-lg) var(--space-lg); }

/* === HEADER BAR === */
.header-bar { background: var(--surface-raised); border-bottom: 1px solid var(--border); padding: 12px 20px; display: flex; align-items: center; gap: 12px; height: 56px; position: sticky; top: 0; z-index: 100; }
.header-bar svg { height: 32px; width: auto; flex-shrink: 0; }
.header-bar .title { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--text-secondary); letter-spacing: -0.01em; }

/* === TYPOGRAPHY === */
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 800; color: var(--text-primary); margin: 0 0 4px; letter-spacing: -0.02em; line-height: 1.2; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin: 0 0 var(--space-xl); }
.breadcrumb { margin-bottom: var(--space-md); font-size: 13px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb span { color: var(--text-primary); font-weight: 500; }

/* === BUTTONS === */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; cursor: pointer; border: none; text-decoration: none; transition: background var(--transition-fast), border-color var(--transition-fast); white-space: nowrap; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); text-decoration: none; }
.btn-secondary { background: var(--surface-raised); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-base); text-decoration: none; }

/* === SETTINGS MENU === */
.settings-menu { display: flex; flex-direction: column; gap: var(--space-sm); }
.settings-item { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md) 20px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); text-decoration: none; color: var(--text-primary); transition: background var(--transition-fast), box-shadow var(--transition-fast); }
.settings-item:hover { background: var(--surface-base); box-shadow: var(--shadow-sm); text-decoration: none; }
.settings-item-icon { font-size: 22px; flex-shrink: 0; }
.settings-item-title { font-size: 15px; font-weight: 600; }
.settings-item-desc { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.settings-item-arrow { margin-left: auto; color: var(--text-muted); font-size: 16px; }

/* === FORMS === */
.form-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-lg); }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.StandardInput { box-sizing: border-box; display: block; width: 100%; height: 40px; padding: 0 12px; font-family: var(--font-body); font-size: 14px; color: var(--text-primary); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color var(--transition-fast); }
.StandardInput:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--border-focus); }
select.StandardInput { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='%235f6b7a' stroke-width='1.5' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space-sm); padding-top: var(--space-md); border-top: 1px solid var(--border); }

/* === CARDS === */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-lg); }
.card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-lg); transition: box-shadow var(--transition-fast); }
.card:hover { box-shadow: var(--shadow-md); }
.card-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.card-slug { font-size: 13px; color: var(--text-muted); margin: 0 0 var(--space-md); font-family: var(--font-mono); }
.card-meta { display: flex; align-items: center; justify-content: space-between; }
.card-run { font-size: 13px; color: var(--text-secondary); }
.card-run a { font-weight: 600; }
.card-norun { font-size: 13px; color: var(--text-muted); }

/* === TABLE === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); }
table { width: 100%; border-collapse: collapse; background: var(--surface-raised); border: none; border-radius: 0; overflow: visible; }
th { background: var(--surface-base); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 10px var(--space-md); text-align: left; font-weight: 600; white-space: nowrap; }
td { padding: 10px var(--space-md); border-top: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:hover td { background: var(--surface-base); }

/* === BADGES (status — always icon + color) === */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; font-family: var(--font-mono); white-space: nowrap; }
.badge-success { background: var(--status-pass-bg); color: var(--status-pass); }
.badge-success::before { content: "✓"; font-weight: 700; }
.badge-danger { background: var(--status-fail-bg); color: var(--status-fail); }
.badge-danger::before { content: "✗"; font-weight: 700; }
.badge-warning { background: var(--status-broken-bg); color: var(--status-broken); }
.badge-warning::before { content: "⚠"; }
.badge-info { background: var(--accent-info-bg); color: var(--accent-info); }
.badge-info::before { content: "⟳"; }
.badge-jenkins { color: #7c3aed; }
.badge-jenkins::before { content: "⟳"; }
.badge-github { color: #1d4ed8; }
.badge-github::before { content: "⟳"; }

/* === PULSE STRIP (signature element) === */
.pulse-strip { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 2px; margin-bottom: var(--space-lg); }
.pulse-strip .seg { flex: 1; min-width: 4px; border-radius: 2px; }
.pulse-strip .seg-pass { background: var(--status-pass); }
.pulse-strip .seg-fail { background: var(--status-fail); }
.pulse-strip .seg-broken { background: var(--status-broken); }
.pulse-strip .seg-other { background: var(--border); }

/* === STATS BAR === */
.stats-bar { display: flex; gap: var(--space-md); flex-wrap: wrap; margin-bottom: var(--space-lg); }
.stat-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; font-family: var(--font-mono); background: var(--surface-raised); border: 1px solid var(--border); }
.stat-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* === EMPTY STATES === */
.empty-state { text-align: center; padding: var(--space-2xl) var(--space-lg); color: var(--text-muted); }
.empty-state-icon { font-size: 32px; margin-bottom: var(--space-sm); opacity: 0.6; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-xs); }
.empty-state-desc { font-size: 13px; line-height: 1.6; }

/* === RESPONSIVE: TABLET === */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100% !important; height: auto; position: fixed; bottom: 0; top: auto; left: 0; right: 0; z-index: 200; border-right: none; border-top: 1px solid var(--border); flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; }
  .sidebar-toggle { display: none; }
  .sidebar.collapsed .sidebar-label { opacity: 1; width: auto; overflow: visible; }
  .sidebar.collapsed .sidebar-item { justify-content: initial; padding: 8px 14px; }
  .sidebar-nav { display: flex; flex-direction: row; padding: 0; overflow-x: auto; gap: 0; flex: 1; }
  .sidebar-item { flex-direction: column; gap: 2px; padding: 8px 14px; font-size: 11px; border-left: none; border-bottom: 3px solid transparent; min-width: 60px; text-align: center; justify-content: center; }
  .sidebar-item.active { border-left-color: transparent; border-bottom-color: var(--brand); }
  .sidebar-icon { font-size: 18px; }
  .sidebar-user { display: none; }
  .main-content { padding-bottom: 72px; }
  .container { padding: var(--space-md); }
  .header-bar { position: sticky; top: 0; }
  .page-title { font-size: 22px; }
}

/* === RESPONSIVE: MOBILE === */
@media (max-width: 480px) {
  .container { padding: var(--space-md) var(--space-sm); }
  .page-title { font-size: 20px; }
  .form-card { padding: var(--space-md); }
  .btn { padding: 8px 12px; font-size: 12px; }
  .stats-bar { gap: var(--space-sm); }
  td, th { padding: 8px 10px; font-size: 12px; }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* === MONOSPACE DATA === */
.data-mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }

/* Legacy compat aliases — maps old --asi-* vars to new tokens */
:root {
  --asi-red: var(--brand);
  --asi-dark: var(--text-primary);
  --asi-gray: var(--text-secondary);
  --asi-border: var(--border);
  --asi-bg: var(--surface-base);
  --asi-card: var(--surface-raised);
  --asi-green: var(--status-pass);
  --asi-amber: var(--status-broken);
  --asi-blue: var(--accent-info);
}
.app-link { font-weight: 600; }
.server-actions, .confirm-remove, .launch-actions { white-space: nowrap; }
