/* ==========================================================================
   LiftOps — Component library
   Reusable primitives only. Screen-specific layout lives in app.css.
   ========================================================================== */

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

/* The overlay roots (modal / sheet / lightbox) and the auth screen all declare
   a `display` value in their own class rules, which would otherwise beat the
   user-agent rule for the `hidden` attribute and leave them painted over the
   app. Toggling `hidden` must always win. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,h2,h3,h4,h5 { margin: 0; font-weight: var(--fw-bold); line-height: var(--lh-tight); color: var(--text); }
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
p  { margin: 0 0 var(--sp-3); }
a  { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0; padding-inline-start: 1.2em; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--divider); margin: var(--sp-4) 0; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Utility ---------- */
.u-muted   { color: var(--muted); }
.u-mono    { font-family: var(--font-mono); font-size: .92em; letter-spacing: .2px; }
.u-xs      { font-size: var(--fs-xs); }
.u-sm      { font-size: var(--fs-sm); }
.u-lg      { font-size: var(--fs-lg); }
.u-bold    { font-weight: var(--fw-bold); }
.u-semi    { font-weight: var(--fw-semi); }
.u-center  { text-align: center; }
.u-nowrap  { white-space: nowrap; }
.u-ellipsis{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-hide    { display: none !important; }
.u-grow    { flex: 1 1 auto; min-width: 0; }
.u-mt-0 { margin-top: 0; } .u-mt-2 { margin-top: var(--sp-2); } .u-mt-3 { margin-top: var(--sp-3); }
.u-mt-4 { margin-top: var(--sp-4); } .u-mt-5 { margin-top: var(--sp-5); } .u-mt-6 { margin-top: var(--sp-6); }
.u-mb-0 { margin-bottom: 0; } .u-mb-2 { margin-bottom: var(--sp-2); } .u-mb-3 { margin-bottom: var(--sp-3); }
.u-mb-4 { margin-bottom: var(--sp-4); }
.row  { display: flex; align-items: center; gap: var(--sp-3); }
.row--top { align-items: flex-start; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.col  { display: flex; flex-direction: column; gap: var(--sp-3); }
.col--tight { gap: var(--sp-2); }
.spacer { flex: 1 1 auto; }

/* ---------- Icons ---------- */
.ico { width: 20px; height: 20px; flex: 0 0 auto; stroke-width: 1.9; vertical-align: -4px; }
.ico--sm { width: 16px; height: 16px; }
.ico--xs { width: 14px; height: 14px; }
.ico--lg { width: 24px; height: 24px; }
.ico--xl { width: 32px; height: 32px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-4);
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-bd); border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: var(--fw-semi); font-family: inherit;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: filter var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; filter: none; }

