:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101820;
  color: #e8edf2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

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

.app-shell.menu-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.sidebar {
  background: #0b1118;
  color: #f9fbfd;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

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

.menu-toggle {
  width: 34px;
  height: 34px;
  background: #162331;
  color: #e8edf2;
  border: 1px solid #2b3d4e;
  padding: 8px;
  display: inline-grid;
  gap: 3px;
  flex: 0 0 auto;
}

.menu-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  background: #dbe5f0;
  border-radius: 999px;
  justify-self: center;
}

.brand span,
.user-chip span,
.muted {
  color: #93a1af;
}

.sidebar .brand span,
.sidebar .user-chip span {
  color: #b8c2cf;
}

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

.nav button {
  text-align: left;
  color: #dbe5f0;
  background: transparent;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav button.active,
.nav button:hover {
  background: #1b2d3e;
  color: #ffffff;
}

.nav-group {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.nav-group > span {
  padding: 12px 12px 2px;
  color: #b8c2cf;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav button.nested {
  padding-left: 24px;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #162331;
  color: #b7c4d1;
  font-size: 12px;
  flex: 0 0 auto;
}

.menu-collapsed .sidebar {
  padding-inline: 12px;
}

.menu-collapsed .sidebar-head {
  display: grid;
  justify-items: center;
}

.menu-collapsed .brand {
  align-items: center;
}

.menu-collapsed .brand span,
.menu-collapsed .nav-label,
.menu-collapsed .nav-group > span,
.menu-collapsed .signout-label {
  display: none;
}

.menu-collapsed .nav button,
.menu-collapsed .nav button.nested {
  justify-content: center;
  padding: 11px 8px;
}

.menu-collapsed .signout {
  padding-inline: 8px;
  font-size: 12px;
}

.signout {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.signout-icon {
  font-weight: 900;
}

.content {
  min-width: 0;
  padding: 28px;
}

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

.topbar h1 {
  font-size: 28px;
  margin: 0 0 6px;
}

.user-chip {
  background: #162331;
  border: 1px solid #2b3d4e;
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 220px;
}

.primary {
  background: #0f7b6c;
  color: #ffffff;
  padding: 10px 14px;
}

.secondary {
  background: #263748;
  color: #e8edf2;
  padding: 10px 14px;
}

.danger {
  background: #9f2d20;
  color: #ffffff;
  padding: 10px 14px;
}

.panel {
  background: #162331;
  border: 1px solid #2b3d4e;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}

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

.metrics {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.metric {
  background: #162331;
  border: 1px solid #2b3d4e;
  border-radius: 8px;
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-bottom: 4px;
}

.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: #162331;
  border: 1px solid #2b3d4e;
  border-radius: 8px;
  overflow: hidden;
}

.grid-host {
  border: 1px solid #2b3d4e;
  border-radius: 8px;
  max-width: 100%;
  overflow: hidden;
  background: #162331;
}

.tabulator {
  background: #162331;
  border: 0;
  color: #e8edf2;
  font-size: 14px;
  width: 100%;
}

.tabulator .tabulator-tableholder {
  overflow-x: auto;
}

.tabulator .tabulator-header,
.tabulator .tabulator-footer {
  background: #1d2b3a;
  border-color: #243545;
  color: #b7c4d1;
}

.tabulator .tabulator-footer .tabulator-footer-contents {
  min-height: 34px;
  padding: 3px 8px;
}

.tabulator .tabulator-footer .tabulator-paginator {
  line-height: 1;
}

.tabulator .tabulator-footer .tabulator-page {
  min-width: 28px;
  min-height: 26px;
  margin: 0 1px;
  padding: 3px 7px;
}

.tabulator .tabulator-header .tabulator-col {
  background: #1d2b3a;
  border-color: #243545;
}

.tabulator .tabulator-header-filter input,
.tabulator .tabulator-header-filter select {
  min-height: 30px;
  padding: 5px 7px;
}

.tabulator-row {
  background: #162331;
  color: #e8edf2;
  border-color: #243545;
}

.tabulator-row.tabulator-row-even {
  background: #13202c;
}

.tabulator-row:hover {
  background: #1b3a36;
}

.tabulator-row .tabulator-cell {
  border-color: #243545;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #243545;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #1d2b3a;
  color: #b7c4d1;
  font-size: 13px;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover,
.selected-row {
  background: #1b3a36;
}

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

.row-actions button {
  padding: 7px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #2b3d4e;
  color: #dce5ee;
  font-size: 12px;
  font-weight: 800;
}

.badge.online {
  background: #163d34;
  color: #72d5b8;
}

.badge.offline {
  background: #4a211d;
  color: #ff9b8d;
}

.badge.maintenance {
  background: #463916;
  color: #ffd76a;
}

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

.compact-panel {
  display: flex;
  align-items: end;
  gap: 12px;
}

.compact-panel label {
  min-width: 260px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.field-help {
  color: #93a1af;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

label {
  display: grid;
  gap: 6px;
  color: #b7c4d1;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid #385064;
  border-radius: 6px;
  padding: 10px 11px;
  color: #e8edf2;
  background: #101820;
}

.tabulator .tabulator-footer select,
.tabulator .tabulator-footer input {
  width: auto;
}

.tabulator .tabulator-footer .tabulator-page-size {
  min-width: 76px;
  max-width: 96px;
  min-height: 26px;
  padding: 3px 8px;
}

input[type="checkbox"] {
  width: auto;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.check-list {
  display: grid;
  gap: 6px;
  color: #b7c4d1;
  font-size: 13px;
  font-weight: 700;
}

.check-list span {
  margin-bottom: 2px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #0b1118 0%, #17323a 55%, #101820 55%);
}

.auth-card {
  width: min(440px, 100%);
  background: #162331;
  border-radius: 8px;
  border: 1px solid #2b3d4e;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.auth-card form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.notice {
  margin-top: 12px;
  border-radius: 6px;
  padding: 10px 12px;
  background: #eef6ff;
  color: #21476b;
}

.error {
  margin: 12px 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fde4df;
  color: #8d271b;
}

.fatal-error {
  margin: 24px;
  border-radius: 8px;
  padding: 16px;
  background: #4a211d;
  color: #ffcec7;
  border: 1px solid #7e352d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

  .app-shell.menu-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 16px;
    height: auto;
  }

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

  .menu-collapsed .sidebar {
    padding: 8px 12px;
  }

  .menu-collapsed .sidebar-head {
    display: flex;
    justify-content: flex-end;
  }

  .menu-collapsed .brand,
  .menu-collapsed .brand span,
  .menu-collapsed .nav-label,
  .menu-collapsed .nav-group > span,
  .menu-collapsed .signout-label {
    display: none;
  }

  .menu-collapsed .nav,
  .menu-collapsed .signout {
    display: none;
  }

  .menu-collapsed .menu-toggle {
    justify-self: end;
  }

  .nav-group {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-group > span {
    grid-column: 1 / -1;
  }

  .nav button {
    text-align: center;
    justify-content: center;
  }

  .nav button.nested {
    padding-left: 12px;
  }

  .content {
    padding: 12px;
  }

  .topbar {
    gap: 8px;
    margin-bottom: 10px;
  }

  .topbar h1 {
    margin-bottom: 2px;
  }

  .topbar .user-chip {
    display: none;
  }

  .panel {
    padding: 12px;
    margin-bottom: 12px;
  }

  .topbar,
  .form-grid,
  .compact-panel,
  .filters,
  .phone-row {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .data-table {
    min-width: 720px;
  }

  .grid-host {
    margin-inline: -2px;
  }
}

@media (max-width: 560px) {
  .metrics {
    grid-template-columns: 1fr;
  }

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

  .user-chip {
    min-width: 0;
    width: 100%;
    padding: 8px 10px;
  }

  .nav,
  .nav-group {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: center;
  }
}
