/**
 * DiaTech OS — Styles v2
 * Revolut-inspired palette: чёрные CTA, приглушённый золотой акцент,
 * тёплые чистые нейтрали. Без emoji, без красного/синего/зелёного/фиолетового.
 *
 * Brand derivation:
 *   #FFED00 (лого) → #C4A600 (UI gold, приглушённый)
 *   #1C1B17 (лого) → primary button + text
 */

/* System fonts keep first paint independent from a third-party font request. */

/* ======================== LIGHT THEME (DEFAULT) ======================== */
:root {
  /* Surfaces — тёплый linen-white, не графит */
  --bg: #F8F7F4;
  --bg-secondary: #F0EFEC;
  --surface: #FFFFFF;
  --surface-hover: #FAFAF8;
  --surface-2: #F4F3F0;

  /* Text — тёплый, чистый */
  --text: #1A1918;
  --text-secondary: #6B6A64;
  --text-muted: #A5A49E;

  /* Borders — едва заметные тёплые линии */
  --border: #E8E7E2;
  --border-light: #F2F1ED;

  /* Primary action = near-black (Revolut pattern) */
  --accent: #1A1918;
  --accent-hover: #2D2C28;
  --accent-light: rgba(26,25,24,0.05);
  --accent-text: #FFFFFF;

  /* Gold — приглушённый, из бренда #FFED00 → sophisticated */
  --gold: #C4A600;
  --gold-hover: #AD9300;
  --gold-light: rgba(196,166,0,0.07);
  --gold-subtle: rgba(196,166,0,0.04);
  --gold-text: #8A7500;
  --gold-on-dark: #D4C200;

  /* Semantic — тёплые нейтрали + gold */
  --success: #4A4A44;
  --success-light: #F0EFEC;
  --success-text: #3A3A35;
  --warning: #C4A600;
  --warning-light: rgba(196,166,0,0.07);
  --warning-text: #8A7500;
  --danger: #9A4030;
  --danger-light: rgba(154,64,48,0.07);
  --danger-text: #7A3025;
  --info: #6B6A64;
  --info-light: #F0EFEC;
  --info-text: #5C5B56;

  /* Shadows — мягкие, едва ощутимые */
  --shadow-sm: 0 1px 3px rgba(26,25,24,0.04), 0 1px 2px rgba(26,25,24,0.03);
  --shadow-md: 0 4px 12px rgba(26,25,24,0.06);
  --shadow-lg: 0 12px 32px rgba(26,25,24,0.08);

  /* Radii — крупнее, premium feel */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Cards — на свету без бордера, только тень */
  --card-border: transparent;
  --card-shadow: var(--shadow-sm);

  /* Sidebar — тёмный, акцент = gold */
  --sidebar-width: 260px;
  --sidebar-bg: #1A1918;
  --sidebar-text: #8A8984;
  --sidebar-text-hover: #FFFFFF;
  --sidebar-active-bg: rgba(196,166,0,0.08);
  --sidebar-active-text: #D4C200;
  --sidebar-border: #2D2C28;

  --header-height: 56px;
  --transition: 0.15s ease;
}

/* ======================== DARK THEME ======================== */
[data-theme="dark"] {
  --bg: #141413;
  --bg-secondary: #1C1C1A;
  --surface: #222220;
  --surface-hover: #2A2A28;
  --surface-2: #262624;

  --text: #EFEEEA;
  --text-secondary: #A5A49E;
  --text-muted: #6B6A64;

  --border: #2D2C28;
  --border-light: #222220;

  /* Dark mode: primary button инвертирован (Revolut pattern) */
  --accent: #EFEEEA;
  --accent-hover: #D8D7D3;
  --accent-light: rgba(239,238,234,0.06);
  --accent-text: #1A1918;

  --gold: #D4C200;
  --gold-hover: #C4B400;
  --gold-light: rgba(212,194,0,0.08);
  --gold-subtle: rgba(212,194,0,0.04);
  --gold-text: #E8DA40;
  --gold-on-dark: #D4C200;

  --success: #5A5A54;
  --success-light: #262624;
  --success-text: #B8B8B2;
  --warning: #D4C200;
  --warning-light: rgba(212,194,0,0.08);
  --warning-text: #E8DA40;
  --danger: #C0705A;
  --danger-light: rgba(192,112,90,0.10);
  --danger-text: #E0A090;
  --info: #7A7A74;
  --info-light: #262624;
  --info-text: #9A9A94;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);

  /* Cards — в тёмной теме нужен тонкий бордер */
  --card-border: var(--border);
  --card-shadow: none;

  --sidebar-bg: #0E0E0D;
  --sidebar-text: #6B6A64;
  --sidebar-text-hover: #EFEEEA;
  --sidebar-active-bg: rgba(212,194,0,0.08);
  --sidebar-active-text: #D4C200;
  --sidebar-border: #222220;
}