.btn--primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-bd: var(--primary); box-shadow: var(--sh-sm); }
.btn--primary:hover { --btn-bg: var(--primary-hover); }
.btn--danger  { --btn-bg: var(--danger);  --btn-fg: #fff; --btn-bd: var(--danger); }
.btn--success { --btn-bg: var(--success); --btn-fg: #fff; --btn-bd: var(--success); }
.btn--warning { --btn-bg: var(--warning); --btn-fg: #fff; --btn-bd: var(--warning); }
.btn--dark    { --btn-bg: var(--brand-900); --btn-fg: #fff; --btn-bd: var(--brand-900); }
.btn--ghost   { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn--ghost:hover { --btn-bg: var(--surface-inset); }
.btn--soft    { --btn-bg: var(--primary-soft); --btn-fg: var(--brand-600); --btn-bd: var(--primary-border); }
.btn--soft-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger-text); --btn-bd: #F8C9CF; }
.btn--outline { --btn-bg: var(--surface); --btn-fg: var(--primary); --btn-bd: var(--primary); }

.btn--sm  { min-height: 34px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--xs  { min-height: 28px; padding: 0 var(--sp-2); font-size: var(--fs-xs); border-radius: var(--r-xs); gap: 4px; }
.btn--lg  { min-height: 52px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn--block { display: flex; width: 100%; }
.btn--icon { padding: 0; width: var(--tap); min-width: var(--tap); }
.btn--icon.btn--sm { width: 34px; min-width: 34px; }

/* Field-grade action button: technicians use these with gloves, in a hurry. */
.btn--field {
  min-height: 58px; font-size: var(--fs-lg); border-radius: var(--r-lg);
  box-shadow: var(--sh-md); letter-spacing: .2px;
}

.btn-group { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.btn-group--stretch > .btn { flex: 1 1 0; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
.card--flat { box-shadow: none; }
.card--pad { padding: var(--sp-4); }
.card--hover { transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card--hover:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.card--clickable { cursor: pointer; }
.card__head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); border-bottom: 1px solid var(--divider);
}
.card__title { font-size: var(--fs-md); font-weight: var(--fw-bold); margin: 0; }
.card__sub { font-size: var(--fs-xs); color: var(--muted); font-weight: var(--fw-regular); }
.card__body { padding: var(--sp-4); }
.card__body--tight { padding: var(--sp-3); }
.card__foot { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--divider); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg); }

.section-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text);
  margin: var(--sp-5) 0 var(--sp-3);
}
.section-title .ico { color: var(--muted); }
.section-title__action { margin-inline-start: auto; font-size: var(--fs-sm); font-weight: var(--fw-medium); }

/* ==========================================================================
   Badges / chips / pills
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-semi); line-height: 1.6;
  background: var(--neutral-soft); color: var(--neutral-text);
  border: 1px solid transparent; white-space: nowrap;
}
.badge .ico { width: 13px; height: 13px; }
.badge--dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge--success { background: var(--success-soft); color: var(--success-text); }
.badge--warning { background: var(--warning-soft); color: var(--warning-text); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-text); }
.badge--info    { background: var(--info-soft);    color: var(--info-text); }
.badge--brand   { background: var(--primary-soft); color: var(--brand-600); }
.badge--purple  { background: #F3EAFE; color: #6B21A8; }
.badge--neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.badge--solid-danger { background: var(--danger); color: #fff; }
.badge--outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.badge--lg { font-size: var(--fs-sm); padding: 5px 12px; }

/* Emergency badge deliberately pulses — it must break scanning. */
.badge--emergency { background: var(--danger); color: #fff; animation: pulseEmg 1.8s var(--ease) infinite; }
@keyframes pulseEmg {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,43,60,.45); }
  60%     { box-shadow: 0 0 0 7px rgba(220,43,60,0); }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 var(--sp-3);
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--brand-300); }
.chip--active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip__count { background: rgba(0,0,0,.08); border-radius: var(--r-pill); padding: 0 6px; font-size: var(--fs-2xs); }
.chip--active .chip__count { background: rgba(255,255,255,.22); }
.chip-bar {
  display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chip-bar::-webkit-scrollbar { display: none; }

/* ==========================================================================
   Status pills (colour + icon + text — never colour alone)
   ========================================================================== */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-semi); white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-text);
}
.status .ico { width: 13px; height: 13px; }
.status--lg { font-size: var(--fs-sm); padding: 5px 13px; }
.status--new       { background: var(--primary-soft); color: var(--brand-600); }
.status--assigned  { background: #EDEAFE; color: #4C2FA8; }
.status--accepted  { background: #E4F4FA; color: var(--info-text); }
.status--travel    { background: var(--info-soft); color: var(--info-text); }
.status--arrived   { background: #E3F2F8; color: #0A6386; }
.status--progress  { background: var(--warning-soft); color: var(--warning-text); }
.status--pending   { background: #FBEFDF; color: #8A4B05; }
.status--temp      { background: #FFF4D6; color: #8A6206; }
.status--done      { background: var(--success-soft); color: var(--success-text); }
.status--waiting   { background: #E8F0FE; color: #1B44C4; }
.status--closed    { background: var(--neutral-soft); color: var(--neutral-text); }
.status--reopened  { background: var(--danger-soft); color: var(--danger-text); }
.status--escalated { background: #FDE7E9; color: #9E1B29; }
.status--cancelled { background: #EEF0F4; color: #64748B; }

/* Elevator operational states */
.status--running { background: var(--success-soft); color: var(--success-text); }
.status--stopped { background: var(--danger-soft);  color: var(--danger-text); }
.status--maint   { background: var(--info-soft);    color: var(--info-text); }
.status--out     { background: #F3EAFE; color: #6B21A8; }
.status--part    { background: var(--warning-soft); color: var(--warning-text); }

/* Priority */
.prio { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: var(--fw-bold); }
.prio--normal    { color: var(--neutral-text); }
.prio--urgent    { color: var(--warning-text); }
.prio--emergency { color: var(--danger-text); }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field__label {
  font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
}
.field__req { color: var(--danger); font-weight: var(--fw-bold); }
.field__hint { font-size: var(--fs-xs); color: var(--muted); }
.field__error { font-size: var(--fs-xs); color: var(--danger-text); display: flex; align-items: center; gap: 4px; }

.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 10px var(--sp-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-size: var(--fs-md); font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--sh-focus);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236B7A94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 6l4 4 4-4'/></svg>");
  background-repeat: no-repeat; background-size: 16px;
  background-position: left var(--sp-3) center; padding-inline-start: var(--sp-3); padding-inline-end: var(--sp-7);
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ico { position: absolute; inset-inline-start: var(--sp-3); color: var(--muted); pointer-events: none; }
.input-group .input { padding-inline-start: var(--sp-8); }
.input-group__btn { position: absolute; inset-inline-end: 6px; }

.check {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  min-height: var(--tap); cursor: pointer; font-size: var(--fs-md);
}
.check input[type="checkbox"], .check input[type="radio"] {
  width: 19px; height: 19px; margin-top: 3px; accent-color: var(--primary); flex: 0 0 auto; cursor: pointer;
}

/* Large selectable option card (used heavily by the report wizard) */
.optcard {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: 56px; padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-md);
  text-align: start; cursor: pointer; font-size: var(--fs-md);
  transition: all var(--dur-fast) var(--ease);
}
.optcard:hover { border-color: var(--brand-300); background: var(--surface-2); }
.optcard--active { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--sh-focus); }
.optcard--danger.optcard--active { border-color: var(--danger); background: var(--danger-soft); box-shadow: 0 0 0 3px rgba(220,43,60,.2); }
.optcard__icon {
  width: 38px; height: 38px; border-radius: var(--r-sm); flex: 0 0 auto;
  display: grid; place-items: center; background: var(--surface-inset); color: var(--text-2);
}
.optcard--active .optcard__icon { background: var(--primary); color: #fff; }
.optcard--danger.optcard--active .optcard__icon { background: var(--danger); }
.optcard__title { font-weight: var(--fw-semi); }
.optcard__sub { font-size: var(--fs-xs); color: var(--muted); }
.optcard__check { margin-inline-start: auto; color: var(--primary); opacity: 0; }
.optcard--active .optcard__check { opacity: 1; }
.optcard-list { display: grid; gap: var(--sp-2); }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 3px; background: var(--surface-inset);
  border-radius: var(--r-md); gap: 3px; border: 1px solid var(--border);
}
.segmented__item {
  border: 0; background: transparent; border-radius: var(--r-sm);
  padding: 7px var(--sp-3); font-size: var(--fs-sm); font-weight: var(--fw-semi);
  color: var(--muted); cursor: pointer; min-height: 36px;
}
.segmented__item--active { background: var(--surface); color: var(--text); box-shadow: var(--sh-xs); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; inset: 0; background: var(--border-strong);
  border-radius: var(--r-pill); transition: background var(--dur) var(--ease); cursor: pointer;
}
.switch__track::before {
  content: ""; position: absolute; height: 20px; width: 20px; inset-block-start: 3px; inset-inline-start: 3px;
  background: #fff; border-radius: 50%; transition: transform var(--dur) var(--ease); box-shadow: var(--sh-sm);
}
.switch input:checked + .switch__track { background: var(--success); }
.switch input:focus-visible + .switch__track { box-shadow: var(--sh-focus); }

/* ==========================================================================
   Steps / wizard
   ========================================================================== */
.steps { display: flex; align-items: center; gap: 4px; margin-bottom: var(--sp-4); }
.steps__dot {
  flex: 1 1 0; height: 5px; border-radius: var(--r-pill); background: var(--border);
  transition: background var(--dur) var(--ease);
}
.steps__dot--done { background: var(--success); }
.steps__dot--active { background: var(--primary); }
.steps__label { font-size: var(--fs-xs); color: var(--muted); margin-bottom: var(--sp-1); }

/* ==========================================================================
   Timeline
   ========================================================================== */
.timeline { position: relative; padding-inline-start: 28px; }
.timeline::before {
  content: ""; position: absolute; inset-block: 8px 8px; inset-inline-start: 9px;
  width: 2px; background: var(--divider);
}
.tl-item { position: relative; padding-bottom: var(--sp-4); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item__dot {
  position: absolute; inset-inline-start: -28px; top: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
  display: grid; place-items: center; color: var(--muted);
}
.tl-item__dot .ico { width: 11px; height: 11px; }
.tl-item--done .tl-item__dot { background: var(--success); border-color: var(--success); color: #fff; }
.tl-item--active .tl-item__dot { background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 0 0 4px rgba(36,86,230,.16); }
.tl-item--alert .tl-item__dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.tl-item--warn .tl-item__dot { background: var(--warning); border-color: var(--warning); color: #fff; }
.tl-item__time { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }
.tl-item__title { font-weight: var(--fw-semi); font-size: var(--fs-sm); }
.tl-item__meta { font-size: var(--fs-xs); color: var(--muted); }
.tl-item--pending .tl-item__title { color: var(--muted-2); font-weight: var(--fw-regular); }

/* ==========================================================================
   Lists
   ========================================================================== */
.list { display: flex; flex-direction: column; }
.list__item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); min-height: 56px;
  border-bottom: 1px solid var(--divider); background: var(--surface);
  text-align: start; width: 100%; border-inline: 0; border-top: 0; cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.list__item:last-child { border-bottom: 0; }
.list__item:hover { background: var(--surface-2); }
.list__item--static { cursor: default; }
.list__item--static:hover { background: var(--surface); }
.list__chevron { color: var(--muted-2); margin-inline-start: auto; flex: 0 0 auto; }

.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px var(--sp-3); font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: var(--fw-medium); }

/* ==========================================================================
   Avatars
   ========================================================================== */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: var(--fw-bold); font-size: var(--fs-sm);
  background: var(--primary-soft); color: var(--brand-600); overflow: hidden;
}
.avatar--sm { width: 30px; height: 30px; font-size: var(--fs-xs); }
.avatar--lg { width: 60px; height: 60px; font-size: var(--fs-lg); }
.avatar--xl { width: 84px; height: 84px; font-size: var(--fs-2xl); }
.avatar--success { background: var(--success-soft); color: var(--success-text); }
.avatar--warning { background: var(--warning-soft); color: var(--warning-text); }
.avatar--danger  { background: var(--danger-soft);  color: var(--danger-text); }
.avatar--neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-inline-start: -10px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-inline-start: 0; }

/* Presence dot on an avatar */
.avatar-wrap { position: relative; flex: 0 0 auto; }
.avatar-wrap__dot {
  position: absolute; inset-block-end: 0; inset-inline-end: 0;
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface);
}
.dot-available { background: var(--success); }
.dot-busy { background: var(--warning); }
.dot-off { background: var(--muted-2); }

/* ==========================================================================
   KPI tiles
   ========================================================================== */
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-4); display: flex; flex-direction: column; gap: 2px; position: relative;
  box-shadow: var(--sh-xs);
}
.kpi__label { font-size: var(--fs-xs); color: var(--muted); font-weight: var(--fw-medium);
  display: flex; align-items: center; gap: 5px; }
.kpi__value { font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi__unit { font-size: var(--fs-md); font-weight: var(--fw-semi); color: var(--muted); }
.kpi__foot { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 4px; }
.kpi__icon {
  position: absolute; inset-block-start: var(--sp-4); inset-inline-end: var(--sp-4);
  width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--primary-soft); color: var(--brand-600);
}
.kpi--danger  .kpi__value { color: var(--danger-text); }
.kpi--danger  .kpi__icon { background: var(--danger-soft); color: var(--danger-text); }
.kpi--success .kpi__value { color: var(--success-text); }
.kpi--success .kpi__icon { background: var(--success-soft); color: var(--success-text); }
.kpi--warning .kpi__value { color: var(--warning-text); }
.kpi--warning .kpi__icon { background: var(--warning-soft); color: var(--warning-text); }
.kpi--info    .kpi__icon { background: var(--info-soft); color: var(--info-text); }
.kpi-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }

/* Compact stat strip for mobile */
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-2); text-align: center;
}
.stat__value { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat__label { font-size: var(--fs-2xs); color: var(--muted); line-height: 1.4; }

/* ==========================================================================
   Progress / meters
   ========================================================================== */
.meter { height: 7px; background: var(--surface-inset); border-radius: var(--r-pill); overflow: hidden; }
.meter__fill { height: 100%; background: var(--primary); border-radius: var(--r-pill); transition: width var(--dur-slow) var(--ease); }
.meter--success .meter__fill { background: var(--success); }
.meter--warning .meter__fill { background: var(--warning); }
.meter--danger  .meter__fill { background: var(--danger); }

/* SLA countdown pill */
.sla {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: var(--fw-semi); font-variant-numeric: tabular-nums;
  background: var(--success-soft); color: var(--success-text);
}
.sla .ico { width: 13px; height: 13px; }
.sla--warn    { background: var(--warning-soft); color: var(--warning-text); }
.sla--breach  { background: var(--danger-soft);  color: var(--danger-text); }
.sla--met     { background: var(--success-soft); color: var(--success-text); }
.sla--none    { background: var(--neutral-soft); color: var(--neutral-text); }

/* ==========================================================================
   Tables (desktop)
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: 760px; }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); text-align: start; font-weight: var(--fw-semi); color: var(--muted);
  padding: var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--border); white-space: nowrap;
  font-size: var(--fs-xs);
}
.table tbody td { padding: var(--sp-3); border-bottom: 1px solid var(--divider); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.row-emg { background: rgba(220,43,60,.045); }

/* ==========================================================================
   Empty / loading / error states
   ========================================================================== */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--sp-8) var(--sp-4); gap: var(--sp-2); color: var(--muted);
}
.state__icon {
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-inset); color: var(--muted-2); margin-bottom: var(--sp-2);
}
.state__title { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--text); }
.state__text { font-size: var(--fs-sm); max-width: 40ch; }
.state--error .state__icon { background: var(--danger-soft); color: var(--danger); }
.state--warn  .state__icon { background: var(--warning-soft); color: var(--warning); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-inset) 25%, #E8EDF5 37%, var(--surface-inset) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skeleton--line { height: 12px; margin-bottom: 8px; }
.skeleton--card { height: 96px; margin-bottom: var(--sp-3); border-radius: var(--r-lg); }

