:root {
    --bg: #0b1120;
    --panel: #121a2b;
    --panel-2: #182238;
    --panel-3: #1e2a44;
    --border: #263146;
    --border-strong: #334261;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --accent: #818cf8;
    --accent-strong: #6366f1;
    --accent-faint: rgba(129, 140, 248, 0.12);
    --accent-border: rgba(129, 140, 248, 0.35);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.14);
    --success-border: rgba(16, 185, 129, 0.35);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.14);
    --warning-border: rgba(245, 158, 11, 0.35);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.14);
    --danger-border: rgba(239, 68, 68, 0.35);
    --info: #06b6d4;
    --info-bg: rgba(6, 182, 212, 0.14);
    --info-border: rgba(6, 182, 212, 0.35);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.3);
    --radius: 10px;
    --radius-sm: 6px;
  }

  body.light {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --panel-3: #eef2f7;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    --accent: #4f46e5;
    --accent-strong: #4338ca;
    --accent-faint: rgba(79, 70, 229, 0.1);
    --accent-border: rgba(79, 70, 229, 0.3);
    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.1);
    --success-border: rgba(5, 150, 105, 0.3);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --warning-border: rgba(217, 119, 6, 0.3);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.1);
    --danger-border: rgba(220, 38, 38, 0.3);
    --info: #0891b2;
    --info-bg: rgba(8, 145, 178, 0.1);
    --info-border: rgba(8, 145, 178, 0.3);
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06);
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; height: 100%; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  code, pre, .mono { font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; }

  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; }
  button { font: inherit; cursor: pointer; }
  input, select, textarea { font: inherit; }

  .hidden { display: none !important; }

  /* ===== LOGIN ===== */
  .login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
      radial-gradient(1200px 600px at 20% 10%, rgba(129, 140, 248, 0.18), transparent 60%),
      radial-gradient(900px 500px at 80% 90%, rgba(6, 182, 212, 0.15), transparent 60%),
      var(--bg);
  }
  .login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 42px 40px;
    width: 420px;
    max-width: calc(100% - 32px);
    box-shadow: var(--shadow);
    text-align: center;
  }
  .login-logo {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent-strong), var(--info));
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 18px;
  }
  .login-card h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.01em; }
  .login-card .tagline { color: var(--text-muted); margin: 0 0 28px; font-size: 13.5px; }
  .btn-sso {
    width: 100%;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    padding: 11px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    transition: background 0.15s;
  }
  .btn-sso:hover { background: #f1f5f9; }
  .ms-tile { width: 16px; height: 16px; display: inline-block; }
  .login-footer {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-dim);
  }
  .login-footer .mono { color: var(--text-muted); }

  /* ===== APP SHELL ===== */
  .shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas: "sidebar topbar" "sidebar main";
    min-height: 100vh;
  }
  .sidebar {
    grid-area: sidebar;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 14px 0;
    overflow-y: auto;
  }
  .brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 18px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }
  .brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-strong), var(--info));
    display: inline-flex; align-items: center; justify-content: center;
  }
  .brand-text { font-weight: 700; letter-spacing: -0.01em; }
  .brand-sub { font-size: 11px; color: var(--text-dim); letter-spacing: 0.04em; text-transform: uppercase; }

  .nav-section { padding: 6px 10px; }
  .nav-label {
    font-size: 11px; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.08em;
    padding: 10px 10px 6px;
    font-weight: 600;
  }
  .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    font-weight: 500;
  }
  .nav-item:hover { background: var(--panel-2); color: var(--text); }
  .nav-item.active {
    background: var(--accent-faint);
    color: var(--accent);
  }
  .nav-item .icn { width: 16px; height: 16px; flex: 0 0 16px; }
  .nav-sub {
    margin-left: 24px;
    display: flex; flex-direction: column; gap: 2px;
    padding: 2px 0 6px;
  }
  .nav-sub .nav-item { padding: 6px 10px; font-size: 13px; font-weight: 400; }
  .nav-sub .nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); }

  /* ===== TOPBAR ===== */
  .topbar {
    grid-area: topbar;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    padding: 0 20px;
  }
  .crumbs {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted); font-size: 13px;
    flex: 1;
  }
  .crumbs .sep { color: var(--text-dim); }
  .crumbs .here { color: var(--text); font-weight: 600; }
  .topbar-actions { display: flex; align-items: center; gap: 10px; }
  .search {
    display: flex; align-items: center; gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    width: 280px;
    color: var(--text-muted);
    font-size: 13px;
  }
  .search input {
    flex: 1; background: transparent; border: 0; outline: 0; color: var(--text);
  }
  .search kbd {
    font-size: 11px; color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 1px 5px; border-radius: 4px;
    background: var(--panel-3);
  }
  .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
  }
  .icon-btn {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent; border: 1px solid var(--border);
    color: var(--text-muted);
  }
  .icon-btn:hover { background: var(--panel-2); color: var(--text); }

  /* ===== MAIN ===== */
  main.main {
    grid-area: main;
    padding: 24px 28px 48px;
    overflow-y: auto;
  }

  .page-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
    margin-bottom: 22px;
  }
  .page-head h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
  .page-head p { margin: 0; color: var(--text-muted); font-size: 13.5px; }
  .page-actions { display: flex; align-items: center; gap: 8px; }

  .btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
  }
  .btn:hover { background: var(--panel-3); border-color: var(--border-strong); }
  .btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
  .btn-primary:hover { background: var(--accent); border-color: var(--accent); }
  .btn-danger-ghost { color: var(--danger); border-color: var(--danger-border); }
  .btn-danger-ghost:hover { background: var(--danger-bg); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  /* ===== STAT ROW ===== */
  .stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
  .stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
  }
  .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; letter-spacing: 0.02em; }
  .stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
  .stat-value .unit { font-size: 13px; color: var(--text-dim); font-weight: 500; margin-left: 4px; }
  .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

  /* ===== ENV CARDS ===== */
  .cluster-header {
    display: flex; align-items: center; justify-content: space-between;
    margin: 24px 0 12px;
  }
  .cluster-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 15px; font-weight: 600;
  }
  .cluster-chip {
    font-size: 11px; color: var(--text-muted);
    padding: 2px 8px; border-radius: 999px;
    background: var(--panel-2);
    border: 1px solid var(--border);
  }

  .env-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
  .env-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px 14px;
    position: relative;
    display: flex; flex-direction: column; gap: 10px;
    transition: border-color 0.15s, transform 0.1s;
  }
  .env-card:hover { border-color: var(--border-strong); cursor: pointer; }
  .env-card.pinned::before {
    content: "";
    position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
    border-radius: 2px;
    background: var(--accent);
  }
  .env-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  }
  .env-name {
    font-weight: 700; font-size: 15px;
    display: flex; align-items: center; gap: 8px;
  }
  .env-tag {
    font-size: 10.5px; font-weight: 700;
    padding: 2px 7px; border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.06em;
  }
  .env-tag.pinned { background: var(--accent-faint); color: var(--accent); border: 1px solid var(--accent-border); }
  .env-tag.ephemeral { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }

  .env-meta { color: var(--text-muted); font-size: 12.5px; }
  .env-meta .mono { color: var(--text); }

  .owner-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 2px 7px; border-radius: 999px;
    font-size: 11px;
    color: var(--text-muted);
  }
  .owner-chip .av-s {
    width: 14px; height: 14px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-strong), var(--info));
    color: #fff; font-size: 8px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
  }

  .service-list { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
  .service-pill {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 10px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
  }
  .service-pill .left { display: flex; align-items: center; gap: 8px; }
  .service-pill .svc-name { font-weight: 600; }
  .service-pill .branch { color: var(--text-muted); font-size: 12px; }

  .ticket-row {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px;
  }
  .ticket {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 3px 8px; border-radius: 999px;
    color: var(--text-muted);
  }
  .ticket .code { color: var(--text); font-weight: 600; font-family: "SF Mono", Menlo, Consolas, monospace; }
  .ticket .st { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); }
  .ticket .st.todo { background: var(--text-dim); }
  .ticket .st.inprogress { background: var(--info); }
  .ticket .st.review { background: var(--warning); }
  .ticket .st.done { background: var(--success); }
  .ticket .qa-tick {
    color: var(--success); font-weight: 700; font-size: 11px;
    margin-left: 2px;
  }

  .health-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(0,0,0,0);
  }
  .health-dot.healthy { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
  .health-dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }
  .health-dot.err { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
  .health-dot.deploying {
    background: var(--info);
    box-shadow: 0 0 0 3px var(--info-bg);
    animation: pulse 1.6s infinite;
  }
  @keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(6, 182, 212, 0); }
    100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
  }

  .add-env-card {
    background: transparent;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: grid; place-items: center;
    min-height: 180px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 14px;
  }
  .add-env-card:hover { border-color: var(--accent-border); color: var(--accent); }
  .add-env-card .plus { font-size: 24px; margin-bottom: 4px; }

  /* ===== ENV DETAIL ===== */
  .detail-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
    padding-bottom: 18px; margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
  }
  .detail-title { display: flex; align-items: center; gap: 12px; }
  .detail-title h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; }

  .tabs {
    display: flex; gap: 2px; border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
  }
  .tab {
    padding: 10px 14px;
    color: var(--text-muted);
    font-size: 13px; font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
  }
  .tab:hover { color: var(--text); }
  .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  .panel-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 14px;
  }
  .panel-card h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-muted); }
  .panel-card .panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .panel-card .panel-head h3 { margin: 0; }

  .detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
  @media (max-width: 1100px) { .detail-grid { grid-template-columns: 1fr; } }

  /* ===== DEPLOYMENT TABLE ===== */
  table.deploy-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
  }
  .deploy-table th, .deploy-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
  }
  .deploy-table th {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600;
  }
  .deploy-table tr:last-child td { border-bottom: 0; }
  .deploy-table .svc { font-weight: 600; }
  .deploy-table .branch-cell {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--panel-2); padding: 2px 8px; border-radius: 4px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
  }
  .deploy-table .sha {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px; color: var(--text-muted);
  }

  /* ===== TICKET LIST (QA SIGN-OFF) ===== */
  .ticket-list { display: flex; flex-direction: column; gap: 8px; }
  .ticket-item {
    display: grid;
    grid-template-columns: 32px auto 1fr auto;
    gap: 12px; align-items: center;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  .ticket-item .code {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px; font-weight: 700; color: var(--accent);
  }
  .ticket-item .title { font-size: 13.5px; }
  .ticket-item .meta { font-size: 12px; color: var(--text-muted); }
  .ticket-item.tested { background: var(--success-bg); border-color: var(--success-border); }
  .ticket-item.tested .title { color: var(--text); }

  .qa-check {
    width: 22px; height: 22px;
    border-radius: 6px;
    border: 1.5px solid var(--border-strong);
    background: var(--panel-3);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: transparent;
    transition: all 0.15s;
  }
  .qa-check:hover { border-color: var(--success); }
  .qa-check.on {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
  }

  .qa-stamp {
    font-size: 11px; color: var(--text-muted);
    text-align: right;
  }
  .qa-stamp .who { color: var(--text); font-weight: 600; }

  .status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600;
    padding: 3px 9px; border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .status-badge.todo { background: var(--panel-3); color: var(--text-muted); }
  .status-badge.inprogress { background: var(--info-bg); color: var(--info); }
  .status-badge.review { background: var(--warning-bg); color: var(--warning); }
  .status-badge.done { background: var(--success-bg); color: var(--success); }
  .status-badge.tested { background: var(--success-bg); color: var(--success); }

  /* ===== TIMELINE ===== */
  .timeline { position: relative; padding-left: 20px; }
  .timeline::before {
    content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px;
    width: 2px; background: var(--border);
  }
  .timeline-item {
    position: relative; padding: 6px 0 14px;
  }
  .timeline-item::before {
    content: ""; position: absolute; left: -17px; top: 11px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--panel);
    border: 2px solid var(--accent);
  }
  .timeline-item.err::before { border-color: var(--danger); }
  .timeline-item.ok::before { border-color: var(--success); }
  .timeline-time { font-size: 11.5px; color: var(--text-dim); }
  .timeline-text { font-size: 13px; }
  .timeline-text .mono { color: var(--text); }

  /* ===== PODS ===== */
  .pod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
  .pod {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
  }
  .pod .name { font-weight: 600; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
  .pod .meta { color: var(--text-muted); font-size: 11.5px; }

  /* ===== SETTINGS ===== */
  .setting-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
  }
  .setting-section h2 {
    margin: 0 0 4px;
    font-size: 15px;
    display: flex; align-items: center; gap: 10px;
  }
  .setting-section .section-desc {
    color: var(--text-muted); margin: 0 0 14px; font-size: 13px;
  }
  .setting-section-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 12px;
  }

  /* ===== STRATEGY CARDS ===== */
  .strategy-list { display: flex; flex-direction: column; gap: 14px; }
  .strategy-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    position: relative;
  }
  .strategy-head {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 14px; align-items: center;
    margin-bottom: 14px;
  }
  .strategy-ord {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--panel-3); color: var(--text); font-weight: 700; font-size: 13px;
  }
  .strategy-type-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
  .strategy-type-row { display: flex; align-items: center; gap: 10px; }
  .strategy-select {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 13px;
    min-width: 180px;
  }
  .strategy-name {
    font-weight: 600; font-size: 14px;
  }
  .strategy-switch {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-muted);
  }
  .switch {
    position: relative;
    width: 36px; height: 20px;
    background: var(--panel-3);
    border-radius: 999px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
  }
  .switch::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
  }
  .switch.on { background: var(--accent-faint); border-color: var(--accent); }
  .switch.on::after { left: 18px; background: var(--accent); }

  .strategy-body {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }
  .strategy-field { display: flex; flex-direction: column; gap: 4px; }
  .strategy-field label {
    font-size: 11px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  }
  .strategy-field input, .strategy-field select {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    outline: 0;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
  }
  .strategy-field input:focus, .strategy-field select:focus { border-color: var(--accent); }
  .strategy-field .hint { font-size: 11.5px; color: var(--text-dim); font-family: inherit; }

  .strategy-preview {
    margin-top: 14px;
    padding: 10px 12px;
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--info);
  }
  .strategy-preview .mono { color: var(--text); }

  /* ===== CAPACITY ===== */
  .capacity-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 10px;
  }
  .capacity-field {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
  }
  .capacity-field label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; font-weight: 600; }
  .capacity-field input, .capacity-field select {
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    outline: 0;
  }
  .capacity-field input:focus, .capacity-field select:focus { border-color: var(--accent); }
  .capacity-field .hint { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }

  .slot-visual {
    display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap;
  }
  .slot {
    flex: 1 1 140px;
    text-align: center;
    padding: 10px 8px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
    background: var(--panel-2);
  }
  .slot.pinned {
    border-style: solid;
    border-color: var(--accent-border);
    background: var(--accent-faint);
    color: var(--accent);
    font-weight: 600;
  }
  .slot.taken {
    border-style: solid;
    border-color: var(--info-border);
    background: var(--info-bg);
    color: var(--info);
  }
  .slot .slot-label { font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 2px; }
  .slot .slot-name { font-weight: 600; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; }
  .slot .slot-owner { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; font-weight: 500; }

  /* ===== PRINCIPAL LIMITS ===== */
  .principal-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .principal-table th, .principal-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .principal-table th {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600;
  }
  .principal-table tr:last-child td { border-bottom: 0; }
  .principal-cell {
    display: inline-flex; align-items: center; gap: 10px;
  }
  .principal-cell .av {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-strong), var(--info));
    color: #fff; font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .principal-cell .av.team {
    border-radius: 6px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
  }
  .principal-cell .label-title { font-weight: 600; }
  .principal-cell .label-sub { font-size: 11.5px; color: var(--text-muted); }
  .usage-bar {
    display: flex; align-items: center; gap: 10px;
  }
  .usage-bar .track {
    flex: 1; height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; max-width: 160px;
  }
  .usage-bar .fill { height: 100%; background: var(--info); }
  .usage-bar .fill.full { background: var(--warning); }
  .usage-bar .lbl { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
  .mini-input {
    width: 60px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    text-align: center;
    outline: 0;
  }
  .mini-input:focus { border-color: var(--accent); }

  /* ===== ACCESS TABS ===== */
  .inner-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
  }
  .inner-tabs .inner-tab {
    padding: 7px 14px;
    font-size: 13px; font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .inner-tabs .inner-tab:hover { color: var(--text); }
  .inner-tabs .inner-tab.active {
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow-card);
  }

  /* ===== TEAM CARDS ===== */
  .team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
  .team-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
  }
  .team-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px;
  }
  .team-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-strong), var(--info));
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
  }
  .team-icon.red { background: linear-gradient(135deg, #ef4444, #f59e0b); }
  .team-icon.green { background: linear-gradient(135deg, #10b981, #06b6d4); }
  .team-icon.purple { background: linear-gradient(135deg, #a855f7, #ec4899); }
  .team-name { font-weight: 700; font-size: 14px; }
  .team-sub { font-size: 12px; color: var(--text-muted); }
  .team-members {
    display: flex; align-items: center; gap: -4px;
    margin: 10px 0;
  }
  .team-members .av-s {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--panel);
    background: linear-gradient(135deg, var(--accent-strong), var(--info));
    color: #fff; font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: -6px;
  }
  .team-members .av-s:first-child { margin-left: 0; }
  .team-members .count {
    margin-left: 8px;
    font-size: 12px; color: var(--text-muted);
  }

  .perm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
  .perm-chip {
    font-size: 10.5px; font-weight: 600;
    padding: 2px 7px; border-radius: 4px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    letter-spacing: 0.02em;
  }
  .perm-chip.p { color: var(--accent); border-color: var(--accent-border); background: var(--accent-faint); }
  .perm-chip.e { color: var(--info); border-color: var(--info-border); background: var(--info-bg); }
  .perm-chip.q { color: var(--success); border-color: var(--success-border); background: var(--success-bg); }
  .perm-chip.a { color: var(--warning); border-color: var(--warning-border); background: var(--warning-bg); }

  /* ===== PERMISSIONS MATRIX ===== */
  .matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
  .matrix th, .matrix td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: center;
  }
  .matrix th {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600;
  }
  .matrix th.perm-group {
    background: var(--panel-2);
    color: var(--accent);
    padding: 10px 12px;
    letter-spacing: 0.1em;
    border-top: 1px solid var(--border);
  }
  .matrix td.perm-label {
    text-align: left;
    padding-left: 20px;
    font-weight: 500;
    color: var(--text);
  }
  .matrix td.perm-label small {
    display: block;
    color: var(--text-muted); font-size: 11.5px; font-weight: 400;
    margin-top: 2px;
  }
  .matrix .check {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 4px;
  }
  .matrix .check.on {
    background: var(--success-bg); color: var(--success);
  }
  .matrix .check.off { color: var(--text-dim); }
  .matrix .check.own {
    background: var(--warning-bg); color: var(--warning);
    font-size: 10px; font-weight: 700;
  }

  /* ===== USERS TABLE ===== */
  .user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .user-table th, .user-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .user-table th {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600;
  }
  .user-table tr:last-child td { border-bottom: 0; }
  .team-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-faint);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    margin: 1px 2px;
  }
  .override-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid var(--warning-border);
    margin: 1px 2px;
  }

  /* ===== AUDIT ===== */
  .audit-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .audit-table th, .audit-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
  }
  .audit-table th {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600;
  }
  .audit-table .when { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
  .audit-table .actor { display: inline-flex; align-items: center; gap: 8px; }
  .audit-table .av {
    width: 22px; height: 22px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-strong), var(--info));
    color: #fff; font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .audit-table .action-chip {
    display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    padding: 3px 8px; border-radius: 4px;
  }
  .audit-table .action-chip.deploy { background: var(--info-bg); color: var(--info); }
  .audit-table .action-chip.destroy { background: var(--danger-bg); color: var(--danger); }
  .audit-table .action-chip.config { background: var(--warning-bg); color: var(--warning); }
  .audit-table .action-chip.create { background: var(--success-bg); color: var(--success); }
  .audit-table .action-chip.qa { background: var(--accent-faint); color: var(--accent); }
  .audit-table .action-chip.auth { background: var(--panel-3); color: var(--text-muted); }

  /* ===== INTEGRATIONS ===== */
  .integration-row {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
  }
  .integration-row:first-of-type { border-top: 0; padding-top: 0; }
  .integration-row:last-of-type { padding-bottom: 0; }
  .int-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--panel-2);
    display: grid; place-items: center;
    flex: 0 0 40px;
  }
  .int-text { flex: 1; }
  .int-name { font-weight: 600; }
  .int-sub { font-size: 12px; color: var(--text-muted); }

  /* ===== MODAL ===== */
  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: grid; place-items: center;
    z-index: 1000;
    padding: 20px;
  }
  .modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 580px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
  }
  .modal-head {
    padding: 20px 22px 10px;
    border-bottom: 1px solid var(--border);
  }
  .modal-head h2 { margin: 0 0 4px; font-size: 17px; }
  .modal-head p { margin: 0; color: var(--text-muted); font-size: 13px; }
  .modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 16px; }
  .modal-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
  }
  .form-field { display: flex; flex-direction: column; gap: 6px; }
  .form-field label {
    font-size: 12px; font-weight: 600;
    color: var(--text); letter-spacing: 0.01em;
  }
  .form-field .hint { font-size: 11.5px; color: var(--text-dim); }
  .form-field input, .form-field select, .form-field textarea {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    outline: 0;
    font-size: 13.5px;
  }
  .form-field input:focus, .form-field select:focus { border-color: var(--accent); }
  .form-field .inline-row { display: flex; gap: 10px; }
  .form-field .inline-row > * { flex: 1; }

  .branch-choice {
    display: flex; flex-direction: column; gap: 6px;
    max-height: 180px; overflow-y: auto;
    padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--panel-2);
  }
  .branch-opt {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    gap: 10px; align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .branch-opt:hover { background: var(--panel-3); }
  .branch-opt.selected { background: var(--accent-faint); }
  .branch-opt .radio {
    width: 14px; height: 14px; border-radius: 50%;
    border: 1.5px solid var(--border-strong);
  }
  .branch-opt.selected .radio {
    border-color: var(--accent);
    background: radial-gradient(circle, var(--accent) 0 40%, transparent 50% 100%);
  }
  .branch-opt .b-name { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
  .branch-opt .b-meta { font-size: 11px; color: var(--text-muted); }

  .budget-note {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--info);
  }

  /* ===== LOCK / FREEZE ===== */
  .lock-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10.5px; font-weight: 700;
    padding: 2px 7px; border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.06em;
    background: var(--warning-bg); color: var(--warning);
    border: 1px solid var(--warning-border);
  }
  .lock-badge svg { width: 10px; height: 10px; }
  .env-card.frozen { border-color: var(--warning-border); }
  .env-card.frozen::after {
    content: "";
    position: absolute; inset: 0;
    border-radius: var(--radius);
    pointer-events: none;
    box-shadow: inset 0 0 0 1px var(--warning-border);
  }

  /* ===== DEPLOY MODE PILL ===== */
  .mode-pill {
    display: inline-flex;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
  }
  .mode-pill .mode-opt {
    padding: 4px 10px;
    font-size: 11.5px; font-weight: 600;
    color: var(--text-muted);
    border-radius: 999px;
    cursor: pointer;
  }
  .mode-pill .mode-opt.active {
    background: var(--panel);
    color: var(--accent);
    box-shadow: var(--shadow-card);
  }

  /* ===== BUDGET PICKER (create modal) ===== */
  .budget-choice {
    display: flex; flex-direction: column; gap: 6px;
    padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--panel-2);
  }
  .budget-opt {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    gap: 10px; align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .budget-opt:hover { background: var(--panel-3); }
  .budget-opt.selected { background: var(--accent-faint); }
  .budget-opt .radio {
    width: 14px; height: 14px; border-radius: 50%;
    border: 1.5px solid var(--border-strong);
  }
  .budget-opt.selected .radio {
    border-color: var(--accent);
    background: radial-gradient(circle, var(--accent) 0 40%, transparent 50% 100%);
  }
  .budget-opt .b-title { font-weight: 600; font-size: 13px; }
  .budget-opt .b-meta { font-size: 11.5px; color: var(--text-muted); }
  .budget-opt .b-usage {
    font-size: 11.5px; color: var(--text-muted);
    text-align: right;
  }
  .budget-opt .b-usage strong { color: var(--text); }

  /* ===== DANGER CONFIRM MODAL ===== */
  .danger-head {
    display: flex; align-items: center; gap: 10px;
    color: var(--danger);
  }
  .danger-head svg { width: 20px; height: 20px; }
  .warn-box {
    padding: 12px 14px;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    line-height: 1.55;
  }
  .warn-box .mono { color: var(--text); }
  .warn-box .label { font-size: 11px; color: var(--warning); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
  .confirm-input {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    outline: 0;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
  }
  .confirm-input:focus { border-color: var(--danger); }

  /* ===== LOCK DURATION PICKER ===== */
  .duration-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .duration-opt {
    padding: 12px 10px;
    text-align: center;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
  }
  .duration-opt:hover { border-color: var(--accent-border); }
  .duration-opt.selected {
    background: var(--accent-faint);
    border-color: var(--accent);
    color: var(--accent);
  }
  .duration-opt .d-sub {
    font-size: 11px; color: var(--text-muted); font-weight: 500;
    margin-top: 2px;
  }
  .duration-opt.selected .d-sub { color: var(--accent); opacity: 0.8; }

  /* ===== THEME TOGGLE ===== */
  .theme-toggle { display: inline-flex; align-items: center; gap: 6px; }

  /* ===== PROTOTYPE NOTICE ===== */
  .proto-banner {
    position: fixed; bottom: 14px; right: 14px;
    background: var(--panel);
    border: 1px solid var(--accent-border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    box-shadow: var(--shadow);
    display: inline-flex; align-items: center; gap: 8px;
    z-index: 100;
  }
  .proto-banner .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 1.8s infinite;
  }
  @keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
  }

  svg { display: block; }

/* ===== AUTOMATIONS ===== */
.automation-row {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.automation-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.automation-name { font-weight: 600; font-size: 14px; }
.automation-desc { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.btn.btn-sm { padding: 5px 10px; font-size: 12px; }

.pill-strip {
  display: flex; align-items: center; gap: 5px;
  min-height: 18px;
}
.run-pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px; cursor: pointer; border-radius: 999px;
  transition: transform 0.08s ease;
}
.run-pill:hover { transform: scale(1.4); }
.run-pill .dot {
  display: block; width: 12px; height: 12px;
  border-radius: 50%; border: 1px solid var(--border);
}
.run-pill.run-green .dot  { background: var(--success); border-color: var(--success); }
.run-pill.run-yellow .dot { background: var(--warning); border-color: var(--warning); }
.run-pill.run-red .dot    { background: var(--danger);  border-color: var(--danger); }
.run-pill.run-blue .dot   { background: var(--info);    border-color: var(--info);
                             animation: pulse 1.6s infinite; }
.run-pill.run-gray .dot   { background: var(--text-dim); border-color: var(--text-dim); }

/* ===== DRY-RUN BANNER ===== */
.dry-run-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.dry-run-banner svg { color: var(--warning); flex-shrink: 0; }
.dry-run-banner strong { color: var(--warning); }
