/* ══════════════════════════════════════════════════════════════
   AEGIS360 — Helendale School District Technology Governance
   ══════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────── */
:root {
  --hsd-navy:      #1B3A6B;
  --hsd-navy-dark: #122848;
  --hsd-navy-mid:  #2a5298;
  --hsd-gold:      #C9A835;
  --hsd-gold-dk:   #a07b10;
  --hsd-gold-lt:   rgba(201,168,53,.15);
  --hsd-surface:   #f4f6fb;
  --hsd-border:    #dde3f0;
  --hsd-text:      #1a202c;
  --hsd-muted:     #64748b;
  --shadow-sm:     0 1px 4px rgba(27,58,107,.09);
  --shadow-md:     0 4px 16px rgba(27,58,107,.13);
  --shadow-lg:     0 8px 32px rgba(27,58,107,.18);
  --sidebar-w:     260px;
  --topbar-h:      58px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Roboto', sans-serif;
  background: var(--hsd-surface);
  color: var(--hsd-text);
  font-size: .9rem;
}

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--hsd-navy-dark) 0%, var(--hsd-navy) 60%, var(--hsd-navy-mid) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(201,168,53,.13) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}
#loginCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.login-card {
  position: relative;
  z-index: 2;
  background: rgba(255,255,255,.97);
  border-radius: 18px;
  padding: 2.5rem 2.75rem 2.25rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  text-align: center;
}
.login-emblem { display: flex; flex-direction: column; align-items: center; margin-bottom: 1.5rem; }
.login-badge-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .6rem;
}
.login-badge-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: rgba(201,168,53,.8);
  border-right-color: rgba(201,168,53,.35);
  animation: ringRotate 8s linear infinite;
}
.login-badge-ring2 {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px dashed rgba(201,168,53,.3);
}
.login-badge-ticks {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.login-badge-ticks span {
  position: absolute;
  width: 6px;
  height: 2px;
  background: rgba(201,168,53,.6);
  border-radius: 1px;
  top: 50%;
  left: 50%;
  transform-origin: -40px 0;
}
.login-badge-ticks span:nth-child(1) { transform: translateY(-50%) rotate(0deg); }
.login-badge-ticks span:nth-child(2) { transform: translateY(-50%) rotate(90deg); }
.login-badge-ticks span:nth-child(3) { transform: translateY(-50%) rotate(180deg); }
.login-badge-ticks span:nth-child(4) { transform: translateY(-50%) rotate(270deg); }
.login-badge-circle {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: linear-gradient(145deg, #0d1f3c 0%, #1B3A6B 55%, #2a5298 100%);
  border: 2px solid rgba(201,168,53,.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 28px rgba(201,168,53,.3), 0 4px 20px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.08);
  position: relative;
  z-index: 1;
}
.login-badge-shield {
  color: #C9A835;
  text-shadow: 0 0 14px rgba(201,168,53,.7);
  line-height: 1;
}
.login-badge-sub {
  font-size: .42rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  margin-top: .15rem;
}
.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--hsd-navy);
  margin: 0 0 .2rem;
  letter-spacing: .02em;
}
.login-title span { color: var(--hsd-gold-dk); }
.login-subtitle { font-size: .78rem; color: var(--hsd-muted); margin: 0 0 1.75rem; }
.login-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  font-size: .72rem;
  color: var(--hsd-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.login-divider::before, .login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hsd-border);
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid var(--hsd-border);
  border-radius: 10px;
  background: #fff;
  font-size: .9rem;
  font-weight: 600;
  color: var(--hsd-text);
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, background .18s;
  text-decoration: none;
}
.btn-google:hover {
  border-color: var(--hsd-navy);
  box-shadow: var(--shadow-md);
  background: var(--hsd-surface);
  color: var(--hsd-navy);
}
.btn-google svg { flex-shrink: 0; }
.login-notice {
  margin-top: 1.1rem;
  font-size: .72rem;
  color: var(--hsd-muted);
  line-height: 1.6;
}
.login-district-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--hsd-gold-lt);
  border: 1px solid rgba(201,168,53,.35);
  border-radius: 20px;
  padding: .28rem .85rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--hsd-gold-dk);
  margin-bottom: 1rem;
}
@keyframes ringRotate { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════
   APP SHELL — SIDEBAR + TOPBAR
   ══════════════════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--hsd-navy-dark) 0%, var(--hsd-navy) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1.25rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
}
.sidebar-logo-emblem {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, #0d1f3c, #2a5298);
  border: 1.5px solid rgba(201,168,53,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(201,168,53,.25);
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--hsd-gold);
}
.sidebar-logo-text { line-height: 1.15; }
.sidebar-logo-name {
  font-size: .98rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .03em;
}
.sidebar-logo-name span { color: var(--hsd-gold); }
.sidebar-logo-district { font-size: .6rem; font-weight: 600; color: rgba(255,255,255,.4); letter-spacing: .07em; text-transform: uppercase; }

