:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #eef3f7;
  --text: #17202a;
  --muted: #667085;
  --line: #d8e0e8;
  --accent: #147d64;
  --accent-dark: #0f604d;
  --danger: #b42318;
  --warning: #a15c07;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button,
.button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

button:hover,
.button:hover {
  background: var(--accent-dark);
}

button.secondary,
.button.secondary {
  background: #e8eef3;
  color: var(--text);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-box h1 {
  margin: 0 0 20px;
  font-size: 28px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  background: #17202a;
  color: #fff;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 18px;
}

.user-chip {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #d7dee6;
  margin-bottom: 18px;
  font-size: 14px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a,
.nav button {
  min-height: 40px;
  justify-content: flex-start;
  background: transparent;
  color: #d7dee6;
  padding: 0 10px;
  border-radius: 8px;
  font-weight: 700;
}

.nav a {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav a.active,
.nav a:hover,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 24px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

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

.grid {
  display: grid;
  gap: 14px;
}

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

.metric,
.panel,
.order-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.04);
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.contact-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.contact-panel + .panel {
  margin-top: 16px;
}

.toolbar {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(130px, 1fr)) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 14px;
}

.order-card {
  padding: 15px;
  display: grid;
  gap: 12px;
}

.order-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.order-head h3 {
  margin: 0;
  font-size: 17px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-new { background: #e7f0ff; color: #1849a9; }
.status-assigned { background: #eef4ff; color: #3538cd; }
.status-accepted { background: #ecfdf3; color: #027a48; }
.status-on_the_way { background: #fff6df; color: #93370d; }
.status-arrived_airport { background: #f4ebff; color: #6941c6; }
.status-client_in_car { background: #e0f2fe; color: #026aa2; }
.status-arrived_uman { background: #dcfae6; color: #067647; }
.status-completed { background: #e7f8ee; color: #05603a; }
.status-cancelled { background: #fee4e2; color: #b42318; }
.pay-unpaid { background: #fee4e2; color: #b42318; }
.pay-deposit_paid { background: #fff6df; color: #93370d; }
.pay-paid { background: #dcfae6; color: #067647; }
.pay-refunded { background: #e8eef3; color: #344054; }

.row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.full {
  grid-column: 1 / -1;
}

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

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.button.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.detail-actions {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.availability {
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.availability.neutral {
  background: #f7f9fb;
  color: var(--muted);
}

.availability.available {
  background: #ecfdf3;
  border-color: #abefc6;
  color: #067647;
}

.availability.warning {
  background: #fffaeb;
  border-color: #fedf89;
  color: #93370d;
}

.availability.conflict {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}

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

.list-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--panel-soft);
  border-radius: 8px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs button {
  background: #e8eef3;
  color: var(--text);
}

.tabs button.active {
  background: var(--accent);
  color: #fff;
}

.empty {
  padding: 22px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.error {
  margin-top: 12px;
  color: var(--danger);
  font-weight: 700;
}

.success {
  margin-top: 12px;
  color: #067647;
  font-weight: 700;
}

.audit-list {
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.audit-row {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr);
  gap: 13px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

.audit-mark {
  min-height: 42px;
  border-radius: 3px;
  background: #98a2b3;
}

.audit-mark.action-create,
.audit-mark.action-login {
  background: #12b76a;
}

.audit-mark.action-update,
.audit-mark.action-status {
  background: #2e90fa;
}

.audit-mark.action-delete {
  background: #f04438;
}

.audit-mark.action-password,
.audit-mark.action-logout_all {
  background: #f79009;
}

.audit-row details {
  margin-top: 8px;
  color: var(--muted);
}

.audit-row summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.audit-row pre {
  max-width: 100%;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.security-panel {
  max-width: 660px;
}

.security-panel + .security-panel {
  margin-top: 16px;
}

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

.export-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.backup-command {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  overflow-x: auto;
}

.deleted-order-row {
  grid-template-columns: 1.5fr 1fr 1fr auto;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: static;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

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

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

@media (max-width: 620px) {
  .main {
    padding: 16px;
  }

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

  .metrics,
    .form-grid,
    .safety-grid,
    .row,
  .toolbar,
  .list-row {
    grid-template-columns: 1fr;
  }

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

  .contact-panel {
    align-items: stretch;
    flex-direction: column;
  }
}