.spinner {
  width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite;
}
.spinner--dark { border-color: var(--border); border-top-color: var(--primary); }
.spinner--lg { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast-root {
  position: fixed; inset-block-end: calc(var(--bottomnav-h) + 16px); inset-inline: 0;
  z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-2); pointer-events: none; padding: 0 var(--sp-4);
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: var(--sp-2);
  background: var(--brand-900); color: #fff; padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); box-shadow: var(--sh-lg); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  max-width: min(520px, 100%); animation: toastIn var(--dur) var(--ease);
}
.toast--success { background: #0B6B36; }
.toast--danger  { background: #9E1B29; }
.toast--warning { background: #8A5405; }
.toast--info    { background: var(--brand-700); }
.toast.is-out { animation: toastOut var(--dur) var(--ease) forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-root {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: grid; place-items: center; padding: var(--sp-4);
  background: var(--overlay); animation: fadeIn var(--dur) var(--ease);
  overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-xl);
  width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  animation: modalIn var(--dur) var(--ease);
}
.modal--wide { width: min(940px, 100%); }
.modal__head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--divider); }
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.modal__body { padding: var(--sp-5); overflow-y: auto; }
.modal__foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--divider);
  display: flex; gap: var(--sp-2); justify-content: flex-end; background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl); flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }

/* ==========================================================================
   Bottom sheet (mobile-native pattern)
   ========================================================================== */
.sheet-root {
  position: fixed; inset: 0; z-index: var(--z-sheet);
  display: flex; align-items: flex-end; justify-content: center;
  background: var(--overlay); animation: fadeIn var(--dur) var(--ease);
}
.sheet {
  background: var(--surface); width: min(var(--mobile-max), 100%);
  border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--sh-xl);
  max-height: 90vh; display: flex; flex-direction: column;
  animation: sheetIn var(--dur) var(--ease);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet__grip { width: 40px; height: 4px; border-radius: var(--r-pill); background: var(--border-strong);
  margin: var(--sp-3) auto var(--sp-1); flex: 0 0 auto; }
.sheet__head { padding: var(--sp-3) var(--sp-4); display: flex; align-items: center; gap: var(--sp-3);
  border-bottom: 1px solid var(--divider); }
.sheet__title { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.sheet__body { padding: var(--sp-4); overflow-y: auto; }
.sheet__foot { padding: var(--sp-3) var(--sp-4) var(--sp-4); border-top: 1px solid var(--divider);
  display: flex; gap: var(--sp-2); }
@keyframes sheetIn { from { transform: translateY(100%); } }

/* ==========================================================================
   Lightbox (photo evidence)
   ========================================================================== */
.lightbox-root {
  position: fixed; inset: 0; z-index: var(--z-lightbox);
  background: rgba(6,12,25,.94); display: grid; place-items: center; padding: var(--sp-4);
  animation: fadeIn var(--dur) var(--ease);
}
.lightbox__img { max-width: 100%; max-height: 78vh; border-radius: var(--r-md); box-shadow: var(--sh-xl); }
.lightbox__cap { color: #fff; text-align: center; margin-top: var(--sp-3); font-size: var(--fs-sm); }
.lightbox__close { position: absolute; inset-block-start: var(--sp-4); inset-inline-end: var(--sp-4); }

/* ==========================================================================
   Photo evidence grid
   ========================================================================== */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: var(--sp-2); }
.photo {
  position: relative; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden;
  background: var(--surface-inset); border: 1px solid var(--border); cursor: pointer; max-width: 100%;
}
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo__del {
  position: absolute; inset-block-start: 4px; inset-inline-end: 4px;
  width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(11,27,58,.78); color: #fff; display: grid; place-items: center;
}
.photo__tag {
  position: absolute; inset-block-end: 0; inset-inline: 0; padding: 3px 6px;
  background: linear-gradient(transparent, rgba(11,27,58,.85)); color: #fff;
  font-size: var(--fs-2xs); font-weight: var(--fw-semi);
}
.photo-add {
  aspect-ratio: 1; border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: var(--fw-medium); text-align: center; padding: 4px;
}
.photo-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* Before / after comparison */
.ba-compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.ba-compare__col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ba-compare__label {
  font-size: var(--fs-xs); font-weight: var(--fw-bold); display: flex; align-items: center; gap: 5px;
}
.ba-compare__label--before { color: var(--warning-text); }
.ba-compare__label--after  { color: var(--success-text); }

/* ==========================================================================
   Alerts / callouts
   ========================================================================== */
.alert {
  display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.6;
  background: var(--info-soft); color: var(--info-text);
  border: 1px solid rgba(14,143,191,.2);
}
.alert .ico { flex: 0 0 auto; margin-top: 2px; }
.alert__title { font-weight: var(--fw-bold); display: block; }
.alert--success { background: var(--success-soft); color: var(--success-text); border-color: rgba(18,161,80,.2); }
.alert--warning { background: var(--warning-soft); color: var(--warning-text); border-color: rgba(222,123,8,.22); }
.alert--danger  { background: var(--danger-soft);  color: var(--danger-text);  border-color: rgba(220,43,60,.2); }
.alert--brand   { background: var(--primary-soft); color: var(--brand-700);    border-color: var(--primary-border); }
.alert--neutral { background: var(--surface-inset); color: var(--text-2); border-color: var(--border); }

/* Emergency banner */
.emg-banner {
  background: linear-gradient(135deg, #C81E2C, #E23B4A);
  color: #fff; border-radius: var(--r-lg); padding: var(--sp-4);
  display: flex; gap: var(--sp-3); align-items: center; box-shadow: 0 6px 20px rgba(220,43,60,.3);
}
.emg-banner__icon {
  width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: grid; place-items: center; flex: 0 0 auto;
}
.emg-banner__title { font-weight: var(--fw-bold); font-size: var(--fs-lg); }
.emg-banner__text { font-size: var(--fs-sm); opacity: .92; }

/* "Coming soon" future-capability card */
.future {
  border: 1.5px dashed var(--border-strong); background:
    repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 10px, var(--surface) 10px, var(--surface) 20px);
  border-radius: var(--r-lg); padding: var(--sp-4);
}
.future__tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  background: #EDEAFE; color: #4C2FA8; padding: 3px 9px; border-radius: var(--r-pill);
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); overflow-x: auto;
  scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; padding: var(--sp-3) var(--sp-3); cursor: pointer;
  font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; min-height: var(--tap);
}
.tab:hover { color: var(--text-2); }
.tab--active { color: var(--primary); border-bottom-color: var(--primary); }