/* ======================== RESET ======================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
.material-icons-round { display: inline-flex; width: 1em; height: 1em; align-items: center; justify-content: center; overflow: hidden; }
html:not(.material-icons-ready) .material-icons-round { color: transparent !important; }
.hidden { display: none !important; }

/* ======================== SCROLLBAR ======================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ======================== LOGIN SCREEN ======================== */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: #1A1918; padding: 20px;
}
.login-box {
  width: 100%; max-width: 420px; background: #FFFFFF;
  border: none;
  border-radius: var(--radius-xl); padding: 52px 44px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35); text-align: center; color: #1A1918;
}
.login-logo-wrap { margin-bottom: 20px; }
.login-logo-img { height: 38px; width: auto; }
.login-logo { font-family: 'Avenir Next', 'Inter', sans-serif; font-size: 28px; font-weight: 900; letter-spacing: -0.5px; margin-bottom: 4px; color: #1A1918; }
.login-logo span { color: #C4A600; font-weight: 700; }
.login-subtitle { font-size: 12px; color: #A5A49E; margin-bottom: 36px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.login-error { background: var(--danger-light); color: var(--danger-text); padding: 10px 16px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 16px; display: none; }
.login-error.show { display: block; }

/* ======================== FORMS ======================== */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-group-inline { display: flex; align-items: center; gap: 12px; }
.form-group-inline label { margin-bottom: 0; white-space: nowrap; }
.form-input {
  width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text); font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition); outline: none;
}
.form-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-light); }
textarea.form-input { resize: vertical; min-height: 80px; }
select.form-input { cursor: pointer; }

/* ======================== BUTTONS ======================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: 1px solid transparent; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); line-height: 1.4; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-gold { background: var(--gold); color: #FFFFFF; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn-danger { background: var(--danger); color: #FFF; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-xs { padding: 5px 10px; font-size: 11px; }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); }
.btn-ghost { background: none; border: none; color: var(--text-muted); padding: 6px; border-radius: var(--radius-sm); }
.btn-ghost:hover { color: var(--text); background: var(--surface-hover); }
.w-full { width: 100%; justify-content: center; }
.btn-icon-xs {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px; border: none; background: none; border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  transition: all var(--transition);
}
.btn-icon-xs:hover { background: var(--surface-hover); color: var(--text); }
.btn-icon-xs.danger:hover { background: rgba(239,68,68,.1); color: #ef4444; }

/* Nav count badge */
.nav-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--accent); color: var(--accent-text);
  border-radius: 10px; font-size: 11px; font-weight: 700; line-height: 1;
}

/* ======================== APP LAYOUT ======================== */
.app-layout { display: flex; min-height: 100vh; }

