:root {
  --ink: #181315;
  --muted: #71686b;
  --paper: #f7f4f1;
  --panel: #ffffff;
  --line: #e3ddd9;
  --maroon: #7e151f;
  --maroon-2: #a9252f;
  --green: #137548;
  --amber: #b76a08;
  --red: #a71927;
  --teal: #0a6d72;
  --shadow: 0 16px 42px rgba(35, 25, 22, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #21191a;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body.locked {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.phone-app {
  display: none;
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  padding: 14px 14px 86px;
  position: relative;
}

body.authenticated .phone-app {
  display: block;
}

.login-screen {
  min-height: 100vh;
  padding: 24px 16px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(33, 25, 26, 0.82), rgba(33, 25, 26, 0.82)),
    radial-gradient(circle at 50% 20%, #7e151f, #21191a 62%);
}

body.authenticated .login-screen {
  display: none;
}

.login-card {
  width: min(100%, 390px);
  background: var(--paper);
  border-radius: 18px;
  padding: 22px;
  display: grid;
  gap: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-card img {
  width: 108px;
  justify-self: center;
}

.login-card h1 {
  text-align: center;
  color: var(--maroon);
}

.login-card .eyebrow {
  text-align: center;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 900;
  text-align: center;
}

.mobile-hero {
  background: linear-gradient(145deg, #201617, #7e151f);
  color: #fff;
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow);
}

.brand-strip {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
}

.hero-logo {
  width: 96px;
  height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.22));
}

.agency-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(126, 21, 31, 0.08);
}

.agency-strip img {
  width: 100%;
  max-height: 46px;
  object-fit: contain;
}

.session-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #f7dbd4;
  font-weight: 900;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layout-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 13px;
  background: #efe7e3;
}

.layout-toggle button {
  border: 0;
  border-radius: 10px;
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.layout-toggle button.active {
  background: var(--maroon);
  color: #fff;
}

.layout-toggle.compact {
  background: rgba(255, 255, 255, 0.12);
}

.layout-toggle.compact button {
  min-height: 34px;
  color: #f7dbd4;
}

.layout-toggle.compact button.active {
  background: #fff;
  color: var(--maroon);
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 999px;
  padding: 7px 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.sync-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2fa66f;
}

.sync-status.pending::before {
  background: #d49b2f;
}

.sync-status.offline::before {
  background: #c91832;
}

.session-strip .ghost-action {
  min-height: 36px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.24);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--maroon-2);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.mobile-hero .eyebrow {
  color: #f3b6a9;
}

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

h1 {
  font-size: 1.72rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1rem;
}

.view {
  display: none;
  padding-top: 14px;
}

