:root {
  --bg: #0b0b0b;
  --bg-soft: #141414;
  --panel: #1f1f1f;
  --text: #e5e5e5;
  --muted: #9f9f9f;
  --line: rgba(229, 229, 229, 0.1);
  --blue: #3f83f8;
  --amber: #d19a32;
  --red: #dc2626;
  --accent: #dc2626;
  --accent-dark: #991b1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(220, 38, 38, 0.16), transparent 22%),
    radial-gradient(circle at bottom right, rgba(63, 131, 248, 0.09), transparent 28%),
    var(--bg);
}

button,
input {
  font: inherit;
}

button,
input,
dialog {
  color: var(--text);
}

body.auth-required .app-shell {
  display: none;
}

body.auth-required .auth-shell {
  display: grid;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2rem;
  padding: 2rem 1.4rem;
  color: var(--text);
  border-right: 1px solid rgba(229, 229, 229, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    var(--bg-soft);
}

.brand-lockup {
  min-height: 96px;
  display: grid;
  align-content: center;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-script {
  margin: 0;
  font-family: "Lobster", cursive;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 0.95;
  color: #f4e8b8;
  text-shadow:
    -2px -2px 0 #111,
    2px -2px 0 #111,
    -2px 2px 0 #111,
    2px 2px 0 #111,
    0 8px 18px rgba(0, 0, 0, 0.35);
}

.topbar h2,
.hero-card h3,
.modal h3 {
  margin: 0;
  line-height: 1;
}

.form-note,
.warning-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.nav {
  display: grid;
  gap: 0.75rem;
}

.nav-item {
  padding: 0.85rem 0;
  border: 0;
  color: var(--muted);
  text-align: left;
  background: transparent;
}

.nav-item-active {
  color: #fff;
  font-weight: 700;
}

.main-content {
  padding: 2rem 2.5rem;
}

.page {
  display: none;
}

.page-active {
  display: block;
}

.topbar,
.warning-bar,
.gauges-grid,
.dashboard-data,
.management-tabs,
.hero-card,
.stats-grid,
.panel-grid,
.action-grid {
  margin-bottom: 1.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-dashboard,
.topbar-management {
  min-height: 56px;
}

.page-title {
  color: #fff;
}

.action-strip,
.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.warning-bar,
.hero-card,
.stat-card,
.modal-card,
.auth-card,
.panel {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.warning-bar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem 0 0.3rem;
}

.warning-label {
  margin: 0;
  font-weight: 700;
  color: var(--red);
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.warning-copy {
  max-width: 820px;
}

.gauges-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 1.5rem;
}

.gauge-card {
  display: grid;
  justify-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.gauge-card-clickable {
  text-align: left;
  cursor: pointer;
}

.gauge-card-clickable:hover {
  transform: translateY(-2px);
}

.gauge-mode-label {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.mode-switch-panel {
  display: grid;
  justify-items: end;
}

.mode-switch {
  display: inline-flex;
  padding: 0.24rem;
  border-radius: 999px;
  background: rgba(229, 229, 229, 0.08);
}

.mode-switch-button {
  padding: 0.45rem 0.8rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}

.mode-switch-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.gauge-shell {
  --gauge-color: var(--blue);
  --gauge-progress: 1;
  position: relative;
  width: min(100%, 320px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(12, 12, 12, 0.95) 0 48%, transparent 49% 100%),
    conic-gradient(var(--gauge-color) calc(var(--gauge-progress) * 1turn), rgba(229, 229, 229, 0.1) 0);
  box-shadow:
    inset 0 0 0 11px rgba(0, 0, 0, 0.96),
    inset 0 0 0 26px rgba(255, 255, 255, 0.04),
    0 24px 42px rgba(0, 0, 0, 0.35);
}

.gauge-shell-lg {
  width: min(100%, 390px);
}

.gauge-shell::before {
  content: "";
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.08), transparent 38%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.01)),
    #0f0f10;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.gauge-inner {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.35rem;
  text-align: center;
  padding: 2.4rem;
}

.gauge-label {
  margin: 0;
  color: var(--gauge-color);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gauge-font {
  font-family: "Bangers", cursive;
  letter-spacing: 0.06em;
}

.gauge-value {
  margin: 0;
  color: var(--gauge-color);
  font-size: clamp(3.4rem, 7vw, 5.4rem);
  line-height: 0.9;
}

.gauge-meta {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 1rem;
}

.dashboard-data {
  display: grid;
  gap: 0.8rem;
}

.dashboard-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(229, 229, 229, 0.08);
}

.dashboard-line:last-child {
  border-bottom: 0;
}

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

.dashboard-value {
  text-align: right;
  font-weight: 700;
}

.dashboard-value-soft {
  font-weight: 500;
  color: var(--text);
}

.management-tabs {
  display: inline-flex;
  gap: 0.45rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(229, 229, 229, 0.08);
}

.report-filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
}

.report-filter {
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(229, 229, 229, 0.08);
}

.report-filter-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.management-tab {
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}

.management-tab-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.management-page {
  display: none;
}

.management-page-active {
  display: block;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.hero-card-plain {
  padding: 0;
}

.hero-card h3 {
  font-size: clamp(1.6rem, 3vw, 2.5rem);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

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

.stat-card {
  padding: 0;
}

.stat-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
}

.stat-value {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.3rem);
  font-weight: 700;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 1rem;
}

.panel-grid-single {
  grid-template-columns: 1fr;
}

.panel,
.panel-flat {
  padding: 0;
}

.panel-large {
  min-width: 0;
}

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

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

.action-grid-single {
  grid-template-columns: 1fr;
}

.action-panel {
  display: grid;
  gap: 0.9rem;
}

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

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

th,
td {
  padding: 0.95rem 0.8rem;
  border-bottom: 1px solid rgba(229, 229, 229, 0.08);
  text-align: left;
}

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

.empty-row td {
  color: var(--muted);
  text-align: center;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  padding: 0.95rem 1.2rem;
  border-radius: 999px;
  font-weight: 700;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.secondary-button {
  color: var(--text);
  background: rgba(229, 229, 229, 0.08);
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(229, 229, 229, 0.08);
}

.auth-shell {
  display: none;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  width: min(460px, 100%);
  padding: 0;
}

.auth-card-plain h2 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 4vw, 3rem);
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.modal {
  width: min(560px, calc(100vw - 2rem));
  padding: 0;
  border: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(12, 12, 12, 0.45);
  backdrop-filter: blur(5px);
}

.modal-card {
  width: 100%;
  padding: 1.35rem;
  border: 1px solid rgba(229, 229, 229, 0.08);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    #151515;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.45);
}

.modal-card-plain {
  padding: 1.35rem;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0 1rem;
}

label {
  display: grid;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

input {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(229, 229, 229, 0.12);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

input:focus {
  outline: 2px solid rgba(63, 131, 248, 0.24);
  border-color: rgba(63, 131, 248, 0.5);
}

input::placeholder {
  color: rgba(229, 229, 229, 0.44);
}

.toggle-row {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 1rem;
}

.toggle-button[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.acknowledge-block {
  display: grid;
  gap: 1rem;
  padding: 1.2rem 0;
  text-align: center;
}

.acknowledge-actions {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
}

#dutyWarningGate .warning-label {
  font-size: 1.6rem;
  font-weight: 900;
}

#dutyWarningGate .warning-copy {
  font-size: 1.1rem;
  font-weight: 700;
}

.status-good {
  color: #2a7b5f;
}

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

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

@media (max-width: 1180px) {
  .gauges-grid,
  .stats-grid,
  .panel-grid,
  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gauge-shell-lg {
    width: min(100%, 340px);
  }

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

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

  .sidebar,
  .main-content {
    padding: 1.25rem;
  }

  .topbar,
  .hero-card,
  .modal-actions,
  .action-strip,
  .acknowledge-actions,
  .report-filter-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .gauges-grid,
  .stats-grid,
  .panel-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .management-tabs {
    display: grid;
    border-radius: 24px;
  }

  .dashboard-line {
    flex-direction: column;
    align-items: flex-start;
  }
}