/* ======================== SIDEBAR ======================== */
.sidebar {
  width: var(--sidebar-width); background: var(--sidebar-bg);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; border-right: 1px solid var(--sidebar-border);
  transition: transform 0.3s ease;
}
.sidebar-logo {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.sidebar-logo-img { height: 19px; width: auto; }
.sidebar-logo-text { font-family: 'Avenir Next', 'Inter', sans-serif; font-size: 20px; font-weight: 800; color: #FFF; letter-spacing: -0.5px; }
.sidebar-logo-text span { color: var(--gold-on-dark); }
.sidebar-version { font-size: 11px; color: var(--sidebar-text); margin-left: auto; }
.sidebar-nav { flex: 1; padding: 12px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; border: none;
  background: none; color: var(--sidebar-text); border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; cursor: pointer; transition: all var(--transition);
  width: 100%; text-align: left;
}
.nav-item:hover { color: var(--sidebar-text-hover); background: rgba(255,255,255,0.04); }
.nav-item.active { color: var(--sidebar-active-text); background: var(--sidebar-active-bg); border-left: 2px solid var(--sidebar-active-text); margin-left: -2px; }
.nav-item .material-icons-round { font-size: 20px; flex-shrink: 0; }
.nav-item .nav-item-label { flex: 1; }
.nav-item .nav-count { margin-left: auto; }
.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--gold-on-dark);
  color: #1A1918; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { color: #FFF; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: var(--sidebar-text); font-size: 11px; }
.sidebar-logout { background: none; border: none; color: var(--sidebar-text); padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.sidebar-logout:hover { color: var(--danger); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
.sidebar-overlay.show { display: block; }

/* ======================== MAIN CONTENT ======================== */
.main-content { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }
.main-header {
  height: var(--header-height); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-title { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
#menu-toggle { display: none; }

.header-control {
  display: inline-flex; background: var(--bg); border-radius: var(--radius-md); padding: 2px;
  border: 1px solid var(--border); overflow-x: auto; max-width: 100%; flex-shrink: 1;
}
.header-control-btn {
  padding: 4px 10px; border: none; background: none; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  transition: all var(--transition); display: flex; align-items: center; gap: 4px;
}
.header-control-btn:hover { color: var(--text); }
.header-control-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.view-container { flex: 1; padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ======================== CARDS ======================== */
.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius-lg); box-shadow: var(--card-shadow); overflow: clip; }
.card-header {
  padding: 16px 20px; display: flex; align-items: center;
  gap: 12px; border-bottom: 1px solid var(--border-light); flex-wrap: wrap;
}
.card-header > .card-title { flex: 1; min-width: 0; }
.card-header > .flex-center:first-child,
.card-header > .flex-between:first-child { flex: 1; min-width: 0; }
.card-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }
.card-body-flush { padding: 0; }
.card-accent { border-left: 3px solid var(--gold); }
.card-accent-pad { padding: 20px; }

/* ======================== KPI BAR ======================== */
.kpi-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-item {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius-lg);
  padding: 18px 22px; display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: all var(--transition); box-shadow: var(--card-shadow);
}
.kpi-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-icon {
  width: 42px; height: 42px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.kpi-icon.accent { background: var(--gold-light); color: var(--gold); }
.kpi-icon.muted { background: var(--info-light); color: var(--info); }
.kpi-icon .material-icons-round { font-size: 20px; }
.kpi-value { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ======================== TABLES ======================== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
tbody td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }
.td-actions { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.cursor-pointer { cursor: pointer; }

/* ======================== BADGES ======================== */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
}
.badge-dark { background: #1A1918; color: #FFF; }
[data-theme="dark"] .badge-dark { background: #EFEEEA; color: #1A1918; }
.badge-accent { background: var(--gold-light); color: var(--gold-text); }
.badge-gray { background: var(--info-light); color: var(--info); }
.badge-warm { background: var(--gold-light); color: var(--gold-text); }
.badge-muted { background: var(--bg-secondary); color: var(--text-muted); }
.badge-graphite { background: var(--accent-light); color: var(--text-secondary); }
.badge-xs { font-size: 10px; padding: 2px 6px; }

/* Status badges — минимальные, Revolut-style */
.status-active { background: var(--gold-light); color: var(--gold-text); }
.status-done { background: var(--bg-secondary); color: var(--text-muted); }
.status-pending { background: var(--info-light); color: var(--info); }
.status-critical { background: #1A1918; color: var(--gold-on-dark); }
[data-theme="dark"] .status-critical { background: var(--gold-light); color: var(--gold-text); }

/* ======================== PRIORITY ======================== */
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.priority-dot.critical { background: #1A1918; }
[data-theme="dark"] .priority-dot.critical { background: #EFEEEA; }
.priority-dot.high { background: var(--gold); }
.priority-dot.medium { background: var(--text-muted); }
.priority-dot.low { background: var(--border); }
.importance-badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: var(--radius-sm); text-transform: uppercase; }
.importance-badge.critical { background: #1A1918; color: #FFFFFF; }
[data-theme="dark"] .importance-badge.critical { background: #EFEEEA; color: #1A1918; }
.importance-badge.high { background: var(--gold-light); color: var(--gold-text); }
.importance-badge.medium { background: var(--info-light); color: var(--info-text); }
.importance-badge.low { background: var(--bg-secondary); color: var(--text-muted); }

/* ======================== DEADLINE BADGES ======================== */
.deadline-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-sm); }
.deadline-badge.normal { background: var(--info-light); color: var(--info); }
.deadline-badge.urgent { background: var(--gold-light); color: var(--gold-text); }
.deadline-badge.overdue { background: #1A1918; color: #FFFFFF; }
[data-theme="dark"] .deadline-badge.overdue { background: #EFEEEA; color: #1A1918; }
.deadline-badge.done { background: var(--bg-secondary); color: var(--text-muted); }

/* ======================== SECTION ======================== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.section-title { font-size: 16px; font-weight: 700; }
.page-title { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ======================== DASHBOARD GRID ======================== */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

/* ======================== EMPTY STATE ======================== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .material-icons-round { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* ======================== MODAL ======================== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(28,27,23,0.5);
  z-index: 200; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-xl); width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 48px rgba(28,27,23,0.3); animation: modalIn 0.2s ease;
}
.modal-wide { max-width: 800px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-header {
  padding: 20px 24px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); padding: 4px; border-radius: var(--radius-sm); cursor: pointer; }
.modal-close:hover { color: var(--text); background: var(--surface-hover); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ======================== TIMELINE (for pipelines) ======================== */
.timeline { display: flex; align-items: flex-start; overflow-x: auto; padding: 12px 0 20px; }
.timeline-step { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 80px; position: relative; }
.timeline-dot {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--surface); z-index: 1; transition: all var(--transition);
}
.timeline-line {
  position: absolute; top: 8px; left: 50%; right: -50%; height: 2px;
  background: var(--border); z-index: 0;
}
.timeline-step:last-child .timeline-line { display: none; }
.timeline-step.completed .timeline-dot { background: var(--text); border-color: var(--text); }
.timeline-step.completed .timeline-line { background: var(--text); }
.timeline-step.active .timeline-dot { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-light); }
.timeline-label { font-size: 10px; color: var(--text-muted); margin-top: 8px; text-align: center; font-weight: 500; max-width: 80px; }
.timeline-step.completed .timeline-label { color: var(--text); }
.timeline-step.active .timeline-label { color: var(--gold-text); font-weight: 700; }

/* ======================== PIPELINE CARDS ======================== */
.pipeline-card { margin-bottom: 16px; overflow-x: auto; }
.pipeline-card .order-timeline { display: none; padding: 0 20px 20px; }
.pipeline-card.expanded .order-timeline { display: block; }
.order-expand-icon { transition: transform 0.2s; }
.pipeline-card.expanded .order-expand-icon { transform: rotate(180deg); }
.dev-progress-track { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.dev-progress-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width 0.3s; }
.dev-project-name { font-size: 15px; font-weight: 700; }
.assignee-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-muted); background: var(--bg-secondary);
  padding: 2px 10px 2px 6px; border-radius: 20px;
}
.assignee-chip .material-icons-round { font-size: 14px; }

/* Stage history */
.stage-history { padding: 0 0 16px; }
.stage-history-item { display: flex; gap: 16px; padding: 8px 0; position: relative; }
.stage-history-item::before { content: ''; position: absolute; left: 7px; top: 24px; bottom: -8px; width: 2px; background: var(--border); }
.stage-history-item:last-child::before { display: none; }
.stage-history-dot {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  border: 2px solid var(--border); background: var(--surface);
}
.stage-history-item.completed .stage-history-dot { background: var(--text); border-color: var(--text); }
.stage-history-item.active .stage-history-dot { background: var(--gold); border-color: var(--gold); }
.stage-history-content { flex: 1; }
.stage-history-title { font-size: 13px; font-weight: 600; }
.stage-history-date { font-size: 11px; color: var(--text-muted); }
.stage-history-comment { font-size: 12px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.subtask-header-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.dev-card-footer { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border-light); flex-wrap: wrap; }

/* Blocker */
.dev-blocker-panel { background: var(--gold-light); border: 1px solid var(--gold); border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 16px; }
.dev-blocker-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--gold-text); }
.dev-blocker-row { display: flex; gap: 10px; padding: 6px 0; align-items: flex-start; }
.blocker-item { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; }
.blocker-item.active .blocker-icon { color: var(--gold-text); }
.blocker-item.resolved .blocker-icon { color: var(--text-muted); }
.blocker-text { font-size: 12px; }
.blocker-date { font-size: 11px; color: var(--text-muted); }

/* ======================== MEETING CARDS ======================== */
.meeting-card {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius-lg);
  margin-bottom: 12px; overflow: hidden; box-shadow: var(--card-shadow);
  cursor: pointer; transition: all var(--transition);
}
.meeting-card:hover { box-shadow: var(--shadow-md); }
.meeting-card-date { font-size: 15px; font-weight: 700; }
.meeting-card-status { font-size: 12px; }
.meeting-card-body { display: none; padding: 0 20px 20px; border-top: 1px solid var(--border-light); }
.meeting-card.expanded .meeting-card-body { display: block; padding-top: 16px; }

/* Meeting tabs */
.m-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.m-tab {
  padding: 8px 16px; border: none; background: none; font-size: 12px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: all var(--transition);
}
.m-tab:hover { color: var(--text); }
.m-tab.active { color: var(--text); border-bottom-color: var(--gold); }
.m-tab-content { display: none; animation: fadeIn 0.2s ease; }
.m-tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Meeting layout */
.m-layout { display: grid; grid-template-columns: 1fr 280px; gap: 24px; }
.m-main { min-width: 0; }
.meetings-sidebar { }
.m-search-wrap { position: relative; }
.m-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 18px; color: var(--text-muted); }
.m-search-input { padding-left: 40px; }

/* Meeting details sections */
.m-section { margin-bottom: 20px; }
.m-section-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.m-item { padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.m-item:last-child { border-bottom: none; }
.m-item-title { font-size: 13px; font-weight: 600; }
.m-item-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; line-height: 1.5; }
.m-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ======================== LINKED ITEMS ======================== */
.linked-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  background: var(--gold-light); border: 1px solid var(--gold);
  border-radius: 20px; font-size: 11px; font-weight: 600; color: var(--gold-text);
}

