:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7f8;
  color: #25313d;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-alt: #eef4f2;
  --border: #d7e0df;
  --border-strong: #b7c6c3;
  --text: #25313d;
  --muted: #667680;
  --accent: #1f6f78;
  --accent-strong: #15525b;
  --accent-soft: #dbeeed;
  --green: #2f7d55;
  --green-soft: #e0f3e8;
  --amber: #9b6818;
  --amber-soft: #f6ead1;
  --red: #a7433d;
  --red-soft: #f7dfdc;
  --shadow: 0 18px 45px rgba(31, 50, 55, 0.11);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

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

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

button,
a.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  text-decoration: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

button:active,
a.button:active {
  transform: translateY(1px);
}

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

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

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

.button-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button-ghost {
  background: transparent;
  color: var(--muted);
}

.button-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.icon-only {
  height: 36px;
  padding: 8px;
  width: 36px;
}

.lucide {
  height: 17px;
  stroke-width: 2;
  width: 17px;
}

.login-screen {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.brand-mark {
  align-items: center;
  background: var(--accent-soft);
  border-radius: 6px;
  color: var(--accent-strong);
  display: inline-flex;
  font-weight: 800;
  height: 40px;
  justify-content: center;
  margin-bottom: 18px;
  width: 40px;
}

.login-panel h1,
.view-title h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 8px;
}

.login-panel p,
.view-title p {
  color: var(--muted);
  margin: 0;
}

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

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

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

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.error-box {
  background: var(--red-soft);
  border: 1px solid #e5b8b4;
  border-radius: 6px;
  color: var(--red);
  display: none;
  padding: 10px 12px;
}

.error-box.is-visible {
  display: block;
}

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

.sidebar {
  background: #21313c;
  color: #f6fbfb;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 16px;
}

.sidebar-brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.sidebar-brand .brand-mark {
  background: #d5f1eb;
  color: #15525b;
  margin: 0;
}

.sidebar-brand strong {
  display: block;
  line-height: 1.1;
}

.sidebar-brand span {
  color: #b9c7ca;
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-button {
  background: transparent;
  border-color: transparent;
  color: #dce7e8;
  justify-content: flex-start;
  width: 100%;
}

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

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 66px;
  padding: 14px 22px;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.topbar-user span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.view-head {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

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

.metrics-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

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

.metric strong {
  display: block;
  font-size: 26px;
  margin-top: 4px;
}

.dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.settings-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

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

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.panel-header h2 {
  font-size: 16px;
  margin: 0;
}

.panel-body {
  padding: 16px;
}

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.filters .wide {
  grid-column: span 2;
}

.filters .checkline {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding-top: 23px;
}

.filters .checkline.compact,
.settings-form .checkline.compact {
  padding-top: 0;
}

.filters .checkline input {
  min-height: auto;
  width: auto;
}

.filter-actions {
  align-items: end;
  display: flex;
  gap: 8px;
}

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

.settings-form.user-create-form {
  align-items: end;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  margin-bottom: 16px;
}

.settings-form button,
.settings-form .message-box {
  align-self: end;
}

.settings-table {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.message-box {
  color: var(--muted);
  font-size: 13px;
  min-height: 20px;
}

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

table {
  border-collapse: collapse;
  min-width: 820px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tbody tr:hover {
  background: #f9fbfb;
}

.row-title {
  color: var(--text);
  font-weight: 700;
}

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

.nowrap {
  white-space: nowrap;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 9px;
}

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

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

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

.status-neutral {
  background: #e9edf0;
  color: #53616b;
}

.pager {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 16px;
}

.empty-state,
.loading-state {
  color: var(--muted);
  padding: 26px;
  text-align: center;
}

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

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-row-header {
  display: flex;
  font-size: 13px;
  justify-content: space-between;
}

.bar-track {
  background: #e8eeee;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.bar-fill {
  background: var(--accent);
  height: 100%;
}

.drawer {
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 40px rgba(31, 50, 55, 0.12);
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-width: 620px;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(105%);
  transition: transform 0.18s ease;
  width: min(620px, 100vw);
  z-index: 30;
}

.drawer.is-open {
  transform: translateX(0);
}

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

.drawer-header h2 {
  font-size: 18px;
  margin: 0;
}

.drawer-content {
  overflow: auto;
  padding: 16px;
}

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

.detail-item {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.detail-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
}

.detail-section {
  margin-top: 22px;
}

.detail-section h3 {
  font-size: 15px;
  margin: 0 0 10px;
}

.mini-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.mini-row {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 12px;
}

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

details {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 22px;
}

summary {
  cursor: pointer;
  font-weight: 700;
  padding: 12px;
}

pre {
  background: #f8faf9;
  border-top: 1px solid var(--border);
  color: #26343f;
  font-size: 12px;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

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

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

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

  .sidebar {
    position: static;
  }

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

  .content {
    padding: 16px;
  }

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

  .metrics-grid,
  .dashboard-grid,
  .settings-grid,
  .settings-form,
  .settings-form.user-create-form,
  .filters,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .filters .wide {
    grid-column: span 1;
  }
}
