:root {
  --bg: #050607;
  --bg-2: #090c0f;
  --panel: #0b0f13;
  --panel-2: #11161b;
  --panel-3: #151015;
  --line: rgba(255, 42, 64, .34);
  --line-soft: rgba(255, 255, 255, .09);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, .58);
  --muted-2: rgba(255, 255, 255, .36);
  --red: #ff263f;
  --red-2: #b80f24;
  --amber: #f5a524;
  --green: #00d084;
  --cyan: #43d9ff;
  --radius: 8px;
  --shadow: 0 12px 34px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(180deg, #0b0608 0, var(--bg) 42%, #030405 100%);
  background-size: 44px 44px, 44px 44px, auto;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea {
  font: inherit;
  border-radius: 6px;
}

button {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #11161b, #090c0f);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 11px;
}

button:hover { border-color: var(--red); box-shadow: 0 0 0 1px rgba(255, 38, 63, .22); }
button:disabled { opacity: .42; cursor: default; box-shadow: none; }

input, textarea, select {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 42, 64, .28);
  background: #05080b;
  color: var(--text);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(255, 38, 63, .16);
}

textarea { min-height: 84px; resize: vertical; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.hidden { display: none !important; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.ok { color: var(--green); }
.bad { color: var(--red); }
.warn { color: var(--amber); }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card {
  width: min(430px, calc(100vw - 40px));
  min-height: 500px;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 40px;
  background: linear-gradient(180deg, rgba(17, 22, 27, .94), rgba(6, 8, 10, .96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 4px 0 0 var(--red);
}

.auth-card h1 {
  margin: 18px 0 0;
  text-align: center;
  font-size: 24px;
  letter-spacing: 0;
}

.auth-card p,
.auth-card small {
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.logo-mark,
.rail-logo {
  justify-self: center;
  width: max-content;
  max-width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--red);
  background: rgba(255, 38, 63, .12);
  color: var(--text);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: .08em;
  text-transform: uppercase;
  box-shadow: 0 0 24px rgba(255, 38, 63, .22);
}

.primary {
  border-color: var(--red);
  background: linear-gradient(180deg, #ff334c, #bf1127);
  color: white;
  box-shadow: 0 10px 22px rgba(255, 38, 63, .22);
}

.ghost {
  background: #080b0f;
  color: #fff;
}

.portal,
.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.admin { min-height: 100vh; }

.rail {
  padding: 18px 12px;
  background: linear-gradient(180deg, #0d1116, #06080a);
  border-right: 1px solid var(--line);
}

.rail-logo {
  margin: 0 auto 28px;
  font-size: 10px;
}

.rail span {
  display: block;
  margin: 0 10px 9px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: .14em;
}

.rail a,
.rail .nav {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  margin: 3px 0;
  padding: 0 12px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, .76);
  text-align: left;
  border-radius: 6px;
}

.rail a.active,
.rail .nav.active {
  background: rgba(255, 38, 63, .14);
  border-color: rgba(255, 38, 63, .42);
  color: var(--text);
}

.content {
  min-width: 0;
  background: rgba(3, 5, 7, .82);
}

.bar {
  min-height: 60px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 15, .95);
}

.page {
  padding: 30px;
}

.page h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.page > p {
  margin: 8px 0 24px;
  color: var(--muted);
}

.notice {
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid rgba(0, 208, 132, .34);
  background: rgba(0, 208, 132, .08);
  border-radius: var(--radius);
  color: var(--green);
  font-weight: 800;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.card,
.plan,
.model-card,
.table-card,
.form-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  padding: 18px;
  border-left: 4px solid var(--red);
}

.card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 1000;
  text-transform: uppercase;
}

.card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.license-details,
.device-row,
.table-card {
  padding: 18px;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}

.row:last-child { border-bottom: 0; }
.row span { color: var(--muted); }
.row strong { text-align: right; }

.badge,
.chip,
.plan-kicker {
  width: max-content;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 1000;
  text-transform: uppercase;
}

.badge {
  background: rgba(0, 208, 132, .12);
  color: var(--green);
}

.badge.locked {
  background: rgba(245, 165, 36, .14);
  color: var(--amber);
}

.chip {
  display: inline-block;
  margin: 0 8px 8px 0;
  background: rgba(255, 255, 255, .08);
  color: rgba(255,255,255,.78);
}

.plans {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 18px;
}

.plan {
  min-height: 318px;
  display: grid;
  align-content: start;
  gap: 11px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.plan::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--red);
}

.plan.featured {
  border-color: rgba(245, 165, 36, .58);
}

.plan.featured::before {
  background: var(--amber);
}

.plan h2 {
  margin: 4px 0 0;
  font-size: 19px;
}

.plan-kicker {
  background: rgba(255, 38, 63, .12);
  color: #ff8d9b;
}

.price {
  margin: 4px 0;
  font-size: 36px;
  font-weight: 1000;
}

.price small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 13px;
}

.plan-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

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

.model-card {
  min-height: 160px;
  padding: 18px;
}

.model-card.locked {
  opacity: .58;
}

.model-card h3 {
  margin: 10px 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.form-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-left: 4px solid var(--red);
}

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

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

th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 1000;
  text-transform: uppercase;
}

td {
  color: rgba(255, 255, 255, .86);
}

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

.actions button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 10px;
}

.model-admin {
  display: grid;
  gap: 14px;
}

.model-admin .model-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px 150px;
  gap: 14px;
  align-items: start;
}

.danger {
  border-color: rgba(255, 38, 63, .58);
  background: rgba(255, 38, 63, .08);
  color: #ff99a5;
}

@media (max-width: 1180px) {
  .plans {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
  .cards {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 960px) {
  .portal,
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .rail {
    position: static;
  }
  .plans,
  .cards,
  .admin-grid,
  .model-admin .model-card {
    grid-template-columns: 1fr;
  }
  .page {
    padding: 20px;
  }
}