.active-view {
  display: grid;
  gap: 14px;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 20;
  width: min(calc(100% - 20px), 500px);
  background: #181315;
  border-radius: 18px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

.tab {
  border: 0;
  min-height: 46px;
  border-radius: 12px;
  background: transparent;
  color: #d7cdca;
  font-weight: 900;
}

.tab.active {
  background: #fff;
  color: var(--maroon);
}

.today-card,
.mobile-card,
.role-card,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.today-card {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.today-card strong {
  color: var(--ink);
}

.mobile-card {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.card-title,
.section-head,
.capture-head,
.role-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.unit-review-banner {
  background: #181315;
  color: #fff;
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 4px;
  box-shadow: var(--shadow);
}

.unit-review-banner span {
  color: #f3b6a9;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.unit-review-banner strong {
  font-size: 1.75rem;
  line-height: 1.05;
}

.unit-review-banner small {
  color: #d7cdca;
  font-weight: 800;
}

.status-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 6px rgba(113, 104, 107, 0.14);
}

.status-dot.open {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(19, 117, 72, 0.16);
}

.status-dot.closed {
  background: var(--teal);
  box-shadow: 0 0 0 6px rgba(10, 109, 114, 0.16);
}

.mobile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.4;
  font-weight: 600;
  caret-color: var(--maroon);
}

textarea::placeholder {
  color: #8a8083;
  font-weight: 700;
  opacity: 0.75;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f2eeee;
  color: #9a9093;
}

.field-hint {
  color: var(--maroon);
  font-size: 0.78rem;
  font-weight: 900;
}

.primary-action,
.ghost-action,
.danger-action,
.segment {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 900;
}

.primary-action {
  background: var(--maroon);
  color: #fff;
}

.ghost-action {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.danger-action {
  background: #fff2f3;
  color: var(--red);
  border-color: #f2c6cb;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice-button {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 14px;
  display: grid;
  gap: 6px;
  text-align: left;
}

.choice-button.active {
  border-color: var(--maroon);
  background: #fff6f5;
  box-shadow: 0 0 0 4px rgba(126, 21, 31, 0.08);
}

.choice-button strong {
  font-size: 1.05rem;
}

.choice-button span {
  color: var(--muted);
  line-height: 1.35;
}

.active-unit-summary {
  display: grid;
  gap: 10px;
}

.active-summary-head,
.active-empty-state {
  border: 1px solid #ead8db;
  border-radius: 14px;
  background: #fff8f7;
  padding: 11px 12px;
}

.active-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.active-summary-head strong,
.active-empty-state strong {
  color: var(--maroon);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.active-summary-head span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--maroon);
  color: #fff;
  font-weight: 900;
}

.active-unit-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.active-unit-chip {
  border: 1px solid #ead8db;
  border-left: 5px solid var(--green);
  border-radius: 14px;
  background: #fff;
  padding: 10px 11px;
  display: grid;
  gap: 4px;
  box-shadow: 0 8px 20px rgba(35, 25, 22, 0.06);
}

.active-unit-chip strong {
  font-size: 1rem;
}

.active-unit-chip span,
.active-unit-chip small,
.active-empty-state span {
  color: var(--muted);
}

.active-unit-chip small {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 0.78rem;
}

.active-unit-chip b {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #d2c5c7;
}

.active-empty-state {
  display: grid;
  gap: 3px;
}

.choice-button.compact {
  min-height: 72px;
}

.close-card-list,
.close-review-prompt {
  display: grid;
  gap: 10px;
}

.close-unit-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 14px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.close-unit-card.active {
  border-color: var(--maroon);
  background: #fff6f5;
  box-shadow: 0 0 0 4px rgba(126, 21, 31, 0.08);
}

.close-unit-card strong {
  font-size: 1.12rem;
}

.close-unit-meta {
  color: var(--muted);
  line-height: 1.35;
  font-weight: 800;
}

.close-unit-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.operation-panel {
  display: none;
}

.operation-panel.active {
  display: grid;
}

.is-hidden {
  display: none !important;
}

.conditional-field {
  display: none;
}

.conditional-field.visible {
  display: grid;
}

.fuel-loads-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fuel-loads-list {
  display: grid;
  gap: 10px;
}

.fuel-load-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fff;
}

.photo-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 12px;
  background: #fff;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.close-section {
  display: none;
  gap: 12px;
}

.close-section.active {
  display: grid;
}

.role-grid {
  display: grid;
  gap: 12px;
}

.role-card {
  padding: 16px;
  display: grid;
  gap: 12px;
  border-left: 6px solid var(--line);
}

.role-card.open {
  border-left-color: var(--green);
}

.role-card.closed {
  border-left-color: var(--teal);
}

.role-card.nogo {
  border-left-color: var(--red);
}

.role-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #f3e9e7;
  color: var(--maroon);
  font-weight: 900;
}

.role-state {
  font-weight: 900;
}

.role-meta {
  color: var(--muted);
  line-height: 1.4;
}

.module-fields {
  display: none;
  gap: 14px;
}

.module-fields.active {
  display: grid;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #eee7e3;
  padding: 6px;
  border-radius: 14px;
}

.segment {
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: #fff;
  color: var(--maroon);
  box-shadow: 0 7px 18px rgba(35, 25, 22, 0.08);
}

.check-list {
  display: grid;
  gap: 10px;
}

