:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #151515;
  --panel-2: #202020;
  --text: #f7f7f7;
  --muted: #b9b9b9;
  --line: #3a3a3a;
  --red: #b00010;
  --red-2: #ed1c24;
  --gold: #d8aa45;
  --silver: #d9dde2;
  --danger: #d84a4a;
  --ok: #35c275;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -180px, rgba(176, 0, 16, 0.58), transparent 420px),
    linear-gradient(180deg, #0a0a0a 0%, #151515 48%, #090909 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button,
a.primary-btn,
a.secondary-btn,
a.danger-btn {
  min-height: 44px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(216, 170, 69, 0.28);
  background: rgba(9, 9, 9, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(216, 170, 69, 0.7);
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(237, 28, 36, 0.95), rgba(176, 0, 16, 0.74)),
    #161616;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-family: Georgia, serif;
  font-weight: 900;
}

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

.brand small {
  color: var(--gold);
}

.nav-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-links a,
.login-link,
.quick-links a {
  text-decoration: none;
}

.nav-links a {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
}

.nav-links a.active,
.nav-links a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.auth-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.user-pill {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--silver);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero-band,
.page-heading,
.login-layout {
  padding: 34px;
  border: 1px solid rgba(216, 170, 69, 0.24);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(176, 0, 16, 0.34), rgba(18, 18, 18, 0.94) 58%),
    var(--panel);
  box-shadow: var(--shadow);
}

.public-hero {
  background:
    linear-gradient(135deg, rgba(176, 0, 16, 0.5), rgba(18, 18, 18, 0.9) 54%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 18px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 42px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

h3 {
  margin-bottom: 4px;
  font-size: 20px;
}

.muted-text,
.page-heading p,
.hero-band p,
.login-copy p {
  color: var(--muted);
}

.stat-grid,
.file-grid,
.split-layout,
.form-grid {
  display: grid;
  gap: 16px;
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin: 18px 0;
}

.stat-card,
.file-card,
.create-panel,
.panel-form,
.quick-links,
.admin-row,
.auth-panel,
.empty-state {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(21, 21, 21, 0.92);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 20px;
}

.stat-card span {
  display: block;
  color: var(--muted);
}

.stat-card strong {
  color: var(--gold);
  font-size: 34px;
}

.split-layout {
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
}

.panel-form,
.quick-links,
.create-panel,
.admin-row,
.empty-state,
.auth-panel {
  padding: 22px;
}

.metric-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  align-items: center;
  margin: 18px 0;
  padding: 22px;
  border: 1px solid rgba(216, 170, 69, 0.2);
  border-radius: var(--radius);
  background: rgba(21, 21, 21, 0.92);
  box-shadow: var(--shadow);
}

.chart-list {
  display: grid;
  gap: 14px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.36fr) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.chart-row span,
.device-row span {
  display: block;
}

.chart-row strong {
  color: var(--gold);
  font-size: 22px;
}

progress {
  width: 100%;
  height: 18px;
  overflow: hidden;
  border: 1px solid rgba(216, 170, 69, 0.28);
  border-radius: 999px;
  background: #0b0b0b;
}

progress::-webkit-progress-bar {
  background: #0b0b0b;
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--red), var(--gold));
}

progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.quick-links {
  display: grid;
  align-content: start;
  gap: 10px;
}

.quick-links a {
  padding: 12px;
  border: 1px solid rgba(216, 170, 69, 0.22);
  border-radius: 8px;
  color: var(--silver);
  background: rgba(255, 255, 255, 0.04);
}

.file-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.file-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.file-topline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.badge.ok {
  color: #08140d;
  background: var(--ok);
}

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

.button-row,
.row-actions,
.copy-row,
.auth-box,
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: white;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
}

.primary-btn {
  background: linear-gradient(180deg, var(--red-2), var(--red));
}

.secondary-btn {
  color: #151515;
  background: linear-gradient(180deg, #f3d88d, var(--gold));
}

.danger-btn {
  background: var(--danger);
}

.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

.full {
  width: 100%;
}

label {
  display: grid;
  gap: 7px;
  color: var(--silver);
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.34);
}

input[type="file"] {
  padding: 8px;
}

.copy-row {
  align-items: stretch;
}

.copy-row input {
  flex: 1 1 280px;
}

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

.wide {
  grid-column: 1 / -1;
}

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

.admin-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

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

.device-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.7fr) minmax(150px, 0.5fr);
  gap: 14px;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(21, 21, 21, 0.92);
  box-shadow: var(--shadow);
}

.device-row strong {
  overflow-wrap: anywhere;
}

.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.row-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.row-delete {
  margin-top: 12px;
}

.edit-details summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 800;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 800;
}

.notice-ok {
  color: #07140d;
  background: var(--ok);
}

.notice-error {
  background: #5c1212;
  color: white;
}

.login-layout {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 380px);
  gap: 24px;
  align-items: center;
  min-height: 58vh;
}

.auth-panel {
  display: grid;
  gap: 14px;
  background: rgba(0, 0, 0, 0.28);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #151515;
  background: var(--gold);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .site-header {
    grid-template-columns: 1fr;
  }

  .nav-links {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .auth-box {
    justify-content: flex-start;
  }

  .stat-grid,
  .file-grid,
  .split-layout,
  .login-layout,
  .metric-panel,
  .form-grid,
  .row-form,
  .device-row,
  .chart-row {
    grid-template-columns: 1fr;
  }

  .hero-band,
  .page-heading,
  .login-layout {
    padding: 24px;
  }

  h1 {
    font-size: 34px;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .site-header {
    padding: 12px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }

  .button-row,
  .row-actions,
  .copy-row,
  .priority-strip {
    align-items: stretch;
  }

  .button-row > *,
  .row-actions > *,
  .copy-row > * {
    width: 100%;
  }
}