/* ==========================================================================
   Tooltip (metric explanations)
   ========================================================================== */
.tip { position: relative; display: inline-flex; cursor: help; color: var(--muted-2); }
.tip__bubble {
  position: absolute; inset-block-end: calc(100% + 8px); inset-inline-start: 50%; transform: translateX(50%);
  background: var(--brand-900); color: #fff; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: var(--fw-regular); line-height: 1.55; width: max-content; max-width: 250px;
  box-shadow: var(--sh-lg); opacity: 0; visibility: hidden; transition: opacity var(--dur-fast) var(--ease);
  z-index: var(--z-sticky); pointer-events: none; text-align: start;
}
.tip:hover .tip__bubble, .tip:focus-visible .tip__bubble { opacity: 1; visibility: visible; }

/* ==========================================================================
   QR placeholder
   ========================================================================== */
.qr {
  width: 148px; height: 148px; border-radius: var(--r-md); background: #fff;
  border: 1px solid var(--border); padding: 8px; display: grid; place-items: center;
}
.qr svg { width: 100%; height: 100%; }

/* ==========================================================================
   Signature pad
   ========================================================================== */
.sigpad {
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--surface-2); width: 100%; height: 150px; touch-action: none; cursor: crosshair;
  display: block;
}

/* ==========================================================================
   Map simulation
   ========================================================================== */