/* ======================== FLEX UTILITIES ======================== */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mb-0 { margin-bottom: 0; } .mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; }
.mt-2 { margin-top: 2px; } .mt-4 { margin-top: 4px; } .mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.p-12 { padding: 12px; } .p-16 { padding: 16px; } .p-20 { padding: 20px; }
.text-sm { font-size: 13px; } .text-xs { font-size: 11px; } .text-base { font-size: 14px; }
.text-muted { color: var(--text-muted); } .text-accent { color: var(--gold-text); }
.font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.icon-14 { font-size: 14px; } .icon-16 { font-size: 16px; } .icon-18 { font-size: 18px; } .icon-20 { font-size: 20px; }
.icon-inline { vertical-align: middle; }
.grid-half { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.overflow-x-auto { overflow-x: auto; }
.inline-flex { display: inline-flex; }

/* ======================== TOAST ======================== */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--gold);
  padding: 14px 20px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500;
  animation: slideIn 0.3s ease; max-width: 400px;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ======================== CONFIRM DIALOG ======================== */
.confirm-dialog-body { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px; text-align: center; }
.confirm-dialog-icon { font-size: 40px; color: var(--gold); }

/* ======================== TABS (pipeline settings etc) ======================== */
.tab-group { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn {
  padding: 8px 16px; border: none; background: none; font-size: 12px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--gold); }

/* ======================== MEETING DATE BLOCK (CHICO OS style) ======================== */
.meeting-date-block { display: flex; flex-direction: column; align-items: center; min-width: 54px; padding: 8px 12px; background: var(--accent-light); border-radius: var(--radius-md); text-align: center; flex-shrink: 0; }
.meeting-date-day { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -1px; color: var(--text); }
.meeting-date-month { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; white-space: nowrap; }
.meeting-title-row { display: flex; align-items: flex-start; gap: 16px; flex: 1; min-width: 0; }
.meeting-meta { flex: 1; min-width: 0; padding-top: 4px; }
.meeting-meta-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meeting-meta-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meeting-card-header { padding: 16px 20px; display: flex; align-items: center; gap: 16px; cursor: pointer; flex-wrap: wrap; }
.meeting-card-header .meeting-title-row { flex: 1; min-width: 0; }
.meeting-card-header .header-control { flex-basis: 100%; order: 10; border-top: 1px solid var(--border-light); padding-top: 10px; }
.meeting-card.expanded .order-expand-icon { transform: rotate(180deg); }
.order-expand-icon { transition: transform var(--transition); }
.meeting-3dot { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); flex-shrink: 0; }
.meeting-3dot:hover { background: var(--bg-secondary); color: var(--text); }

