:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #0f6b63;
  --primary-strong: #0a514b;
  --danger: #c03535;
  --soft: #eaf7f4;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(180deg, rgba(15, 107, 99, 0.08), transparent 320px),
    var(--bg);
  color: var(--text);
}

body.is-loading {
  cursor: wait;
}

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

button {
  cursor: pointer;
}

.screen {
  min-height: 100vh;
  padding: 20px;
}

.auth-screen {
  display: grid;
  place-items: center;
}

.boot-screen {
  display: grid;
  place-items: center;
}

.boot-loading-box {
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(23, 32, 51, 0.28);
  backdrop-filter: blur(2px);
}

.loading-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-width: 150px;
  padding: 18px 22px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
  font-weight: 700;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #d9e0ea;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-panel {
  width: min(100%, 460px);
}

.brand h1,
.topbar h1,
.section-head h2,
.section-head h3 {
  margin: 0;
}

.brand p,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 107, 99, 0.14);
  outline: none;
}

textarea {
  resize: vertical;
}

.primary,
.ghost,
.danger {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

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

.primary:hover {
  background: var(--primary-strong);
}

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

.ghost:hover {
  border-color: #9bb7b2;
}

.danger {
  background: #fff1f1;
  color: var(--danger);
  border-color: #f0c3c3;
}

.error {
  color: var(--danger);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  text-align: center;
  text-decoration: none;
}

.tab.active {
  background: var(--soft);
  border-color: #94ccc4;
  color: var(--primary);
}

.content {
  display: grid;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head.small {
  margin-bottom: 8px;
}

.inline-form,
.grid.two,
.form-actions,
.calendar-actions,
.topbar-actions {
  display: grid;
  gap: 10px;
}

.inline-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-actions,
.calendar-actions,
.topbar-actions {
  grid-auto-flow: column;
  justify-content: start;
}

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

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  background: #fff;
}

.list-item h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.list-item p {
  margin: 0;
  color: var(--muted);
}

.item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.item-actions .ghost,
.item-actions .danger {
  padding: 6px 10px;
  font-size: 13px;
  min-height: 32px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.calendar-column {
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  display: flex;
  flex-direction: column;
}

.calendar-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.calendar-head strong,
.calendar-head span {
  display: block;
}

.calendar-body {
  padding: 10px;
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 100%;
}

.route-card,
.add-card {
  border-radius: 8px;
  padding: 10px;
}

.route-card {
  background: #fff;
  border: 1px solid #cae5df;
  color: var(--text);
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.route-card:hover {
  border-color: #73b8ae;
  box-shadow: 0 8px 18px rgba(15, 107, 99, 0.1);
}

.route-card h4 {
  margin: 0;
}

.route-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
}

.route-settings-button {
  border: 0;
  background: var(--primary);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #fff;
  font-size: 17px;
  line-height: 1;
}

.route-settings-button::before {
  content: "⚙";
}

.route-settings-button:hover {
  background: #0b5a53;
}

.route-card p,
.route-card ul {
  margin: 0;
  color: var(--muted);
}

.route-card ul {
  padding-left: 18px;
}

.orders-mode .route-main-fields,
.orders-mode .route-main-fields + div,
.orders-mode .form-actions {
  display: none;
}

.add-card {
  border: 1px dashed #84bdb5;
  background: var(--soft);
  color: var(--primary);
  width: 100%;
}

.route-city-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.route-main-fields {
  max-width: 720px;
}

.route-cities-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.add-route-city-button {
  width: 42px;
}

.list.compact {
  gap: 8px;
}

.list.compact .list-item {
  box-shadow: none;
}

.list.compact {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  align-items: stretch;
}

.delivery-tile {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: space-between;
}

.add-delivery-tile {
  border: 0;
  background: var(--primary);
  color: #fff;
  justify-items: center;
  align-content: center;
  text-align: center;
}

.add-delivery-tile:hover {
  background: var(--primary-strong);
}

.add-delivery-plus {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
}

.delivery-tile-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.delivery-city {
  color: var(--primary);
  font-weight: 700;
}

.delivery-tile p,
.delivery-tile b {
  margin: 0;
}

.delivery-tile p {
  color: var(--muted);
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
}

.dialog-box {
  width: min(100%, 390px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  padding: 18px;
}

.dialog-box h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.dialog-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-form,
  .grid.two,
  .route-cities-grid {
    grid-template-columns: 1fr;
  }

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

  .list-item {
    display: grid;
  }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(220px, 1fr));
  }

  .dialog-actions {
    display: grid;
  }
}

@media (max-width: 1200px) and (min-width: 901px) {
  .route-cities-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