.sidebar-section-label {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 1rem 1.25rem .35rem;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0 .6rem; }
.sidebar-nav li { margin-bottom: .15rem; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: rgba(201,168,53,.18); color: var(--hsd-gold); font-weight: 600; }
.sidebar-nav a .nav-icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: #dc2626;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.sidebar-user {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .65rem;
}
.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--hsd-gold-dk), var(--hsd-gold));
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .65rem; color: rgba(255,255,255,.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout { color: rgba(255,255,255,.35); background: none; border: none; cursor: pointer; padding: .25rem; border-radius: 6px; transition: color .15s; font-size: .9rem; }
.sidebar-logout:hover { color: #f87171; }

/* Main area */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--hsd-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--hsd-navy); flex: 1; }
.topbar-subtitle { font-size: .72rem; color: var(--hsd-muted); font-weight: 400; margin-left: .5rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.btn-topbar {
  display: inline-flex;
  vertical-align: middle;
  align-items: center;
  gap: .4rem;
  padding: .42rem .9rem;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s;
}
.btn-primary { background: var(--hsd-navy); color: #fff; border-color: var(--hsd-navy); }
.btn-primary:hover { background: var(--hsd-navy-dark); border-color: var(--hsd-navy-dark); }
.btn-gold { background: var(--hsd-gold); color: #3a2800; border-color: var(--hsd-gold); }
.btn-gold:hover { background: var(--hsd-gold-dk); border-color: var(--hsd-gold-dk); color: #fff; }
.btn-outline { background: #fff; color: var(--hsd-navy); border-color: var(--hsd-border); }
.btn-outline:hover { border-color: var(--hsd-navy); box-shadow: var(--shadow-sm); }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

/* ══════════════════════════════════════════════════════════════
   CONTENT AREA
   ══════════════════════════════════════════════════════════════ */
.content-area { padding: 1.5rem; flex: 1; }
.view-panel { display: none; }
.view-panel.active { display: block; }

/* Section label (gold left border) */
.section-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--hsd-navy);
  border-left: 3px solid var(--hsd-gold);
  padding-left: .55rem;
  margin: 1.5rem 0 1rem;
}
.section-label:first-child { margin-top: 0; }

/* Page header */
.page-header { margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.25rem; font-weight: 700; color: var(--hsd-navy); margin: 0 0 .25rem; }
.page-header p { font-size: .82rem; color: var(--hsd-muted); margin: 0; }

/* ══════════════════════════════════════════════════════════════
   STAT CARDS
   ══════════════════════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .85rem; margin-bottom: 1.25rem; }
.stat-card {
  background: #fff;
  border: 1px solid var(--hsd-border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--hsd-navy);
}
.stat-card.gold::after { background: var(--hsd-gold); }
.stat-card.green::after { background: #16a34a; }
.stat-card.red::after { background: #dc2626; }
.stat-card.orange::after { background: #d97706; }
.stat-card.purple::after { background: #7c3aed; }
.stat-icon { font-size: 1.5rem; margin-bottom: .35rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--hsd-navy); line-height: 1; margin-bottom: .2rem; }
.stat-label { font-size: .68rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--hsd-muted); }
.stat-delta { font-size: .68rem; color: #16a34a; font-weight: 600; margin-top: .25rem; }
.stat-delta.negative { color: #dc2626; }

/* ══════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════ */
.card {
  background: #fff;
  border: 1px solid var(--hsd-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--hsd-border);
  background: #fafbfd;
}
.card-header-title { font-size: .9rem; font-weight: 700; color: var(--hsd-navy); margin: 0; }
.card-body { padding: 1.1rem 1.25rem; }

/* Navy card */
.card-navy {
  background: linear-gradient(135deg, var(--hsd-navy-dark) 0%, var(--hsd-navy) 70%, var(--hsd-navy-mid) 100%);
  border-color: transparent;
}
.card-navy .card-header { background: rgba(0,0,0,.15); border-color: rgba(255,255,255,.1); }
.card-navy .card-header-title { color: #fff; }
.card-navy .card-body { color: rgba(255,255,255,.85); }

/* ══════════════════════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th {
  text-align: left;
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--hsd-muted);
  padding: .65rem .9rem;
  background: var(--hsd-surface);
  border-bottom: 1px solid var(--hsd-border);
  white-space: nowrap;
}
.data-table td {
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--hsd-border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s; cursor: pointer; }
.data-table tbody tr:hover { background: #f8f9fc; }
.data-table .td-name { font-weight: 600; color: var(--hsd-navy); }
.data-table .td-meta { font-size: .75rem; color: var(--hsd-muted); }

/* ══════════════════════════════════════════════════════════════
   BADGES / STATUS CHIPS
   ══════════════════════════════════════════════════════════════ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .2rem .6rem;
  border-radius: 20px;
  white-space: nowrap;
}
.chip-pending    { background: #fef3c7; color: #92400e; }
.chip-approved   { background: #d1fae5; color: #065f46; }
.chip-denied     { background: #fee2e2; color: #991b1b; }
.chip-info       { background: #dbeafe; color: #1e40af; }
.chip-review     { background: #f3e8ff; color: #6b21a8; }
.chip-board      { background: #fde8d0; color: #9a3412; }
.chip-draft      { background: #f1f5f9; color: #475569; }
.chip-active     { background: #d1fae5; color: #065f46; }
.chip-expired    { background: #fee2e2; color: #991b1b; }
.chip-renewal    { background: #fef3c7; color: #92400e; }
.chip-high-risk  { background: #fee2e2; color: #991b1b; }
.chip-med-risk   { background: #fef3c7; color: #92400e; }
.chip-low-risk   { background: #d1fae5; color: #065f46; }

/* ══════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--hsd-navy);
  margin-bottom: .35rem;
}
.form-label .req { color: #dc2626; margin-left: .2rem; }
.form-control {
  display: block;
  width: 100%;
  padding: .55rem .8rem;
  border: 1.5px solid var(--hsd-border);
  border-radius: 8px;
  font-size: .875rem;
  font-family: inherit;
  color: var(--hsd-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
}
.form-control:focus { outline: none; border-color: var(--hsd-navy); box-shadow: 0 0 0 3px rgba(27,58,107,.1); }
.form-control.error { border-color: #dc2626; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: .73rem; color: var(--hsd-muted); margin-top: .3rem; }
.form-error { font-size: .73rem; color: #dc2626; margin-top: .3rem; display: none; }
.form-error.visible { display: block; }

/* Form grid */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* File upload zone */
.upload-zone {
  border: 2px dashed var(--hsd-border);
  border-radius: 10px;
  padding: 1.75rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--hsd-surface);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--hsd-navy);
  background: rgba(27,58,107,.04);
}
.upload-zone-icon { font-size: 2rem; margin-bottom: .5rem; color: var(--hsd-muted); }
.upload-zone p { font-size: .82rem; color: var(--hsd-muted); margin: 0; }
.upload-zone strong { color: var(--hsd-navy); }

/* Step wizard */
.wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 1.75rem;
  border-radius: 10px;
  overflow: hidden;
  background: var(--hsd-surface);
  border: 1px solid var(--hsd-border);
}
.wizard-step {
  flex: 1;
  padding: .7rem .5rem;
  text-align: center;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--hsd-muted);
  border-right: 1px solid var(--hsd-border);
  position: relative;
  transition: background .15s, color .15s;
}
.wizard-step:last-child { border-right: none; }
.wizard-step.active { background: var(--hsd-navy); color: #fff; }
.wizard-step.completed { background: var(--hsd-gold-lt); color: var(--hsd-gold-dk); }
.wizard-step-num {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: .2rem;
}

/* ══════════════════════════════════════════════════════════════
   APPROVAL CHAIN TIMELINE
   ══════════════════════════════════════════════════════════════ */
.approval-chain { display: flex; flex-direction: column; gap: 0; }
.approval-step {
  display: flex;
  gap: 1rem;
  position: relative;
}
.approval-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 36px;
  bottom: -12px;
  width: 2px;
  background: var(--hsd-border);
}
.approval-step-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--hsd-surface);
  border: 2px solid var(--hsd-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.approval-step.completed .approval-step-icon { background: #d1fae5; border-color: #16a34a; color: #16a34a; }
.approval-step.current   .approval-step-icon { background: var(--hsd-gold-lt); border-color: var(--hsd-gold); color: var(--hsd-gold-dk); animation: pulse 2s ease-in-out infinite; }
.approval-step.denied    .approval-step-icon { background: #fee2e2; border-color: #dc2626; color: #dc2626; }
.approval-step.pending   .approval-step-icon { background: #fff; border-color: #e2e8f0; color: #94a3b8; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(201,168,53,.4); } 50% { box-shadow: 0 0 0 8px rgba(201,168,53,0); } }
.approval-step-body { padding-bottom: 1.25rem; flex: 1; }
.approval-step-title { font-size: .85rem; font-weight: 700; color: var(--hsd-navy); margin: .4rem 0 .2rem; }
.approval-step-meta { font-size: .75rem; color: var(--hsd-muted); }
.approval-step-note {
  background: var(--hsd-surface);
  border: 1px solid var(--hsd-border);
  border-radius: 8px;
  padding: .6rem .85rem;
  font-size: .8rem;
  color: var(--hsd-text);
  margin-top: .5rem;
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════════
   AI ANALYSIS PANEL
   ══════════════════════════════════════════════════════════════ */
.ai-panel {
  background: #fff;
  border: 1px solid var(--hsd-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ai-panel-header {
  background: linear-gradient(135deg, var(--hsd-navy-dark), var(--hsd-navy));
  padding: .9rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.ai-panel-title { font-size: .88rem; font-weight: 700; color: #fff; margin: 0; }
.ai-badge {
  background: var(--hsd-gold);
  color: #3a2800;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .18rem .55rem;
  border-radius: 10px;
}
.ai-sections { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.ai-section-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: .7rem 1rem;
  border: 1px solid var(--hsd-border);
  border-radius: 9px;
  background: var(--hsd-surface);
  font-size: .82rem;
  font-weight: 600;
  color: var(--hsd-navy);
  cursor: pointer;
  text-align: left;
  transition: background .12s, border-color .12s;
}
.ai-section-btn:hover { background: var(--hsd-gold-lt); border-color: rgba(201,168,53,.4); }
.ai-section-btn .risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.risk-dot.high   { background: #dc2626; }
.risk-dot.medium { background: #d97706; }
.risk-dot.low    { background: #16a34a; }
.ai-content {
  padding: 1rem;
  border-top: 1px solid var(--hsd-border);
  font-size: .84rem;
  line-height: 1.75;
  color: var(--hsd-text);
}
.ai-content h4 { font-size: .82rem; font-weight: 700; color: var(--hsd-navy); margin: 1rem 0 .4rem; }
.ai-content ul { padding-left: 1.2rem; margin: .4rem 0; }
.ai-content ul li { margin-bottom: .3rem; }
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  gap: .75rem;
  color: var(--hsd-muted);
  font-size: .82rem;
}
.ai-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--hsd-border);
  border-top-color: var(--hsd-gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* AI Chat */
.ai-chat-wrap {
  display: flex;
  flex-direction: column;
  height: 340px;
}
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.chat-msg { max-width: 88%; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.ai   { align-self: flex-start; }
.chat-bubble {
  padding: .6rem .9rem;
  border-radius: 12px;
  font-size: .83rem;
  line-height: 1.6;
}
.chat-msg.user .chat-bubble { background: var(--hsd-navy); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.ai   .chat-bubble { background: var(--hsd-surface); border: 1px solid var(--hsd-border); color: var(--hsd-text); border-bottom-left-radius: 3px; }
.chat-meta { font-size: .68rem; color: var(--hsd-muted); margin-top: .2rem; }
.ai-chat-input {
  border-top: 1px solid var(--hsd-border);
  padding: .65rem .9rem;
  display: flex;
  gap: .5rem;
}
.ai-chat-input input {
  flex: 1;
  border: 1.5px solid var(--hsd-border);
  border-radius: 8px;
  padding: .5rem .75rem;
  font-size: .83rem;
  font-family: inherit;
}
.ai-chat-input input:focus { outline: none; border-color: var(--hsd-navy); }
.ai-chat-input button {
  background: var(--hsd-gold);
  color: #3a2800;
  border: none;
  border-radius: 8px;
  padding: .5rem .9rem;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.ai-chat-input button:hover { background: var(--hsd-gold-dk); color: #fff; }

/* ══════════════════════════════════════════════════════════════
   SWOT GRID
   ══════════════════════════════════════════════════════════════ */
.swot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.swot-cell { border-radius: 10px; padding: .85rem 1rem; font-size: .82rem; line-height: 1.65; }
.swot-cell h5 { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 .5rem; }
.swot-cell ul { margin: 0; padding-left: 1.1rem; }
.swot-cell ul li { margin-bottom: .2rem; }
.swot-s { background: #d1fae5; color: #064e3b; }
.swot-w { background: #fee2e2; color: #7f1d1d; }
.swot-o { background: #dbeafe; color: #1e3a8a; }
.swot-t { background: #fef3c7; color: #78350f; }

/* ══════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 100px rgba(0,0,0,.35);
}
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--hsd-border);
  background: linear-gradient(135deg, var(--hsd-navy-dark), var(--hsd-navy));
  border-radius: 16px 16px 0 0;
}
.modal-title { font-size: 1rem; font-weight: 700; color: #fff; margin: 0; }
.modal-close {
  background: rgba(255,255,255,.1);
  border: none;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  padding: .3rem .55rem;
  border-radius: 6px;
  line-height: 1;
  transition: background .15s;
}
.modal-close:hover { background: rgba(255,255,255,.2); }
.modal-body { padding: 1.4rem 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: .9rem 1.5rem;
  border-top: 1px solid var(--hsd-border);
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  background: #fafbfd;
  border-radius: 0 0 16px 16px;
}

/* ══════════════════════════════════════════════════════════════
   ALERTS
   ══════════════════════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .9rem 1.1rem;
  border-radius: 10px;
  font-size: .83rem;
  margin-bottom: .75rem;
}
.alert-icon { font-size: 1.1rem; flex-shrink: 0; }
.alert-info    { background: #dbeafe; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-warning { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }
.alert-danger  { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #d1fae5; border: 1px solid #a7f3d0; color: #065f46; }

/* ══════════════════════════════════════════════════════════════
   CONTRACT / LIFECYCLE INDICATORS
   ══════════════════════════════════════════════════════════════ */
.expiry-bar-wrap { height: 6px; background: var(--hsd-border); border-radius: 3px; overflow: hidden; margin-top: .4rem; }
.expiry-bar { height: 100%; border-radius: 3px; transition: width .5s; }
.expiry-bar.safe   { background: #16a34a; }
.expiry-bar.warn   { background: #d97706; }
.expiry-bar.danger { background: #dc2626; }

/* ══════════════════════════════════════════════════════════════
   BOARD MEMO
   ══════════════════════════════════════════════════════════════ */
.memo-editor {
  font-family: 'Georgia', serif;
  font-size: .9rem;
  line-height: 1.8;
  border: 1.5px solid var(--hsd-border);
  border-radius: 10px;
  padding: 1.5rem;
  min-height: 400px;
  width: 100%;
  background: #fffef9;
  color: var(--hsd-text);
}
.memo-editor:focus { outline: none; border-color: var(--hsd-navy); }
.memo-toolbar {
  display: flex;
  gap: .35rem;
  padding: .55rem .75rem;
  background: var(--hsd-surface);
  border: 1px solid var(--hsd-border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  flex-wrap: wrap;
}
.memo-toolbar button {
  padding: .28rem .6rem;
  border: 1px solid var(--hsd-border);
  border-radius: 5px;
  background: #fff;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--hsd-navy);
  transition: background .12s;
}
.memo-toolbar button:hover { background: var(--hsd-gold-lt); }

/* ══════════════════════════════════════════════════════════════
   RISK SCORE GAUGE
   ══════════════════════════════════════════════════════════════ */
.risk-gauge-wrap { display: flex; align-items: center; gap: 1rem; }
.risk-score {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--hsd-navy);
  line-height: 1;
}
.risk-score.high   { color: #dc2626; }
.risk-score.medium { color: #d97706; }
.risk-score.low    { color: #16a34a; }
.risk-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--hsd-muted); margin-top: .25rem; }

/* ══════════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--hsd-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: .75rem; opacity: .5; }
.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--hsd-navy); margin: 0 0 .4rem; }
.empty-state p { font-size: .82rem; max-width: 340px; line-height: 1.65; margin: 0 0 1.1rem; }

/* ══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: .75rem 1.1rem;
  border-radius: 10px;
  font-size: .83rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 260px;
  max-width: 380px;
  animation: toastIn .25s ease;
}
.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }
.toast.warning { background: #92400e; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* ══════════════════════════════════════════════════════════════
   LOADER OVERLAY
   ══════════════════════════════════════════════════════════════ */
#page-loader {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 900;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .75rem;
  font-size: .85rem;
  color: var(--hsd-navy);
  font-weight: 600;
}
#page-loader.visible { display: flex; }
.loader-ring {
  width: 48px;
  height: 48px;
  border: 4px solid var(--hsd-border);
  border-top-color: var(--hsd-navy);
  border-right-color: var(--hsd-gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ══════════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════════ */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1       { gap: .35rem; }
.gap-2       { gap: .65rem; }
.gap-3       { gap: 1rem; }
.mt-1        { margin-top: .35rem; }
.mt-2        { margin-top: .65rem; }
.mt-3        { margin-top: 1rem; }
.mb-1        { margin-bottom: .35rem; }
.mb-2        { margin-bottom: .65rem; }
.mb-3        { margin-bottom: 1rem; }
.text-muted  { color: var(--hsd-muted); }
.text-navy   { color: var(--hsd-navy); }
.text-gold   { color: var(--hsd-gold-dk); }
.text-sm     { font-size: .8rem; }
.text-xs     { font-size: .72rem; }
.fw-700      { font-weight: 700; }
.fw-800      { font-weight: 800; }
.w-100       { width: 100%; }
.btn-topbar.w-100 { display: flex; }   /* full width buttons stay block level */
.grid-2      { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3      { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.d-none      { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(27,58,107,.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(27,58,107,.4); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .sidebar-toggle { display: flex !important; }
}
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--hsd-border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--hsd-navy);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ══════════════════════════════════════════════════════════════
   MOBILE: action modals become full screen sheets
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .modal-overlay { padding: 0 !important; align-items: stretch !important; }
  .modal {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .modal-body { max-height: calc(100vh - 132px) !important; overflow-y: auto; }
  .modal-header { position: sticky; top: 0; z-index: 2; background: var(--hsd-navy); }
  .modal-footer {
    position: sticky; bottom: 0; z-index: 2; background: #fff;
    display: flex; gap: .4rem; flex-wrap: wrap;
  }
  .modal-footer button, .modal-footer a { flex: 1 1 auto; text-align: center; }
  .form-grid-2 { grid-template-columns: 1fr !important; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .data-table { font-size: .78rem; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ══════════════════════════════════════════════════════════════
   WIZARD NAVIGATION
   ══════════════════════════════════════════════════════════════ */
.wizard-nav {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: center;
  gap: .6rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hsd-border);
}
.wizard-nav > .spacer { flex: 1 1 auto; }
.wizard-nav > button { min-width: 130px; justify-content: center; white-space: nowrap; }
.wizard-nav > .btn-gold, .wizard-nav > .btn-primary { min-width: 172px; }

@media (max-width: 520px) {
  .wizard-nav { flex-direction: column-reverse !important; align-items: stretch; }
  .wizard-nav > .spacer { display: none; }
  .wizard-nav > button { width: 100%; min-width: 0; }
}
