:root {
  color-scheme: dark;
  --bg: #0f1012;
  --card: #17191e;
  --card-2: #1d2026;
  --sidebar: #0b0c0f;
  --sidebar-2: #12141a;
  --border: #2a2f38;
  --text: #eef1f4;
  --muted: #aeb7c2;
  --field: #101216;
  --orange: #ff8c1a;
  --orange-2: #ffa53d;
  --orange-3: #e37200;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #38bdf8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Sans 3", Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}

body {
  overflow-x: hidden;
}

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

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--orange-3), var(--orange));
  color: #111;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.secondary {
  border: 1px solid var(--border);
  background: #1a1d23;
  color: var(--text);
}

button.warn {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.34);
}

button.danger {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.34);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 0.2rem rgba(255, 140, 26, 0.16);
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 28% 16%, rgba(255, 140, 26, 0.12), transparent 28%),
    var(--bg);
}

.login-panel,
.panel,
.metric-card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--orange-3), var(--orange));
  color: #101114;
  font-weight: 950;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 1.5rem;
}

.brand-lockup p,
.sidebar-brand span,
.metric-card p,
.topbar .eyebrow {
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  background: var(--bg);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  border-right: 1px solid #1d2128;
}

.sidebar-brand {
  min-height: 78px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-menu {
  display: grid;
  gap: 6px;
  padding: 14px 10px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 750;
}

.sidebar-menu a.active {
  background: linear-gradient(90deg, var(--orange-3), var(--orange));
  color: #fff;
}

.sidebar-menu a:hover {
  background: rgba(255, 140, 26, 0.1);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  color: #ffb25b;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.86rem;
}

.app-main {
  min-width: 0;
  padding: 22px 24px 44px;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 20px;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: 1.55rem;
}

.eyebrow {
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 800;
}

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

.metric-card {
  min-height: 132px;
  padding: 20px;
  border-color: rgba(255, 140, 26, 0.12);
}

.metric-card span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 2.25rem;
  line-height: 1;
}

.metric-card p {
  margin-bottom: 0;
}

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

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

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

.panel-heading h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  font-size: 1.08rem;
}

form.panel {
  display: grid;
  gap: 12px;
}

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

.check {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--text);
}

.check input {
  min-height: auto;
}

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

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

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

th {
  background: #1b1f26;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #15181e;
}

.card h3 {
  margin-bottom: 8px;
}

.card p,
.audit p {
  color: var(--muted);
  margin-bottom: 8px;
}

.audit {
  display: grid;
  gap: 8px;
}

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

.error {
  min-height: 20px;
  color: #fca5a5;
  margin-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #101216;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.status span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status.on {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.14);
}

.status.on span {
  background: var(--green);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.36);
}

.status.off {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.14);
}

.status.off span {
  background: var(--blue);
}

.status.offline {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.14);
}

.status.offline span {
  background: var(--red);
}

small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar-menu {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar-footer {
    display: none;
  }

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

@media (max-width: 760px) {
  .app-main {
    padding: 18px 14px 36px;
  }

  .sidebar-menu,
  .stats-grid,
  .grid,
  .cols {
    grid-template-columns: 1fr;
  }

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