/* ============================================================
   HSRP OPS — Stylesheet
   Clean enterprise ops-dashboard aesthetic: light neutral canvas,
   indigo accent, card-based layout, semantic status colors.
   ============================================================ */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  --primary: #2554e8;
  --primary-dark: #1a3fc4;
  --primary-soft: #eaefff;

  --success: #059669;
  --success-soft: #e7f7f1;
  --warning: #d97706;
  --warning-soft: #fef3e0;
  --critical: #dc2626;
  --critical-soft: #fde8e8;
  --info: #7c3aed;
  --info-soft: #f2ebfe;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1,h2,h3,h4 { margin: 0; }

/* ---------------- App shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-badge {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.brand-title { font-weight: 700; font-size: 15px; color: var(--text); line-height: 1.1;}
.brand-sub { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; color: var(--primary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 2px; border-radius: 8px;
  color: var(--text-muted); font-weight: 500; font-size: 13.5px;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 14px 18px; font-size: 11.5px; color: var(--text-faint);
  border-top: 1px solid var(--border); display: flex; align-items: center; gap: 6px;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; }
.ai-spark { color: var(--primary); }
.ai-chip {
  background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; margin-left: 4px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.vehicle-toggle { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; border: 1px solid var(--border); }
.vt-btn { border: none; background: transparent; padding: 6px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.vt-btn.active { background: var(--primary); color: #fff; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; background: var(--surface);
}
.icon-btn:hover { background: var(--bg); }

.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 8px; border-left: 1px solid var(--border); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10.5px; color: var(--text-faint); }

.page-content { padding: 22px 26px 60px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ---------------- Cards / grid ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 18px;
}
.card-title { font-size: 14.5px; font-weight: 700; margin-bottom: 2px; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 16px; display: flex; gap: 12px; align-items: flex-start; }
.kpi-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.kpi-label { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: var(--text-faint); text-transform: uppercase; }
.kpi-value { font-size: 21px; font-weight: 800; margin-top: 3px; }
.kpi-icon.blue { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.green { background: var(--success-soft); color: var(--success); }
.kpi-icon.amber { background: var(--warning-soft); color: var(--warning); }
.kpi-icon.red { background: var(--critical-soft); color: var(--critical); }
.kpi-icon.purple { background: var(--info-soft); color: var(--info); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt-16 { margin-top: 16px; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-critical { background: var(--critical-soft); color: var(--critical); }
.badge-high { background: var(--warning-soft); color: var(--warning); }
.badge-medium { background: #fff7d6; color: #92730a; }
.badge-low { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------------- Buttons / forms ---------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 700; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 13.5px; background: var(--surface); color: var(--text);
}
label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); display: block; margin: 10px 0 5px; }

/* ---------------- Auth page ---------------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, #eef1fb, #f5f6f8); }
.auth-card { width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-form { margin-top: 4px; }
.auth-hint { margin-top: 18px; font-size: 11.5px; color: var(--text-muted); background: var(--bg); padding: 10px 12px; border-radius: 8px; line-height: 1.6; }
.alert-box { padding: 10px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 10px; }
.alert-error { background: var(--critical-soft); color: var(--critical); }

/* ---------------- Alerts list ---------------- */
.alert-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); }
.alert-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.alert-title { font-weight: 700; font-size: 13.5px; }
.alert-desc { font-size: 12.5px; color: var(--text-muted); }
.alert-date { font-size: 11px; color: var(--text-faint); margin-left: auto; }

