*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; }

:root {
  --esri-blue: #0079c1;
  --esri-blue-dark: #005a8e;
  --esri-blue-light: #e5f2fb;
  --esri-teal: #00b6ad;
  --sidebar-bg: #1a2332;
  --sidebar-text: #c8d3de;
  --sidebar-hover: #243447;
  --sidebar-active: #0079c1;
  --body-bg: #f4f6f8;
  --bg-secondary: #f9fafb;
  --card-bg: #ffffff;
  --border: #dce0e5;
  --text-primary: #1a2332;
  --text-secondary: #5c6775;
  --success: #288835;
  --warning: #da7c0b;
  --danger: #d83020;
  --info: #00619b;
  --pending: #8b93a0;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--body-bg);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
}

/* SIDEBAR */
.sidebar { width: 220px; background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 18px 16px; border-bottom: 1px solid #2d3f54; display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 32px; height: 32px; background: var(--esri-blue); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.logo-text { color: white; font-weight: 600; font-size: 15px; line-height: 1.1; }
.logo-sub { color: var(--sidebar-text); font-size: 10px; font-weight: 400; }

.sidebar-nav { padding: 10px 0; flex: 1; overflow-y: auto; }
.nav-section { padding: 14px 14px 4px; color: #4a5e74; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: var(--sidebar-text); cursor: pointer; border-left: 3px solid transparent; transition: background 0.15s; font-size: 13.5px; user-select: none; }
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--sidebar-hover); color: white; border-left-color: var(--esri-blue); }
.nav-icon { font-size: 16px; width: 18px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--esri-blue); color: white; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 600; }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid #2d3f54; }
.sidebar-user { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); font-size: 12.5px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--esri-blue); color: white; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 0 24px; height: 52px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

