:root {
  --ink: #1a1d23;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f7f1e3;
  --accent: #b45309;
  --error: #b42318;
  --warning: #92400e;
  --accent-bright: #f59e0b;

  /* Chart-only status colors -- deliberately distinct from each other for
     wedge separation, independent of the .status-* badge shades above.
     Picked for max hue separation (red / violet / amber / cyan) so no two
     wedges read as "basically the same color" even at a glance. */
  --chart-error: #dc2626;
  --chart-failed: #7c3aed;
  --chart-warning: #d97706;
  --chart-aborted: #0891b2;
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

header a { color: var(--muted); text-decoration: none; margin-left: 16px; }
header a:hover { text-decoration: underline; }

.mode-badge {
  margin-left: 12px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
}

main { max-width: 960px; margin: 0 auto; padding: 28px; }

h1 { font-size: 20px; }

.toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin: 20px 0; }

.chart-panel h2 {
  margin: 0 0 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pie-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.pie-chart { width: 88px; height: 88px; flex-shrink: 0; }
.pie-chart path { stroke: #fff; stroke-width: 2; transition: opacity .15s; cursor: default; }
.pie-chart path:hover { opacity: .85; }
.pie-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pie-legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend-count { color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

.slice-error, .swatch.slice-error { fill: var(--chart-error); background: var(--chart-error); }
.slice-failed, .swatch.slice-failed { fill: var(--chart-failed); background: var(--chart-failed); }
.slice-warning, .swatch.slice-warning { fill: var(--chart-warning); background: var(--chart-warning); }
.slice-aborted, .swatch.slice-aborted { fill: var(--chart-aborted); background: var(--chart-aborted); }

table { width: 100%; border-collapse: collapse; margin-top: 16px; background: #fff; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.message-cell { color: var(--muted); }

.status { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-error, .status-failed { background: #fee4e2; color: var(--error); }
.status-aborted { background: #fef0c7; color: var(--warning); }
.status-warning { background: #fef9c3; color: #854d0e; }

.category { font-size: 12px; color: var(--accent); }
.not-triaged { font-size: 12px; color: var(--muted); font-style: italic; }

button {
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
button.secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }

.login-wrap {
  max-width: 380px;
  margin: 12vh auto;
  background: #fff;
  padding: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.brand-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: -32px -32px 22px;
  padding: 22px 28px;
  background: linear-gradient(135deg, #1a1d23 0%, #343a45 100%);
  border-radius: 9px 9px 0 0;
  border-bottom: 3px solid var(--accent);
}
.brand-mark { width: 40px; height: 40px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; gap: 4px; line-height: 1; }
.brand-name { font-size: 19px; font-weight: 700; color: #fff; letter-spacing: .01em; }
.brand-num { color: var(--accent-bright); }
.brand-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: rgba(255, 255, 255, .62);
}
.login-wrap .brand-banner + h1 { margin-top: 0; }
.login-wrap h1 { font-size: 20px; margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: 14px; margin-top: 0; }
.login-wrap form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.login-wrap label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.login-wrap input { padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 18px; }
.error { color: var(--error); font-size: 14px; }

.panel { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-top: 16px; }
.message-block { white-space: pre-wrap; background: var(--bg); padding: 12px; border-radius: 6px; font-size: 13px; }
.meta { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); }

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  background: var(--bg);
  transition: border-color .15s, background .15s;
}
.dropzone-active { border-color: var(--accent); background: #fff; }
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.dropzone-text { margin: 0; font-size: 14px; color: var(--ink); pointer-events: none; }
.dropzone-text strong { color: var(--accent); }
.dropzone-filename { margin: 10px 0 0; font-size: 13px; color: var(--muted); pointer-events: none; }

button:disabled { opacity: .6; cursor: not-allowed; }

.processing-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 35, 0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.processing-overlay.active { display: flex; }
.processing-box {
  background: #fff;
  border-radius: 10px;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-text { margin: 0; font-size: 14px; color: var(--muted); }

/* ---- admin ---- */
.flash { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin: 16px 0 0; }
.flash-ok { background: #ecfdf3; color: #067647; border: 1px solid #abefc6; }
.flash-error { background: #fef3f2; color: var(--error); border: 1px solid #fecdca; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.inline-form input { padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; min-width: 200px; }
.inline-form form { display: inline; }

.stacked-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; max-width: 480px; }
.stacked-form label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.stacked-form input { padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.stacked-form button { align-self: flex-start; }

.user-card .user-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.ip-table { margin-top: 12px; }
.ip-table td, .ip-table th { padding: 8px 10px; }
.ip-table form { margin: 0; }
button.small { padding: 4px 10px; font-size: 12px; }
code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* ---- confirmation modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 29, 35, 0.5);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 24px 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  border-top: 4px solid var(--error);
}
.modal-box h2 { margin: 0 0 10px; font-size: 17px; }
.modal-box p { font-size: 14px; margin: 0 0 12px; }
.modal-list { font-size: 14px; margin: 0 0 14px; padding-left: 20px; color: var(--muted); }
.modal-confirm { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 16px 0; }
.modal-confirm input { margin-top: 3px; flex-shrink: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.danger { background: var(--error); }
.danger[disabled] { opacity: .45; }
.status-inactive { background: #f2f4f7; color: var(--muted); }
.row-inactive td { opacity: .62; }
.unrestricted { background: #fef0c7; color: var(--warning); }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions form { margin: 0; }
