/* ============================================================
   ASSETVAULT — ENTERPRISE UI STYLESHEET
   Professional asset tracking & custody portal
   ============================================================ */

/* --- RESET & BASE --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
}

/* --- CSS CUSTOM PROPERTIES --- */
:root {
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f1f5f9;
  --sidebar-hover: #1e293b;
  --sidebar-accent: #3b82f6;
  --sidebar-width: 240px;
  --topbar-h: 60px;

  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-muted: #f8fafc;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border: #e2e8f0;
  --border-focus: #3b82f6;

  --blue: #3b82f6;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --blue-mid: #bfdbfe;

  --green: #10b981;
  --green-dark: #059669;
  --green-light: #ecfdf5;

  --amber: #f59e0b;
  --amber-dark: #d97706;
  --amber-light: #fffbeb;

  --red: #ef4444;
  --red-dark: #dc2626;
  --red-light: #fef2f2;

  --orange: #f97316;
  --orange-light: #fff7ed;

  --purple: #8b5cf6;
  --purple-light: #f5f3ff;

  --gray: #6b7280;
  --gray-light: #f9fafb;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --transition: 0.18s ease;
}

/* --- LAYOUT SHELL --- */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ============ SIDEBAR ============ */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0,0,0,.25);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59,130,246,.4);
}
.logo-title { display: block; font-size: 14px; font-weight: 700; color: #f1f5f9; letter-spacing: .3px; }
.logo-sub   { display: block; font-size: 10px; color: var(--sidebar-text); letter-spacing: .5px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
  position: relative;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item i { width: 16px; text-align: center; font-size: 13px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: #cbd5e1; }
.nav-item.active {
  background: rgba(59,130,246,.15);
  color: var(--sidebar-text-active);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--blue);
  border-radius: 0 3px 3px 0;
}
.nav-badge {
  margin-left: auto;
  background: linear-gradient(135deg, var(--blue), #6366f1);
  color: white; font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 20px;
  letter-spacing: .5px;
}

.sidebar-footer {
  padding: 8px 8px 0;
  border-top: 1px solid rgba(255,255,255,.06);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 16px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.user-name  { display: block; font-size: 12px; color: #e2e8f0; font-weight: 600; }
.user-role  { display: block; font-size: 10px; color: var(--sidebar-text); }

/* ============ MAIN AREA ============ */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* --- TOPBAR --- */
#topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 50;
}
.topbar-left { flex: 1; min-width: 0; }
#page-title  { font-size: 17px; font-weight: 700; color: var(--text-primary); }
#breadcrumb  { font-size: 12px; color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-body); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 12px;
  width: 220px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-mid); }
.search-box i { color: var(--text-muted); font-size: 12px; }
.search-box input { border: none; background: transparent; font-size: 13px; color: var(--text-primary); outline: none; width: 100%; }

.btn-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--bg-body); color: var(--blue); }

.notification-bell { position: relative; cursor: pointer; padding: 4px; color: var(--text-secondary); }
.notification-bell:hover { color: var(--text-primary); }
.notification-dot {
  position: absolute; top: 2px; right: 2px;
  width: 7px; height: 7px;
  background: var(--red); border-radius: 50%;
  border: 1.5px solid white;
}

/* ============ CONTENT AREA ============ */
#content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg-body); }