/* Meeting sub-tabs (inside Overview tab) */
.m-subtabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.m-subtab {
  padding: 5px 14px; border: 1px solid var(--border); background: none; border-radius: 20px;
  font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.m-subtab:hover { color: var(--text); border-color: var(--text-muted); }
.m-subtab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* File chip */
.file-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  background: var(--surface-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 11px; color: var(--text-secondary);
  margin: 2px 2px 0 0; cursor: default; white-space: nowrap;
}
.stage-history-files { display: flex; flex-wrap: wrap; gap: 4px; }

/* m-section-title flex (for inline Add button) */
.m-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ======================== MINI CALENDAR ======================== */
.mcal-title { font-size: 13px; font-weight: 700; }
.mcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mcal-day { font-size: 10px; text-align: center; padding: 2px; font-weight: 600; color: var(--text-muted); }
.mcal-cell {
  font-size: 11px; text-align: center; padding: 6px 2px; border-radius: var(--radius-sm);
  cursor: default; color: var(--text-secondary);
}
.mcal-cell.has-meeting { background: var(--gold-light); color: var(--gold-text); font-weight: 700; cursor: pointer; }
.mcal-cell.today { border: 1px solid var(--gold); font-weight: 700; }

/* ======================== QUICK STATS ======================== */
.m-stats-label { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.m-stat-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border-light); }
.m-stat-row:last-child { border-bottom: none; }
.m-stat-val { font-weight: 700; }

/* ======================== RESPONSIVE ======================== */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  #menu-toggle { display: flex; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .m-layout { grid-template-columns: 1fr; }
  .meetings-sidebar { display: none; }
  .grid-half { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .view-container { padding: 12px; }
  /* card-header: title + add-btn в одной строке, header-control под ними */
  .card-header { gap: 8px; }
  .card-header .header-control {
    order: 10;
    flex-basis: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  /* Горизонтальный скролл для pipeline-card и table-wrapper внутри card */
  .card { overflow-x: auto; }
  .pipeline-card { min-width: 0; }
  .table-wrapper { min-width: 480px; }
}

/* ======================== STAGE 0 CONTROL CENTER ======================== */
.stage0-layout { min-height: 100dvh; }
.stage0-brand { height: auto; min-height: 92px; align-items: flex-start; flex-direction: column; gap: 12px; padding-top: 22px; padding-bottom: 18px; }
.stage0-brand .sidebar-logo-img { height: 22px; }
.stage0-brand-meta { display: flex; flex-direction: column; gap: 3px; }
.stage0-brand-meta span { color: rgba(255,255,255,.36); font-size: 8px; font-weight: 800; letter-spacing: 1.4px; }
.stage0-brand-meta strong { color: rgba(255,255,255,.82); font-size: 11px; font-weight: 600; }
.stage0-nav { padding-top: 20px; }
.stage0-nav .nav-item { min-height: 48px; border-radius: 9px; }
.stage0-nav .nav-item > .material-icons-round { width: 20px; display: inline-flex; justify-content: center; }
.stage0-nav .nav-item-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage0-footer { min-height: 78px; }
.stage0-header { min-height: 78px; height: auto; padding-top: 12px; padding-bottom: 12px; }
.stage0-eyebrow { margin: 0 0 3px; color: var(--text-muted); font-size: 8px; line-height: 1; font-weight: 800; letter-spacing: 1.25px; }
.stage0-header .header-title { font-size: 18px; letter-spacing: -.35px; }
.stage0-header-actions { gap: 10px; }
.stage0-refresh { min-height: 40px; gap: 6px; }
.stage0-refresh .material-icons-round { font-size: 17px; }
.stage0-refresh.is-loading .material-icons-round { animation: stage0-spin .75s linear infinite; }
.mobile-only { display: none; }

.runtime-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 13px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: 11px; font-weight: 700; }
.runtime-dot { width: 7px; height: 7px; border-radius: 50%; background: #6d725c; box-shadow: 0 0 0 4px rgba(109,114,92,.1); }
.runtime-pill.is-error .runtime-dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-light); }

