:root {
  color-scheme: dark;
  --background: #09090b;
  --foreground: #fafafa;
  --muted: #a1a1aa;
  --muted-2: #71717a;
  --panel: #171923;
  --panel-soft: rgba(23, 25, 35, 0.72);
  --border: rgba(255, 255, 255, 0.12);
  --accent: #47a3f3;
  --accent-strong: #7cc7ff;
  --danger: #f87171;
  --ok: #7dd3a8;
  --warning: #facc15;
  --radius: 8px;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.top-rule {
  min-height: 3px;
  background: #093054;
}

.nav-bar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 4vw, 3rem);
  background: var(--panel);
}

.brand,
.nav-bar nav {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  color: var(--foreground);
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  object-fit: cover;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) 0 4rem;
}

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

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

h1 {
  max-width: 720px;
  margin-bottom: 0.55rem;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0.3rem;
  font-size: 1.12rem;
  line-height: 1.2;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.status-pill,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--foreground);
  font-size: 0.8rem;
  font-weight: 700;
}

.status-pill.is-on,
.pill.active {
  border-color: rgba(125, 211, 168, 0.36);
  color: var(--ok);
}

.pill.expired,
.pill.cancelled,
.pill.arrived {
  color: var(--muted);
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: clamp(1rem, 2vw, 1.35rem);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 1rem;
}

.subscriptions-panel {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-grid {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--foreground);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 2.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(9, 9, 11, 0.78);
  color: var(--foreground);
  padding: 0.65rem 0.75rem;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(71, 163, 243, 0.8);
  box-shadow: 0 0 0 3px rgba(71, 163, 243, 0.16);
}

.primary-button,
.secondary-button,
.link-button,
.danger-button {
  min-height: 2.45rem;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
}

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

.secondary-button {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--foreground);
}

.link-button {
  min-height: auto;
  background: transparent;
  color: var(--foreground);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.danger-button {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.stack-list {
  display: grid;
  gap: 0.55rem;
}

.list-item {
  display: grid;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.035);
}

.list-title {
  font-weight: 800;
}

.list-meta {
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

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

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

th,
td {
  padding: 0.85rem 0.7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  color: var(--foreground);
}

.route {
  display: grid;
  gap: 0.15rem;
  font-weight: 800;
}

.muted {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.empty-state {
  display: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 1rem;
  color: var(--muted);
}

.empty-state.is-visible {
  display: block;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(420px, calc(100% - 2rem));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #11131b;
  color: var(--foreground);
  padding: 0.9rem 1rem;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.34);
}

.toast.is-error {
  border-color: rgba(248, 113, 113, 0.38);
}

@media (max-width: 840px) {
  .intro,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-grid,
  .field-row {
    grid-template-columns: 1fr;
  }

  .status-panel {
    flex-wrap: wrap;
    white-space: normal;
  }
}
