:root {
  --green: #8f1024;
  --green-2: #b5122e;
  --mint: #f8e7ea;
  --lime: #d9b34a;
  --ink: #2b171a;
  --muted: #75666a;
  --line: #e6dadd;
  --paper: #f8f6f5;
  --amber: #b47b17;
  --red: #b5122e;
  --shadow: 0 12px 30px rgba(82, 12, 25, 0.16);
  background: #eee8e9;
}

body {
  background: #eee8e9;
}

.login-screen {
  width: 100%;
  min-height: 100dvh;
  padding: max(32px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #fff 0 31%, #f7edef 31% 100%);
}

.login-screen[hidden],
.app-shell[hidden],
.admin-shell[hidden] {
  display: none;
}

.login-panel {
  width: min(100%, 420px);
}

.login-logo {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin: 0 auto 52px;
}

.login-heading {
  margin-bottom: 24px;
}

.login-heading h1 {
  margin: 0;
  color: #3a2227;
  font-size: 30px;
  letter-spacing: 0;
}

.login-heading > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form .primary-button {
  width: 100%;
  margin-top: 4px;
  background: #a61029;
  color: #fff;
}

.login-error {
  margin: -4px 0 0;
  color: #a61029;
  font-size: 13px;
  font-weight: 700;
}

.demo-access {
  margin: 22px 0 0;
  text-align: center;
  color: #8a7479;
  font-size: 11px;
}

.return-login {
  width: 100%;
  margin-top: 14px;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: #8f1024;
  font-weight: 800;
}

.admin-shell {
  min-height: 100dvh;
  background: var(--paper);
}

.admin-header {
  min-height: 78px;
  padding: 12px max(20px, calc((100vw - 1120px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.admin-header img {
  width: min(260px, 50vw);
  height: auto;
}

.admin-header > div {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-header span {
  color: #765d63;
  font-size: 13px;
  font-weight: 700;
}

.admin-header button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #d9c9cd;
  border-radius: 6px;
  background: #fff;
  color: #8f1024;
  font-weight: 800;
}

.admin-main {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 34px 20px 60px;
}

.admin-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.admin-heading h1 {
  margin: 0;
  font-size: 30px;
}

.admin-heading p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.admin-heading .primary-button {
  min-width: 120px;
  padding: 0 18px;
  background: #a61029;
  color: #fff;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 28px 0;
}

.admin-stats div {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 3px solid #b5122e;
  border-radius: 7px;
}

.admin-stats b {
  display: block;
  font-size: 26px;
}

.admin-stats span {
  color: var(--muted);
  font-size: 12px;
}

.user-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.user-section-head {
  min-height: 66px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.user-section-head h2 {
  margin: 0;
  font-size: 18px;
}

.user-section-head input {
  width: min(250px, 55%);
  padding: 10px 12px;
  border: 1px solid #d5c9cc;
  border-radius: 6px;
}

.user-row {
  min-height: 72px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 42px minmax(150px, 1.3fr) minmax(180px, 1.8fr) 76px 248px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.user-row:last-child {
  border-bottom: 0;
}

.user-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f4e1e5;
  color: #a61029;
  font-size: 12px;
  font-weight: 900;
}

.user-name,
.user-email {
  min-width: 0;
}

.user-name b,
.user-email span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name small,
.user-email small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.role-pill {
  justify-self: start;
  padding: 5px 8px;
  border-radius: 4px;
  background: #f3e4c1;
  color: #6b4710;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.account-toggle {
  min-height: 34px;
  border: 1px solid #d6c8cc;
  border-radius: 5px;
  background: #fff;
  color: #8f1024;
  font-size: 11px;
  font-weight: 800;
}

.account-toggle:disabled {
  color: #998b8f;
  background: #f3f1f1;
}

.user-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.delete-user {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid #e3bfc6;
  border-radius: 5px;
  background: #fff7f8;
  color: #a61029;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
}

.reset-user-password {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid #decfa9;
  border-radius: 5px;
  background: #fffaf0;
  color: #76510f;
  font-size: 11px;
  font-weight: 800;
}

.delete-user svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.delete-user:disabled {
  color: #a99b9e;
  border-color: #ddd6d8;
  background: #f3f1f1;
}

.user-empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

#adminModal {
  z-index: 120;
}

.password-backdrop {
  z-index: 130;
}

.password-intro {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.password-rules {
  margin: -5px 0 0;
  color: #765d63;
  font-size: 11px;
  line-height: 1.4;
}

.password-sheet .primary-button {
  background: #a61029;
  color: #fff;
}

.work-state {
  min-height: 170px;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.work-state b,
.work-loading b {
  font-size: 16px;
}

.work-state span,
.work-loading span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.work-state .primary-button,
.work-loading .primary-button {
  min-width: 120px;
  margin-top: 10px;
}

.duty-card .work-loading {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
}

.duty-card .work-loading span {
  color: #f2dde1;
}

@media (max-width: 720px) {
  .admin-header span {
    display: none;
  }

  .admin-header img {
    width: min(180px, 40vw);
  }

  .admin-header > div {
    gap: 6px;
  }

  .admin-header button {
    padding: 0 8px;
    font-size: 11px;
  }

  .admin-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-heading .primary-button {
    width: 100%;
  }

  .user-row {
    grid-template-columns: 42px minmax(0, 1fr) auto;
  }

  .user-email {
    grid-column: 2 / 4;
    grid-row: 2;
  }

  .role-pill {
    grid-column: 3;
    grid-row: 1;
  }

  .user-actions {
    grid-column: 2 / 4;
  }
}

.topbar {
  min-height: 76px;
  height: auto;
  border-bottom-color: #ead9dd;
  box-shadow: 0 3px 14px rgba(94, 15, 31, 0.07);
}

.header-wordmark {
  display: block;
  width: min(68%, 310px);
  min-width: 0;
  height: auto;
  object-fit: contain;
}

.driver-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-control-button {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #b41d36;
  border-radius: 6px;
  background: #fff;
  color: #9f1028;
  font-size: 11px;
  font-weight: 800;
}

.admin-control-button[hidden] {
  display: none;
}

.admin-label-short {
  display: none;
}

.driver-app-button {
  position: relative;
  min-height: 42px;
  padding: 5px 0 5px 10px;
  border: 0;
  border-left: 1px solid #ead9dd;
  background: transparent;
  color: #9f1028;
  display: flex;
  align-items: center;
  gap: 7px;
}

.driver-app-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.driver-app-button b {
  color: #4f3b40;
  font-size: 12px;
  white-space: nowrap;
}

.driver-app-button .notification-dot {
  position: absolute;
  left: 25px;
  top: 7px;
  transform: none;
}

.greeting-row > div:first-child {
  min-width: 0;
}

.notification-dot {
  border-color: #fff;
  background: #d9b34a;
}

.sync-state i {
  background: #b5122e;
}

.duty-card {
  background: linear-gradient(145deg, #8f1024 0%, #ae1730 100%);
}

.duty-card::after {
  border-color: rgba(217, 179, 74, 0.2);
}

.status-pill {
  background: #e2bf5b;
  color: #4b2305;
}

.duty-ref,
.operator-line,
.route-line span {
  color: #f2dde1;
}

.route-line {
  border-left-color: rgba(226, 191, 91, 0.7);
}

.route-line div::before {
  background: #e2bf5b;
}

.primary-button {
  background: #e2bf5b;
  color: #4a2205;
}

.task.complete .task-state,
.check-row input:checked + i {
  background: #b5122e;
  border-color: #b5122e;
}

.progress-track span,
.mini-duty {
  border-color: #b5122e;
}

.progress-track span {
  background: #b5122e;
}

.check-summary {
  background: linear-gradient(145deg, #8f1024, #ae1730);
}

.ring::before {
  background: #991227;
}

.bottom-nav button.active,
.menu-group svg,
.eyebrow {
  color: #a61029;
}

.avatar {
  background: #9f1028;
  box-shadow: inset 0 0 0 2px #d9b34a;
}

@media (max-width: 470px) {
  .topbar {
    padding-left: 16px;
    padding-right: 12px;
  }

  .header-wordmark {
    width: min(50%, 180px);
  }

  .admin-control-button {
    padding: 7px 8px;
  }

  .admin-label-full,
  .driver-app-button b {
    display: none;
  }

  .admin-label-short {
    display: inline;
  }

  .driver-app-button {
    padding-left: 8px;
    gap: 5px;
  }

}
