:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #151515;
  --text: #f4e6aa;
  --muted: #cdbb72;
  --accent: #d71920;
  --accent2: #ffcd1f;
  --line: #4a2f0b;
  --surface: #1b1b1b;
  --surface-soft: #222;
  --surface-alt: #2a1808;
  --button-text: #fff8d6;
  --secondary-text: #ffe38d;
  --danger-bg: #5d1111;
  --danger-text: #ffd1a8;
  --chip-bg: #2b1a08;
  --chip-text: #ffd666;
  --warn-bg: #493108;
  --warn-text: #ffd666;
  --good-bg: #26360c;
  --good-text: #d7ff8f;
  --overlay: rgba(0, 0, 0, 0.72);
  --shadow-soft: 0 10px 22px rgba(0, 0, 0, 0.45);
  --shadow-strong: 0 18px 34px rgba(0, 0, 0, 0.62);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f1ec;
  --panel: #fffdf8;
  --text: #2b221d;
  --muted: #5f5148;
  --accent: #b44f23;
  --accent2: #f4b400;
  --line: #d7cec1;
  --surface: #fffdf8;
  --surface-soft: #e8e1d5;
  --surface-alt: #f4eee3;
  --button-text: #ffffff;
  --secondary-text: #47392f;
  --danger-bg: #e9b8b8;
  --danger-text: #5f1717;
  --chip-bg: #e0eee9;
  --chip-text: #1b5b53;
  --warn-bg: #fdeacd;
  --warn-text: #7f4918;
  --good-bg: #dbf2e5;
  --good-text: #1b6e3c;
  --overlay: rgba(19, 13, 9, 0.45);
  --shadow-soft: 0 7px 16px rgba(44, 34, 20, 0.06);
  --shadow-strong: 0 18px 30px rgba(20, 13, 7, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0 0, rgba(215, 25, 32, 0.24) 0%, transparent 34%),
    radial-gradient(circle at 100% 0, rgba(255, 205, 31, 0.2) 0%, transparent 30%),
    var(--bg);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.auth-card h1 {
  margin: 0;
}

.auth-card p {
  margin-top: 0.3rem;
  color: var(--muted);
}

body[data-page="home"] .auth-shell {
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 205, 31, 0.16) 0%, transparent 32%),
    radial-gradient(circle at 80% 85%, rgba(215, 25, 32, 0.22) 0%, transparent 35%);
}

body[data-page="home"] .auth-card.auth-card-logo {
  width: min(660px, 100%);
  padding: 1.2rem 1rem 1rem;
  border: 1px solid rgba(244, 180, 0, 0.35);
  background: linear-gradient(160deg, rgba(20, 20, 20, 0.92), rgba(9, 9, 9, 0.94));
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.5);
}

.auth-hero-logo {
  width: min(420px, 88vw);
  display: block;
  margin: 0 auto 0.95rem;
  border-radius: 24px;
  border: 1px solid rgba(244, 180, 0, 0.45);
  box-shadow:
    0 24px 44px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 205, 31, 0.12) inset;
}

body[data-page="home"] #login-form.form-grid.compact {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 0.5rem;
  margin-bottom: 0;
}

body[data-page="home"] #login-form label {
  font-size: 0.8rem;
}

body[data-page="home"] #login-form button[type="submit"] {
  min-width: 126px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  display: block;
  object-fit: cover;
  background: #120a04;
}

.brand-stack {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-stack h1 {
  margin: 0;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
}

.topbar h1 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.topbar p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  max-width: 74ch;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 0.8rem;
  padding: 0.8rem;
}

.app-shell.portrait-shell {
  width: 100%;
  max-width: min(1180px, 96vw);
  margin: 0 auto;
  min-height: 100vh;
}

.layout.layout-single {
  grid-template-columns: 1fr;
}

.page-nav {
  display: flex;
  gap: 0.35rem;
  padding: 0 0.8rem 0.7rem;
  overflow: auto;
}

.page-nav a {
  text-decoration: none;
  color: var(--secondary-text);
  border: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 600;
}

.page-nav a.active {
  color: #1a0c00;
  background: linear-gradient(135deg, var(--accent2), #f29d00);
  border-color: #f29d00;
}

.card-links {
  display: grid;
  gap: 0.45rem;
}

.op-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--secondary-text);
  text-decoration: none;
  padding: 0.6rem;
  font-weight: 700;
}

button.op-card {
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--secondary-text);
  text-align: left;
  width: 100%;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 0.8rem;
  box-shadow: var(--shadow-soft);
}

.panel h2, .panel h3 {
  margin: 0 0 0.6rem;
  color: var(--accent);
  line-height: 1.2;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.row-actions {
  display: flex;
  gap: 0.35rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.83rem;
}

input, select, textarea, button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  font: inherit;
}

