:root {
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color-scheme: dark;
  --blue: #0b2a5b;
  --green: #2ed47a;
  --ink: #e4eaf2;
  --muted: #a1adbd;
  --line: #374251;
  --divider: #303a48;
  --surface: #252e3b;
  --header-surface: #202833;
  --sidebar-surface: #222c39;
  --raised: #2b3544;
  --input: #323e4e;
  --hover: #303c4c;
  --selected: #304767;
  --link: #93bff0;
  --background: #1c2430;
  --primary: #295d98;
  --primary-hover: #3571b2;
  --secondary: #364558;
  --secondary-hover: #40536a;
  --status-success: #26d18b;
  --status-warning: #e7ac45;
  --status-danger: #e76868;
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

h1, h2, h3, p {
  margin: 0;
}

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  min-height: 100dvh;
}

.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--header-surface);
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}

.hub-pill {
  padding: 3px 8px;
  border-radius: 4px;
  background: #304767;
  color: #cfe3fb;
  font-size: 11px;
  font-weight: 600;
}

.sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--sidebar-surface);
  border-right: 1px solid var(--divider);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  padding: 6px 18px;
  font-size: 11px;
  color: #99a7b9;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 9px 16px;
  border-left: 3px solid transparent;
  text-align: left;
  color: #c7d2df;
  font-size: 13px;
}

.nav-btn:hover {
  background: var(--hover);
}

.nav-btn.active {
  border-left-color: var(--green);
  background: #31435a;
  color: #ecf3fc;
  font-weight: 600;
}

.main {
  grid-column: 2;
  grid-row: 2;
  padding: 24px 28px 40px;
  min-width: 0;
}

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

.page-title h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

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

.button-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.button-secondary {
  background: var(--secondary);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  background: var(--secondary-hover);
}

.button-danger {
  background: #7c2d36;
  color: #fde8e8;
}

.button-danger:hover:not(:disabled) {
  background: #963742;
}

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

.button-ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--ink);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 18px;
}

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

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: #fff;
}

.stat-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

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

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
}

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

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

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

th {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: #354152;
  color: #cbd5e1;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success {
  color: #83d5a9;
  background: #29463c;
}

.badge-warning {
  color: #e6c079;
  background: #4b4130;
}

.badge-danger {
  color: #f0a1a1;
  background: #50363c;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.field label {
  font-size: 12px;
  font-weight: 500;
  color: #cfd8e3;
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--ink);
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.alert {
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 12.5px;
}

.alert-success {
  background: #233f36;
  border: 1px solid #2e6251;
  color: #a9e9c7;
}

.alert-error {
  background: #47282e;
  border: 1px solid #763843;
  color: #f4b6be;
}

.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 28px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 22px;
}

.progress-track {
  height: 8px;
  background: var(--input);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.2s ease;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
  }
  .sidebar {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--divider);
    padding: 8px;
  }
  .nav-section-title {
    display: none;
  }
  .nav-btn {
    width: auto;
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 7px 12px;
  }
  .nav-btn.active {
    border-left-color: transparent;
    border-bottom-color: var(--green);
  }
  .main {
    grid-column: 1;
    grid-row: 3;
    padding: 16px;
  }
}