.stage0-view { max-width: 1320px; padding: 34px 32px 54px; }
.stage0-hero { position: relative; min-height: 300px; display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; overflow: hidden; padding: 42px; color: #fff; border-radius: 24px; background: #171714; box-shadow: 0 22px 60px rgba(20,20,18,.14); }
.stage0-hero::before { content: ''; position: absolute; width: 440px; height: 440px; right: -125px; top: -215px; border-radius: 50%; border: 92px solid rgba(255,237,0,.12); }
.stage0-hero::after { content: ''; position: absolute; width: 1px; height: 180%; left: 66%; top: -45%; background: rgba(255,255,255,.08); transform: rotate(34deg); }
.stage0-hero-copy { position: relative; z-index: 1; max-width: 720px; }
.stage0-kicker, .stage0-page-intro > span { display: block; margin-bottom: 18px; color: #d5c33b; font-size: 9px; font-weight: 800; letter-spacing: 1.6px; }
.stage0-hero h2 { max-width: 650px; margin: 0; font-size: clamp(38px, 5vw, 66px); line-height: .98; letter-spacing: -3.5px; }
.stage0-hero p { max-width: 660px; margin: 24px 0 0; color: rgba(255,255,255,.58); font-size: 14px; line-height: 1.65; }
.stage0-gate-orbit { position: relative; z-index: 1; width: 124px; height: 124px; flex: 0 0 124px; display: grid; place-content: center; text-align: center; border: 1px solid rgba(255,237,0,.35); border-radius: 50%; background: rgba(255,255,255,.03); box-shadow: inset 0 0 0 9px rgba(255,255,255,.02); }
.stage0-gate-orbit::after { content: ''; position: absolute; inset: -7px; border: 1px solid rgba(255,255,255,.07); border-radius: 50%; }
.stage0-gate-orbit strong { font-size: 36px; line-height: 1; letter-spacing: -2px; }
.stage0-gate-orbit strong span { color: rgba(255,255,255,.32); font-size: 17px; letter-spacing: -1px; }
.stage0-gate-orbit small { margin-top: 8px; color: rgba(255,255,255,.42); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }

.stage0-section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin: 38px 0 15px; }
.stage0-section-head span, .panel-heading span, .muted-label { color: var(--text-muted); font-size: 8px; font-weight: 800; letter-spacing: 1.2px; }
.stage0-section-head h2, .panel-heading h3 { margin: 5px 0 0; color: var(--text); font-size: 19px; letter-spacing: -.45px; }
.stage0-section-head p { margin: 0; color: var(--text-muted); font-size: 11px; }
.stage0-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.stage0-card { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.binding-card { min-height: 175px; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease; }
.binding-card:hover { transform: translateY(-2px); border-color: rgba(196,166,0,.28); box-shadow: var(--shadow-md); }
.binding-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.binding-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--bg-secondary); color: var(--text); }
.binding-icon .material-icons-round { font-size: 19px; }
.binding-card h3 { margin: 0; font-size: 16px; letter-spacing: -.2px; }
.binding-card p { margin: 7px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 6px 8px; border-radius: 999px; background: var(--bg-secondary); color: var(--text-muted); font-size: 9px; font-weight: 750; white-space: nowrap; }
.status-chip > span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-chip.good { color: #596044; background: rgba(89,96,68,.09); }
.status-chip.bad { color: var(--danger); background: var(--danger-light); }
.status-chip.pending { color: var(--gold-text); background: var(--gold-light); }

.stage0-two-column { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .6fr); gap: 13px; margin-top: 13px; }
.stage0-panel { padding: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.text-action { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: 10px; font-weight: 700; cursor: pointer; min-height: 32px; }
.text-action .material-icons-round { font-size: 14px; }
.gate-list { display: flex; flex-direction: column; }
.gate-row { display: grid; grid-template-columns: 34px 1fr 28px; align-items: center; gap: 12px; min-height: 60px; border-top: 1px solid var(--border-light); }
.gate-row:first-child { border-top: 0; }
.gate-number { color: var(--text-muted); font-size: 9px; font-weight: 800; }
.gate-row strong { display: block; font-size: 12px; font-weight: 650; }
.gate-row small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 9px; }
.gate-state { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--bg-secondary); color: var(--text-muted); }
.gate-state.good { background: rgba(89,96,68,.09); color: #596044; }
.gate-state.bad { background: var(--danger-light); color: var(--danger); }
.gate-state.pending { background: var(--gold-light); color: var(--gold-text); }
.gate-state .material-icons-round { font-size: 14px; }
.next-action-panel { position: relative; overflow: hidden; background: var(--gold-light); }
.next-action-index { position: absolute; right: 14px; bottom: -20px; color: rgba(196,166,0,.11); font-size: 118px; line-height: 1; font-weight: 900; letter-spacing: -10px; }
.next-action-panel h4 { position: relative; margin: 46px 0 10px; font-size: 21px; line-height: 1.1; letter-spacing: -.65px; }
.next-action-panel p { position: relative; max-width: 340px; margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.65; }
.next-action-meta { position: relative; display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 30px; color: var(--text-secondary); font-size: 9px; font-weight: 700; }
.next-action-meta span { display: inline-flex; align-items: center; gap: 5px; }
.next-action-meta .material-icons-round { font-size: 14px; color: var(--gold-text); }

.stage0-page-intro { max-width: 810px; margin: 18px 0 34px; }
.stage0-page-intro > span { color: var(--gold-text); margin-bottom: 13px; }
.stage0-page-intro h2 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.02; letter-spacing: -2.1px; }
.stage0-page-intro p { max-width: 720px; margin: 18px 0 0; color: var(--text-secondary); font-size: 13px; line-height: 1.65; }
.fresh-scenario-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.mirror-scenario-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-section-head { margin-top: 24px; }
.fresh-scenario { position: relative; min-height: 210px; display: flex; flex-direction: column; align-items: flex-start; padding: 20px; overflow: hidden; }
.fresh-scenario .status-chip { margin-left: auto; }
.scenario-index { position: absolute; left: 14px; top: 8px; color: var(--bg-secondary); font-size: 78px; line-height: 1; font-weight: 900; letter-spacing: -7px; }
.fresh-scenario h3 { position: relative; margin: auto 0 8px; max-width: 190px; font-size: 16px; line-height: 1.2; letter-spacing: -.25px; }
.fresh-scenario p { position: relative; margin: 0; color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; }
.command-panel { margin-top: 13px; }
.empty-inline { min-height: 76px; display: grid; place-items: center; border: 1px dashed var(--border); border-radius: 10px; color: var(--text-muted); font-size: 11px; text-align: center; padding: 18px; }
.command-list { display: flex; flex-direction: column; }
.command-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; padding: 13px 0; border-top: 1px solid var(--border-light); font-size: 10px; }
.command-row code { color: var(--text); }
.command-row span { color: var(--text-muted); }