input, select, textarea {
  background: var(--surface);
  color: var(--text);
}

input:not([type="checkbox"]), select, textarea {
  width: 100%;
}

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

button {
  border: none;
  color: var(--button-text);
  font-weight: 700;
  background: linear-gradient(160deg, var(--accent), #87070c);
  cursor: pointer;
}

button.secondary {
  background: var(--surface-soft);
  color: var(--secondary-text);
  border: 1px solid var(--line);
}

button.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.chip {
  background: var(--chip-bg);
  color: var(--chip-text);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
}

.chip.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.chip.good {
  background: var(--good-bg);
  color: var(--good-text);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}

.wo-job-checkboxes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.6rem;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem;
  background: var(--surface);
}

.job-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
}

.job-check input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

.span-2 {
  grid-column: span 2;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  max-height: none;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.table-wrap.short {
  max-height: 240px;
  overflow: auto;
}

.muted-line {
  color: var(--muted);
}

.mirror-toolbar {
  align-items: flex-end;
}

.mirror-controls {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.mirror-controls label {
  min-width: 160px;
}

.mirror-inline-check {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.mirror-board {
  margin-top: 0.6rem;
  overflow-x: auto;
}

.mirror-monthly {
  margin-top: 0.6rem;
}

.mirror-month-wrap.mirror-layout-list .month-grid {
  grid-template-columns: 1fr;
}

.mirror-month-wrap.mirror-layout-list .month-grid-head {
  display: none;
}

.mirror-month-wrap.mirror-layout-list .month-cell.empty {
  display: none;
}

.mirror-month-wrap.mirror-size-compact .month-cell {
  min-height: 64px;
  padding: 0.28rem;
}

.mirror-month-wrap.mirror-size-compact .month-cell strong {
  font-size: 0.85rem;
}

.mirror-month-wrap.mirror-size-large .month-cell {
  min-height: 118px;
  padding: 0.55rem;
}

.mirror-month-wrap.mirror-size-large .month-cell strong {
  font-size: 1.05rem;
}

.month-grid-head {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.month-grid-head span {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}

.month-cell {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.4rem;
  display: grid;
  gap: 0.1rem;
  align-content: start;
  cursor: pointer;
}

.month-cell.empty {
  background: transparent;
  border-style: dashed;
  opacity: 0.45;
}

.month-cell.has-data {
  background: var(--surface-alt);
}

.month-cell.selected {
  outline: 2px solid var(--accent2);
  outline-offset: 1px;
}

.month-cell.today {
  background: rgba(255, 110, 110, 0.2);
  border-color: rgba(255, 130, 130, 0.8);
}

.month-cell.today strong {
  color: #ffb3b3;
}

.month-cell strong {
  color: var(--accent2);
}

.month-cell span {
  font-size: 0.74rem;
  color: var(--secondary-text);
}

.month-cell small {
  font-size: 0.7rem;
  color: var(--muted);
}

.mirror-day-detail {
  margin-top: 0.6rem;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.mirror-day-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.45rem;
}

.mirror-day-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  padding: 0.5rem;
  display: grid;
  gap: 0.2rem;
}

.mirror-day-card small {
  color: var(--muted);
}

.mirror-grid-shell {
  display: grid;
  grid-template-columns: 180px minmax(960px, 1fr);
  gap: 0.4rem;
}

.mirror-header-spacer {
  min-height: 32px;
}

.mirror-hours {
  display: grid;
  grid-template-columns: repeat(24, minmax(60px, 1fr));
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.mirror-hour {
  font-size: 0.72rem;
  text-align: center;
  padding: 0.35rem 0.1rem;
  background: var(--surface-alt);
  color: var(--secondary-text);
  border-right: 1px solid var(--line);
}

.mirror-hour:last-child {
  border-right: 0;
}

.mirror-installer {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--secondary-text);
  font-weight: 700;
  padding: 0.55rem;
  display: flex;
  align-items: center;
}

.mirror-row-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 0.45rem;
  box-shadow: var(--shadow-soft);
}

.mirror-row-track {
  position: relative;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.mirror-hour-lines {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(100% / 24 - 1px),
    var(--line) calc(100% / 24 - 1px),
    var(--line) calc(100% / 24)
  );
  opacity: 0.45;
}

.mirror-block {
  position: absolute;
  top: 7px;
  bottom: 7px;
  border-radius: 8px;
  border: 1px solid #f29d00;
  background: linear-gradient(135deg, rgba(244, 180, 0, 0.95), rgba(215, 25, 32, 0.9));
  color: #1f1200;
  padding: 0.24rem 0.35rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.mirror-block strong,
.mirror-block small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mirror-block small {
  font-size: 0.68rem;
}

.mirror-row-actions {
  margin-top: 0.35rem;
  display: flex;
  justify-content: flex-end;
}

.mirror-expand {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.mirror-card {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  padding: 0.45rem;
  display: grid;
  gap: 0.15rem;
}

.mirror-card small {
  color: var(--muted);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-card {
  width: min(900px, 95vw);
  max-height: 92vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-strong);
  padding: 0.8rem;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.modal-head h3 {
  margin: 0;
  color: var(--accent);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  table-layout: auto;
}

th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  padding: 0.45rem 0.3rem;
  word-wrap: break-word;
}

small {
  color: var(--muted);
}

.customer-vehicle {
  min-width: 0;
}

.vehicle-one-line {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
}

.row-actions {
  flex-wrap: wrap;
}

.row-actions button {
  white-space: nowrap;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.7rem 0;
}

.app-shell.contract-shell {
  max-width: min(980px, 96vw);
  margin: 0 auto;
  min-height: 100vh;
  padding: 0.8rem;
}

.contract-pin-grid {
  grid-template-columns: minmax(200px, 320px) minmax(140px, 220px);
  align-items: end;
}

#contract-terms {
  width: 100%;
  min-height: 390px;
  line-height: 1.4;
  resize: vertical;
}

.agreement-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
}

.agreement-row input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

.app-footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  padding: 0.85rem 0.75rem 1rem;
  margin-top: 0.4rem;
  border-top: 1px solid color-mix(in oklab, var(--line) 72%, transparent);
  background: linear-gradient(180deg, transparent, color-mix(in oklab, var(--surface-alt) 28%, transparent));
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.footer-brand img {
  width: min(132px, 38vw);
  height: auto;
  display: block;
  border-radius: 9px;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.26);
}

.footer-copy {
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: color-mix(in oklab, var(--accent2) 80%, #fff 20%);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.footer-meta {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

body[data-page="home"] #auth-view:not(.hidden) ~ .app-footer {
  display: none;
}

@media (max-width: 960px) {
  .form-grid.compact,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .mirror-grid-shell {
    grid-template-columns: 1fr;
  }

  .mirror-controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .mirror-controls > button,
  .mirror-controls > .mirror-inline-check,
  .mirror-controls > label {
    min-width: 0;
  }

  .mirror-controls > #mirror-refresh {
    grid-column: 1 / -1;
  }

  .month-grid,
  .month-grid-head {
    min-width: 0;
  }

  .mirror-installer {
    margin-top: 0.35rem;
  }
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .app-shell.portrait-shell {
    max-width: 100%;
  }

  .app-shell.contract-shell {
    max-width: 100%;
    padding: 0.55rem;
  }

  .topbar {
    padding: 0.65rem 0.7rem;
    border-bottom: 1px solid var(--line);
  }

  .topbar > div:first-child {
    width: 100%;
  }

  .topbar h1 {
    font-size: 1.08rem;
    line-height: 1.25;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .topbar p {
    font-size: 0.76rem;
    line-height: 1.3;
    max-width: 100%;
  }

  .toolbar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .toolbar .chip {
    grid-column: 1 / -1;
    text-align: center;
  }

  .layout {
    padding: 0.6rem;
    gap: 0.6rem;
  }

  .panel {
    padding: 0.65rem;
    border-radius: 10px;
  }

  .mirror-controls {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }

  .mirror-controls label {
    min-width: 0;
  }

  .mirror-controls > #mirror-refresh,
  .mirror-controls > .mirror-inline-check,
  .mirror-controls > .mirror-search-wrap {
    grid-column: 1 / -1;
  }

  .month-grid-head,
  .month-grid {
    min-width: 0;
  }

  .month-grid-head {
    display: none;
  }

  .month-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .month-cell {
    min-height: 92px;
    padding: 0.45rem;
  }

  .mirror-grid-shell {
    gap: 0.35rem;
  }

  .mirror-hours {
    grid-template-columns: repeat(24, minmax(42px, 1fr));
  }

  .mirror-hour {
    font-size: 0.66rem;
    padding: 0.25rem 0.05rem;
  }

  .mirror-row-track {
    height: 64px;
  }

  .mirror-block {
    top: 8px;
    bottom: 8px;
    padding: 0.2rem 0.3rem;
  }

  .mirror-block strong {
    font-size: 0.72rem;
  }

  .mirror-block small {
    font-size: 0.62rem;
  }

  .page-nav {
    padding: 0 0.6rem 0.55rem;
    gap: 0.3rem;
    margin-bottom: 0.1rem;
  }

  .page-nav a {
    flex: 0 0 auto;
    padding: 0.4rem 0.62rem;
    font-size: 0.86rem;
  }

  input, select, textarea, button {
    min-height: 42px;
    font-size: 16px;
  }

  .table-wrap {
    width: 100%;
    max-height: none;
    border-top: none;
    padding-top: 0;
    overflow: visible;
  }

  table {
    min-width: 0;
    width: 100%;
    font-size: 0.82rem;
  }

  table thead {
    display: none;
  }

  table tbody,
  table tr,
  table td {
    display: block;
    width: 100%;
  }

  table tr {
    margin: 0 0 0.55rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 0.2rem 0.35rem;
    box-shadow: var(--shadow-soft);
  }

  table td {
    border-bottom: none;
    padding: 0.2rem 0.15rem;
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 0.35rem;
    align-items: start;
  }

  table td + td {
    margin-top: 0.1rem;
    padding-top: 0.22rem;
    border-top: 1px dashed rgba(255, 205, 31, 0.2);
  }

  table td::before {
    content: attr(data-label);
    display: inline-block;
    font-weight: 700;
    color: var(--muted);
    margin: 0;
    line-height: 1.2;
  }

  table td select,
  table td button {
    width: 100%;
  }

  table td[data-label="Action"] {
    margin-top: 0.25rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--line);
    grid-template-columns: 1fr;
  }

  table td[data-label="Action"]::before {
    margin-bottom: 0.1rem;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-head > button {
    width: 100%;
  }

  .wo-job-checkboxes {
    grid-template-columns: 1fr;
    max-height: 260px;
  }

  .row-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .row-actions button {
    width: 100%;
  }

  .vehicle-one-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .modal-overlay {
    padding: 0.45rem;
    align-items: end;
  }

  .modal-card {
    width: 100%;
    max-width: none;
    max-height: 90vh;
    border-radius: 14px 14px 0 0;
    padding: 0.7rem;
  }

  .modal-head {
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: 1;
    padding-bottom: 0.4rem;
  }

  .contract-pin-grid {
    grid-template-columns: 1fr;
  }

  #contract-terms {
    min-height: 46vh;
    font-size: 0.95rem;
  }
}

@media (max-width: 900px) {
  .auth-card {
    width: min(680px, 100%);
    padding: 0.9rem;
  }

  .app-shell.portrait-shell {
    max-width: 100%;
  }

  .topbar {
    gap: 0.55rem;
    padding: 0.7rem 0.75rem;
  }

  .brand-stack {
    width: 100%;
    min-width: 0;
  }

  .brand-stack > div {
    min-width: 0;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .table-wrap.short {
    max-height: none;
  }

  .mirror-day-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .auth-shell {
    padding: 0.55rem;
  }

  .auth-card {
    border-radius: 12px;
    padding: 0.8rem;
  }

  .auth-card .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .auth-hero-logo {
    border-radius: 18px;
    margin-bottom: 0.75rem;
  }

  body[data-page="home"] #login-form.form-grid.compact {
    grid-template-columns: 1fr;
  }

  .page-nav {
    position: sticky;
    top: 0;
    z-index: 15;
    background: linear-gradient(180deg, rgba(9, 9, 9, 0.95), rgba(9, 9, 9, 0.88));
    backdrop-filter: blur(4px);
  }

  .page-nav a {
    scroll-snap-align: start;
  }

  .brand-stack {
    align-items: flex-start;
  }

  .brand-stack h1 {
    font-size: 1.02rem;
  }

  .panel-head label,
  .panel-head select {
    width: 100%;
  }

  .mirror-month-wrap.mirror-layout-list .month-grid {
    grid-template-columns: 1fr;
  }

  .mirror-card {
    min-width: 190px;
  }

  .modal-head h3 {
    font-size: 1rem;
    max-width: 78%;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding: 0.55rem;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .layout {
    padding: 0.45rem;
    gap: 0.5rem;
  }

  .panel {
    padding: 0.55rem;
  }

  .page-nav a {
    font-size: 0.8rem;
    padding: 0.34rem 0.5rem;
  }

  .mirror-controls {
    grid-template-columns: 1fr;
  }

  .month-grid {
    grid-template-columns: 1fr;
  }

  .row-actions {
    grid-template-columns: 1fr;
  }

  table td {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .app-footer {
    padding: 0.65rem 0.45rem 0.85rem;
  }

  .footer-brand {
    gap: 0.45rem;
  }

  .footer-brand img {
    width: min(108px, 44vw);
    border-radius: 8px;
  }

  .footer-copy {
    font-size: 0.74rem;
  }

  .footer-meta {
    font-size: 0.64rem;
    text-align: center;
  }
}
