/* ============================================================
   REDENES Portal — Global Stylesheet
   Theme: Dark Navy  |  Font: Inter
   ============================================================ */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --bg:            #0D1B2A;
  --card:          #142236;
  --card-hover:    #1A2D45;
  --primary:       #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: rgba(37, 99, 235, .12);
  --text:          #E2E8F0;
  --text-secondary:#94A3B8;
  --border:        #1E3A5F;
  --error:         #DC2626;
  --error-bg:      rgba(220, 38, 38, .1);
  --success:       #059669;
  --success-bg:    rgba(5, 150, 105, .1);
  --warning:       #D97706;
  --warning-bg:    rgba(217, 119, 6, .1);
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,.35);
  --transition:    .2s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ---------- Typography ---------- */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }

/* ---------- Logo ---------- */
.logo {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  user-select: none;
}
.logo-sm { font-size: 1.25rem; }

/* ---------- Auth Layout (centered card) ---------- */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  padding: 2.5rem 2rem;
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 2rem;
  display: block;
}

.auth-card h2 {
  text-align: center;
  margin-bottom: .5rem;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: .9rem;
  margin-bottom: 1.5rem;
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 1.125rem;
}

.form-group label {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: .375rem;
  letter-spacing: .02em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .625rem .875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-secondary);
  opacity: .6;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input.invalid,
.form-group select.invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-bg);
}

.form-group .field-error {
  font-size: .75rem;
  color: var(--error);
  margin-top: .25rem;
  min-height: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Phone input with prefix */
.phone-group {
  display: flex;
  gap: .5rem;
}
.phone-group .prefix {
  flex: 0 0 60px;
  text-align: center;
}

/* Checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}
.checkbox-row label {
  font-size: .875rem;
  color: var(--text);
  cursor: pointer;
  margin: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  outline: none;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }

/* Disabled buttons read as unavailable at a glance — a faded version of
   their own color rather than a normal-looking button that just refuses
   the click. No hover, no press animation, not-allowed cursor. */
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
}
.btn:disabled:active { transform: none; }

/* The primary button gets an explicit faded blue instead of plain
   transparency, so it stays clearly blue (recognisably "the submit
   button") while obviously being out of action. */
.btn-primary:disabled {
  opacity: 1;
  background: rgba(37, 99, 235, .30);
  color: rgba(226, 232, 240, .45);
}
.btn-secondary:disabled {
  opacity: 1;
  color: rgba(226, 232, 240, .35);
  border-color: rgba(30, 58, 95, .65);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 2px 12px rgba(37,99,235,.35);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--card-hover);
  border-color: var(--text-secondary);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-block { width: 100%; }

.btn-sm { padding: .375rem 1rem; font-size: .8125rem; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; }

/* ---------- Links inside auth card ---------- */
.auth-links {
  text-align: center;
  margin-top: 1.25rem;
  font-size: .875rem;
  color: var(--text-secondary);
}
.auth-links a { margin: 0 .25rem; }

.forgot-link {
  display: block;
  text-align: right;
  font-size: .8125rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}
.forgot-link:hover { color: var(--primary); }

