:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #172033;
  background: #eef2f6;
  font-synthesis: none;
  --navy: #071a2d;
  --navy-2: #0b2946;
  --blue: #0878f9;
  --blue-dark: #075fc3;
  --green: #159447;
  --red: #d52d33;
  --amber: #d97706;
  --muted: #64748b;
  --line: #d7dee8;
  --surface: #ffffff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #eef2f6; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px 1fr; }
.sidebar { background: #07111e; color: #dce8f4; padding: 22px 0; position: sticky; top: 0; height: 100vh; }
.brand { padding: 0 20px 24px; color: white; font-weight: 800; font-size: 19px; letter-spacing: 0; }
.brand span { color: #1683ff; }
.nav-label { padding: 16px 20px 8px; color: #698099; font-size: 11px; text-transform: uppercase; font-weight: 700; }
.nav-button { width: 100%; border: 0; background: transparent; color: #c6d2df; text-align: left; padding: 13px 20px; border-left: 3px solid transparent; display: flex; align-items: center; justify-content: space-between; }
.nav-button:hover { background: #0b1d30; color: white; }
.nav-button.active { background: #0c2239; border-left-color: #1683ff; color: #42a0ff; }
.count-badge { min-width: 24px; padding: 2px 7px; text-align: center; color: white; background: var(--blue); border-radius: 4px; font-weight: 700; font-size: 12px; }

.main { min-width: 0; overflow: hidden; }
.topbar { height: 60px; background: white; border-bottom: 1px solid var(--line); display: flex; justify-content: flex-end; align-items: center; gap: 24px; padding: 0 28px; color: #344155; font-size: 13px; }
.topbar strong { color: #172033; }
.workspace { padding: 14px 18px 28px; max-width: 1600px; margin: 0 auto; }
.page-header { background: var(--navy); color: white; display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-radius: 5px 5px 0 0; }
.page-header h1 { font-size: 22px; margin: 0; }
.page-header p { margin: 4px 0 0; color: #aebfd1; font-size: 12px; }
.status-live { color: #d9ffe8; border: 1px solid #3f9e68; background: #123c2a; border-radius: 3px; padding: 6px 9px; font-size: 10px; font-weight: 800; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.btn { border: 1px solid #cbd5e1; background: white; color: #253247; padding: 9px 14px; border-radius: 4px; font-weight: 650; }
.btn:hover { border-color: #8ea3bb; background: #f8fafc; }
.btn-primary { background: var(--blue); color: white; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-danger { color: #b4232a; border-color: #f0b8bb; }
.btn-compact { padding: 6px 9px; font-size: 12px; }
.icon-btn { width: 30px; height: 30px; padding: 0; border: 1px solid #ccd6e1; border-radius: 4px; background: white; color: #405168; font-weight: 800; }

.control-band { background: white; border: 1px solid var(--line); border-top: 0; padding: 10px 14px 13px; }
.watchlist-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.field { display: grid; gap: 5px; }
.field label { font-size: 11px; font-weight: 700; color: #536277; }
.field input, .field select { height: 36px; border: 1px solid #cbd5e1; border-radius: 4px; background: white; padding: 0 10px; color: #1e293b; }
.field.wide select { width: 355px; }
.production-badge { display: inline-block; background: var(--blue); color: white; border-radius: 3px; padding: 3px 7px; font-size: 10px; font-weight: 800; margin-left: 7px; }
.toggle-wrap { margin-left: 12px; display: flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 700; }
.toggle { width: 38px; height: 21px; border-radius: 11px; background: #aeb8c5; position: relative; border: 0; padding: 0; }
.toggle::after { content: ""; position: absolute; width: 17px; height: 17px; top: 2px; left: 2px; background: white; border-radius: 50%; transition: transform .16s ease; box-shadow: 0 1px 2px #0003; }
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(17px); }

.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 12px; background: white; border: 1px solid var(--line); border-top: 0; padding: 12px; }
.filters { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) auto; gap: 9px; margin-bottom: 9px; }
.filters input, .filters select { min-width: 0; height: 36px; border: 1px solid #cbd5e1; border-radius: 4px; padding: 0 10px; background: white; }
.panel { min-width: 0; border: 1px solid var(--line); background: white; border-radius: 5px; overflow: hidden; }
.panel-title { background: var(--navy); color: white; padding: 10px 13px; display: flex; align-items: center; justify-content: space-between; font-weight: 750; }
.panel-title.light { background: #f5f7fa; color: #172033; border-bottom: 1px solid var(--line); }
.panel-body { padding: 12px; }
.sync-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #e5eaf0; font-size: 13px; }
.sync-row:last-child { border: 0; }
.success { color: var(--green); font-weight: 700; }
.warning { color: var(--amber); font-weight: 700; }
.danger { color: var(--red); font-weight: 700; }

.table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th { font-size: 11px; text-align: left; color: #405168; background: #f7f9fb; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { font-size: 12px; padding: 8px 10px; border-bottom: 1px solid #e5eaf0; white-space: nowrap; }
tbody tr:hover { background: #f8fbff; }
.direction-bull { color: var(--green); font-weight: 750; }
.direction-bear { color: var(--red); font-weight: 750; }
.table-actions { display: flex; gap: 5px; }
.table-footer { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; font-size: 11px; color: var(--muted); }
.pagination { display: flex; align-items: center; gap: 8px; }
.pagination strong { color: #253247; font-size: 11px; }
.pagination .btn:disabled { opacity: .45; cursor: default; }

.section-panel { margin-top: 12px; }
.section-panel table { min-width: 900px; }
.panel-subtitle { padding: 9px 13px; color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--line); font-size: 12px; }
.armed-panel .panel-title { background: #12395e; }
.armed-count { background: #e08a00; }
.armed-badge { display: inline-block; padding: 3px 7px; border-radius: 3px; background: #fff3d6; color: #a85f00; border: 1px solid #f1cf8b; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.metric-strip { display: grid; grid-template-columns: repeat(5, 1fr); background: white; border: 1px solid var(--line); border-top: 0; }
.metric-strip > div { min-height: 88px; padding: 16px 18px; border-right: 1px solid var(--line); display: grid; align-content: center; gap: 5px; }
.metric-strip > div:last-child { border-right: 0; }
.metric-strip span { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-strip strong { font-size: 25px; color: #172033; }
.metric-strip strong.success { color: var(--green); }
.metric-strip strong.warning { color: var(--amber); }
.metric-strip strong.danger { color: var(--red); }
.compact-metrics { grid-template-columns: repeat(4, 1fr); }
.dashboard-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-top: 12px; }
.coverage-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #e5eaf0; font-size: 13px; }
.coverage-row:last-child { border-bottom: 0; }
.coverage-ok { color: var(--green); font-weight: 750; }
.review-summary { display: flex; justify-content: space-between; gap: 20px; padding: 13px 16px; background: #fff7e8; border: 1px solid #f0d39b; border-top: 0; color: #73521c; font-size: 12px; }
.isolated-badge { display: inline-block; padding: 3px 7px; border-radius: 3px; background: #eef2f7; color: #536277; border: 1px solid #cbd5e1; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.sync-summary { display: flex; gap: 1px; background: var(--line); border: 1px solid var(--line); border-top: 0; }
.sync-summary span { flex: 1; padding: 13px 15px; background: white; color: var(--muted); font-size: 12px; }
.sync-summary strong { color: #172033; }
.completed-badge { display: inline-block; padding: 3px 7px; border-radius: 3px; background: #e9f8ef; color: var(--green); border: 1px solid #b9e2c8; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.pipeline-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--line); }
.pipeline-row span { padding: 14px 10px; background: white; text-align: center; color: #405168; font-size: 11px; font-weight: 700; }
.pipeline-complete::after { content: " Complete"; display: block; margin-top: 4px; color: var(--green); font-size: 10px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.settings-form { display: grid; gap: 13px; }
.settings-form .field select, .settings-form .field input { width: 100%; }
.setting-row { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 0; border-bottom: 1px solid #e5eaf0; }
.setting-row:last-child { border-bottom: 0; }
.setting-row > div { display: grid; gap: 4px; }
.setting-row strong { font-size: 13px; }
.setting-row span { color: var(--muted); font-size: 11px; }
.locked-setting { background: #f7f9fb; margin: 8px -12px -12px; padding: 12px; }
.safety-badge { color: white !important; background: #26374a; border-radius: 3px; padding: 5px 7px; font-weight: 800; }
.coverage-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.coverage-list span { display: flex; justify-content: space-between; padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px; color: #405168; font-size: 12px; }
.coverage-list strong { color: var(--green); }
.setting-note { margin-top: 12px; padding: 10px; background: #f5f9ff; border-left: 3px solid var(--blue); color: var(--muted); font-size: 11px; line-height: 1.45; }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.section-tools { display: flex; gap: 8px; align-items: center; }
.section-tools select { height: 30px; min-width: 142px; border: 1px solid #cbd5e1; border-radius: 4px; background: white; padding: 0 8px; }
.lower-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; margin-top: 12px; }
.admin-only { background: #f28b22; color: white; padding: 3px 7px; border-radius: 3px; font-size: 10px; font-weight: 800; margin-left: 8px; }
.scan-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.scan-summary-grid > div { min-height: 88px; padding: 14px; display: grid; align-content: center; gap: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.scan-summary-grid > div:nth-child(3n) { border-right: 0; }
.scan-summary-grid span, .scan-summary-grid small { color: var(--muted); font-size: 11px; }
.scan-summary-grid strong { color: #172033; font-size: 20px; }
.scan-summary-grid strong.warning { color: var(--amber); }
.scan-summary-grid strong.success { color: var(--green); }
.stack { display: grid; gap: 12px; }
.lower-grid table { min-width: 0; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; background: #06111dcc; display: grid; place-items: center; padding: 20px; }
.modal { width: min(520px, 100%); background: white; border-radius: 6px; box-shadow: 0 24px 80px #0006; }
.modal h2 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 18px; }
.modal-content { padding: 18px; display: grid; gap: 13px; }
.modal-content .field input, .modal-content .field select, .modal-content .field textarea { width: 100%; }
.modal-content .field textarea { min-height: 132px; resize: vertical; border: 1px solid #cbd5e1; border-radius: 4px; padding: 10px; color: #1e293b; line-height: 1.45; }
.modal-content .field textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bulk-destination { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 10px 12px; border: 1px solid #d8e6f5; border-radius: 4px; background: #f5f9ff; font-size: 12px; color: var(--muted); }
.bulk-destination strong { color: #172033; text-align: right; }
.helper-text { color: var(--muted); font-size: 11px; }
.automation-note { margin-top: 11px; padding: 10px 12px; display: flex; gap: 12px; align-items: baseline; border-left: 3px solid var(--blue); background: #f3f8ff; color: #3d4c61; font-size: 12px; }
.automation-note strong { color: #172033; white-space: nowrap; }
.automation-explainer { display: grid; gap: 4px; padding: 11px 12px; border: 1px solid #d8e6f5; border-radius: 4px; background: #f5f9ff; font-size: 12px; color: var(--muted); }
.automation-explainer strong { color: #172033; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; background: #0d2136; color: white; padding: 12px 16px; border-radius: 5px; box-shadow: 0 10px 30px #0004; font-size: 13px; }
.hidden { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #07111e; }
.login-panel { width: min(430px, 100%); display: grid; gap: 22px; padding: 30px; border: 1px solid #24405d; border-radius: 6px; background: white; box-shadow: 0 24px 80px #0008; }
.login-brand { padding-bottom: 18px; border-bottom: 1px solid var(--line); color: #0a223b; font-size: 21px; font-weight: 850; }
.login-brand span { color: var(--blue); }
.login-panel h1 { margin: 0; font-size: 22px; }
.login-panel p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-panel form { display: grid; gap: 15px; }
.login-panel .field input { width: 100%; }
.login-submit { width: 100%; margin-top: 3px; }
.login-submit:disabled { opacity: .65; cursor: wait; }
.login-error { padding: 10px 12px; border: 1px solid #efb8bb; border-radius: 4px; background: #fff3f3; color: #a91f26; font-size: 12px; }
.login-safety { padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: 11px; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 72px 1fr; }
  .brand { font-size: 0; padding: 0 15px 20px; }
  .brand span { font-size: 18px; }
  .nav-button { font-size: 0; padding: 14px 12px; justify-content: center; }
  .nav-button .count-badge { font-size: 11px; }
  .nav-label { display: none; }
  .grid-main, .lower-grid, .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; display: flex; overflow-x: auto; padding: 0; }
  .brand { display: none; }
  .nav-button { width: auto; min-width: 92px; border-left: 0; border-bottom: 3px solid transparent; font-size: 11px; }
  .nav-button.active { border-bottom-color: #1683ff; }
  .topbar { height: 48px; padding: 0 12px; gap: 12px; }
  .topbar span:first-child { display: none; }
  .workspace { width: 100%; max-width: 100vw; padding: 8px; overflow: hidden; }
  .page-header { align-items: flex-start; gap: 12px; }
  .actions { justify-content: flex-end; }
  .field.wide { width: 100%; }
  .field.wide select { width: 100%; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .grid-main, .lower-grid, .stack { min-width: 0; }
  .grid-main > *, .lower-grid > * { min-width: 0; }
  .section-tools { display: none; }
  .modal-grid { grid-template-columns: 1fr; }
  .metric-strip, .compact-metrics { grid-template-columns: 1fr 1fr; }
  .review-summary { display: grid; }
  .sync-summary { display: grid; }
  .pipeline-row { grid-template-columns: 1fr; }
  .scan-summary-grid { grid-template-columns: 1fr 1fr; }
  .scan-summary-grid > div:nth-child(3n) { border-right: 1px solid var(--line); }
  .scan-summary-grid > div:nth-child(2n) { border-right: 0; }
  .table-footer { align-items: flex-start; gap: 8px; flex-wrap: wrap; }
}