.simmap {
  position: relative; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border);
  background:
    radial-gradient(circle at 22% 28%, rgba(36,86,230,.07), transparent 42%),
    radial-gradient(circle at 78% 72%, rgba(18,161,80,.07), transparent 42%),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(15,27,51,.055) 27px, rgba(15,27,51,.055) 28px),
    repeating-linear-gradient(90deg, transparent, transparent 27px, rgba(15,27,51,.055) 27px, rgba(15,27,51,.055) 28px),
    #EFF3F9;
  min-height: 240px;
}
.simmap__pin {
  position: absolute; transform: translate(50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.simmap__pin-dot {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 4px; transform: rotate(45deg);
  display: grid; place-items: center; box-shadow: var(--sh-md); border: 2px solid #fff;
}
.simmap__pin-dot .ico { transform: rotate(-45deg); width: 14px; height: 14px; color: #fff; }
.simmap__pin-label {
  background: rgba(255,255,255,.95); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 1px 6px; font-size: var(--fs-2xs); font-weight: var(--fw-semi); white-space: nowrap;
  box-shadow: var(--sh-xs);
}
.simmap__radius {
  position: absolute; transform: translate(50%, -50%); border-radius: 50%;
  background: rgba(36,86,230,.1); border: 2px dashed rgba(36,86,230,.45);
}
.simmap__legend {
  position: absolute; inset-block-end: var(--sp-3); inset-inline-start: var(--sp-3);
  background: rgba(255,255,255,.94); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3); font-size: var(--fs-2xs); display: flex; gap: var(--sp-3);
  box-shadow: var(--sh-sm); flex-wrap: wrap;
}
.simmap__legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-inline-end: 4px; }
.simmap__note {
  position: absolute; inset-block-start: var(--sp-3); inset-inline-end: var(--sp-3);
  background: rgba(255,255,255,.94); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 3px 8px; font-size: var(--fs-2xs); color: var(--muted); box-shadow: var(--sh-xs);
}

/* ==========================================================================
   Charts
   ========================================================================== */
.chart-box { position: relative; width: 100%; }
.chart-box canvas, .chart-box svg { max-width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--muted); margin-top: var(--sp-2); }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-inline-end: 5px; }

