/* WVRS Triage Prototype — Professional neutral palette */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #f4f5f7;
  --surface:    #ffffff;
  --border:     #dde1e7;
  --text:       #1a1d23;
  --text-muted: #6b7280;
  --accent:     #1a56db;
  --accent-hover:#1444b8;

  /* Tier colours */
  --c-emergency:   #b91c1c;
  --c-accelerated: #c2410c;
  --c-enhanced:    #b45309;
  --c-standard:    #15803d;
  --c-low:         #475569;

  --radius: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.app-header {
  background: #0f1923;
  color: #e8edf3;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.app-header h1 { font-size: 17px; font-weight: 600; letter-spacing: .02em; }
.app-header .badge {
  background: #1a56db;
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

/* ---- Upload zone ---- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  transition: border-color .2s;
  cursor: pointer;
}
.upload-zone.drag-over { border-color: var(--accent); background: #eff6ff; }
.upload-zone input[type=file] { display: none; }
.upload-zone .hint { color: var(--text-muted); font-size: 13px; margin-top: 6px; }
.upload-zone .file-selected { font-weight: 600; color: var(--accent); margin-top: 8px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-outline:hover { background: #eff6ff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---- Progress bar ---- */
.progress-wrap { margin: 12px 0; }
.progress-bar-outer {
  background: #e5e7eb;
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .3s;
  width: 0%;
}
.progress-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---- Tier summary cards ---- */
.tier-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.tier-card {
  flex: 1 1 140px;
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #fff;
  min-width: 140px;
}
.tier-card .cnt { font-size: 28px; font-weight: 700; line-height: 1; }
.tier-card .lbl { font-size: 11px; opacity: .85; margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }
.tc-emergency   { background: var(--c-emergency); }
.tc-accelerated { background: var(--c-accelerated); }
.tc-enhanced    { background: var(--c-enhanced); }
.tc-standard    { background: var(--c-standard); }
.tc-low         { background: var(--c-low); }

/* ---- Batch summary ---- */
.batch-summary {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}
.batch-summary h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.batch-summary ul { padding-left: 18px; }
.batch-summary li { margin-bottom: 3px; }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.filter-bar select, .filter-bar input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}
.filter-bar label { font-size: 13px; color: var(--text-muted); }

/* ---- Data table ---- */
.tbl-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: #f1f3f6;
  border-bottom: 2px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}
thead th:hover { background: #e5e7eb; }
thead th .sort-icon { font-size: 10px; opacity: .5; margin-left: 4px; }
thead th.sorted .sort-icon { opacity: 1; }

tbody tr:hover { background: #f9fafb; }
tbody td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  vertical-align: top;
}

.rank-num {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 15px;
}

.wvrs-score {
  font-size: 16px;
  font-weight: 700;
}

/* Severity band badges */
.band {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.band-Critical    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.band-High        { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.band-Medium      { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.band-Low         { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.band-Minimal     { background: #f8fafc; color: #475569; border: 1px solid #cbd5e1; }

/* Tier badge */
.tier-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tb-emergency   { background: #fef2f2; color: var(--c-emergency);   border: 1px solid #fecaca; }
.tb-accelerated { background: #fff7ed; color: var(--c-accelerated); border: 1px solid #fed7aa; }
.tb-enhanced    { background: #fffbeb; color: var(--c-enhanced);    border: 1px solid #fde68a; }
.tb-standard    { background: #f0fdf4; color: var(--c-standard);    border: 1px solid #bbf7d0; }
.tb-low         { background: #f8fafc; color: var(--c-low);         border: 1px solid #cbd5e1; }

/* Confidence meter */
.conf-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.conf-bar-track {
  width: 60px;
  height: 4px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}
.conf-bar-fill { height: 100%; border-radius: 99px; }
.conf-High    { background: #16a34a; }
.conf-Medium  { background: #d97706; }
.conf-Low     { background: #dc2626; }

/* Triage flags */
.flag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.flag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid;
  white-space: nowrap;
}
.flag-IMMEDIATE_RESPONSE_CANDIDATE { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.flag-CHAINED_TO_TIER1     { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.flag-CORE_IAM_SSO         { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; }
.flag-SECURITY_TOOLING     { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }
.flag-NETWORK_INFRA        { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

/* Missing factor tags */
.missing-tag {
  font-size: 10px;
  background: #f1f5f9;
  color: #64748b;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

/* ---- Modal / Detail overlay ---- */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  max-width: 820px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  line-height: 1;
  flex-shrink: 0;
}
.modal-body { overflow-y: auto; padding: 20px; flex: 1; }

/* Reasoning trace */
.trace-step {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  align-items: flex-start;
}
.trace-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: #1a56db;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.trace-step-num.agent { background: #0f1923; }
.trace-step-content { flex: 1; }
.trace-step-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.trace-step-detail {
  font-size: 13px;
  font-family: 'Menlo', 'Consolas', monospace;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Factor table in detail */
.factor-table td, .factor-table th { padding: 6px 8px; }
.factor-table tr:nth-child(even) { background: #f9fafb; }

/* ---- Validation report ---- */
.validation-report {
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: #fafafa;
}
.validation-report .err  { color: #b91c1c; }
.validation-report .warn { color: #b45309; }

/* ---- Utility ---- */
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.align-center { align-items: center; }
.hidden { display: none !important; }

/* ---- Import history ---- */
.import-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  background: var(--surface);
  transition: border-color .2s;
}
.import-pill:hover { border-color: var(--accent); }
.import-pill.active { border-color: var(--accent); background: #eff6ff; }
.import-pill .ip-filename { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

/* ---- Tabs ---- */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { }

/* ---- Manual entry form ---- */
.form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.form-section-note { font-weight: 400; text-transform: none; letter-spacing: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field-wide { grid-column: span 2; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.form-label .req { color: #dc2626; }
.form-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  display: block;
}
.form-input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
.form-input.invalid { border-color: #dc2626; }

.form-verify {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  cursor: pointer;
  user-select: none;
}

/* KEV toggle switch */
.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  margin-top: 4px;
}
.toggle-wrap input[type=checkbox] { display: none; }
.toggle-slider {
  position: relative;
  width: 40px;
  height: 22px;
  background: #d1d5db;
  border-radius: 99px;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-wrap input:checked ~ .toggle-slider { background: #dc2626; }
.toggle-wrap input:checked ~ .toggle-slider::after { left: 21px; }
.toggle-label { font-size: 13px; font-weight: 500; }
.form-field-kev { justify-content: flex-start; }

/* Triage flag checkboxes */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.check-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.check-card:hover { border-color: var(--accent); background: #f8faff; }
.check-card input[type=checkbox] { margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.check-card-body { display: flex; flex-direction: column; gap: 2px; }
.check-card-body strong { font-size: 13px; }
.check-card-body span { font-size: 11px; color: var(--text-muted); }

/* Form actions bar */
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.form-status {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 4px;
}
.form-status.ok  { color: #15803d; background: #f0fdf4; }
.form-status.err { color: #b91c1c; background: #fef2f2; }

/* Delete button in table (manual entries) */
.btn-danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

@media (max-width: 768px) {
  .main-container { padding: 12px; }
  .tier-card { flex: 1 1 120px; }
  .modal { max-height: 100vh; border-radius: 0; }
  .form-field-wide { grid-column: span 1; }
}
