:root {
  color-scheme: light;
  --ink: #15202b;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --canvas: #f4f6f8;
  --navy: #173b5f;
  --blue: #1769aa;
  --green: #087a55;
  --amber: #b54708;
  --red: #b42318;
  --shadow: 0 8px 30px rgba(16, 24, 40, .07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }

.topbar {
  min-height: 68px;
  padding: 14px max(20px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: white;
}
.brand { font-size: 19px; font-weight: 750; }
.mailbox { margin-left: 12px; opacity: .72; font-size: 13px; }
.top-actions, .action-row { display: flex; align-items: center; gap: 10px; }
.container { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; }

.page-heading, .case-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}
h1, h2 { line-height: 1.18; margin-top: 0; }
h1 { font-size: 30px; margin-bottom: 6px; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }

.button {
  border: 0;
  border-radius: 9px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 650;
}
.button-primary { background: var(--blue); color: white; }
.button-secondary { background: #e7eff7; color: var(--navy); }
.button-mode-auto { background: #d9f7e9; color: #066848; }
.button-danger { background: #fee4e2; color: var(--red); }
.button-danger-solid { background: var(--red); color: white; }
.button-ghost { background: rgba(255,255,255,.12); color: white; }
.push-active { background: #d9f7e9; color: #066848; }

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f6;
  font-size: 12px;
  font-weight: 700;
}
.badge-shadow { background: #fff1d6; color: #8a4b00; }
.badge-live { background: #d9f7e9; color: #066848; }
.badge-awaiting { background: #e7eff7; color: var(--navy); }
.badge-error { background: #fee4e2; color: var(--red); }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0 16px;
}
.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.filter {
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--muted);
}
.filter.active { color: var(--navy); background: white; box-shadow: var(--shadow); }
.filter span { margin-left: 5px; font-weight: 700; }

.case-list { display: grid; gap: 10px; }
.case-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid #98a2b3;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 14px;
  box-shadow: 0 2px 6px rgba(16,24,40,.03);
}
.case-row:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.priority-1 { border-left-color: #3b82c4; }
.priority-2 { border-left-color: #e38919; }
.priority-3 { border-left-color: #d92d20; }
.case-priority { font-size: 18px; font-weight: 800; }
.case-title { font-weight: 750; font-size: 16px; }
.case-meta, .case-summary, .confidence { color: var(--muted); font-size: 13px; }
.case-summary { margin-top: 5px; }
.case-side { display: flex; flex-direction: column; align-items: end; gap: 8px; }

.empty-state, .panel, .case-header {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.empty-state { padding: 48px; text-align: center; }
.panel { padding: 22px; }
.case-header { margin: 14px 0 20px; padding: 24px; border-left-width: 6px; }
.eyebrow { color: var(--blue); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; font-weight: 800; }
.status-card { min-width: 150px; display: flex; flex-direction: column; align-items: end; }
.status-label { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.back-link { color: var(--blue); font-weight: 650; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.reply-panel { margin-top: 16px; }

.details { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; }
.details dt { color: var(--muted); font-weight: 650; }
.details dd { margin: 0; }
.email-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow: auto;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.stack { display: grid; gap: 13px; }
label { display: grid; gap: 6px; font-weight: 650; }
input, textarea {
  width: 100%;
  border: 1px solid #cfd5dd;
  background: white;
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 180px; }
.reject-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 20px; }
.analysis-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.reanalyze-form { margin-top: 20px; }
.alert { border-radius: 10px; padding: 13px 15px; margin: 14px 0; }
.alert-error { background: #fee4e2; color: #7a271a; }
.alert-warning { background: #fffaeb; color: #7a2e0e; }
.danger-zone, .restore-zone {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.danger-zone h2, .restore-zone h2 { margin-bottom: 5px; }
.danger-zone p, .restore-zone p { margin: 0; }
.destructive-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.pwa-hint, .pwa-message {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 16px;
}
.pwa-hint { background: #e7eff7; color: var(--navy); }
.pwa-message { background: #d9f7e9; color: #066848; }
.pwa-message-error { background: #fee4e2; color: #7a271a; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(420px, 100%);
  background: white;
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-mark {
  width: 54px; height: 54px; display: grid; place-items: center;
  border-radius: 14px; background: var(--navy); color: white;
  font-weight: 850; margin-bottom: 20px;
}

@media (max-width: 760px) {
  .mailbox { display: none; }
  .topbar { align-items: flex-start; gap: 12px; }
  .top-actions { justify-content: flex-end; flex-wrap: wrap; }
  .top-actions .badge { display: none; }
  .push-toggle { padding: 8px 10px; }
  .container { padding: 20px 14px 48px; }
  .page-heading, .case-header { flex-direction: column; }
  .page-actions { width: 100%; justify-content: stretch; }
  .page-actions form, .page-actions .button { width: 100%; }
  .two-column { grid-template-columns: 1fr; }
  .case-row { grid-template-columns: 42px minmax(0, 1fr); }
  .case-side { grid-column: 2; flex-direction: row; align-items: center; }
  .status-card { align-items: start; }
  .details { grid-template-columns: 1fr; }
  .details dt { margin-top: 8px; }
  .reject-form { grid-template-columns: 1fr; }
  .analysis-actions { align-items: stretch; flex-direction: column; }
  .analysis-actions .button { width: 100%; }
  .danger-zone, .restore-zone { align-items: stretch; flex-direction: column; }
  .destructive-actions { align-items: stretch; flex-direction: column; }
  .destructive-actions .button { width: 100%; }
}