/* ---------------- AI Assistant ---------------- */
.assistant-wrap { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .assistant-wrap { grid-template-columns: 1fr; } }
.chat-window { min-height: 320px; max-height: 480px; overflow-y: auto; border: 1px dashed var(--border); border-radius: 10px; padding: 16px; background: var(--bg); margin-bottom: 12px; }
.chat-empty { text-align: center; color: var(--text-faint); padding: 40px 10px; font-size: 13px; }
.chat-msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; margin-bottom: 10px; font-size: 13.5px; line-height: 1.5; }
.chat-msg.user { background: var(--primary); color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.chat-msg.assistant { background: var(--surface); border: 1px solid var(--border); margin-right: auto; border-bottom-left-radius: 3px; white-space: pre-wrap; }
.chat-input-row { display: flex; gap: 8px; }
.mic-btn { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 17px; flex-shrink: 0; }
.mic-btn.recording { background: var(--critical); color: #fff; border-color: var(--critical); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.5);} 100% { box-shadow: 0 0 0 10px rgba(220,38,38,0);} }
.quick-prompt { display: block; width: 100%; text-align: left; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; margin-bottom: 8px; color: var(--text); }
.quick-prompt:hover { background: var(--primary-soft); border-color: var(--primary); }

/* ---------------- Map ---------------- */
.map-container { width: 100%; height: 420px; }
.top-states-list { display: flex; flex-direction: column; gap: 8px; }
.state-pill { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 9px; color: #fff; font-weight: 700; font-size: 13px; }

.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }

.section-title { font-size: 16px; font-weight: 700; margin: 26px 0 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.empty-state { text-align: center; padding: 30px; color: var(--text-faint); font-size: 13px; }

/* ---------------- AI Dashboard (freeform widget grid) ---------------- */
.ai-dash-layout { display: grid; grid-template-columns: 270px 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .ai-dash-layout { grid-template-columns: 1fr; } }

.ai-prompt-box {
  display: flex; gap: 10px; margin-bottom: 8px; padding: 16px;
  background: linear-gradient(135deg, #eef1ff 0%, #f5f6f8 60%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.ai-prompt-box input { flex: 1; background: var(--surface); }
.ai-prompt-box .btn-primary { flex-shrink: 0; padding: 10px 20px; }

.ai-example {
  display: block; width: 100%; text-align: left; padding: 10px 13px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12px;
  margin-bottom: 8px; color: var(--text-muted); transition: all .15s ease;
}
.ai-example:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); transform: translateX(2px); }

.ai-history-item {
  padding: 11px 12px; border-radius: 9px; border: 1px solid var(--border); cursor: pointer;
  margin-bottom: 6px; background: var(--surface); border-left: 3px solid transparent; transition: all .15s ease;
}
.ai-history-item:hover { background: var(--bg); border-left-color: var(--text-faint); }
.ai-history-item.active { background: var(--primary-soft); border-left-color: var(--primary); }
.ai-history-title { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.ai-history-date { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }
.ai-history-del { float: right; opacity: .4; font-size: 12px; padding: 2px 4px; }
.ai-history-del:hover { opacity: 1; color: var(--critical); }

.ai-dash-banner {
  background: linear-gradient(135deg, #2554e8 0%, #4f46e5 50%, #7c3aed 100%);
  border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 18px; color: #fff;
  box-shadow: 0 8px 24px rgba(37,84,232,.25);
}
.ai-dash-banner .adb-eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .85; margin-bottom: 6px; }
.ai-dash-banner h2 { font-size: 21px; font-weight: 800; margin: 0; color: #fff; }
.ai-dash-banner p { font-size: 13px; opacity: .9; margin: 6px 0 0; }

.ai-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.ai-span-full { grid-column: span 12; }
.ai-span-half { grid-column: span 6; }
.ai-span-third { grid-column: span 4; }
@media (max-width: 900px) { .ai-span-half, .ai-span-third { grid-column: span 12; } }

.ai-widget {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 18px; transition: box-shadow .2s ease, transform .2s ease;
}
.ai-widget:hover { box-shadow: 0 6px 20px rgba(16,24,40,.08); transform: translateY(-1px); }
.ai-widget-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 7px; }

.ai-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.ai-kpi-item { border-radius: 12px; padding: 14px; position: relative; overflow: hidden; }
.ai-kpi-item .aik-icon {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: rgba(255,255,255,.6); margin-bottom: 8px;
}
.ai-kpi-item .aik-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.ai-kpi-item .aik-value { font-size: 21px; font-weight: 800; margin-top: 3px; }
.ai-kpi-item.tone-blue { background: linear-gradient(135deg, #eef1ff, #dde5ff); } .ai-kpi-item.tone-blue .aik-value { color: var(--primary); }
.ai-kpi-item.tone-green { background: linear-gradient(135deg, #e9f9f2, #d7f3e6); } .ai-kpi-item.tone-green .aik-value { color: var(--success); }
.ai-kpi-item.tone-amber { background: linear-gradient(135deg, #fef6e6, #fdecc7); } .ai-kpi-item.tone-amber .aik-value { color: var(--warning); }
.ai-kpi-item.tone-red { background: linear-gradient(135deg, #fdecec, #fbd9d9); } .ai-kpi-item.tone-red .aik-value { color: var(--critical); }
.ai-kpi-item.tone-purple { background: linear-gradient(135deg, #f3eefe, #e8dcfd); } .ai-kpi-item.tone-purple .aik-value { color: var(--info); }

.ai-insight { border-radius: 12px; padding: 0; overflow: hidden; border: 1px solid var(--border); }
.ai-insight .ai-insight-head {
  display: flex; align-items: center; gap: 9px; padding: 13px 16px; font-weight: 700; font-size: 13.5px;
  background: var(--primary-soft); color: var(--primary-dark);
}
.ai-insight .ai-insight-head .aih-icon { font-size: 16px; }
.ai-insight .ai-insight-body { padding: 14px 16px; }
.ai-insight ul { margin: 0; padding-left: 4px; list-style: none; }
.ai-insight li { font-size: 12.8px; margin-bottom: 8px; line-height: 1.55; padding-left: 18px; position: relative; color: var(--text); }
.ai-insight li:last-child { margin-bottom: 0; }
.ai-insight li::before { content: '→'; position: absolute; left: 0; color: var(--primary); font-weight: 700; }
.ai-insight.tone-warning .ai-insight-head, .ai-insight.tone-amber .ai-insight-head { background: var(--warning-soft); color: #92620a; }
.ai-insight.tone-warning li::before, .ai-insight.tone-amber li::before { color: var(--warning); }
.ai-insight.tone-success .ai-insight-head, .ai-insight.tone-green .ai-insight-head { background: var(--success-soft); color: #046c4e; }
.ai-insight.tone-success li::before, .ai-insight.tone-green li::before { color: var(--success); }
.ai-insight.tone-critical .ai-insight-head, .ai-insight.tone-red .ai-insight-head { background: var(--critical-soft); color: #a11616; }
.ai-insight.tone-critical li::before, .ai-insight.tone-red li::before { color: var(--critical); }

.ai-comparison { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.ai-comp-item {
  text-align: center; border-radius: 12px; padding: 16px 10px; background: var(--bg); border: 1px solid var(--border);
}
.ai-comp-item .aic-value { font-size: 22px; font-weight: 800; color: var(--primary); }
.ai-comp-item .aic-label { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

.ai-loading { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.ai-loading .spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; margin: 0 auto 16px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