/* ==========================================================================
   Misc
   ========================================================================== */
.divider { height: 1px; background: var(--divider); margin: var(--sp-4) 0; }
.dot-sep::before { content: "\2022"; margin: 0 6px; color: var(--muted-2); }

.count-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--danger); color: #fff; font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  display: inline-grid; place-items: center; line-height: 1;
}

.ticket-no { font-family: var(--font-mono); font-weight: var(--fw-semi); letter-spacing: .3px; direction: ltr; display: inline-block; unicode-bidi: isolate; }

.evidence-lock {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-2xs);
  color: var(--muted); background: var(--surface-inset); padding: 2px 8px; border-radius: var(--r-pill);
}

/* ==========================================================================
   Stacked label pairs
   Several patterns render a title and a subtitle as sibling <span>s inside a
   flex child (so the parent controls the row). Spans are inline by default,
   which would run the two lines together — they must stack.
   ========================================================================== */
.osidebar__brand-name, .osidebar__brand-sub,
.osidebar__tenant-name, .osidebar__tenant-plan,
.auth__brand-name, .auth__brand-sub,
.auth__role-name, .auth__role-desc,
.roleswitch__name, .roleswitch__role,
.emg-banner__title, .emg-banner__text,
.notif__title, .notif__body,
.optcard__title, .optcard__sub,
.feed__text, .sresult__type {
  display: block;
}

.stars { display: inline-flex; gap: 2px; color: #E9A400; }
.stars .ico { width: 15px; height: 15px; }
.star-btn { background: none; border: 0; cursor: pointer; padding: 2px; color: var(--border-strong); line-height: 0; }
.star-btn .ico { width: 34px; height: 34px; }
.star-btn--on { color: #F0A500; }