/* ---------- Alerts / Inline Messages ---------- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show { display: block; }
.alert-error   { background: var(--error-bg);   color: #FCA5A5; border: 1px solid rgba(220,38,38,.25); }
.alert-success { background: var(--success-bg); color: #6EE7B7; border: 1px solid rgba(5,150,105,.25); }
.alert-warning { background: var(--warning-bg); color: #FCD34D; border: 1px solid rgba(217,119,6,.25); }

/* ---------- Toast Notification ---------- */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.toast {
  padding: .875rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  min-width: 280px;
  max-width: 420px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  animation: toastIn .3s ease;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.toast-error   { background: #7F1D1D; color: #FCA5A5; }
.toast-success { background: #064E3B; color: #6EE7B7; }
.toast-info    { background: #1E3A5F; color: #93C5FD; }
.toast.removing { animation: toastOut .3s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ---------- Spinner ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  display: none;
}
.loading-overlay.show { display: flex; }

/* ---------- Navbar ---------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 2rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .logo { font-size: 1.25rem; }
.nav-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.nav-user {
  color: var(--text-secondary);
  font-size: .875rem;
}
.nav-user strong { color: var(--text); font-weight: 600; }

/* ---------- Main Content ---------- */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ---------- Dashboard Cards ---------- */
.org-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.org-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.org-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.org-card h3 { margin-bottom: .25rem; }
.org-card .org-abbr {
  color: var(--text-secondary);
  font-size: .8125rem;
  margin-bottom: .75rem;
}
.org-card .org-type {
  display: inline-block;
  padding: .2rem .6rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .75rem;
  font-weight: 600;
  border-radius: 4px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: .4;
}
.empty-state h2 { margin-bottom: .5rem; }
.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Multi-Step Form ---------- */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.step-dot.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.step-dot.completed {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}
.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  max-width: 60px;
  transition: background var(--transition);
}
.step-line.completed { background: var(--success); }

.step-panel { display: none; }
.step-panel.active { display: block; }

.step-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.step-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ---------- Entitlement Cards ---------- */
.entitlement-list {
  display: grid;
  gap: .75rem;
  margin-top: .75rem;
}
.entitlement-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.entitlement-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}
.entitlement-item input[type="checkbox"] {
  margin-top: .125rem;
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.entitlement-info { flex: 1; }
.entitlement-info .name { font-weight: 600; font-size: .9375rem; }
.entitlement-info .desc { color: var(--text-secondary); font-size: .8125rem; margin-top: .125rem; }
.entitlement-price {
  font-weight: 700;
  color: var(--primary);
  font-size: .9375rem;
  white-space: nowrap;
}

/* ---------- Address Autocomplete (Mapbox) ---------- */
.address-autocomplete { position: relative; }
.address-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--card-bg, var(--bg));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 2px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  display: none;
}
.address-suggestions.open { display: block; }
.address-suggestion {
  padding: .625rem .875rem;
  font-size: .875rem;
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.address-suggestion:last-child { border-bottom: none; }
.address-suggestion:hover,
.address-suggestion.active { background: var(--primary-light); }

/* ---------- OTP Input ---------- */
.otp-group {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin: 1.5rem 0;
}
.otp-group input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.otp-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.otp-timer {
  text-align: center;
  color: var(--text-secondary);
  font-size: .875rem;
  margin-bottom: 1rem;
}
.otp-timer .timer-value {
  color: var(--warning);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Success Screen ---------- */
.success-screen {
  text-align: center;
  padding: 2rem 1rem;
}
.success-screen .checkmark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}
.success-screen .checkmark svg { width: 32px; height: 32px; }
.success-screen h2 { margin-bottom: .5rem; }
.success-screen p { color: var(--text-secondary); }

/* ---------- Password Strength ---------- */
.pw-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: .375rem;
  overflow: hidden;
}
.pw-strength .bar {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width .3s, background .3s;
}
.pw-strength .bar.weak   { width: 33%; background: var(--error); }
.pw-strength .bar.medium { width: 66%; background: var(--warning); }
.pw-strength .bar.strong { width: 100%; background: var(--success); }

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ---------- Wide card for multi-step ---------- */
.auth-card.wide {
  max-width: 560px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .auth-card { padding: 2rem 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
  .navbar { padding: .75rem 1rem; }
  .main-content { padding: 1.25rem 1rem; }
  .step-indicator { gap: 0; }
  .step-line { max-width: 36px; }
  .otp-group input { width: 40px; height: 48px; font-size: 1.25rem; }
  h1 { font-size: 1.375rem; }
}

@media (max-width: 400px) {
  .auth-card { padding: 1.5rem 1rem; }
  .logo { font-size: 1.375rem; }
  .step-dot { width: 28px; height: 28px; font-size: .6875rem; }
}

/* ============================================================
   Worksheet (Server UI) pages — form.html / worksheet.html
   ============================================================ */

/* ---------- Navbar logo + env badge ---------- */
.navbar-logo { height: 30px; width: auto; }
.env-badge {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning);
  border-radius: 999px;
  padding: .125rem .625rem;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------- Page scaffold ---------- */
.ws-page { max-width: 860px; }
.ws-page-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ws-loading {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: 4rem 0; color: var(--text-secondary);
}
.ws-toolbar {
  display: flex; align-items: center; gap: .75rem;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.ws-toolbar-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.ws-search { width: 180px; }
.org-select { width: auto; max-width: 220px; padding: .375rem .625rem; }
.section-heading { margin: 1.5rem 0 .75rem; color: var(--text-secondary); font-size: 1rem; }

/* ---------- Cards ---------- */
.ws-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.ws-card-title { font-weight: 600; margin-bottom: .75rem; }
.ws-card-body { display: flex; flex-direction: column; gap: .25rem; }
.ws-optional { color: var(--text-secondary); font-weight: 400; font-size: .8125rem; }
.ws-clickable { cursor: pointer; transition: background var(--transition), transform var(--transition); }
.ws-clickable:hover { background: var(--card-hover); transform: translateY(-1px); }

/* ---------- Sections ---------- */
.ws-section summary { list-style: none; }
.ws-section summary::-webkit-details-marker { display: none; }
.ws-section-header {
  font-weight: 600; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: .5rem;
}
.ws-section-header::before { content: '▸'; color: var(--text-secondary); transition: transform var(--transition); }
.ws-section[open] > .ws-section-header::before { transform: rotate(90deg); }
.ws-section-body { padding-top: .75rem; display: flex; flex-direction: column; gap: .875rem; }

/* ---------- Fields ---------- */
.ws-field { display: flex; flex-direction: column; gap: .25rem; }
.ws-label { font-size: .8125rem; font-weight: 500; color: var(--text-secondary); }
.ws-mini-label { font-size: .6875rem; font-weight: 500; color: var(--text-secondary); display: block; margin-bottom: .125rem; }
.ws-input {
  width: 100%;
  padding: .5rem .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .9375rem;
  transition: border-color var(--transition);
}
.ws-input:focus { outline: none; border-color: var(--primary); }
.ws-input:disabled { opacity: .6; cursor: not-allowed; }
.ws-input.invalid { border-color: var(--error); }
textarea.ws-input { resize: vertical; min-height: 90px; }
/* Paragraph and note fields grow to fit their text instead of scrolling
   inside a fixed box. The JS sets an explicit height from scrollHeight,
   so the internal scrollbar has to be off — otherwise the box would
   never appear to fit its own content. min-height above keeps the
   multi-line affordance for a short answer; resize stays available so a
   user can still shrink one by hand. */
textarea.ws-autogrow { overflow-y: hidden; }
.ws-value { font-size: .9375rem; }
.ws-pre { white-space: pre-wrap; }
.ws-note { color: var(--text-secondary); font-size: .8125rem; padding: .25rem 0; }
.ws-divider { border: none; border-top: 2px solid var(--border); margin: .25rem 0; }

.ws-check-field { flex-direction: row; }
.ws-check-wrap { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .9375rem; }
.ws-check-wrap input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary); }
.ws-multiselect { display: flex; flex-direction: column; gap: .375rem; }

/* App parity: centered pill, 45px tall, 8px corners, 14dp-medium text
   (Android item_incident_list_button1 / iOS button cell). */
.ws-action-btn {
  padding: .5rem 1.5rem;
  min-height: 45px;
  border: none; border-radius: 8px;
  font-family: inherit; font-size: .9375rem; font-weight: 600;
  cursor: pointer;
  background: var(--primary); color: #fff;
}
/* A designer-colored action button carries an INLINE background, which
   beats any stylesheet color — so fade and desaturate it instead; that
   reads as disabled whatever color the button was given. */
.ws-action-btn:disabled {
  opacity: .45;
  filter: grayscale(.5);
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- Location / coordinates ---------- */
.ws-location-grid, .ws-coord-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem;
}
.ws-loc-wide { grid-column: 1 / -1; }
.ws-coord-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .75rem; margin-bottom: .5rem; }
.ws-coord-group summary { cursor: pointer; font-size: .8125rem; font-weight: 600; color: var(--text-secondary); }
.ws-coord-group[open] summary { margin-bottom: .5rem; }

