:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --border: #dce2e7;
  --border-strong: #c7d0d8;
  --text: #17212b;
  --muted: #65717e;
  --nav: #132235;
  --nav-muted: #a9b6c4;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #16845b;
  --green-soft: #e8f6ef;
  --amber: #a86408;
  --amber-soft: #fff4dd;
  --red: #c43c3c;
  --red-soft: #fff0f0;
  --shadow: 0 8px 26px rgb(19 34 53 / 8%);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: 232px;
  flex-direction: column;
  background: var(--nav);
  color: #fff;
}

.brand {
  display: flex;
  min-height: 78px;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid rgb(255 255 255 / 10%);
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 6px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 14px;
}

.brand span {
  margin-top: 2px;
  color: var(--nav-muted);
  font-size: 11px;
}

.nav-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  padding: 14px 10px;
}

.nav-link {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 6px;
  color: var(--nav-muted);
  font-weight: 600;
}

.nav-link svg {
  width: 18px;
  height: 18px;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgb(255 255 255 / 9%);
  color: #fff;
}

.sidebar-user {
  padding: 12px 14px 15px;
  border-top: 1px solid rgb(255 255 255 / 10%);
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  background: #28425f;
  font-weight: 800;
}

.sidebar-user-name {
  overflow: hidden;
  flex: 1;
}

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

.sidebar-user-name span {
  color: var(--nav-muted);
  font-size: 11px;
}

.sidebar-user-actions {
  display: flex;
  gap: 4px;
}

.main-shell {
  min-width: 0;
  margin-left: 232px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 18px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 96%);
}

.icon-btn.mobile-menu {
  display: none;
}

.global-search {
  position: relative;
  width: min(430px, 45vw);
}

.global-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  transform: translateY(-50%);
  color: var(--muted);
}

.global-search input {
  width: 100%;
  height: 40px;
  padding: 8px 12px 8px 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.page {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.page-heading h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.page-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.actions select {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.btn {
  min-height: 38px;
  gap: 8px;
  padding: 8px 13px;
}

.btn svg {
  width: 17px;
  height: 17px;
}

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

.btn-secondary {
  border-color: var(--border-strong);
  background: #fff;
  color: var(--text);
}

.btn-danger {
  border-color: #efb7b7;
  background: #fff;
  color: var(--red);
}

.btn-success {
  background: var(--green);
  color: #fff;
}

.btn-sm {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
}

.btn:disabled,
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: inherit;
}

.icon-btn:hover {
  background: rgb(255 255 255 / 8%);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
}

.metric-icon svg {
  width: 17px;
}

.metric-value {
  margin-top: 12px;
  font-size: 27px;
  font-weight: 800;
  line-height: 1;
}

.metric-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.75fr);
  gap: 16px;
}

.layout-2 > * {
  min-width: 0;
}

.surface {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.surface + .surface {
  margin-top: 16px;
}

.surface-header {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.surface-header h2,
.surface-header h3 {
  margin: 0;
  font-size: 15px;
}

.surface-body {
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfcfd;
}

.cell-main {
  font-weight: 700;
}

.cell-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-success {
  background: var(--green-soft);
  color: var(--green);
}

.badge-danger {
  background: var(--red-soft);
  color: var(--red);
}

.badge-warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-info {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-muted {
  background: #eef1f4;
  color: var(--muted);
}

.fuel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.fuel-chip {
  display: inline-grid;
  min-width: 34px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.fuel-chip.is-yes {
  border-color: #abd9c5;
  background: var(--green-soft);
  color: var(--green);
}

.fuel-chip.is-no {
  border-color: #efc2c2;
  background: var(--red-soft);
  color: var(--red);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.field label,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.file-control {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.file-control input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.file-control .cell-sub {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus,
.toolbar select:focus,
.global-search input:focus {
  border-color: var(--blue);
  outline: 3px solid rgb(37 99 235 / 12%);
}

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

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.check-row input {
  width: 17px;
  height: 17px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid;
  border-radius: 6px;
  font-weight: 650;
}

.alert svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.alert-success {
  border-color: #b7dccb;
  background: var(--green-soft);
  color: #126947;
}

.alert-error {
  border-color: #edbdbd;
  background: var(--red-soft);
  color: #a92f2f;
}

.alert-warning {
  border-color: #ead09b;
  background: var(--amber-soft);
  color: #805109;
}

.empty-state {
  padding: 42px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.pagination-links {
  display: flex;
  gap: 6px;
}

.status-list {
  display: grid;
  gap: 0;
}

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.status-item:last-child {
  border-bottom: 0;
}

.definition-list {
  display: grid;
  grid-template-columns: minmax(140px, 0.65fr) minmax(0, 1.35fr);
  margin: 0;
}

.definition-list dt,
.definition-list dd {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.definition-list dt {
  color: var(--muted);
}

.definition-list dd {
  font-weight: 650;
}

#station-map {
  width: 100%;
  height: 430px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #e9edf1;
}

.map-placeholder {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--muted);
}

dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 30px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(13 25 38 / 55%);
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
}

.dialog-header {
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-body {
  padding: 16px;
}

.dialog-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
  background: #e9eef3;
}

.auth-panel {
  width: min(420px, 100%);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
}

.auth-brand img {
  width: 50px;
  height: 50px;
  border-radius: 6px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 18px;
}

.auth-brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.auth-form .btn {
  width: 100%;
  min-height: 42px;
}

.code {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

pre.code {
  max-height: 320px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
}

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

.text-success {
  color: var(--green);
}

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

.mt-6 {
  margin-top: 6px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-14 {
  margin-top: 14px;
}

.sidebar-overlay {
  display: none;
}

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

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

@media (max-width: 760px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: none;
    background: rgb(13 25 38 / 45%);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .main-shell {
    margin-left: 0;
  }

  .icon-btn.mobile-menu {
    display: inline-flex;
    color: var(--text);
  }

  .topbar {
    gap: 8px;
    padding: 10px 12px;
  }

  .global-search {
    width: 100%;
  }

  .topbar-status {
    display: none;
  }

  .page {
    padding: 16px 12px 24px;
  }

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

  .page-heading h1 {
    font-size: 21px;
  }

  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-full {
    grid-column: auto;
  }

  .metric {
    min-height: 102px;
  }

  .toolbar > * {
    min-width: min(100%, 180px);
    flex: 1;
  }

  #station-map {
    height: 320px;
  }

  .definition-list {
    grid-template-columns: 1fr;
  }

  .definition-list dt {
    padding-bottom: 2px;
    border-bottom: 0;
  }

  .definition-list dd {
    padding-top: 0;
  }
}
