* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, p {
  margin: 0;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.app-header {
  padding: calc(var(--space-3) + var(--safe-top)) var(--space-4) var(--space-3);
  background: var(--color-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header .brand {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  line-height: 1.15;
}

.app-header .brand-name {
  font-weight: 700;
  font-size: 17px;
}

.app-header .brand-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
}

.app-header .step-badge {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

main {
  flex: 1;
  padding: var(--space-4) var(--space-4) calc(var(--space-6) + var(--safe-bottom));
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.view[hidden] {
  display: none;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
}

.card + .card {
  margin-top: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-3);
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.field .hint {
  font-size: 12px;
  color: var(--color-text-muted);
}

.field-row {
  display: flex;
  gap: var(--space-3);
}

.field-row > .field {
  flex: 1;
  min-width: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 16px;
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}

textarea {
  resize: vertical;
  min-height: 70px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--color-blue);
  outline-offset: 1px;
}

.segmented {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented button {
  flex: 1;
  border: none;
  background: var(--color-surface);
  padding: 11px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border);
  cursor: pointer;
}

.segmented button:last-child {
  border-right: none;
}

.segmented button.active {
  background: var(--color-blue);
  color: #fff;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.toggle-row label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
}

.switch input {
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  position: absolute;
  cursor: pointer;
  z-index: 1;
}

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 999px;
  transition: background 0.15s ease;
}

.switch .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.switch input:checked ~ .track {
  background: var(--color-blue);
}

.switch input:checked ~ .thumb {
  transform: translateX(18px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--color-blue);
  color: #fff;
}

.btn-primary:active {
  background: var(--color-blue-dark);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-blue);
  border: 1px solid var(--color-blue);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
  width: auto;
}

.btn-row {
  display: flex;
  gap: var(--space-3);
}

.btn-row .btn {
  flex: 1;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.banner {
  background: #eaf1ff;
  border: 1px solid #c7d9f7;
  color: var(--color-blue-dark);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-size: 13px;
}

.banner-warn {
  background: #fff4e5;
  border-color: #f3d8a6;
  color: #8a5a00;
}

.call-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.call-card .call-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
}

.call-card .call-index {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.call-card .call-tcode {
  font-size: 16px;
  font-weight: 700;
}

.call-card .call-cancelled-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-danger);
  background: #fbe9e7;
  padding: 2px 8px;
  border-radius: 999px;
}

.call-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px var(--space-3);
  margin: var(--space-2) 0 0;
  font-size: 13px;
}

.call-card dt {
  color: var(--color-text-muted);
}

.call-card dd {
  margin: 0;
  font-weight: 600;
}

.call-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-6) var(--space-4);
  font-size: 14px;
}

.count-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-blue);
  background: #eaf1ff;
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-block;
}

.pdf-frame {
  width: 100%;
  height: 60vh;
  min-height: 380px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 380px;
}

.modal-card p {
  font-size: 15px;
  line-height: 1.5;
  margin: var(--space-2) 0 var(--space-4);
  white-space: pre-line;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-5) + var(--safe-bottom));
  transform: translate(-50%, 0);
  /* Fixed dark chip regardless of page theme — var(--color-text) flips to
     near-white in dark mode, which paired with white text was unreadable. */
  background: #1c1f26;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -4px);
}

/* Login screen background — tiled outlined "TowOps" wordmark on black, with
   a large solid wordmark centered behind the sign-in card. Fixed/dark
   regardless of light/dark mode — this is a brand splash, not themed
   content. Applied to <body> (not #view-login) via router.js so it's a
   true full-bleed background, unconstrained by <main>'s 560px column. */
body.login-bg {
  background-color: #0a0a0a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='170' viewBox='0 0 320 170'%3E%3Ctext x='2' y='58' font-family='Helvetica Neue,Arial,sans-serif' font-weight='800' font-size='46' fill='none' stroke='%23c0392b' stroke-width='2'%3ETowOps%3C/text%3E%3Ctext x='166' y='143' font-family='Helvetica Neue,Arial,sans-serif' font-weight='800' font-size='46' fill='none' stroke='%23c0392b' stroke-width='2'%3ETowOps%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 320px 170px;
  /* Reuse the existing dark-mode variable values so the card, inputs, and
     hint text all render correctly against this fixed-dark background —
     without this, a system in light mode would flip the card to white and
     hint text to near-black, unreadable against the black splash behind
     it. Overriding the variables (rather than hand-restyling each element)
     means every existing rule that already reads var(--color-surface) etc.
     just works, no duplicated color rules to keep in sync. */
  --color-surface: #1f222a;
  --color-border: #33363f;
  --color-text: #f2f3f5;
  --color-text-muted: #9aa0ab;
}

/* Grid-stacks the wordmark and the card into the same cell so the wordmark
   is always centered on the card's own box — mostly hidden behind it,
   visible only at the edges — regardless of viewport height or how tall
   the card ends up being. No fixed pixel offsets to keep in sync. */
.login-hero {
  display: grid;
}

.login-hero > * {
  grid-area: 1 / 1;
}

.login-wordmark {
  align-self: center;
  justify-self: center;
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  z-index: 0;
  pointer-events: none;
}

.login-hero .card {
  z-index: 1;
}
