:root {
  --navy: #10233f;
  --navy-light: #16305a;
  --bg: #f7f7f5;
  --border: #e2e2de;
  --text: #1a1a1a;
  --muted: #6b7280;
  --green: #1f7a5c;
  --amber: #b8860b;
  --red: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--navy);
  color: white;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { flex: 1; }
.brand-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9fb0c9;
}
.brand h1 { margin: 2px 0 0; font-size: 22px; font-weight: 600; }

.btn {
  border: none;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn-primary { background: white; color: var(--navy); }
.btn-primary:hover { background: #e8ecf3; }
.btn-ghost { background: transparent; color: white; border: 1px solid rgba(255,255,255,0.4); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

main { max-width: 1100px; margin: 0 auto; padding: 20px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 20px; font-weight: 600; margin-top: 2px; }
.stat-value.flag { color: var(--red); }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.toolbar input[type="text"], .toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.flag-toggle { font-size: 13px; display: flex; align-items: center; gap: 6px; }

table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
thead { background: #fafaf8; }
th, td { text-align: left; padding: 10px 12px; font-size: 13px; border-bottom: 1px solid #f0f0ee; }
tbody tr:hover { background: #fafaf8; cursor: pointer; }

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
}
.pill-green { background: #ecfbf3; color: var(--green); border-color: #c7ecd9; }
.pill-amber { background: #fdf3e0; color: var(--amber); border-color: #f2ddab; }
.pill-red { background: #fceceb; color: var(--red); border-color: #f3c8c4; }
.pill-blue { background: #f1f4f9; color: var(--navy); border-color: #d7e0ec; }

.hidden { display: none !important; }

.drawer, .modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; justify-content: flex-end; z-index: 50;
}
.modal { justify-content: center; align-items: center; }
.drawer-inner {
  background: white; width: 480px; max-width: 100%; height: 100%;
  overflow-y: auto; padding: 24px; position: relative;
}
.modal-inner {
  background: white; width: 480px; max-width: 90%; max-height: 90vh;
  overflow-y: auto; border-radius: 10px; padding: 24px;
}
.drawer-close {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  font-size: 22px; cursor: pointer; color: var(--muted);
}

.modal-inner form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.modal-inner label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.modal-inner input, .modal-inner textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.modal-actions .btn-primary { background: var(--navy); color: white; }
.modal-actions .btn-ghost { background: none; color: var(--text); border: 1px solid var(--border); }
.hint { font-size: 12px; color: var(--muted); }
.hint code { background: #f0f0ee; padding: 1px 4px; border-radius: 4px; }

.case-detail h2 { margin-top: 0; }
.detail-row { font-size: 13px; margin: 4px 0; color: var(--muted); }
.detail-row strong { color: var(--text); }
.section-title { font-size: 13px; font-weight: 600; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.timeline-item { font-size: 13px; padding: 6px 0; border-bottom: 1px solid #f0f0ee; }
.stage-select { padding: 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 13px; }
.event-form { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.event-form select, .event-form input { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 12px; }
