@import url("https://fonts.googleapis.com/css2?family=Sriracha&display=swap");

:root {
  --bg: #eef4f9;
  --panel: #ffffff;
  --text: #10213f;
  --muted: #6a7b93;
  --line: #dbe5ef;
  --blue-700: #234bb7;
  --blue-600: #2f63d6;
  --cyan-500: #18b7d7;
  --green-500: #28cb88;
  --amber-500: #ffb320;
  --red-500: #ef5d59;
  --hero-gradient: linear-gradient(135deg, #2648b4 0%, #2358ba 42%, #15b8d7 100%);
  --shadow-panel: 0 18px 40px rgba(19, 37, 72, 0.1);
  --shadow-hero: 0 24px 52px rgba(29, 60, 126, 0.18);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(24, 183, 215, 0.1), transparent 24%),
    radial-gradient(circle at top left, rgba(47, 99, 214, 0.12), transparent 22%),
    linear-gradient(180deg, #f7fafc 0%, var(--bg) 100%);
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

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

.hidden {
  display: none !important;
}

.admin-app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 28px 44px;
}

.auth-shell,
.admin-shell {
  display: grid;
  gap: 24px;
}

.auth-hero {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 30px 32px;
  border-radius: var(--radius-xl);
  color: #fff;
  background: var(--hero-gradient);
  box-shadow: var(--shadow-hero);
}

.brand-mark {
  width: auto;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff;
}

.brand-mark svg,
.brand-mark img {
  width: clamp(170px, 24vw, 240px);
  height: auto;
  display: block;
  object-fit: contain;
}

.brand-mark img {
  filter: drop-shadow(0 12px 24px rgba(11, 33, 76, 0.28));
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}

.auth-brand .brand-mark img,
.auth-brand .brand-mark svg {
  width: clamp(58px, 7vw, 78px);
}

.brand-wordmark {
  font-family: "Sriracha", "Segoe UI Variable", "Trebuchet MS", cursive;
  font-size: clamp(40px, 5vw, 62px);
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 12px 24px rgba(11, 33, 76, 0.22);
}

.eyebrow {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.88;
}

.auth-hero h1 {
  font-size: clamp(30px, 3.2vw, 42px);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.hero-copy {
  max-width: 760px;
  margin-top: 10px;
  font-size: 17px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.96);
}

.auth-card,
.panel,
.overview-card {
  background: var(--panel);
  box-shadow: var(--shadow-panel);
}

.auth-card {
  padding: 26px;
  border-radius: var(--radius-xl);
}

.auth-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  background: #edf3fb;
}

.auth-tab {
  min-height: 44px;
  min-width: 180px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--blue-700);
  background: #fff;
  box-shadow: 0 10px 18px rgba(20, 37, 72, 0.08);
}

.auth-panel {
  margin-top: 22px;
}

.auth-helper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

.auth-helper a {
  color: var(--blue-700);
  font-weight: 800;
  text-decoration: none;
}

.auth-helper a:hover {
  text-decoration: underline;
}

.auth-helper-smile {
  font-size: 18px;
  line-height: 1;
}

.flash {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid transparent;
}

.flash.info {
  background: #eef8ff;
  border-color: #b6def8;
  color: #22507e;
}

.flash.warning {
  background: #fff8eb;
  border-color: #ffd88d;
  color: #835a00;
}

.flash.danger {
  background: #fff2f2;
  border-color: #ffbcb9;
  color: #a43632;
}

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

.form-grid.compact {
  margin-top: 14px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.form-grid input {
  min-height: 54px;
  width: 100%;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  background: #fbfdff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-grid input:disabled {
  color: #8a98ad;
  background: #f1f5fa;
  cursor: not-allowed;
}

.form-grid input:focus {
  border-color: #74c7ef;
  box-shadow: 0 0 0 5px rgba(87, 193, 234, 0.15);
}

.choice-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.choice-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.choice-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-pill span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.choice-pill span::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #9eb0c7;
  background: #fff;
  box-shadow: inset 0 0 0 4px #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.choice-pill:has(input:checked) {
  border-color: #74c7ef;
  background: #ffffff;
  box-shadow: 0 0 0 5px rgba(87, 193, 234, 0.12);
}

.choice-pill:has(input:checked) span::before {
  border-color: var(--blue-600);
  background: var(--blue-600);
  box-shadow: inset 0 0 0 4px #eef8ff;
}

.full-row {
  grid-column: 1 / -1;
}

.primary-button,
.ghost-button,
.device-threshold {
  border: none;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.primary-button:hover,
.ghost-button:hover,
.device-threshold:hover {
  transform: translateY(-1px);
}

.primary-button {
  min-height: 54px;
  padding: 0 20px;
  border-radius: 16px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #234db8 0%, #16b6d4 100%);
  box-shadow: 0 14px 28px rgba(37, 82, 191, 0.22);
}

.ghost-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  color: var(--blue-700);
  font-weight: 700;
  background: #eef4fb;
}

