/* ==========================================================================
   App shell CSS — loaded after css/styles.css on authenticated pages only.
   Extends the existing design tokens/components rather than inventing a
   new visual language.
   ========================================================================== */

.auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4) var(--space-3);
  background: var(--paper);
}
.auth-card {
  width: 100%;
  max-width: 440px;
}
.auth-card__brand {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}
.auth-card .form-card {
  max-width: none;
}
.auth-card__foot {
  text-align: center;
  margin-top: var(--space-3);
  font-size: 0.9375rem;
  color: var(--text-muted);
}
.auth-card__foot a { font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--border-strong); }

/* ---- Password strength meter ---- */
.strength-meter { margin-top: 0.6rem; }
.strength-meter__bars {
  display: flex;
  gap: 0.4rem;
}
.strength-meter__bars .progress-track__seg { height: 4px; }
.strength-meter__bars .progress-track__seg.is-filled::after { width: 100%; }
.strength-meter__bars .progress-track__seg[data-tier="0"].is-filled::after { background: var(--danger); }
.strength-meter__bars .progress-track__seg[data-tier="1"].is-filled::after { background: #c47a2b; }
.strength-meter__bars .progress-track__seg[data-tier="2"].is-filled::after { background: var(--accent); }
.strength-meter__bars .progress-track__seg[data-tier="3"].is-filled::after,
.strength-meter__bars .progress-track__seg[data-tier="4"].is-filled::after { background: #3f6b4f; }
.strength-meter__row {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-size: 0.8125rem;
}
.strength-meter__row [data-label] { font-weight: 600; color: var(--text-muted); }
.strength-meter__row [data-hint] { color: var(--text-faint); }

/* ---- Toasts ---- */
.toast-stack {
  position: fixed;
  bottom: var(--space-3);
  right: var(--space-3);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 360px;
}
.toast {
  background: var(--ink);
  color: var(--white);
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9375rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--danger); }
.toast--success { background: #1e6b4d; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---- App shell (dashboard / staff) ---- */
.app-shell {
  min-height: 100dvh;
  display: flex;
}
.app-rail {
  width: 240px;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--on-ink);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
}
.app-rail__brand { color: var(--white); margin-bottom: var(--space-4); }
.app-rail__brand .brand__mark { background: var(--white); }
.app-rail nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.app-rail__link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--on-ink-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.app-rail__link svg { width: 18px; height: 18px; flex-shrink: 0; }
.app-rail__link:hover { color: var(--white); background: rgba(245,243,238,0.06); }
.app-rail__link.is-active { color: var(--white); background: rgba(245,243,238,0.1); }
.app-rail__link .badge-count {
  margin-left: auto;
  background: var(--accent);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}
.app-rail__foot { border-top: 1px solid rgba(245,243,238,0.12); padding-top: var(--space-2); margin-top: var(--space-2); }

.app-rail__company { margin-bottom: var(--space-3); }
.app-rail__company-select {
  width: 100%;
  background: rgba(245,243,238,0.06);
  border: 1px solid rgba(245,243,238,0.14);
  color: var(--white);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  appearance: none;
  cursor: pointer;
}
.app-rail__company-select:focus { outline: 1px solid var(--accent); outline-offset: 1px; }
.app-rail__add-company {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.8125rem;
  color: var(--on-ink-muted);
  text-align: center;
}
.app-rail__add-company:hover { color: var(--white); }

.app-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  max-width: 1100px;
}
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .app-rail { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; }
  .app-rail nav { flex-direction: row; }
  .app-rail__foot { display: none; }
  .app-main { padding: var(--space-3); }
}

.app-header { margin-bottom: var(--space-4); }
.app-header h1 { margin-bottom: 0.3rem; }
.app-header p { color: var(--text-muted); }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.tabs__item {
  padding: 0.75rem 0.25rem;
  margin-right: var(--space-3);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs__item.is-active { color: var(--ink); border-color: var(--ink); }
.tabs__item:hover { color: var(--ink); }

/* ---- Switch (toggle) ---- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.switch-row__label { font-weight: 600; font-size: 0.9375rem; }
.switch-row__desc { font-size: 0.8125rem; color: var(--text-faint); margin-top: 0.2rem; }
.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  border: none;
  transition: background-color var(--dur-base) var(--ease-out);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--white);
  transition: transform var(--dur-base) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.switch.is-on { background: var(--ink); }
.switch.is-on::after { transform: translateX(18px); }

/* ---- Locked field ---- */
.locked-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: 0.9375rem;
  color: var(--text-muted);
}
.locked-field svg { width: 15px; height: 15px; color: var(--text-faint); flex-shrink: 0; }

/* ---- Session item ---- */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.session-item:last-child { border-bottom: none; }
.session-item__meta { font-size: 0.8125rem; color: var(--text-faint); margin-top: 0.2rem; }
.session-item.is-current .badge { background: var(--ink); color: var(--white); border-color: var(--ink); }

/* ---- QR frame ---- */
.qr-frame {
  display: flex;
  justify-content: center;
  padding: var(--space-3);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-block: var(--space-3);
}
.qr-frame svg { width: 180px; height: 180px; }
.secret-code {
  font-family: monospace;
  font-size: 0.9375rem;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 0.6rem;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* ---- Data table ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.data-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tbody tr:hover { background: var(--surface-alt); }
.data-table tbody tr { cursor: pointer; }

/* ---- Chat ---- */
.chat { display: flex; flex-direction: column; gap: var(--space-2); }
.chat__bubble-row { display: flex; }
.chat__bubble-row--out { justify-content: flex-end; }
.chat__bubble {
  max-width: 70%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat__bubble-row--in .chat__bubble { background: var(--surface-alt); border: 1px solid var(--border); }
.chat__bubble-row--out .chat__bubble { background: var(--ink); color: var(--white); }
.chat__bubble-row--system .chat__bubble { background: transparent; color: var(--text-faint); font-size: 0.8125rem; text-align: center; margin-inline: auto; }
.chat__meta { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.25rem; }
.chat__bubble-row--out .chat__meta { text-align: right; }
.chat__attach {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}
.chat__bubble-row--in .chat__attach { background: var(--white); border: 1px solid var(--border); }
.chat__attach svg { width: 14px; height: 14px; flex-shrink: 0; }
.chat__attach a { color: inherit; text-decoration: underline; }

.choice-card { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.6rem; }
.choice-option {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--dur-base) var(--ease-out);
}
.choice-option:hover { border-color: var(--ink); }
.choice-option.is-selected { background: var(--ink); border-color: var(--ink); color: var(--white); }
.choice-option:disabled { cursor: default; opacity: 0.7; }

.chat-composer {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
}
.chat-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  resize: vertical;
}
.chat-composer__attach-btn {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.chat-composer__attach-btn svg { width: 18px; height: 18px; }