.screen { display: none; }
.screen.active { display: block; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 0; border: none; cursor: pointer; font-size: 13.5px; font-weight: 500; line-height: 1; transition: background 0.15s, opacity 0.15s; font-family: var(--font); }
.btn .ph { display: inline-flex; align-items: center; }
.btn-primary { background: var(--esri-blue); color: white; }
.btn-primary:hover { background: var(--esri-blue-dark); }
.btn-secondary { background: var(--card-bg); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f0f2f4; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 11px; font-size: 14px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* CARDS */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 4px; padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* GRID */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* BADGES */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 12px; font-size: 11.5px; font-weight: 600; vertical-align: middle; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: #edf6ef; color: var(--success); }
.badge-warning { background: #fcf4eb; color: var(--warning); }
.badge-danger  { background: #fceeec; color: var(--danger); }
.badge-info    { background: var(--esri-blue-light); color: var(--info); }
.badge-pending { background: #f0f2f4; color: var(--pending); }
.badge-running { background: #e5f2fb; color: var(--esri-blue); }
.badge-running::before { animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* STAT CARDS */
.stat-card { background: white; border: 1px solid var(--border); border-radius: 4px; padding: 18px 20px; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-top: 4px; }
.stat-delta { font-size: 12px; margin-top: 4px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* TABLES */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 14px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); border-bottom: 1px solid var(--border); background: #f9fafb; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f9fafb; cursor: pointer; }
.table .item-name { font-weight: 500; color: var(--text-primary); }
.table .item-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 0; font-size: 13.5px; color: var(--text-primary); background: white; outline: none; font-family: var(--font); }
.form-control:focus { border-color: var(--esri-blue); box-shadow: 0 0 0 3px rgba(0,121,193,0.12); }
.form-control:disabled { background: #f4f6f8; color: var(--text-secondary); }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: 0; flex: 1; }
.input-group .btn { border-radius: 0; }

/* TABS */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 18px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--esri-blue); border-bottom-color: var(--esri-blue); font-weight: 600; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: 4px; font-size: 13.5px; border-left: 3px solid; margin-bottom: 16px; }
.alert-info { background: var(--esri-blue-light); border-color: var(--esri-blue); color: var(--esri-blue-dark); }
.alert-warning { background: #fdf3e3; border-color: var(--warning); color: #7a4a00; }
.alert-success { background: #eaf7ec; border-color: var(--success); color: #1a5c28; }
.alert-danger { background: #fdecea; border-color: var(--danger); color: #7a1a10; }

/* ENV TAGS */
.env-tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.03em; }
.env-dev { background: #e8f5e9; color: #2e7d32; }
.env-test { background: #fff3e0; color: #e65100; }
.env-prod { background: #fce4ec; color: #b71c1c; }
.env-staging { background: #e8eaf6; color: #283593; }

/* MISC UTILITIES */
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.text-mono { font-family: 'Consolas', monospace; font-size: 12.5px; }
.fw-600 { font-weight: 600; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.section-heading { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; }
.inline-flex { display: inline-flex; align-items: center; gap: 10px; }

/* ENV STATUS DOTS */
.env-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.dot-green  { background: var(--success); }
.dot-yellow { background: var(--warning); }
.dot-red    { background: var(--danger); }
.dot-grey   { background: var(--pending); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c0c8d0; border-radius: 3px; }

/* THEME TOGGLE BUTTON */
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 18px; display: flex; align-items: center; padding: 5px; border-radius: 4px; transition: color 0.15s, background 0.15s; }
.btn-icon:hover { color: var(--text-primary); background: var(--bg-secondary); }

/* DARK THEME */
[data-theme="dark"] {
  --body-bg: #0f1623;
  --bg-secondary: #151e2d;
  --card-bg: #1a2537;
  --border: #2a3a50;
  --text-primary: #e2e8f0;
  --text-secondary: #8896a8;
  --esri-blue-light: #0d2a3f;
  --pending: #4a5568;
  --success: #36da43;
  --warning: #f89927;
  --danger: #fe583e;
  --info: #00a0ff;
}
[data-theme="dark"] .btn-secondary:hover { background: #243040; }
[data-theme="dark"] .badge-success { background: #0d2318; }
[data-theme="dark"] .badge-warning { background: #2a1f0a; }
[data-theme="dark"] .badge-danger  { background: #2a0d0a; }
[data-theme="dark"] .badge-info    { background: #0d2a3f; }
[data-theme="dark"] .badge-running { background: #0d2a3f; }
[data-theme="dark"] .badge-pending { background: #2a3a50; }
[data-theme="dark"] .alert-warning { background: #2a1f0a; color: #f0b860; }
[data-theme="dark"] .alert-success { background: #0d2318; color: #5ecf76; }
[data-theme="dark"] .alert-danger  { background: #2a0d0a; color: #f07070; }
[data-theme="dark"] .env-dev     { background: #0d2310; color: #6ecf7e; }
[data-theme="dark"] .env-test    { background: #2a1800; color: #f0a060; }
[data-theme="dark"] .env-prod    { background: #2a0d15; color: #f07090; }
[data-theme="dark"] .env-staging { background: #0d1030; color: #8090e0; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a4a60; }

/* Tables */
[data-theme="dark"] .table th { background: #151e2d; }
[data-theme="dark"] .table tr:hover td { background: #151e2d; }

/* Forms */
[data-theme="dark"] .form-control { background: #151e2d; color: var(--text-primary); }
[data-theme="dark"] .form-control:disabled { background: #0f1623; }
[data-theme="dark"] .stat-card { background: var(--card-bg); }

/* Pipe bubbles */
[data-theme="dark"] .pipe-bubble { background: var(--card-bg); }

/* Toggle */
[data-theme="dark"] .toggle-slider { background: #3a4a60; }
[data-theme="dark"] .toggle-slider::before { background: #c8d3de; }

/* Wizard */
[data-theme="dark"] .wizard-step-num { background: #2a3a50; }

/* Env pills */
[data-theme="dark"] .env-pill { background: var(--card-bg); }
[data-theme="dark"] .env-pill.selected-dev  { border-color: #36da43; background: #0d2318; color: #36da43; }
[data-theme="dark"] .env-pill.selected-test { border-color: #f89927; background: #2a1f0a; color: #f89927; }
[data-theme="dark"] .env-pill.selected-prod { border-color: #fe583e; background: #2a0d0a; color: #fe583e; }

/* Env card headers */
[data-theme="dark"] .env-card-dev  .env-card-header { background: #0d2310; }
[data-theme="dark"] .env-card-test .env-card-header { background: #2a1800; }
[data-theme="dark"] .env-card-prod .env-card-header { background: #2a0d15; }
[data-theme="dark"] .kv { border-bottom-color: #2a3a50; }

/* Modal */
[data-theme="dark"] .modal { background: var(--card-bg); }
[data-theme="dark"] .modal-close:hover { background: #243040; }

/* Diff tool */
[data-theme="dark"] .diff-src-row.selected { background: #0d2a3f; }
[data-theme="dark"] .diff-badge-modified { background: #2a1f0a; color: #f0b860; }
[data-theme="dark"] .diff-badge-added    { background: #0d2318; color: #5ecf76; }
[data-theme="dark"] .diff-badge-removed  { background: #2a0d0a; color: #f07070; }
[data-theme="dark"] .diff-legend-from { color: #f07070; }
[data-theme="dark"] .diff-legend-to   { color: #5ecf76; }
[data-theme="dark"] .diff-line-add    { background: #0d2318; }
[data-theme="dark"] .diff-line-del    { background: #2a0d0a; }
[data-theme="dark"] .diff-line-add .diff-lpfx { color: #5ecf76; }
[data-theme="dark"] .diff-line-del .diff-lpfx { color: #f07070; }

/* jsondiffpatch */
[data-theme="dark"] .jsondiffpatch-added .jsondiffpatch-value,
[data-theme="dark"] .jsondiffpatch-added .jsondiffpatch-property-name   { background: #0d2318; }
[data-theme="dark"] .jsondiffpatch-deleted .jsondiffpatch-value,
[data-theme="dark"] .jsondiffpatch-deleted .jsondiffpatch-property-name { background: #2a0d0a; }
[data-theme="dark"] .jsondiffpatch-modified .jsondiffpatch-left-value   { background: #2a0d0a; }
[data-theme="dark"] .jsondiffpatch-modified .jsondiffpatch-right-value  { background: #0d2318; }
[data-theme="dark"] .jsondiffpatch-moved-destination { background: #2a1f0a; }

/* Timeline */
[data-theme="dark"] .tl-wrap { background: var(--card-bg); }
[data-theme="dark"] .tl-band-even { fill: #1a2537; }
[data-theme="dark"] .tl-node-extract { stroke: #1a2537; }
[data-theme="dark"] .tl-node-dep     { stroke: #1a2537; }
[data-theme="dark"] .tl-tooltip { background: var(--card-bg); }

/* Dashboard stat cards */
[data-theme="dark"] .db-stat-card { background: var(--card-bg); }
