:root {
  --navy: #041f4f;
  --navy-2: #073273;
  --blue: #0b58d0;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #071b49;
  --muted: #61708f;
  --line: #dfe7f2;
  --green: #0f9d58;
  --red: #db3b44;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(4, 31, 79, 0.92), rgba(4, 31, 79, 0.54), rgba(4, 31, 79, 0.1)),
    url("image.png") center / cover;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  margin-right: auto;
  margin-left: min(8vw, 110px);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 70px rgba(4, 31, 79, 0.28);
  padding: 28px;
}

.auth-card .logo {
  width: 132px;
  margin-bottom: 18px;
}

.auth-card h1 {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-card input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  padding: 0 12px;
  color: var(--text);
}

.auth-card button {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
}

.auth-error {
  margin: 0 0 12px !important;
  color: var(--red) !important;
  font-size: 13px;
  font-weight: 700;
}

#app {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px 1fr;
}

#app.auth-mode {
  display: block;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  flex-direction: column;
  gap: 28px;
  background: #05265d;
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 30px 16px;
  color: white;
}

.sidebar nav {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 18px;
}

.sidebar nav::-webkit-scrollbar {
  width: 8px;
}

.sidebar nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.sidebar nav::-webkit-scrollbar-track {
  background: transparent;
}

.brand {
  padding: 0 18px;
}

.logo {
  width: 118px;
  height: auto;
  display: block;
}

.brand h1 {
  margin: 14px 0 4px;
  font-size: 22px;
  font-weight: 650;
  line-height: 1;
}

.brand p,
.admin-chip small,
.stat-card p,
.stat-card span,
.route-row span,
.compact-list span {
  color: var(--muted);
}

.sidebar .brand p,
.sidebar-art {
  color: #b9c9e8;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

nav button {
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 8px;
  background: transparent;
  padding: 14px 18px;
  color: #edf5ff;
  text-align: left;
}

nav button span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: currentColor;
}

svg {
  width: 20px;
  height: 20px;
}

nav button.active,
nav button:hover {
  background: #0b58d0;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  min-height: 88px;
  grid-template-columns: 40px 1fr minmax(260px, 420px) auto;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 0 28px;
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
}

.hamburger {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 12px 16px;
}

.search span {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
}

.admin-chip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-chip b {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 999px;
  background: var(--navy);
  color: white;
}

.admin-chip span {
  display: flex;
  flex-direction: column;
  font-weight: 600;
}

.admin-menu {
  position: relative;
  justify-self: end;
}

.admin-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
  background: var(--navy);
  color: white;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.admin-menu-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: 0 12px 30px rgba(9, 36, 82, 0.14);
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.admin-menu.open .admin-menu-pop {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.admin-menu-item {
  width: 100%;
  border-radius: 8px;
  background: transparent;
  padding: 8px 10px;
  color: var(--text);
  text-align: left;
  font-size: 14px;
  font-weight: 600;
}

.admin-menu-item:hover {
  background: #eef4ff;
}

.content {
  padding: 22px 28px 32px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(9, 36, 82, 0.06);
}

.stat-card {
  display: flex;
  gap: 16px;
  min-height: 112px;
  align-items: center;
  padding: 18px;
}

.stat-icon {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  background: #eaf3ff;
  color: var(--blue);
}

.stat-card p {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.stat-card strong {
  display: block;
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
}

.stat-card span {
  display: block;
  margin-top: 10px;
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.panel {
  overflow: hidden;
  padding: 18px;
}

.panel.full {
  min-height: calc(100vh - 150px);
}

.panel.wide {
  grid-row: span 2;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.panel-head button,
td button,
.primary {
  border-radius: 8px;
  background: #eef4ff;
  padding: 8px 11px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
}

td button.danger-soft,
.danger-soft {
  background: #fff0f1;
  color: var(--red);
}

td button.danger-soft:hover,
.danger-soft:hover {
  background: #ffe0e3;
}

.mode-toggle {
  display: inline-flex;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7faff;
  padding: 3px;
}

.mode-toggle button {
  border-radius: 7px;
  background: transparent;
  padding: 7px 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.mode-toggle button.active {
  background: white;
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(9, 36, 82, 0.08);
}

.primary {
  background: var(--blue);
  color: white;
}

.chart {
  display: flex;
  height: 260px;
  align-items: end;
  gap: 20px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 22px 22px 28px;
}

.chart span {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: start;
  justify-content: center;
  border-radius: 8px 8px 0 0;
  background: #d9e8fb;
  border-top: 3px solid var(--blue);
}

.chart b {
  transform: translateY(-22px);
  font-size: 13px;
  font-weight: 600;
}

.chart em {
  position: absolute;
  bottom: -24px;
  font-style: normal;
  color: var(--muted);
  font-size: 13px;
}

.route-row,
.compact-list p,
.status-list p {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 14px 0;
}

.route-row:last-child,
.compact-list p:last-child,
.status-list p:last-child {
  border-bottom: 0;
}

.route-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: #eaf3ff;
  color: var(--blue);
}

.route-row div:nth-child(2),
.compact-list strong {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.route-row strong,
.compact-list strong {
  font-weight: 600;
}

.route-row b {
  font-weight: 600;
}

.status-list i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
}

.status-list span {
  margin-left: auto;
  color: var(--green);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  background: #f5f8fd;
  color: #50617f;
  font-size: 12px;
  font-weight: 600;
}

td {
  font-weight: 450;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  background: #fff2cf;
  padding: 6px 10px;
  color: #9b6500;
  font-size: 12px;
  font-weight: 600;
}

.badge.neutral {
  background: #eef4ff;
  color: var(--blue);
}

.badge.info {
  background: #e2f0ff;
  color: #0b58d0;
}

.badge.warn {
  background: #fff2cf;
  color: #9b6500;
}

.badge.good {
  background: #dff8e9;
  color: var(--green);
}

.badge.bad {
  background: #ffe3e5;
  color: var(--red);
}

.row-actions {
  display: flex;
  gap: 8px;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin: 0 0 14px;
}

.muted-action {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(5, 17, 43, 0.45);
  padding: 24px;
}

.modal-card {
  width: min(680px, 100%);
  border-radius: 16px;
  background: white;
  padding: 22px;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.form-grid input,
.form-grid select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  color: var(--text);
  font-weight: 500;
  background: white;
}

.form-grid .check {
  flex-direction: row;
  align-items: center;
}

.form-grid .check input {
  min-height: 0;
  width: 20px;
  height: 20px;
}

@media (max-width: 1100px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 3;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

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

  .stats-grid,
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: auto 1fr;
    padding: 14px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .search,
  .admin-chip,
  .admin-menu {
    grid-column: 1 / -1;
  }

  .content {
    padding: 14px;
  }

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

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
