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

:root {
  --bg:            #0b0f17;
  --surface:       #111827;
  --surface-2:     #182236;
  --surface-hover: #1e2a40;
  --border:        #243044;
  --border-hi:     #354d6b;

  --text-primary:   #eef2f9;
  --text-secondary: #8fa3c1;
  --text-muted:     #4e6280;

  --brand:       #f5d474;
  --brand-dim:   rgba(245, 212, 116, 0.1);
  --brand-dim2:  rgba(245, 212, 116, 0.18);

  --green:       #22c55e;
  --green-dim:   rgba(34, 197, 94, 0.12);
  --amber:       #f59e0b;
  --amber-dim:   rgba(245, 158, 11, 0.12);
  --blue:        #60a5fa;
  --blue-dim:    rgba(96, 165, 250, 0.12);
  --red:         #ef4444;
  --red-dim:     rgba(239, 68, 68, 0.12);
  --orange:      #f97316;
  --orange-dim:  rgba(249, 115, 22, 0.12);

  --p-critical: #ef4444;
  --p-high:     #f97316;
  --p-medium:   #f59e0b;
  --p-low:      #22c55e;
}

html, body {
  min-height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* =========================================
   Login / Setup pages
   ========================================= */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-img {
  display: block;
  max-width: 180px;
  height: auto;
  margin: 0 auto 0.5rem;
}

.logo-sub {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.logo-sub-sm {
  display: block;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--brand);
  text-transform: uppercase;
  margin-top: 0.1rem;
  font-weight: 600;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.03em;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--brand);
}

.btn-login {
  width: 100%;
  padding: 0.7rem;
  background: var(--brand);
  color: #080a0f;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  margin-top: 0.75rem;
  color: var(--red);
  font-size: 0.82rem;
  text-align: center;
}

/* =========================================
   App chrome — header
   ========================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 54px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-header .logo-img {
  height: 26px;
  width: auto;
  display: block;
  margin: 0;
  max-width: none;
}

.header-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}

.header-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.32rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-sm:hover {
  border-color: var(--border-hi);
  color: var(--text-primary);
}

/* =========================================
   Stats bar
   ========================================= */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.stat {
  padding: 0.85rem 1.5rem;
  border-right: 1px solid var(--border);
}

.stat:last-child { border-right: none; }

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.stat-critical .stat-value { color: var(--p-critical); }
.stat-high     .stat-value { color: var(--p-high); }

/* =========================================
   Main feed
   ========================================= */
.main-content {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* Section headers */
.section-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 1.75rem 0 0.75rem;
}

.section-head:first-child { margin-top: 0; }

.section-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 0.45rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.section-rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Empty state */
.feed-empty {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* =========================================
   Cards
   ========================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

/* Preserve left accent on hover */
.card.p-critical { border-left-color: var(--p-critical); }
.card.p-high     { border-left-color: var(--p-high); }
.card.p-medium   { border-left-color: var(--p-medium); }
.card.p-low      { border-left-color: var(--p-low); }

.card-main {
  padding: 0.85rem 1rem 0.75rem 1.1rem;
}

/* Title row */
.card-top {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.card-id {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
  flex-shrink: 0;
}

.card-title {
  font-size: 0.93rem;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.card-age {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Badge row */
.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.55rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Priority badges */
.badge-p-critical { background: var(--red-dim);    color: var(--p-critical); border: 1px solid rgba(239, 68,  68,  .3); }
.badge-p-high     { background: var(--orange-dim); color: var(--p-high);     border: 1px solid rgba(249, 115, 22,  .3); }
.badge-p-medium   { background: var(--amber-dim);  color: var(--p-medium);   border: 1px solid rgba(245, 158, 11,  .3); }
.badge-p-low      { background: var(--green-dim);  color: var(--p-low);      border: 1px solid rgba(34,  197, 94,  .3); }

/* Type badge */
.badge-type { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(96, 165, 250, .25); }

/* Impact badge */
.badge-impact { background: rgba(255,255,255,.04); color: var(--text-secondary); border: 1px solid var(--border); }

/* Technician badge */
.badge-tech { background: var(--brand-dim); color: var(--brand); border: 1px solid var(--brand-dim2); }

/* Staff override badge */
.badge-override { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(96,165,250,.25); }

/* AI reasoning */
.card-reasoning {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 0.65rem;
  padding: 0.4rem 0.7rem;
  border-left: 2px solid var(--border);
  background: rgba(255,255,255,.02);
  border-radius: 0 4px 4px 0;
}

/* Card footer row */
.card-foot {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Status dots */
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-green { background: var(--green); box-shadow: 0 0 5px rgba(34,197,94,.6); }
.dot-amber { background: var(--amber); }
.dot-blue  { background: var(--blue); }
.dot-grey  { background: var(--border-hi); }

.status-label {
  font-size: 0.71rem;
  color: var(--text-muted);
  flex: 1;
}

/* Override button */
.btn-override {
  padding: 0.22rem 0.65rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn-override:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-dim);
}

/* =========================================
   Override panel (inline form)
   ========================================= */
.override-panel {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: 1rem 1.1rem;
}

.override-panel.open { display: block; }

.override-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.override-field label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.override-field select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.override-field select:focus { border-color: var(--brand); }

.override-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-save {
  padding: 0.4rem 1.1rem;
  background: var(--brand);
  color: #0b0f17;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-save:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-cancel {
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s;
}

.btn-cancel:hover { color: var(--text-primary); }

.override-error {
  font-size: 0.75rem;
  color: var(--red);
  margin-left: 0.25rem;
}

/* =========================================
   Unclassified cards
   ========================================= */
.card-unclassified {
  opacity: 0.72;
  transition: opacity 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.card-unclassified:hover { opacity: 1; }

.btn-classify {
  padding: 0.25rem 0.75rem;
  background: var(--brand);
  color: #0b0f17;
  border: none;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn-classify:disabled { opacity: 0.5; cursor: not-allowed; }

.classify-error {
  font-size: 0.72rem;
  color: var(--red);
  margin-top: 0.3rem;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 700px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: none; }
  .stat:nth-child(3) { border-top: 1px solid var(--border); }
  .stat:nth-child(4) { border-top: 1px solid var(--border); border-right: none; }

  .main-content { padding: 1rem 0.75rem 3rem; }

  .card-top { flex-wrap: wrap; }

  .override-form { grid-template-columns: 1fr; }

  .app-header { padding: 0 1rem; }
  .app-header .header-title { display: none; }
}
