:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #121e30;
  --panel2: #18263a;
  --border: #263750;
  --text: #edf4fc;
  --muted: #91a2b8;
  --accent: #42d6c5;
  --accent-dark: #153f43;
  --danger: #ff7777;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.error { color: var(--danger); min-height: 20px; font-size: 13px; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 0%, #1b3850 0%, transparent 55%),
    var(--bg);
}

.auth-card {
  width: min(100%, 410px);
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(18, 30, 48, .96);
  box-shadow: 0 24px 80px #0005;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 17px;
  color: #071b24;
  background: var(--accent);
  font-size: 30px;
  font-weight: 900;
}

.brand-name {
  text-align: center;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: .5px;
}

.auth-card > .muted {
  text-align: center;
  margin: 8px 0 28px;
}

label {
  display: block;
  margin: 17px 0 8px;
  color: #c7d4e5;
  font-size: 13px;
  font-weight: 600;
}

input, select {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  color: var(--text);
  background: #0d1828;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #42d6c51c;
}

.primary, .secondary {
  min-height: 43px;
  padding: 10px 17px;
  border-radius: 10px;
  font-weight: 700;
  transition: .18s ease;
}

.primary {
  color: #06211f;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.primary:hover { background: #65e6d8; transform: translateY(-1px); }
.secondary {
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
}
.secondary:hover { border-color: var(--accent); }
.full { width: 100%; margin-top: 23px; }

.text-button {
  display: block;
  margin: 16px auto 0;
  padding: 8px;
  color: var(--accent);
  background: none;
  border: 0;
}

.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  width: 250px;
  padding: 27px 17px 20px;
  background: #101b2b;
  border-right: 1px solid var(--border);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 9px 35px;
  font-size: 20px;
}

.brand-mark.small {
  width: 35px;
  height: 35px;
  margin: 0;
  border-radius: 11px;
  font-size: 21px;
}

.side-caption, .eyebrow {
  color: #71869f;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.side-caption { padding: 0 11px 13px; }

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 12px;
  margin: 3px 0;
  color: #a9b8ca;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
}

.nav:hover, .nav.active {
  color: var(--accent);
  background: #1a3040;
  border-color: #244653;
}

.side-bottom {
  margin-top: auto;
  padding: 17px 10px 0;
  border-top: 1px solid var(--border);
}

.user-email {
  margin: 7px 0 15px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.logout {
  width: 100%;
  padding: 10px;
  color: #e5a1a1;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
}
.logout:hover { background: #39232b; }

.main {
  min-height: 100vh;
  margin-left: 250px;
  padding: 35px clamp(22px, 4vw, 58px) 60px;
  max-width: 1600px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 28px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--border);
}

h1 { margin: 7px 0 0; font-size: 27px; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0 0 10px; }

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  color: #a9c5c4;
  background: #142d31;
  border: 1px solid #28504e;
  border-radius: 30px;
  font-size: 12px;
}
.status span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}

.welcome {
  padding: 30px;
  margin-bottom: 34px;
  border: 1px solid #294b5b;
  border-radius: var(--radius);
  background: linear-gradient(115deg, #183447, #17253b 65%, #17243a);
}
.welcome h2 { margin: 12px 0 8px; font-size: 25px; }
.welcome p { margin-bottom: 0; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 30px 0 17px;
}
.section-heading p { margin: 6px 0 0; font-size: 13px; }

.summary-grid, .quick-grid, .plans-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}

.panel, .stat-card, .quick-card, .plan-card {
  padding: 21px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.summary-card .value {
  margin: 9px 0;
  font-size: 25px;
  font-weight: 800;
}
.summary-card .caption { color: var(--muted); font-size: 12px; }

.quick-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 145px;
  color: var(--text);
  text-align: left;
}
.quick-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.quick-icon { color: var(--accent); font-size: 24px; }
.quick-card .muted { font-size: 12px; }

.plans-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.plan-card { position: relative; }
.plan-card h3 { font-size: 17px; }
.plan-price { margin: 17px 0 5px; font-size: 30px; font-weight: 850; }
.plan-period { color: var(--muted); font-size: 12px; }
.plan-devices { margin: 18px 0; color: #c5d4e5; font-size: 13px; }
.plan-card button { width: 100%; }

.request-row, .device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.request-row:last-child, .device-row:last-child { border-bottom: 0; }
.request-info { min-width: 0; }
.request-info b, .request-info span { display: block; }
.request-info span { margin-top: 5px; color: var(--muted); font-size: 12px; }

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 30px;
  color: #b8c7d8;
  background: #253449;
  font-size: 11px;
  white-space: nowrap;
}
.pill.active, .pill.approved { color: #8ce5d8; background: #163b3b; }
.pill.pending { color: #f1d18a; background: #41351e; }
.pill.rejected, .pill.expired, .pill.cancelled { color: #f0a0a0; background: #42252d; }

.device-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 14px;
  margin-top: 15px;
}
.device-form label { margin-top: 0; }
.device-form button { margin-top: 17px; }

.empty {
  padding: 27px 10px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.loading { color: var(--muted); }
.toast {
  position: fixed;
  right: 25px;
  bottom: 25px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 18px;
  color: var(--text);
  background: #1c3445;
  border: 1px solid #3b6570;
  border-radius: 11px;
  box-shadow: 0 10px 35px #0006;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 950px) {
  .sidebar { width: 205px; }
  .main { margin-left: 205px; }
  .summary-grid, .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .device-form { grid-template-columns: 1fr 1fr; }
  .device-form button { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .sidebar {
    position: sticky;
    inset: 0 0 auto;
    width: 100%;
    height: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .side-brand { padding: 0 5px 10px; }
  .side-caption, .side-bottom { display: none; }
  .sidebar .nav {
    display: inline-flex;
    width: auto;
    padding: 9px 10px;
    margin: 0 2px;
    font-size: 12px;
  }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-brand { width: 100%; }
  .main { margin-left: 0; padding: 22px 16px 45px; }
  .topbar { align-items: flex-start; }
  h1 { font-size: 23px; }
  .status { padding: 7px 9px; font-size: 10px; }
  .welcome { padding: 22px; }
  .welcome h2 { font-size: 21px; }
  .summary-grid, .quick-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; }
  .plans-grid { grid-template-columns: 1fr; }
  .device-form { grid-template-columns: 1fr; }
  .device-form button { grid-column: auto; }
  .request-row, .device-row { align-items: flex-start; }
  .auth-card { padding: 27px 22px; }
}