.page { display: none; animation: fadeIn .2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary   { background: var(--blue); color: white; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); box-shadow: 0 2px 8px rgba(59,130,246,.35); }
.btn-outline   { background: white; color: var(--text-primary); border-color: var(--border); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger-outline { background: white; color: var(--red); border-color: var(--red); }
.btn-danger-outline:hover { background: var(--red-light); }
.btn-link { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 13px; font-weight: 500; padding: 0; }
.btn-link:hover { text-decoration: underline; }

/* ============ DASHBOARD ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-card::after {
  content: ''; position: absolute;
  top: 0; right: 0; width: 3px; height: 100%;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.kpi-card:nth-child(1)::after { background: var(--blue); }
.kpi-card:nth-child(2)::after { background: var(--green); }
.kpi-card:nth-child(3)::after { background: var(--amber); }
.kpi-card:nth-child(4)::after { background: var(--red); }

.kpi-icon {
  width: 42px; height: 42px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.kpi-icon.blue   { background: var(--blue-light);   color: var(--blue); }
.kpi-icon.green  { background: var(--green-light);  color: var(--green); }
.kpi-icon.orange { background: var(--amber-light);  color: var(--amber); }
.kpi-icon.red    { background: var(--red-light);    color: var(--red); }

.kpi-body { flex: 1; }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }
.kpi-trend { font-size: 11px; margin-top: 8px; font-weight: 500; }
.kpi-trend.up   { color: var(--red); }
.kpi-trend.down { color: var(--green); }
.kpi-trend.neutral { color: var(--text-muted); }

/* --- CHARTS --- */
.charts-row { display: grid; grid-template-columns: 1fr 340px; gap: 16px; margin-bottom: 16px; }

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-card.small { }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.chart-header h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.chart-period { font-size: 11px; color: var(--text-muted); background: var(--bg-body); padding: 2px 8px; border-radius: 20px; }
.chart-container { position: relative; height: 200px; }
.chart-legend { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* --- SECTION CARD & ACTIVITY --- */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.text-orange { color: var(--amber); }

.activity-feed { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  transition: background var(--transition);
}
.activity-item:hover { background: var(--bg-body); }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 12px; color: var(--text-primary); font-weight: 500; }
.activity-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.attention-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.attention-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-card);
}
.attention-card:hover { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(245,158,11,.1); }
.attention-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.attention-id { font-size: 11px; font-weight: 700; color: var(--blue); background: var(--blue-light); padding: 2px 7px; border-radius: 20px; }
.attention-name { font-size: 12px; font-weight: 600; color: var(--text-primary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attention-health { font-size: 12px; font-weight: 700; }
.attention-status { font-size: 11px; color: var(--text-muted); }

/* ============ ASSETS TABLE ============ */
.page-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar-filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.toolbar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.filter-group select,
.filter-group input {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 10px; font-size: 12px; color: var(--text-primary);
  background: white; min-width: 140px; outline: none;
  transition: border-color var(--transition);
}
.filter-group select:focus, .filter-group input:focus { border-color: var(--blue); }
.record-count { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.table-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  background: var(--bg-muted); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-muted); }
.data-table td { padding: 10px 16px; font-size: 12px; color: var(--text-primary); vertical-align: middle; }

.asset-id { font-size: 11px; font-weight: 700; color: var(--blue); }
.asset-name { font-weight: 600; font-size: 12px; }
.asset-model { font-size: 11px; color: var(--text-muted); }

/* --- STATUS BADGE --- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-active       { background: var(--green-light);  color: var(--green-dark); }
.badge-maintenance  { background: var(--amber-light);  color: var(--amber-dark); }
.badge-transit      { background: var(--blue-light);   color: var(--blue-dark); }
.badge-reserved     { background: var(--purple-light); color: var(--purple); }
.badge-decommissioned { background: #f3f4f6; color: var(--gray); }

/* --- HEALTH BAR (table) --- */
.health-cell { display: flex; align-items: center; gap: 8px; min-width: 100px; }
.health-mini-bar { flex: 1; height: 5px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.health-mini-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.health-pct { font-size: 12px; font-weight: 700; min-width: 32px; }

/* --- VALUE CELL --- */
.value-cell { font-weight: 700; font-size: 13px; }

/* ============ CUSTODY TIMELINE ============ */
.timeline-container { position: relative; }
.timeline-container::before {
  content: ''; position: absolute;
  left: 140px; top: 0; bottom: 0; width: 2px;
  background: var(--border);
}
.timeline-container.mini::before { left: 100px; }

.timeline-entry {
  display: flex; gap: 0; margin-bottom: 24px; position: relative;
}
.timeline-date {
  width: 130px; flex-shrink: 0;
  text-align: right; padding-right: 20px;
  padding-top: 4px;
}
.timeline-date-val  { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.timeline-date-time { font-size: 10px; color: var(--text-muted); }

.timeline-dot-wrap {
  width: 20px; flex-shrink: 0;
  display: flex; justify-content: center;
  position: relative; z-index: 1;
}
.timeline-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid white; margin-top: 4px;
  box-shadow: 0 0 0 2px currentColor;
  flex-shrink: 0;
}

.timeline-card {
  flex: 1; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; margin-left: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.timeline-card:hover { box-shadow: var(--shadow-md); }

.timeline-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.timeline-card-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.timeline-asset-id { font-size: 11px; font-weight: 700; color: var(--blue); background: var(--blue-light); padding: 2px 8px; border-radius: 20px; }

.timeline-from-to { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; }
.timeline-from-to .from { color: var(--text-secondary); }
.timeline-from-to .arrow { color: var(--text-muted); font-size: 10px; }
.timeline-from-to .to { color: var(--text-primary); font-weight: 600; }

.timeline-meta { display: flex; gap: 16px; margin-bottom: 6px; flex-wrap: wrap; }
.timeline-meta-item { font-size: 11px; color: var(--text-muted); }
.timeline-meta-item strong { color: var(--text-secondary); }

.timeline-notes { font-size: 12px; color: var(--text-secondary); background: var(--bg-muted); border-radius: var(--radius-sm); padding: 6px 10px; margin-top: 6px; line-height: 1.5; }

.timeline-footer { display: flex; gap: 12px; margin-top: 8px; }
.timeline-signed { font-size: 10px; color: var(--text-muted); }
.timeline-signed strong { color: var(--text-secondary); }

/* mini timeline (modal) */
.timeline-container.mini { padding-left: 0; }
.timeline-container.mini .timeline-date { width: 90px; }

/* ============ AI ASSISTANT ============ */
.assistant-layout {
  display: grid; grid-template-columns: 280px 1fr;
  gap: 0; height: calc(100vh - var(--topbar-h) - 48px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  overflow: hidden;
}

.assistant-sidebar {
  background: var(--bg-muted); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px; gap: 16px;
  overflow-y: auto;
}
.assistant-header { display: flex; align-items: center; gap: 12px; }
.ai-avatar {
  width: 40px; height: 40px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue), #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
}
.assistant-header h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.ai-status { font-size: 11px; color: var(--text-muted); }

.suggested-questions h4 { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.suggestion-chip {
  display: block; width: 100%;
  text-align: left; padding: 7px 11px; margin-bottom: 5px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: white; font-size: 12px; color: var(--text-primary);
  cursor: pointer; transition: all var(--transition); font-weight: 500;
}
.suggestion-chip:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

.api-key-status {
  margin-top: auto;
  display: flex; align-items: center; gap: 6px;
  background: var(--amber-light); border: 1px solid #fcd34d;
  border-radius: var(--radius); padding: 10px;
  font-size: 11px; color: var(--amber-dark);
}
.api-key-status.configured {
  background: var(--green-light); border-color: #6ee7b7; color: var(--green-dark);
}
.api-key-status i { font-size: 12px; }

/* Chat area */
.chat-area { display: flex; flex-direction: column; min-height: 0; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px;
}

.chat-welcome {
  max-width: 480px; margin: auto; text-align: center; padding: 40px 20px;
}
.welcome-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--blue), #6366f1);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 22px;
}
.chat-welcome h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.chat-welcome p  { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 8px; }

.message { display: flex; gap: 10px; max-width: 85%; }
.message.user   { margin-left: auto; flex-direction: row-reverse; }
.message.ai     { margin-right: auto; }

.message-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; margin-top: 2px;
}
.message.ai   .message-avatar { background: linear-gradient(135deg, var(--blue), #6366f1); color: white; }
.message.user .message-avatar { background: var(--text-primary); color: white; font-weight: 700; }

.message-content {
  padding: 10px 14px; border-radius: var(--radius-lg);
  font-size: 13px; line-height: 1.6;
}
.message.user .message-content { background: var(--blue); color: white; border-bottom-right-radius: 4px; }
.message.ai   .message-content { background: var(--bg-muted); color: var(--text-primary); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.message.ai   .message-content p  { margin-bottom: 6px; }
.message.ai   .message-content ul { padding-left: 16px; margin-bottom: 6px; }
.message.ai   .message-content li { margin-bottom: 3px; }
.message.ai   .message-content h3,
.message.ai   .message-content h4 { margin-bottom: 6px; margin-top: 8px; font-size: 13px; }
.message.ai   .message-content code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 3px; font-size: 11px; }
.message-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: right; }

/* Typing dots */
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 6px 0; }
.typing-dots span {
  width: 7px; height: 7px; background: var(--text-muted);
  border-radius: 50%; display: inline-block;
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce { 0%,80%,100% { transform: scale(0.8); opacity: .5; } 40% { transform: scale(1.1); opacity: 1; } }

/* Chat input */
.chat-input-area {
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.chat-input-box { display: flex; gap: 8px; align-items: flex-end; }
#chat-input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 10px 14px; font-size: 13px; resize: none;
  font-family: inherit; outline: none; max-height: 120px;
  transition: border-color var(--transition);
  line-height: 1.5;
}
#chat-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-mid); }
.btn-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--blue); color: white; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}
.btn-send:hover:not(:disabled) { background: var(--blue-dark); transform: scale(1.05); }
.btn-send:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; transform: none; }
.chat-disclaimer { font-size: 10px; color: var(--text-muted); text-align: center; margin-top: 6px; }