/* ---------- Index / incident cards ---------- */
.ws-index-card { padding-left: 1rem; }
.ws-card-grid { display: flex; gap: .75rem; align-items: flex-start; }
.ws-card-grid .ws-card-body { flex: 1; min-width: 0; }
.ws-card-side {
  display: flex; flex-direction: column; align-items: center; gap: .375rem;
  flex-shrink: 0; width: 64px;
}
.ws-card-letter {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1rem;
}
.ws-card-iconimg { width: 32px; height: 32px; object-fit: contain; }
.ws-compact-row { font-size: .875rem; font-weight: 600; }
.ws-compact-label { color: var(--text-secondary); font-weight: 600; }
.ws-compact-value { color: var(--text); }

.ws-incident-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.ws-incident-name { font-weight: 700; }
.ws-incident-type { color: var(--text-secondary); font-size: .8125rem; }
.ws-incident-badges { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.ws-badge {
  border-radius: 999px; padding: .125rem .625rem;
  font-size: .75rem; font-weight: 700; letter-spacing: .5px;
}
.ws-badge-closed { background: var(--error-bg); color: #FCA5A5; border: 1px solid var(--error); }
.ws-badge-timer { background: var(--primary-light); color: #93C5FD; font-variant-numeric: tabular-nums; }
.ws-badge-timer:empty { display: none; }

/* ---------- Uploads / approvals / signature / timers ---------- */
.ws-upload-list { display: flex; flex-direction: column; gap: .375rem; }
.ws-upload-row, .ws-approver-row { font-size: .875rem; }
.ws-signed { color: #6EE7B7; font-weight: 600; }
.ws-unsigned { color: var(--text-secondary); font-size: .875rem; }
.ws-timer-row { display: flex; align-items: center; gap: .75rem; padding: .375rem 0; }
.ws-timer-label { flex: 1; }
.ws-timer-display { font-variant-numeric: tabular-nums; font-weight: 600; }
.ws-freeform-add { display: flex; gap: .5rem; margin-top: .75rem; align-items: center; }
.ws-freeform-add select, .ws-freeform-add input { width: auto; flex: 1; }

/* ---------- Charts ---------- */
.ws-bar-chart { display: flex; flex-direction: column; gap: .5rem; }
.ws-bar-row { display: flex; align-items: center; gap: .625rem; }
.ws-bar-label { width: 120px; flex-shrink: 0; font-size: .8125rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-bar-track { flex: 1; background: var(--bg); border-radius: 4px; height: 18px; overflow: hidden; }
.ws-bar-fill { height: 100%; border-radius: 4px; }
.ws-bar-value { width: 48px; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.ws-pie-wrap { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.ws-pie { width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0; }
.ws-chart-legend { display: flex; flex-direction: column; gap: .375rem; margin-top: .5rem; }
.ws-legend-item { display: flex; align-items: center; gap: .5rem; font-size: .8125rem; }
.ws-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ws-line-chart { width: 100%; height: auto; background: var(--bg); border-radius: var(--radius-sm); }

/* ---------- Honeypot (anti-bot) — visually hidden, still in the DOM ---------- */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.success-icon {
  width: 64px; height: 64px; margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--success-bg); color: #6EE7B7;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}

/* ---------- Module tiles (dashboard) ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.module-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: .625rem;
  text-decoration: none; color: var(--text);
  transition: background var(--transition), transform var(--transition);
}
a.module-tile:hover { background: var(--card-hover); transform: translateY(-2px); text-decoration: none; color: var(--text); }
.module-tile-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: #334155; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; font-weight: 700;
}
.module-tile-name { font-size: .875rem; font-weight: 600; text-align: center; }
.module-tile-iconimg { width: 40px; height: 40px; object-fit: contain; }
.module-grid-muted .module-tile { opacity: .45; cursor: default; }

@media (max-width: 640px) {
  .ws-toolbar-actions { width: 100%; }
  .ws-search { flex: 1; width: auto; }
  .ws-bar-label { width: 84px; }
}

/* ---------- Auth card logo image ---------- */
.auth-logo {
  height: 44px; width: auto;
  margin: 0 auto 1rem;
}

/* ============================================================
   App-parity worksheet chrome (Server UI pages)
   ============================================================ */

/* ---------- App toolbar band (#000017, centered title, back + ⋮) ---------- */
.ws-appbar {
  display: flex; align-items: center;
  background: #000017;
  border-radius: var(--radius-sm);
  min-height: 52px;
  padding: 0 .375rem;
  margin-bottom: 1rem;
}
.ws-appbar-btn {
  background: none; border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.25rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.ws-appbar-btn:hover { background: rgba(255,255,255,.12); }
.ws-appbar-btn.hidden { display: none; }
.ws-appbar-title {
  flex: 1; text-align: center; color: #fff;
  font-size: 1.0625rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin: 0 .25rem;
}
.ws-appbar-spacer { width: 40px; flex-shrink: 0; }

/* Pull-to-refresh hint */
.ws-pull-hint {
  text-align: center; color: var(--text-secondary);
  font-size: .8125rem; font-weight: 600;
  padding: .375rem 0; margin-bottom: .5rem;
}

/* Search row under the app bar */
.ws-search-row { margin-bottom: 1rem; }
.ws-search-row .ws-input { width: 100%; }

/* incident_list tab bar: List / Map with #E93323 underline */
.ws-tabbar {
  display: flex; margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.ws-tab {
  flex: 1; text-align: center; padding: .625rem .5rem;
  background: none; border: none; color: var(--text-secondary);
  font-family: inherit; font-size: .9375rem; font-weight: 600;
  cursor: pointer; border-bottom: 3px solid transparent;
}
.ws-tab.active { color: var(--text); border-bottom-color: #E93323; }

/* ---------- Section header band (app parity) ---------- */
.ws-section-card { padding: 0; overflow: hidden; }
.ws-section-card > .ws-section-body { padding: .75rem 1.25rem 1rem; }
.ws-sec-head {
  display: flex; align-items: center; gap: .5rem;
  background: var(--card-hover);
  padding: .625rem 1rem;
  user-select: none;
}
.ws-clickable-head { cursor: pointer; }
.ws-sec-title {
  flex: 1; color: #4E73DF; font-weight: 700; font-size: .9875rem;
  overflow: hidden; text-overflow: ellipsis;
}
.ws-sec-chevron {
  color: var(--text-secondary); font-size: 1rem;
  transition: transform .18s ease; display: inline-block;
}
.ws-sec-chevron.ws-collapsed { transform: rotate(-90deg); }
.ws-kebab-btn {
  background: none; border: none; color: var(--text-secondary);
  font-size: 1.125rem; font-weight: 700; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.ws-kebab-btn:hover { background: rgba(148,163,184,.15); color: var(--text); }
.ws-section-body { display: flex; flex-direction: column; gap: .875rem; }

/* Sub-cards (user_info/vehicle_info entries, approvals, details rows) */
.ws-subcard {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.ws-subcard-head {
  display: flex; align-items: center; gap: .5rem;
  background: var(--card-hover);
  padding: .5rem .75rem;
  font-weight: 600; font-size: .875rem;
}
.ws-subcard-head > span:first-child { flex: 1; }
.ws-subcard-body {
  padding: .625rem .75rem;
  display: flex; flex-direction: column; gap: .75rem;
}
.ws-subcard > .ws-compact-row, .ws-subcard > .ws-field { padding: .375rem .75rem; }
.ws-subcard > .ws-note { padding: .25rem .75rem; }

/* Required star */
.ws-required-star { color: #FF0000; font-weight: 700; }

/* Search highlight (form pages) — #4CAF50 like the apps */
.ws-field.ws-search-hit .ws-input,
.ws-field.ws-search-hit .ws-value { border: 1px solid #4CAF50 !important; border-radius: var(--radius-sm); }
.ws-sec-head.ws-search-hit-head { background: rgba(76,175,80,.22); }

/* ---------- Popup (kebab) menu — app style ---------- */
.ws-popup-menu {
  position: absolute; z-index: 10000;
  min-width: 180px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  display: flex; flex-direction: column;
}
.ws-popup-item {
  background: none; border: none; text-align: left;
  color: var(--text); font-family: inherit; font-size: .9375rem;
  padding: .75rem; border-radius: 6px; cursor: pointer;
}
.ws-popup-item:hover { background: var(--card-hover); }
.ws-popup-item-disabled { opacity: .5; }
.ws-popup-sep { border: none; border-top: 1px solid var(--border); margin: .25rem 0; }

/* ---------- Modal (name prompts, data popups, collapse editor) ---------- */
.ws-modal-overlay {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.ws-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 420px;
  max-height: 80vh; overflow-y: auto;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.ws-modal-title { font-weight: 700; font-size: 1.0625rem; margin-bottom: .75rem; }
.ws-modal-body { display: flex; flex-direction: column; gap: .5rem; font-size: .9375rem; }
.ws-modal-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* Collapse editor rows */
.ws-collapse-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .375rem 0;
}

/* ---------- Buttons group / button rows — centered like the apps ---------- */
.ws-button-field { flex-direction: row; flex-wrap: wrap; gap: .5rem; justify-content: center; }

/* ---------- Stopwatch max badge / overrun ---------- */
.ws-badge-max { background: #FF9500; color: #fff; }
.ws-timer-display.ws-timer-over { color: var(--error); }

/* Top-level element with no section wrapper — its own card, matching
   the apps' stacked one-card-per-row list. */
.ws-loose-element { padding: .875rem 1.25rem; }

/* ---------- Phone fields: country-code selector + input ---------- */
.ws-phone-row { display: flex; gap: .5rem; }
.ws-phone-cc { flex: 0 0 auto; width: auto; max-width: 118px; padding-right: 1.5rem; }
.ws-phone-input { flex: 1; min-width: 0; }

/* ---------- File preview links / signature canvas ---------- */
.ws-preview-link { color: #4E73DF; font-weight: 600; font-size: .875rem; cursor: pointer; }
.ws-sign-canvas {
  width: 100%; max-width: 360px; height: 160px;
  background: #fff; border: 1px dashed var(--border); border-radius: var(--radius-sm);
  touch-action: none; cursor: crosshair; margin-top: .5rem;
}

/* ---------- Chart extras ---------- */
.ws-bar-track { position: relative; }
.ws-bar-limit { position: absolute; top: -2px; bottom: -2px; width: 2px; }
.ws-chart-clickable { cursor: pointer; }
.ws-pie { position: relative; display: flex; align-items: center; justify-content: center; }
.ws-pie-hole {
  width: 52%; height: 52%; border-radius: 50%;
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 600; color: var(--text-secondary);
  text-align: center; overflow: hidden; padding: .25rem;
}

/* ============================================================
   Command Board (worksheet_type = "command")
   Functional colors match the apps: gray #8E8C8C cards, red
   #E83224 selection/alerts, blue #4E73DF accents, light-green
   #ddf5cc drop highlight, GAR/status bands.
   ============================================================ */

.cb-root { display: flex; flex-direction: column; gap: .75rem; }

/* ── Header strip ── */
.cb-header {
  display: flex; flex-wrap: wrap; gap: .5rem;
  border: 1px solid #E83224; border-radius: var(--radius-sm);
  padding: .5rem; background: var(--card);
}
.cb-pane { display: flex; flex-direction: column; gap: .3rem; padding: .25rem .5rem; }
.cb-pane + .cb-pane { border-left: 1px solid #E8322455; }
.cb-pane-insight { min-width: 150px; }
.cb-pane-btns { flex-direction: row; flex-wrap: wrap; align-content: flex-start;
  gap: .35rem; max-width: 260px; }
.cb-pane-incident { flex: 1; min-width: 220px; }
.cb-pane-incident.cb-clickable { cursor: pointer; }
.cb-fact { font-size: .8125rem; line-height: 1.35; color: var(--text-secondary); }
.cb-fact-val { color: #4E73DF; font-weight: 600; }
.cb-fact-val.cb-red { color: #E83224; }
.cb-red { color: #E83224 !important; }

.cb-pill {
  border: 1px solid #4E73DF; color: #4E73DF; background: transparent;
  border-radius: 6px; padding: .3rem .7rem; font-size: .8125rem;
  font-weight: 700; cursor: pointer; font-family: inherit;
}
.cb-pill:hover { background: rgba(78, 115, 223, .12); }
.cb-pill-active { border-color: #E83224; color: #E83224; }
.cb-pill.cb-blink { background: #E83224; color: #fff; border-color: #E83224; }

/* ── Board ── */
.cb-board {
  border: 1px solid #E83224; border-radius: var(--radius-sm);
  padding: .5rem; background: var(--card);
  display: flex; flex-direction: column; gap: .5rem;
}
.cb-toprow {
  display: flex; gap: .6rem; overflow-x: auto; padding: .25rem;
  border-bottom: 1px solid #E8322455;
}
.cb-main { display: flex; gap: .5rem; min-height: 420px; }

/* Slots (top row + left rail) */
.cb-slot { display: flex; flex-direction: column; gap: .2rem; min-width: 120px;
  position: relative; flex: 0 0 auto; }
.cb-slot-box {
  min-height: 34px; border: 1px solid #8E8C8C; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 600; color: #fff; text-align: center;
  padding: .15rem .3rem; position: relative;
}
.cb-slot-full { background: #8E8C8C; cursor: grab; }
.cb-slot-label { font-size: .75rem; color: var(--text-secondary); text-align: center; }
.cb-slot.cb-rail-row { min-width: 0; }

/* Left rail */
.cb-rail { width: 190px; flex: 0 0 190px; display: flex; flex-direction: column;
  gap: .4rem; border-right: 1px solid #E8322455; padding-right: .5rem; }
.cb-rail-rows { display: flex; flex-direction: column; gap: .45rem;
  max-height: 300px; overflow-y: auto; }
.cb-rail-row { border-radius: 4px; padding: .2rem; cursor: pointer; }
.cb-rail-sel { background: #E83224; }
.cb-rail-sel .cb-slot-label { color: #fff; }
.cb-pool-label { font-size: .8125rem; font-weight: 700; color: var(--text-secondary);
  border-top: 1px solid var(--border); padding-top: .4rem; }
.cb-unassigned { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: .4rem; }
.cb-pool-section { border: 1px solid var(--border); border-radius: 4px; padding: .3rem; }
.cb-pool-section-name { font-size: .7rem; color: var(--text-secondary);
  text-align: center; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.cb-pool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem; }
.cb-pool-list { display: flex; flex-direction: column; gap: .35rem; }
.cb-chip {
  background: #8E8C8C; color: #fff; border-radius: 4px; font-size: .65rem;
  font-weight: 700; text-align: center; padding: .35rem .15rem; cursor: grab;
  overflow: hidden; position: relative;
}

/* Grid columns */
.cb-columns { display: flex; gap: .6rem; overflow-x: auto; flex: 1; padding-bottom: .3rem; }
.cb-col {
  flex: 0 0 190px; border: 1px solid #8E8C8C; border-radius: 4px;
  display: flex; flex-direction: column; max-height: 560px; position: relative;
  transition: background .15s ease;
}
.cb-col-head {
  font-size: .8125rem; font-weight: 600; color: var(--text-secondary);
  text-align: center; padding: .35rem .3rem; border-bottom: 1px solid #8E8C8C;
}
.cb-col-body { flex: 1; overflow-y: auto; padding: .35rem; display: flex;
  flex-direction: column; gap: .35rem; }

/* Unit / task cards */
.cb-card {
  background: #8E8C8C; border-radius: 4px; color: #fff; padding: .35rem .45rem;
  cursor: grab; position: relative; min-height: 44px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.cb-card-name { font-size: .78rem; font-weight: 700; text-align: center; }
.cb-card-foot { display: flex; justify-content: space-between;
  font-size: .65rem; font-weight: 700; }
.cb-card-gar { position: absolute; top: .2rem; right: .35rem;
  font-size: .7rem; font-weight: 800; }
.cb-split::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: #4E73DF; border-radius: 4px 4px 0 0;
}
.cb-primary { outline: 2px solid #E8C95A; }
.cb-primary-star { position: absolute; top: .15rem; left: .3rem;
  color: #E8C95A; font-size: .7rem; }

/* Channel chips on container headers */
.cb-channels { display: flex; flex-wrap: wrap; gap: .2rem; padding: .2rem .3rem; }
.cb-channel {
  font-size: .6rem; font-weight: 700; color: #4E73DF;
  border: 1px solid #4E73DF; border-radius: 8px; padding: 0 .35rem;
}

/* Drag and drop */
.cb-dragging { opacity: .4; }
.cb-drop-hot, .cb-col.cb-drop-hot, .cb-slot-box.cb-drop-hot {
  background: #ddf5cc !important; color: #1a2b12 !important;
}
.cb-drop-hot .cb-card-name, .cb-drop-hot .cb-col-head { color: #1a2b12; }

/* Search */
.cb-search-hit { outline: 2px solid #E8C95A; }
.cb-search-dim { opacity: .35; }

/* Edit mode */
.cb-add-tile {
  border: 1px dashed #8E8C8C; background: transparent; color: var(--text-secondary);
  border-radius: 4px; font-size: 1.2rem; cursor: pointer; font-family: inherit;
}
.cb-slot-add { min-width: 90px; min-height: 34px; }
.cb-col-add { flex: 0 0 90px; }
.cb-task-add { min-height: 40px; }
.cb-pencil {
  position: absolute; top: .2rem; right: .2rem; z-index: 2;
  background: #4E73DF; color: #fff; border: none; border-radius: 4px;
  width: 22px; height: 22px; cursor: pointer; font-size: .75rem;
}

/* Dialogs */
.cb-modal-wide { width: min(720px, 94vw); max-height: 86vh; overflow-y: auto; }
.cb-modal-body { max-height: 62vh; overflow-y: auto; }
.cb-notes { min-height: 110px; resize: vertical; }
.cb-field-label { font-size: .8125rem; color: var(--text-secondary); font-weight: 600; }
.cb-inline { display: flex; gap: .5rem; align-items: center; }
.cb-note { font-size: .8125rem; color: var(--text-secondary); }
.cb-list { display: flex; flex-direction: column; gap: .3rem; }
.cb-scroll-list { max-height: 180px; overflow-y: auto; }
.cb-list-head { font-weight: 700; font-size: .875rem; margin-top: .3rem; }
.cb-list-head.cb-clickable, .cb-list-row.cb-clickable { cursor: pointer; }
.cb-list-head.cb-clickable:hover, .cb-list-row.cb-clickable:hover { color: var(--primary); }
.cb-list-row { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.cb-list-row.cb-indent { padding-left: 1.25rem; }
.cb-choice { cursor: pointer; }
.cb-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: #4E73DF;
  color: #fff; font-size: .65rem; font-weight: 700; flex: 0 0 26px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* PAR */
.cb-par-head { display: flex; justify-content: flex-end; }
.cb-par-unit { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  border-top: 1px solid var(--border); padding-top: .45rem; }
.cb-par-name { font-weight: 700; font-size: .9rem; flex: 1; min-width: 140px; }
.cb-par-meta { display: flex; gap: .6rem; font-size: .75rem; color: var(--text-secondary); }
.cb-par-timer { font-variant-numeric: tabular-nums; }
.cb-par-btns { display: flex; gap: .4rem; }
.cb-par-person { display: flex; align-items: center; gap: .5rem; padding-left: 1.5rem; }
.cb-par-person-name { flex: 1; font-size: .85rem; }
.cb-par-btn {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 12px; font-size: .72rem; font-weight: 700; padding: .2rem .6rem;
  cursor: pointer; font-family: inherit;
}
.cb-par-ok.cb-on { background: #4C9100; border-color: #4C9100; color: #fff; }
.cb-par-bad.cb-on { background: #E83224; border-color: #E83224; color: #fff; }
.cb-par-bad.cb-open { background: #e6b800; border-color: #e6b800; color: #1a1a1a; }

/* Timers */
.cb-timer-row { display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 6px;
  padding: .5rem .6rem; }
.cb-timer-alert { background: #E83224; }
.cb-timer-alert .cb-timer-name, .cb-timer-alert .cb-timer-interval { color: #fff; }
.cb-timer-name { font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; }
.cb-timer-interval { font-size: .75rem; color: var(--text-secondary); }

/* GAR */
.cb-gar-total { border: 2px solid #8E8E93; border-radius: 8px; padding: .5rem .75rem;
  text-align: center; }
.cb-gar-total-score { font-size: 1.1rem; font-weight: 800; }
.cb-gar-total-sub { font-size: .8rem; color: var(--text-secondary); }
.cb-gar-row { border-top: 1px solid var(--border); padding-top: .5rem; }
.cb-gar-head { display: flex; justify-content: space-between; align-items: center; }
.cb-gar-title { font-weight: 700; font-size: .875rem; }
.cb-gar-badge { color: #fff; font-weight: 800; font-size: .75rem;
  border-radius: 10px; padding: .1rem .5rem; }
.cb-gar-desc { font-size: .75rem; color: var(--text-secondary); margin: .2rem 0 .35rem; }
.cb-gar-strip { display: flex; gap: .25rem; flex-wrap: wrap; }
.cb-gar-chip {
  width: 34px; height: 30px; border-radius: 5px; border: none; color: #fff;
  font-weight: 800; cursor: pointer; font-family: inherit;
}
.cb-gar-sel { outline: 3px solid #fff; }

/* Weather */
.cb-weather-strip { display: flex; gap: .5rem; overflow-x: auto; padding: .3rem 0; }
.cb-weather-card { flex: 0 0 120px; border: 1px solid var(--border); border-radius: 6px;
  padding: .4rem; text-align: center; }
.cb-weather-name { font-size: .7rem; color: var(--text-secondary); }
.cb-weather-temp { font-size: 1rem; font-weight: 800; }
.cb-weather-short { font-size: .68rem; }
.cb-weather-detail { font-size: .8rem; }

/* IWI / IAP panel + popups */
.cb-listpanel { border: 1px solid #E83224; border-radius: var(--radius-sm);
  padding: .75rem; background: var(--card); }
.cb-listpanel-head { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .5rem; }
.cb-popup { position: fixed; z-index: 1200; }
.cb-popup-title { font-size: .75rem; font-weight: 700; color: var(--text-secondary);
  padding: .35rem .75rem .1rem; }

/* Incident history (V265) */
.cb-hist-bar { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  margin-bottom: .6rem; }
.cb-hist-chip { border: 1px solid var(--border); background: var(--card);
  color: var(--text-secondary); border-radius: 999px; padding: .25rem .8rem;
  font-size: .78rem; cursor: pointer; }
.cb-hist-chip.active { background: #E83224; border-color: #E83224; color: #fff; }
.cb-hist-actor { width: auto; min-width: 150px; margin-left: auto;
  padding: .3rem .5rem; font-size: .8rem; }
.cb-hist-list { display: flex; flex-direction: column; }
.cb-hist-row { display: flex; gap: .6rem; align-items: baseline;
  padding: .42rem .15rem; border-bottom: 1px solid var(--border); font-size: .82rem; }
.cb-hist-row:last-of-type { border-bottom: none; }
.cb-hist-when { flex: 0 0 4.4rem; color: var(--text-secondary); font-size: .74rem;
  font-variant-numeric: tabular-nums; }
.cb-hist-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.cb-hist-who { flex: 0 0 auto; max-width: 10rem; color: var(--text-secondary);
  font-size: .74rem; text-align: right; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
/* Server-side cascades (actor_source: "system") read as machinery, not a person */
.cb-hist-sys .cb-hist-text { color: var(--text-secondary); font-style: italic; }
.cb-hist-empty { color: var(--text-secondary); font-size: .82rem;
  padding: .8rem .2rem; text-align: center; }
.cb-hist-more { margin: .6rem auto .2rem; display: block; border: 1px solid var(--border);
  background: var(--card); color: var(--text); border-radius: var(--radius-sm);
  padding: .35rem .9rem; font-size: .78rem; cursor: pointer; }
.cb-hist-more:hover { border-color: #E83224; }

@media (max-width: 760px) {
  .cb-main { flex-direction: column; }
  .cb-rail { width: 100%; flex: none; border-right: none;
    border-bottom: 1px solid #E8322455; padding-bottom: .5rem; }
  .cb-rail-rows { flex-direction: row; overflow-x: auto; max-height: none; }
  .cb-rail-row { min-width: 110px; }
}