.check-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.check-group summary {
  list-style: none;
  padding: 14px;
  font-weight: 900;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.check-group summary::-webkit-details-marker {
  display: none;
}

.check-items {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.check-row {
  display: grid;
  grid-template-columns: 1fr 116px;
  gap: 10px;
  align-items: center;
}

.check-row span {
  line-height: 1.25;
}

.check-row select {
  min-height: 38px;
  padding: 6px 8px;
}

.bad-reason {
  display: none;
  grid-column: 1 / -1;
}

.bad-reason.visible {
  display: grid;
}

.status-preview {
  border-radius: 14px;
  padding: 12px;
  background: #eee7e3;
  color: var(--muted);
  line-height: 1.35;
  font-weight: 800;
}

.status-preview.ready {
  background: #e8f6ef;
  color: var(--green);
}

.status-preview.pending {
  background: #fff3df;
  color: var(--amber);
}

.status-preview.nogo {
  background: #fff0f2;
  color: var(--red);
}

.records-list,
.alerts-list {
  display: grid;
  gap: 10px;
}

.record-card,
.alert-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.record-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.record-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-weight: 900;
  font-size: 0.78rem;
}

.pill.ready,
.pill.closed {
  background: #e8f6ef;
  color: var(--green);
}

.pill.pending,
.pill.open {
  background: #fff3df;
  color: var(--amber);
}

.pill.nogo {
  background: #fff0f2;
  color: var(--red);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric {
  padding: 14px;
  display: grid;
  gap: 6px;
}

.metric span {
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  font-size: 2rem;
}

.metric.danger strong {
  color: var(--red);
}

.mileage-card {
  gap: 12px;
}

.auto-note {
  border: 1px solid #d7eadf;
  border-radius: 12px;
  background: #eef9f3;
  color: var(--green);
  padding: 9px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}

.mileage-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mileage-stats article,
.empty-mileage {
  border: 1px solid #ead8db;
  border-radius: 14px;
  background: #fff8f7;
  padding: 10px;
}

.mileage-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.mileage-stats strong {
  display: block;
  margin-top: 3px;
  color: var(--maroon);
  font-size: 1.15rem;
}

.empty-mileage {
  grid-column: 1 / -1;
  color: var(--muted);
}

.mileage-log-list {
  display: grid;
  gap: 8px;
}

.mileage-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 11px;
  display: grid;
  gap: 9px;
}

.mileage-row strong {
  display: block;
}

.mileage-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.mileage-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.mileage-numbers span {
  border-radius: 10px;
  background: #f7f1ef;
  padding: 7px 5px;
  text-align: center;
  font-size: 0.72rem;
}

.mileage-numbers b {
  display: block;
  color: var(--ink);
  font-size: 0.9rem;
}

dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(24, 19, 21, 0.58);
}

.password-box {
  width: min(420px, calc(100vw - 28px));
  padding: 18px;
  display: grid;
  gap: 12px;
}

.password-box p {
  color: var(--muted);
}

.password-box menu {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 30;
  transform: translate(-50%, 30px);
  width: min(calc(100% - 28px), 460px);
  background: #181315;
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  opacity: 0;
  transition: 180ms ease;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
}

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

body.layout-desktop {
  background: #f0ece8;
}

body.layout-desktop .phone-app {
  width: min(100%, 1180px);
  padding: 18px 22px 34px;
}

body.layout-desktop .mobile-hero {
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
}

body.layout-desktop .brand-strip {
  grid-template-columns: 104px 1fr;
}

body.layout-desktop .agency-strip {
  min-height: 74px;
}

body.layout-desktop .session-strip {
  grid-column: 1 / -1;
}

body.layout-desktop .bottom-tabs {
  position: sticky;
  top: 12px;
  left: auto;
  bottom: auto;
  transform: none;
  width: 100%;
  margin: 14px 0;
  border-radius: 12px;
  z-index: 10;
}

body.layout-desktop .view {
  padding-top: 0;
}

body.layout-desktop .active-view {
  gap: 16px;
}

body.layout-desktop #home.active-view {
  grid-template-columns: minmax(320px, 0.8fr) minmax(520px, 1.2fr);
  align-items: start;
}

body.layout-desktop #home .today-card,
body.layout-desktop #home .action-choice {
  grid-column: 1;
}

body.layout-desktop #home .operation-panel,
body.layout-desktop #home #reviewChoicePanel {
  grid-column: 2;
}

body.layout-desktop #reviewChoicePanel {
  grid-template-columns: 1fr 1fr;
}

body.layout-desktop #reviewChoicePanel > .mobile-card {
  grid-column: 1 / -1;
}

body.layout-desktop .mobile-grid {
  grid-template-columns: repeat(3, 1fr);
}

body.layout-desktop .choice-grid,
body.layout-desktop .close-card-list,
body.layout-desktop .records-list,
body.layout-desktop .alerts-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.layout-desktop .metric-grid,
body.layout-desktop .mileage-stats {
  grid-template-columns: repeat(4, 1fr);
}

body.layout-desktop .login-card {
  width: min(100%, 460px);
}

@media (max-width: 720px) {
  .session-strip {
    display: grid;
  }

  .session-actions {
    justify-content: space-between;
  }

  .layout-toggle.compact {
    flex: 1;
  }
}

@media (max-width: 420px) {
  .mobile-grid,
  .metric-grid,
  .check-row,
  .photo-grid {
    grid-template-columns: 1fr;
  }

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