/* ============ SETTINGS ============ */
.settings-container { max-width: 720px; display: flex; flex-direction: column; gap: 16px; }
.settings-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow);
}
.settings-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.settings-notice {
  display: flex; gap: 12px; background: var(--amber-light);
  border: 1px solid #fcd34d; border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 18px; font-size: 12px;
}
.settings-notice i { color: var(--amber); margin-top: 2px; flex-shrink: 0; }
.settings-notice strong { display: block; font-weight: 700; margin-bottom: 3px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; font-size: 13px; outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus, .form-group select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-mid); }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.form-hint a { color: var(--blue); }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-bottom: 12px; }
.test-result {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 12px; font-weight: 500; margin-bottom: 12px;
}
.test-result.success { background: var(--green-light); color: var(--green-dark); border: 1px solid #6ee7b7; }
.test-result.error   { background: var(--red-light); color: var(--red-dark); border: 1px solid #fca5a5; }
.hidden { display: none !important; }

/* Deployment guide */
.deployment-guide { display: flex; flex-direction: column; gap: 14px; }
.guide-step { display: flex; gap: 14px; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blue);
  color: white; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.step-content strong { display: block; font-size: 13px; margin-bottom: 4px; }
.step-content p { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.step-content code { background: var(--bg-body); padding: 1px 5px; border-radius: 3px; font-size: 11px; border: 1px solid var(--border); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
.modal-container {
  background: white; border-radius: var(--radius-xl);
  width: 100%; max-width: 820px; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title-group { display: flex; align-items: center; gap: 10px; }
.modal-title-group h2 { font-size: 16px; font-weight: 700; }
.asset-id-badge { font-size: 11px; font-weight: 700; color: var(--blue); background: var(--blue-light); padding: 3px 10px; border-radius: 20px; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--bg-muted); color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition); font-size: 13px;
}
.modal-close:hover { background: var(--red-light); color: var(--red); }

.modal-tabs {
  display: flex; gap: 0; padding: 0 24px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-tab {
  padding: 11px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; background: transparent; color: var(--text-muted);
  border-bottom: 2px solid transparent; transition: all var(--transition);
  margin-bottom: -1px;
}
.modal-tab:hover { color: var(--text-primary); }
.modal-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.modal-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.modal-tab-content { display: none; }
.modal-tab-content.active { display: block; }

/* Modal overview */
.detail-kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.detail-kpi { background: var(--bg-muted); border-radius: var(--radius); padding: 12px 14px; }
.detail-kpi label { display: block; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.value-large { font-size: 18px; font-weight: 800; }
.value-large.green { color: var(--green); }

.health-bar-container { margin-bottom: 20px; background: var(--bg-muted); border-radius: var(--radius); padding: 14px; }
.health-bar-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.health-bar { height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; margin-bottom: 6px; }
.health-bar-fill { height: 100%; border-radius: 5px; transition: width .6s ease; }
.health-bar-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); }

.detail-info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.detail-info-item { padding: 10px 12px; background: var(--bg-muted); border-radius: var(--radius); }
.detail-info-item label { display: block; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.detail-info-item span { font-size: 12px; font-weight: 600; color: var(--text-primary); }

.detail-notes { background: var(--bg-muted); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.detail-notes label { display: block; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.detail-notes p { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--blue-light); color: var(--blue-dark); font-weight: 600; }

.specs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.spec-item { background: var(--bg-muted); border-radius: var(--radius); padding: 12px 14px; }
.spec-item label { display: block; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.spec-item span { font-size: 13px; font-weight: 600; color: var(--text-primary); }

.analytics-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.analytics-charts .chart-card { border: 1px solid var(--border); }
.analytics-charts .chart-card h4 { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.analytics-charts .chart-container { height: 180px; }

/* ============ TOAST ============ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  background: var(--text-primary); color: white;
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.success { background: var(--green-dark); }
.toast.error   { background: var(--red-dark); }
.toast.warning { background: var(--amber-dark); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============ UTILITY ============ */
.mt-4 { margin-top: 4px; }
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px; }
.empty-state i { font-size: 28px; margin-bottom: 10px; display: block; }

/* ============================================================
   NEW: FORM MODALS, CRUD ACTIONS, INCIDENTS, AI ANALYSIS
   ============================================================ */

/* ─── Modal Overlay ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }

/* ─── Modal Box ─────────────────────────────────────────────── */
.modal-box {
/* Modal box: solid white background */
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}

.modal-box-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-box-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close-btn:hover { background: var(--border); color: var(--text-primary); }

.modal-form-body {
/* Modal form body: solid white background */
  overflow-y: auto;
  padding: 20px 24px;
  flex: 1;
  background: #fff;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 12px 12px;
}

/* ─── Form Layout ───────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row-highlight {
/* Highlighted form row: solid very light blue background */
  background: #f1f5fd;
  border: 1px solid #c7d7f5;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}
.form-group {
/* Form group: solid background for clarity */
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: #fff;
  border-radius: 6px;
  padding: 0 0 8px 0;
}
/* Inputs: solid white background, no transparency */
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}
.form-hint {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 6px;
}
.required {
  color: var(--red);
  margin-left: 2px;
}
.form-control {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; }
select.form-control { cursor: pointer; }

.form-highlight-banner {
  background: rgba(59,130,246,0.07);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Row Action Buttons (table) ────────────────────────────── */
.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--surface); color: var(--text-primary); border-color: var(--text-secondary); }
.btn-icon.btn-ai:hover { color: var(--blue); border-color: var(--blue); }
.btn-icon.btn-danger { border-color: transparent; }
.btn-icon.btn-danger:hover { background: rgba(239,68,68,0.1); color: var(--red); border-color: var(--red); }

/* ─── Btn Sizes ─────────────────────────────────────────────── */
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-danger {
  background: var(--red, #ef4444);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-danger:hover { background: #dc2626; }

/* ─── Timeline CRUD Buttons ──────────────────────────────────── */
.timeline-crud-btns {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: flex-end;
}

/* ─── Incident Cards ────────────────────────────────────────── */
.incident-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.incident-card:hover { border-color: var(--text-secondary); }
.incident-resolved {
  opacity: 0.6;
  border-style: dashed;
}
.incident-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.incident-actions {
  display: flex;
  gap: 4px;
}
.severity-badge,
.incident-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.incident-type-badge {
  background: var(--border);
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: none;
}
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  background: rgba(59,130,246,0.12);
  color: var(--blue);
  border: 1px solid rgba(59,130,246,0.2);
  text-transform: uppercase;
}
.incident-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}
.incident-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}
.incident-actions-list {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.incident-actions-list ul {
  margin: 4px 0 0 16px;
  padding: 0;
}
.incident-actions-list li { margin-bottom: 2px; }
.incident-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ─── AI Analysis Panel ─────────────────────────────────────── */
.ai-analysis-placeholder {
  text-align: center;
  padding: 48px 24px;
}
.ai-analysis-placeholder-icon {
  font-size: 48px;
  color: var(--blue);
  margin-bottom: 16px;
  opacity: 0.6;
}
.ai-analysis-placeholder h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.ai-analysis-placeholder p {
  color: var(--text-secondary);
  font-size: 13px;
  max-width: 400px;
  margin: 0 auto 20px;
  line-height: 1.6;
}

.ai-analysis-box {
  padding: 4px 0;
}
.ai-analysis-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.ai-analysis-classification {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.ai-analysis-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.ai-recommendation {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}
.ai-anomaly-flags {
  background: rgba(245,158,11,0.06);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.ai-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}
.ai-flag-item {
  font-size: 12px;
  color: var(--amber, #f59e0b);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.ai-eol-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.ai-eol-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
}
.ai-eol-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.ai-eol-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Value Projection Grid */
.value-projection-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.vp-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 10px;
  text-align: center;
}
.vp-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.vp-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.vp-delta {
  font-size: 11px;
  font-weight: 600;
  margin-top: 3px;
}
.vp-delta.neg { color: var(--red, #ef4444); }
.vp-delta.pos { color: var(--green, #10b981); }

/* Risk Badges */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

/* AI Thinking Spinner */
.ai-thinking {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  gap: 12px;
}
.ai-thinking-spinner { font-size: 40px; color: var(--blue); }
.ai-thinking-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.ai-thinking-sub {
  font-size: 12px;
  color: var(--text-secondary);
}
.ai-error {
  text-align: center;
  padding: 40px;
  color: var(--red);
  font-size: 13px;
}

/* Custody AI flags row */
.ai-flags-row {
  margin-top: 6px;
  font-size: 11px;
}

