/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #0f172a;
  background: #f0f4f8;
  -webkit-font-smoothing: antialiased;
}

/* ── Color Tokens ── */
:root {
  --navy: #0f2a4a;
  --navy-light: #1a3a5c;
  --navy-muted: #2d4f6e;
  --white: #ffffff;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  /* AP accent colors */
  --ap1: #16a34a;       /* green */
  --ap1-light: #dcfce7;
  --ap1-mid: #86efac;
  --ap2: #2563eb;       /* blue */
  --ap2-light: #dbeafe;
  --ap2-mid: #93c5fd;
  --ap3: #7c3aed;       /* purple */
  --ap3-light: #ede9fe;
  --ap3-mid: #c4b5fd;
  --ap4: #ea580c;       /* orange */
  --ap4-light: #ffedd5;
  --ap4-mid: #fdba74;
}

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.main-content { padding: 32px; max-width: 1200px; margin: 0 auto; }
.page-section { animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.stack  { display: flex; flex-direction: column; gap: 16px; }
.row    { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.nav-left  { display: flex; align-items: center; gap: 32px; }
.nav-right { display: flex; align-items: center; gap: 12px; }

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.nav-brand-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white;
}
.nav-brand-poc {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.2);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  letter-spacing: 0.05em;
}

.nav-links { display: flex; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.nav-link:hover  { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active { background: rgba(255,255,255,0.15); color: white; font-weight: 500; }

.nav-ap-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.nav-ap-dot.ap1 { background: var(--ap1); }
.nav-ap-dot.ap2 { background: var(--ap2); }
.nav-ap-dot.ap3 { background: var(--ap3); }
.nav-ap-dot.ap4 { background: var(--ap4); }

.nav-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
}
.nav-user-avatar {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white;
}
.nav-user-info { display: flex; flex-direction: column; }
.nav-user-name { font-size: 0.8rem; font-weight: 500; color: white; line-height: 1.2; }
.nav-user-org  { font-size: 0.7rem; color: rgba(255,255,255,0.6); line-height: 1.2; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}
.card-sm { padding: 16px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.card-header {
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Stat Cards ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  border-left: 4px solid var(--border);
  transition: transform 0.15s;
}
.stat-card:hover { transform: translateY(-1px); }
.stat-card.ap1 { border-left-color: var(--ap1); }
.stat-card.ap2 { border-left-color: var(--ap2); }
.stat-card.ap3 { border-left-color: var(--ap3); }
.stat-card.ap4 { border-left-color: var(--ap4); }
.stat-card.navy { border-left-color: var(--navy); }

.stat-label  { font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px; }
.stat-value  { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px; }
.stat-sub    { font-size: 0.8rem; color: var(--text-muted); }
.stat-prog   { margin-top: 10px; }

/* ── Progress Bar ── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}
.progress-fill.ap1 { background: var(--ap1); }
.progress-fill.ap2 { background: var(--ap2); }
.progress-fill.ap3 { background: var(--ap3); }
.progress-fill.ap4 { background: var(--ap4); }
.progress-fill.navy { background: var(--navy); }

/* ── AP Section Headers ── */
.ap-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.ap-badge {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 10px;
  font-size: 0.7rem; font-weight: 700; color: white;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.ap-badge.ap1 { background: var(--ap1); }
.ap-badge.ap2 { background: var(--ap2); }
.ap-badge.ap3 { background: var(--ap3); }
.ap-badge.ap4 { background: var(--ap4); }

.ap-header-text h2 { font-size: 1.3rem; font-weight: 700; }
.ap-header-text p  { color: var(--text-muted); font-size: 0.875rem; margin-top: 2px; }

/* ── Page Header ── */
.page-header {
  margin-bottom: 28px;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header p  { color: var(--text-muted); margin-top: 4px; }

/* ── Typography ── */
h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.02em; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: 0.9rem; font-weight: 600; }
p  { color: var(--text-muted); line-height: 1.7; }

.text-muted   { color: var(--text-muted); }
.text-subtle  { color: var(--text-subtle); font-size: 0.8rem; }
.text-strong  { font-weight: 600; color: var(--text); }
.label        { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-subtle); }
.link         { color: var(--ap2); text-decoration: none; }
.link:hover   { text-decoration: underline; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  font-size: 0.85rem; font-weight: 500; font-family: inherit;
  border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap; text-decoration: none;
}
.btn-primary   { background: var(--navy); color: white; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-light); }
.btn-secondary { background: white; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost     { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger    { background: #dc2626; color: white; }
.btn-success   { background: var(--ap1); color: white; }
.btn-sm        { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg        { padding: 12px 22px; font-size: 0.95rem; }
.btn-full      { width: 100%; }
.btn:disabled  { opacity: 0.45; cursor: not-allowed; }

.btn-ap1 { background: var(--ap1); color: white; }
.btn-ap1:hover { background: #15803d; }
.btn-ap2 { background: var(--ap2); color: white; }
.btn-ap2:hover { background: #1d4ed8; }
.btn-ap3 { background: var(--ap3); color: white; }
.btn-ap3:hover { background: #6d28d9; }
.btn-ap4 { background: var(--ap4); color: white; }
.btn-ap4:hover { background: #c2410c; }

/* ── Forms ── */
.form-group   { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label   { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.form-hint    { font-size: 0.78rem; color: var(--text-subtle); }
.form-section { margin: 20px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-section h4 { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

input, select, textarea {
  width: 100%; padding: 9px 12px;
  font-size: 0.875rem; font-family: inherit;
  color: var(--text); background: white;
  border: 1px solid var(--border); border-radius: 5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ap2);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
input::placeholder { color: var(--text-subtle); }
textarea { resize: vertical; min-height: 80px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; background: white; }
th {
  text-align: left; padding: 10px 16px;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; cursor: pointer; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 0.72rem; font-weight: 500;
}
.badge-default  { background: #f1f5f9; color: #64748b; }
.badge-success  { background: #dcfce7; color: #15803d; }
.badge-warning  { background: #fef3c7; color: #b45309; }
.badge-danger   { background: #fee2e2; color: #b91c1c; }
.badge-blue     { background: #dbeafe; color: #1d4ed8; }
.badge-purple   { background: #ede9fe; color: #6d28d9; }
.badge-orange   { background: #ffedd5; color: #c2410c; }
.badge-navy     { background: #e0e7ef; color: #0f2a4a; }

.badge-dsp  { background: #e0e7ef; color: #0f2a4a; }
.badge-kthv { background: #dbeafe; color: #1d4ed8; }
.badge-suv  { background: #ede9fe; color: #6d28d9; }

/* ── Alerts ── */
.alert         { padding: 12px 16px; border-radius: 6px; border: 1px solid transparent; font-size: 0.875rem; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-error   { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #b45309; }

/* ── Auth Screen ── */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-muted) 100%);
  padding: 24px;
}
.auth-card {
  background: white;
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.auth-logo {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.auth-logo-icon {
  width: 48px; height: 48px;
  background: var(--navy);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: white;
  flex-shrink: 0;
}
.auth-logo h1 { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.auth-logo p  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.auth-footer  { text-align: center; margin-top: 16px; font-size: 0.85rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px;
  z-index: 1000;
  overflow-y: auto;
}
.modal {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 760px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  margin: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--text-muted);
  padding: 4px 8px; border-radius: 4px;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #0f172a; color: white;
  padding: 12px 20px; border-radius: 8px;
  font-size: 0.875rem; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 2000;
  animation: slideUp 0.2s ease;
}
.toast.success { background: #15803d; }
.toast.error   { background: #b91c1c; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Case Detail ── */
.case-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dim-row {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px; border-radius: 6px;
  background: var(--bg);
}
.dim-row-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.dim-row-value { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.dim-row-notes { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.story-block {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 4px;
}
.story-block p { font-size: 0.875rem; line-height: 1.7; color: var(--text); }

/* ── Dimension Card (AP2) ── */
.dim-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  transition: box-shadow 0.15s;
}
.dim-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.dim-card.inactive { opacity: 0.5; }
.dim-card-num {
  width: 28px; height: 28px;
  background: var(--ap2-light);
  color: var(--ap2);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  flex-shrink: 0;
}
.dim-card-body { flex: 1; }
.dim-card-body h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 3px; }
.dim-card-body p  { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.dim-card-body .dim-cat { font-size: 0.72rem; font-weight: 500; color: var(--ap2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }

/* ── AI Placeholder ── */
.ai-placeholder {
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  border: 1px dashed var(--ap3-mid);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}
.ai-placeholder .ai-icon { font-size: 1.5rem; margin-bottom: 8px; }
.ai-placeholder h4 { color: var(--ap3); font-size: 0.875rem; }
.ai-placeholder p  { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ── Phase Timeline ── */
.phase-timeline { display: flex; gap: 0; margin-bottom: 32px; }
.phase-item {
  flex: 1;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-right: none;
  position: relative;
}
.phase-item:first-child { border-radius: 8px 0 0 8px; }
.phase-item:last-child  { border-right: 1px solid var(--border); border-radius: 0 8px 8px 0; }
.phase-item.active { background: var(--navy); color: white; border-color: var(--navy); }
.phase-item.active .phase-name { color: white; }
.phase-item.active .phase-months { color: rgba(255,255,255,0.7); }
.phase-name   { font-size: 0.8rem; font-weight: 600; }
.phase-months { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.phase-status {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.68rem; font-weight: 500;
  padding: 1px 6px; border-radius: 99px;
}
.phase-status.active  { background: rgba(255,255,255,0.2); color: white; }
.phase-status.planned { background: var(--bg); color: var(--text-muted); }

/* ── Filter Bar ── */
.filter-bar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar select,
.filter-bar input { width: auto; min-width: 160px; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 0.875rem; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .main-content { padding: 20px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .nav-links { display: none; }
  .case-detail-grid { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .phase-timeline { flex-direction: column; }
  .phase-item { border-right: 1px solid var(--border); border-bottom: none; border-radius: 0; }
  .phase-item:first-child { border-radius: 8px 8px 0 0; }
  .phase-item:last-child  { border-bottom: 1px solid var(--border); border-radius: 0 0 8px 8px; }
}