.ghost-button.danger {
  color: #b83632;
  background: #fff0f0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 28px 30px;
  border-radius: var(--radius-xl);
  color: #fff;
  background: var(--hero-gradient);
  box-shadow: var(--shadow-hero);
}

.topbar h2 {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.muted {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.92);
}

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

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

.overview-card {
  padding: 24px 22px;
  border-radius: 22px;
}

.overview-label {
  display: block;
  color: var(--muted);
  font-size: 15px;
}

.overview-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(34px, 3vw, 48px);
  line-height: 1;
  letter-spacing: -0.05em;
}

.analytics-helper {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
}

.panel {
  padding: 24px;
  border-radius: 24px;
}

.full-width {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head h3 {
  font-size: 28px;
  letter-spacing: -0.03em;
}

.panel-head p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.panel-head.compact {
  margin-bottom: 14px;
}

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

.info-item {
  padding: 16px 18px;
  border-radius: 18px;
  background: #f7fafc;
  border: 1px solid #e4edf5;
}

.info-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.info-item strong {
  font-size: 16px;
  line-height: 1.45;
}

.pairing-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f8fcff 0%, #eef7ff 100%);
  border: 1px solid #cfe4f7;
}

.pairing-result strong {
  display: block;
  font-size: 18px;
}

.devices-list {
  display: grid;
  gap: 16px;
}

.device-card-admin {
  padding: 20px 20px 18px;
  border-radius: 20px;
  border: 1px solid #e4edf5;
  background: #fbfdff;
}

.device-card-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.device-card-top h4 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.device-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef5fb;
  color: var(--blue-700);
  font-size: 13px;
  font-weight: 700;
}

.device-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-500);
}

.device-badge.warning {
  background: #fff5e8;
  color: #b96b00;
}

.device-badge.warning::before {
  background: var(--amber-500);
}

.ghost-button.is-active {
  color: #18724d;
  background: #eaf8f0;
}

.ghost-button.is-blocked {
  color: #9a4b14;
  background: #fff2e3;
}

.expiring-banner {
  margin-top: -4px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 700;
  line-height: 1.55;
}

.expiring-banner.info {
  background: #eef8ff;
  border-color: #b6def8;
  color: #22507e;
}

.expiring-banner.warning {
  background: #fff8eb;
  border-color: #ffd88d;
  color: #835a00;
}

.expiring-alert-list {
  display: grid;
  gap: 14px;
}

.expiring-alert-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid #e4edf5;
  background: linear-gradient(180deg, #fbfdff 0%, #f6fbff 100%);
}

.expiring-alert-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.expiring-alert-main strong {
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.expiring-alert-meta {
  color: var(--muted);
  line-height: 1.5;
}

.expiring-alert-date {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: #eef5fb;
  color: var(--blue-700);
  font-size: 13px;
  font-weight: 800;
}

.device-thresholds {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  margin-top: 16px;
  border-radius: 15px;
  background: #edf3fb;
}

.device-threshold {
  min-height: 40px;
  min-width: 88px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 700;
  background: transparent;
}

.device-threshold.active {
  color: var(--blue-700);
  background: #fff;
  box-shadow: 0 10px 18px rgba(19, 37, 72, 0.08);
}

.device-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff8eb;
  border: 1px solid #ffd88d;
  color: #845900;
  font-size: 14px;
  line-height: 1.5;
}

.device-note strong {
  display: inline;
}

.analytics-shell {
  display: grid;
  gap: 18px;
}

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

.analytics-column {
  min-width: 0;
}

.analytics-list {
  display: grid;
  gap: 14px;
}

.analytics-item {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid #e4edf5;
  background: linear-gradient(180deg, #fbfdff 0%, #f6fbff 100%);
}

.recommendation-card.priority-high {
  border-color: #ffd0c8;
  background: linear-gradient(180deg, #fff8f7 0%, #fff2ef 100%);
}

.recommendation-card.priority-medium {
  border-color: #ffe4a8;
  background: linear-gradient(180deg, #fffdf8 0%, #fff8e8 100%);
}

.recommendation-card.priority-low {
  border-color: #d6efe6;
  background: linear-gradient(180deg, #fbfffd 0%, #f1faf6 100%);
}

.analytics-item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.analytics-item-top strong {
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.analytics-copy {
  margin-top: 14px;
  color: var(--text);
  line-height: 1.55;
}

.analytics-copy strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}

.analytics-copy p {
  color: var(--muted);
}

.analytics-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  color: var(--muted);
  background: #f7fafc;
  border: 1px dashed #cdd9e5;
}

@media (max-width: 1160px) {
  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .admin-app {
    padding: 16px;
  }

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

  .form-grid,
  .pairing-result {
    grid-template-columns: 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .expiring-alert-card {
    flex-direction: column;
  }

  .panel-head-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .analytics-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
  }

  .ghost-button,
  .primary-button {
    width: 100%;
  }
}
