/* ============================================================
   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); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.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; }
.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;
}
.ws-action-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 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); }

/* ---------- 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;
}