.data-layer-stack { overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.data-layer-row { min-height: 118px; display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 24px; padding: 20px 24px; border-top: 1px solid var(--border-light); }
.data-layer-row:first-child { border-top: 0; }
.layer-no { color: var(--gold-text); font-size: 10px; font-weight: 800; }
.data-layer-row h3 { margin: 0; font-size: 17px; letter-spacing: -.25px; }
.data-layer-row p { margin: 8px 0 0; color: var(--text-secondary); font-size: 11px; line-height: 1.55; }

.progress-intro { margin-bottom: 22px; }
.progress-policy { display: grid; grid-template-columns: 48px 1fr; gap: 18px; align-items: center; padding: 22px; border-radius: 17px; background: #171714; color: #fff; box-shadow: var(--shadow-lg); }
.progress-policy-icon { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid rgba(255,237,0,.35); border-radius: 14px; color: var(--gold-on-dark); }
.progress-policy-icon .material-icons-round { font-size: 22px; }
.progress-policy span, .progress-summary article > div > span, .progress-gate-card > span, .progress-closure-card > span { color: #d5c33b; font-size: 8px; font-weight: 800; letter-spacing: 1.25px; }
.progress-policy h3 { margin: 5px 0 4px; font-size: 19px; }
.progress-policy p { margin: 0; color: rgba(255,255,255,.58); font-size: 11px; line-height: 1.5; }
.progress-summary { display: grid; grid-template-columns: 1.4fr .7fr .9fr; gap: 13px; margin-top: 13px; }
.progress-summary > article { min-height: 155px; padding: 20px; }
.progress-active-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.progress-active-card h3 { margin: 22px 0 2px; font-size: 28px; letter-spacing: -1px; }
.progress-active-card p { margin: 0; color: var(--text-muted); font-size: 11px; }
.progress-gate-card strong { display: block; margin-top: 24px; font-size: 34px; line-height: 1; letter-spacing: -1.5px; }
.progress-gate-card strong small { color: var(--text-muted); font-size: 16px; }
.progress-gate-card p, .progress-closure-card p { margin: 9px 0 0; color: var(--text-muted); font-size: 9px; line-height: 1.5; }
.progress-closure-card strong { display: block; margin-top: 25px; font-size: 18px; }
.progress-stage-list { overflow: hidden; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.progress-stage-row { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 22px; min-height: 118px; padding: 20px 24px; border-top: 1px solid var(--border-light); }
.progress-stage-row:first-child { border-top: 0; }
.progress-stage-row.in_progress { background: linear-gradient(90deg, var(--gold-light), transparent 46%); }
.progress-stage-code { color: var(--gold-text); font-size: 19px; font-weight: 850; letter-spacing: -1px; }
.progress-stage-copy h3 { margin: 0 0 8px; font-size: 15px; }
.progress-stage-copy p { margin: 3px 0; color: var(--text-muted); font-size: 9px; line-height: 1.45; }
.progress-stage-copy p strong { color: var(--text-secondary); }
.progress-gates-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.progress-gate-item { min-height: 135px; padding: 17px; }
.progress-gate-item h3 { margin: 23px 0 6px; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.progress-gate-item p { margin: 0; color: var(--text-muted); font-size: 8px; }

.settings-intro { margin-bottom: 22px; }
.settings-lock { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; padding: 12px 15px; border: 1px solid var(--gold); border-radius: 12px; background: var(--gold-light); color: var(--gold-text); font-size: 11px; font-weight: 700; }
.settings-lock .material-icons-round { font-size: 16px; }
.settings-form { display: flex; flex-direction: column; gap: 13px; }
.settings-group { overflow: hidden; }
.settings-group-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--bg-secondary); }
.settings-group-head span { color: var(--text); font-size: 13px; font-weight: 750; }
.settings-group-head strong { color: var(--text-muted); font-size: 9px; font-weight: 700; }
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); align-items: center; gap: 28px; padding: 20px; border-top: 1px solid var(--border-light); }
.settings-group-head + .setting-row { border-top: 0; }
.setting-title-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 12px; }
.setting-title-line h3 { margin: 0; font-size: 14px; letter-spacing: -.2px; }
.setting-title-line code { color: var(--text-muted); font-size: 8px; }
.setting-copy p { max-width: 680px; margin: 7px 0 0; color: var(--text-secondary); font-size: 11px; line-height: 1.5; }
.setting-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 9px; color: var(--text-muted); font-size: 9px; }
.setting-source { padding: 3px 7px; border-radius: 999px; background: var(--bg-secondary); font-weight: 750; }
.setting-source.d1 { color: #596044; background: rgba(89,96,68,.09); }
.setting-source.deployment { color: var(--gold-text); background: var(--gold-light); }
.setting-action { display: flex; flex-direction: column; align-items: stretch; gap: 7px; }
.setting-number-wrap { position: relative; }
.setting-number-wrap span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 9px; pointer-events: none; }
.setting-control { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 12px; font-weight: 650; outline: none; transition: border-color 120ms ease, box-shadow 120ms ease; }
.setting-number-wrap .setting-control { padding-right: 52px; }
.setting-control:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(196,166,0,.12); }
.setting-control:disabled { opacity: .55; cursor: not-allowed; }
.setting-reset { align-self: flex-end; min-height: 26px; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 9px; font-weight: 650; cursor: pointer; }
.setting-reset:not(:disabled):hover { color: var(--text); }
.setting-reset:disabled { opacity: .35; cursor: default; }
.setting-readonly-value { display: flex; align-items: baseline; justify-content: flex-end; gap: 7px; min-height: 42px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-secondary); }
.setting-readonly-value strong { font-size: 17px; }
.setting-readonly-value span { color: var(--text-muted); font-size: 9px; }
.load-profile-note { display: flex; align-items: center; gap: 9px; padding: 14px 20px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); font-size: 10px; line-height: 1.5; }
.load-profile-note .material-icons-round { flex: 0 0 auto; color: var(--gold-text); font-size: 17px; }
.load-profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; }
.load-profile-card { min-width: 0; padding: 15px; border: 1px solid var(--border-light); border-radius: 13px; background: var(--bg-secondary); }
.load-profile-card > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.load-profile-card code { overflow: hidden; color: var(--text-secondary); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.load-profile-card > strong { display: block; margin: 17px 0 13px; font-size: 27px; letter-spacing: -1px; }
.load-profile-card > strong small { color: var(--text-muted); font-size: 9px; letter-spacing: 0; }
.load-profile-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.load-profile-card dl div { min-width: 0; }
.load-profile-card dt { color: var(--text-muted); font-size: 8px; }
.load-profile-card dd { margin: 3px 0 0; overflow-wrap: anywhere; font-size: 10px; font-weight: 700; }
.load-profile-empty { padding: 25px 20px; color: var(--text-muted); font-size: 10px; text-align: center; }
.btn-compact { min-height: 38px; padding: 0 14px; font-size: 10px; }
.refresh-pool-panel { margin-top: 13px; }
.refresh-pool-rule { max-width: 760px; margin: -4px 0 18px; color: var(--text-secondary); font-size: 10px; line-height: 1.55; }
.refresh-job-list { overflow: hidden; border: 1px solid var(--border-light); border-radius: 13px; }
.refresh-job-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 13px 15px; border-top: 1px solid var(--border-light); }
.refresh-job-row:first-child { border-top: 0; }
.refresh-job-row strong { display: block; font-size: 10px; }
.refresh-job-row small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 8px; }
.refresh-job-row code { max-width: 220px; overflow: hidden; color: var(--text-muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.settings-savebar { position: sticky; bottom: 12px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 15px 18px; border: 1px solid rgba(196,166,0,.32); border-radius: 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow-lg); backdrop-filter: blur(16px); }
.settings-savebar > div { display: flex; flex-direction: column; gap: 3px; }
.settings-savebar strong { font-size: 11px; }
.settings-savebar span { color: var(--text-muted); font-size: 9px; }
.settings-savebar .btn { min-height: 40px; gap: 7px; }
.settings-savebar .material-icons-round { font-size: 16px; }

.stage0-error { min-height: 58vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.stage0-error > .material-icons-round { margin-bottom: 20px; color: var(--gold); font-size: 38px; }
.stage0-error > span { color: var(--gold-text); font-size: 8px; font-weight: 800; letter-spacing: 1.4px; }
.stage0-error h2 { margin: 10px 0; font-size: 30px; letter-spacing: -1px; }
.stage0-error p { max-width: 520px; margin: 0 0 24px; color: var(--text-secondary); font-size: 12px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.stage0-toast { max-width: min(360px, calc(100vw - 32px)); padding: 12px 16px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-size: 11px; font-weight: 650; animation: stage0-toast-in 140ms ease-out; }
.stage0-skeleton { position: relative; overflow: hidden; border-radius: 18px; background: var(--bg-secondary); }
.stage0-skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); animation: stage0-shimmer 1.2s infinite; }
.skeleton-hero { height: 300px; margin-bottom: 38px; }
.skeleton-card { height: 175px; }

@keyframes stage0-spin { to { transform: rotate(360deg); } }
@keyframes stage0-toast-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes stage0-shimmer { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 1080px) {
  .stage0-card-grid, .fresh-scenario-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage0-two-column { grid-template-columns: 1fr; }
  .progress-summary { grid-template-columns: 1fr; }
  .progress-gates-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-only { display: flex; }
}

@media (max-width: 700px) {
  .stage0-header { min-height: 70px; padding: 10px 14px; }
  .stage0-eyebrow, .runtime-pill, .stage0-refresh span:not(.material-icons-round) { display: none; }
  .stage0-header-actions { gap: 5px; }
  .stage0-refresh { width: 40px; padding: 0; justify-content: center; }
  .stage0-view { padding: 18px 12px 34px; }
  .stage0-hero { min-height: 360px; align-items: flex-start; padding: 28px 24px; }
  .stage0-hero h2 { font-size: 42px; letter-spacing: -2.4px; }
  .stage0-hero p { font-size: 12px; }
  .stage0-gate-orbit { position: absolute; right: 28px; bottom: 28px; width: 90px; height: 90px; flex-basis: 90px; }
  .stage0-gate-orbit strong { font-size: 28px; }
  .stage0-section-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .stage0-card-grid, .fresh-scenario-grid { grid-template-columns: 1fr; }
  .binding-card { min-height: 142px; }
  .fresh-scenario { min-height: 170px; }
  .data-layer-row { grid-template-columns: 34px 1fr; gap: 12px; padding: 18px; }
  .data-layer-row .status-chip { grid-column: 2; }
  .command-row { grid-template-columns: 1fr; gap: 5px; }
  .progress-stage-row { grid-template-columns: 60px 1fr; gap: 12px; padding: 18px; }
  .progress-stage-row .status-chip { grid-column: 2; }
  .progress-gates-grid { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; gap: 16px; padding: 18px; }
  .load-profile-grid { grid-template-columns: 1fr; }
  .refresh-job-row { grid-template-columns: 1fr; }
  .refresh-job-row code { max-width: 100%; }
  .settings-savebar { align-items: stretch; flex-direction: column; }
  .settings-savebar .btn { width: 100%; justify-content: center; }
}
