:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-soft: #f1f6fa;
  --ink: #0f172a;
  --muted: #64748b;
  --muted-dark: #475569;
  --line: #e2e8f0;
  --navy: #071a2f;
  --navy-soft: #102842;
  --navy-card: #132d49;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --accent-light: #38bdf8;
  --green: #16c98d;
  --green-soft: #e5fbf3;
  --amber: #f3b63f;
  --amber-soft: #fff7df;
  --red: #ee6474;
  --red-soft: #fff0f2;
  --violet: #8b5cf6;
  --shadow-sm: 0 8px 25px rgba(15, 23, 42, .06);
  --shadow-md: 0 22px 60px rgba(15, 23, 42, .12);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

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

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
.is-hidden { display: none !important; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: var(--accent);
  background: linear-gradient(145deg, #e0f6ff, #f4fbff);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, .12);
}

.brand-mark svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.brand-mark svg rect { fill: rgba(14, 165, 233, .16); }
.brand-copy { display: grid; line-height: 1; }
.brand-copy strong { font-family: Onest, "Segoe UI", sans-serif; font-size: 22px; letter-spacing: .03em; }
.brand-copy small { margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.eyebrow > span { width: 22px; height: 2px; border-radius: 999px; background: var(--accent); }

/* Login */
.login-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr);
  align-items: center;
  min-height: 100vh;
  padding: 70px max(6vw, 48px);
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 15%, rgba(56, 189, 248, .10), transparent 29%),
    linear-gradient(120deg, #fbfdff 0%, #f7fbfe 52%, #eef7fc 100%);
}

.login-shell::after {
  position: absolute;
  right: -8vw;
  bottom: -28vh;
  width: 58vw;
  height: 58vw;
  border: 1px solid rgba(14, 165, 233, .10);
  border-radius: 50%;
  content: "";
}

.login-ambient { position: absolute; border-radius: 50%; filter: blur(1px); pointer-events: none; }
.login-ambient-one { top: 8%; right: 28%; width: 180px; height: 180px; background: rgba(56, 189, 248, .08); }
.login-ambient-two { bottom: 9%; left: 35%; width: 260px; height: 260px; background: rgba(22, 201, 141, .055); }

.login-intro { position: relative; z-index: 1; max-width: 680px; padding-right: 7vw; }
.login-intro .brand { margin-bottom: clamp(70px, 10vh, 120px); }
.login-intro .eyebrow { margin-bottom: 20px; }

.login-intro h1 {
  max-width: 660px;
  margin: 0;
  color: var(--ink);
  font-family: Onest, "Segoe UI", sans-serif;
  font-size: clamp(44px, 5.2vw, 78px);
  font-weight: 750;
  letter-spacing: -.055em;
  line-height: 1.03;
}

.login-intro h1 em { display: block; color: transparent; background: linear-gradient(105deg, var(--accent-dark), var(--accent-light)); background-clip: text; font-style: normal; }
.login-intro > p { max-width: 600px; margin: 28px 0 0; color: var(--muted-dark); font-size: 18px; line-height: 1.75; }
.intro-badges { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 42px; }
.intro-badges span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted-dark); font-size: 13px; font-weight: 650; }
.intro-badges i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(22, 201, 141, .11); }

.login-card-wrap { position: relative; z-index: 2; width: min(100%, 530px); justify-self: end; }

.login-card {
  position: relative;
  padding: clamp(36px, 4vw, 58px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 32px;
  color: #fff;
  background:
    radial-gradient(circle at 100% 0, rgba(56, 189, 248, .13), transparent 35%),
    linear-gradient(145deg, #0c223a, #07182b 74%);
  box-shadow: 0 35px 90px rgba(7, 26, 47, .25);
}

.login-card::after {
  position: absolute;
  right: -65px;
  bottom: -85px;
  width: 240px;
  height: 240px;
  border: 1px solid rgba(56, 189, 248, .10);
  border-radius: 50%;
  content: "";
}

.login-icon { display: grid; width: 50px; height: 50px; margin-bottom: 29px; place-items: center; border-radius: 15px; color: var(--accent-light); background: rgba(14, 165, 233, .13); }
.login-icon svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.panel-label { color: var(--accent-light); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.login-card h2 { position: relative; margin: 11px 0 10px; font-family: Onest, "Segoe UI", sans-serif; font-size: 31px; letter-spacing: -.035em; }
.login-card > p { position: relative; margin: 0 0 30px; color: #9fb0c2; font-size: 14px; line-height: 1.65; }
.login-card > label:not(.remember-row) { display: block; margin-bottom: 9px; color: #bdcad7; font-size: 11px; font-weight: 800; letter-spacing: .08em; }

.password-field { position: relative; z-index: 1; }
.password-field input {
  width: 100%;
  height: 56px;
  padding: 0 52px 0 17px;
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: 13px;
  outline: 0;
  color: #eef8ff;
  background: rgba(255, 255, 255, .055);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.password-field input::placeholder { color: #70849a; }
.password-field input:focus { border-color: var(--accent); background: rgba(255, 255, 255, .08); box-shadow: 0 0 0 4px rgba(14, 165, 233, .12); }
.password-field button { position: absolute; top: 7px; right: 7px; display: grid; width: 42px; height: 42px; padding: 0; place-items: center; border: 0; border-radius: 10px; color: #8296aa; background: transparent; }
.password-field button:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.password-field svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.remember-row { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; margin: 15px 0 24px; color: #8fa3b7; font-size: 12px; cursor: pointer; }
.remember-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.primary-button {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 56px;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 28px rgba(14, 165, 233, .25);
  font-weight: 750;
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 16px 35px rgba(14, 165, 233, .32); }
.primary-button:disabled { cursor: wait; opacity: .65; transform: none; }
.primary-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; }
.form-message { position: relative; z-index: 1; min-height: 20px; margin-top: 13px; color: #ff9aa6; font-size: 12px; text-align: center; }

.security-note { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(148, 163, 184, .13); color: #71869b; font-size: 11px; line-height: 1.45; }
.security-note svg { flex: 0 0 auto; width: 20px; fill: none; stroke: var(--green); stroke-width: 1.7; }

.floating-stat { position: absolute; z-index: 3; display: grid; padding: 17px 20px; border: 1px solid rgba(226, 232, 240, .9); border-radius: 17px; background: rgba(255, 255, 255, .95); box-shadow: var(--shadow-md); backdrop-filter: blur(12px); }
.floating-stat-top { top: -34px; left: -56px; }
.floating-stat-top strong { color: var(--accent); font-family: Onest, sans-serif; font-size: 28px; }
.floating-stat-top span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.floating-stat-bottom { right: -30px; bottom: -27px; display: flex; align-items: center; gap: 9px; padding: 14px 18px; color: var(--ink); font-size: 12px; }

.pulse-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(22, 201, 141, .12); }
.pulse-dot::after { position: absolute; inset: -4px; border: 1px solid rgba(22, 201, 141, .35); border-radius: 50%; content: ""; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: .8; transform: scale(.8); } 60% { opacity: 0; transform: scale(1.5); } }

/* Application */
.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; border-bottom: 1px solid rgba(226, 232, 240, .85); background: rgba(255, 255, 255, .91); box-shadow: 0 4px 20px rgba(15, 23, 42, .035); backdrop-filter: blur(18px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; width: min(1440px, calc(100% - 64px)); height: 78px; margin: 0 auto; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.api-state { display: flex; align-items: center; gap: 10px; margin-right: 8px; padding: 9px 13px; border: 1px solid #d9f3e9; border-radius: 999px; color: #147a5b; background: #effcf7; font-size: 12px; font-weight: 700; }
.api-state .pulse-dot { width: 7px; height: 7px; box-shadow: none; }

.icon-button, .logout-button { display: inline-flex; height: 41px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 11px; color: var(--muted-dark); background: #fff; transition: border-color .2s, color .2s, background .2s, transform .2s; }
.icon-button { width: 41px; padding: 0; }
.icon-button:hover, .logout-button:hover { border-color: #b8e7fb; color: var(--accent-dark); background: #f4fbff; transform: translateY(-1px); }
.icon-button.is-loading svg { animation: rotate .8s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }
.logout-button { gap: 8px; padding: 0 14px; font-size: 12px; font-weight: 700; }
.icon-button svg, .logout-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.main-content { width: min(1440px, calc(100% - 64px)); margin: 0 auto; padding: 54px 0 80px; }
.overview-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 35px; }
.overview-heading .eyebrow { margin-bottom: 10px; }
.overview-heading h1 { margin: 0; font-family: Onest, "Segoe UI", sans-serif; font-size: clamp(30px, 3vw, 46px); letter-spacing: -.045em; }
.overview-heading p { margin: 10px 0 0; color: var(--muted); font-size: 15px; }
.update-stamp { display: grid; justify-items: end; min-width: 260px; }
.update-stamp span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.update-stamp strong { margin-top: 4px; font-family: Onest, sans-serif; font-size: 17px; }
.update-stamp small { margin-top: 4px; color: #94a3b8; font-size: 10px; }

.summary-grid { display: grid; grid-template-columns: 1.16fr repeat(3, 1fr); gap: 18px; margin-bottom: 54px; }
.summary-card { position: relative; display: grid; grid-template-columns: auto 1fr; min-height: 154px; align-items: center; gap: 17px; padding: 26px; overflow: hidden; border: 1px solid #e7edf3; border-radius: 20px; background: #fff; box-shadow: var(--shadow-sm); }
.summary-card > div:nth-child(2) { display: grid; }
.summary-card span { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .055em; text-transform: uppercase; }
.summary-card strong { margin: 6px 0 3px; font-family: Onest, "Segoe UI", sans-serif; font-size: 32px; letter-spacing: -.03em; }
.summary-card strong.summary-time { font-size: 20px; }
.summary-card small { color: #94a3b8; font-size: 11px; }
.summary-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 15px; color: var(--accent); background: #eaf8fe; }
.summary-icon.success { color: var(--green); background: var(--green-soft); }
.summary-icon.danger { color: var(--red); background: var(--red-soft); }
.summary-icon.info { color: var(--violet); background: #f3efff; }
.summary-icon svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.summary-primary { border: 0; color: #fff; background: linear-gradient(140deg, #102c49, #081b30); box-shadow: 0 18px 45px rgba(7, 26, 47, .18); }
.summary-primary::after { position: absolute; right: -60px; bottom: -90px; width: 220px; height: 220px; border: 1px solid rgba(56, 189, 248, .12); border-radius: 50%; content: ""; }
.summary-primary span, .summary-primary small { color: #9eb2c6; }
.summary-primary .summary-icon { color: var(--accent-light); background: rgba(56, 189, 248, .12); }
.summary-spark { position: absolute; right: 22px; bottom: 25px; display: flex; height: 32px; align-items: end; gap: 4px; opacity: .75; }
.summary-spark i { width: 6px; border-radius: 3px 3px 1px 1px; background: linear-gradient(to top, var(--accent-dark), var(--accent-light)); }
.summary-spark i:nth-child(1) { height: 12px; }.summary-spark i:nth-child(2) { height: 25px; }.summary-spark i:nth-child(3) { height: 17px; }.summary-spark i:nth-child(4) { height: 29px; }.summary-spark i:nth-child(5) { height: 20px; }.summary-spark i:nth-child(6) { height: 31px; }

.devices-section { padding-top: 4px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 22px; }
.section-heading > div:first-child { display: flex; align-items: center; gap: 12px; }
.section-heading h2 { margin: 0; font-family: Onest, sans-serif; font-size: 24px; letter-spacing: -.025em; }
.count-badge { padding: 5px 9px; border-radius: 999px; color: var(--accent-dark); background: #e9f7fe; font-size: 10px; font-weight: 750; }
.toolbar { display: flex; align-items: center; gap: 12px; }
.search-field { position: relative; display: block; }
.search-field svg { position: absolute; top: 12px; left: 13px; width: 18px; fill: none; stroke: #94a3b8; stroke-width: 1.8; }
.search-field input { width: 300px; height: 43px; padding: 0 14px 0 40px; border: 1px solid var(--line); border-radius: 11px; outline: 0; color: var(--ink); background: #fff; font-size: 12px; transition: border-color .2s, box-shadow .2s; }
.search-field input:focus, .select-field select:focus { border-color: #7dd3fc; box-shadow: 0 0 0 4px rgba(14, 165, 233, .09); }
.select-field { display: flex; height: 43px; align-items: center; gap: 7px; padding-left: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.select-field span { color: #94a3b8; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.select-field select { height: 100%; padding: 0 31px 0 2px; border: 0; outline: 0; color: var(--muted-dark); background: transparent; font-size: 12px; font-weight: 650; }

.device-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.device-card { position: relative; min-width: 0; padding: 24px; overflow: hidden; border: 1px solid #e6edf3; border-radius: var(--radius); background: #fff; box-shadow: 0 9px 30px rgba(15, 23, 42, .055); transition: transform .22s, border-color .22s, box-shadow .22s; }
.device-card:hover { transform: translateY(-3px); border-color: #bde8fa; box-shadow: 0 19px 45px rgba(15, 23, 42, .09); }
.device-card-accent { position: absolute; top: 0; right: 26px; left: 26px; height: 2px; border-radius: 0 0 999px 999px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .75; }
.device-card.is-offline .device-card-accent { background: linear-gradient(90deg, transparent, #94a3b8, transparent); }
.device-card.is-attention .device-card-accent { background: linear-gradient(90deg, transparent, var(--amber), transparent); }
.device-card.is-revoked { opacity: .72; }
.device-card.is-revoked .device-card-accent { background: linear-gradient(90deg, transparent, var(--red), transparent); }
.device-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.device-identity { display: flex; min-width: 0; align-items: center; gap: 12px; }
.device-identity > div:last-child { min-width: 0; }
.device-identity h3 { overflow: hidden; margin: 0 0 4px; font-family: Onest, sans-serif; font-size: 16px; letter-spacing: -.015em; text-overflow: ellipsis; white-space: nowrap; }
.device-identity p { overflow: hidden; margin: 0; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.device-avatar { position: relative; display: grid; flex: 0 0 auto; width: 43px; height: 43px; place-items: center; border-radius: 14px; color: var(--accent); background: #eaf8fe; }
.device-avatar::before { width: 14px; height: 24px; border: 2px solid currentColor; border-radius: 4px; content: ""; }
.device-avatar::after { position: absolute; bottom: 12px; width: 4px; height: 2px; border-radius: 4px; background: currentColor; content: ""; }
.device-avatar.type-tv_box::before, .device-avatar.type-android_tv::before { width: 25px; height: 17px; border-radius: 4px; }
.device-avatar.type-tv_box::after, .device-avatar.type-android_tv::after { bottom: 10px; width: 12px; height: 2px; }
.device-avatar.type-tablet::before { width: 20px; height: 26px; }
.device-avatar.large { width: 56px; height: 56px; border-radius: 17px; }
.device-avatar.large::before { transform: scale(1.15); }

.status-pill { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid #d6f4e8; border-radius: 999px; color: #11815e; background: #effcf7; font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.status-pill b { font-weight: 800; }
.status-pill.offline { border-color: #e2e8f0; color: #64748b; background: #f8fafc; }
.status-pill.offline i { background: #94a3b8; }
.status-pill.attention { border-color: #f9e7b8; color: #a36e09; background: var(--amber-soft); }
.status-pill.attention i { background: var(--amber); }
.status-pill.revoked { border-color: #ffd6dc; color: #b43d4b; background: var(--red-soft); }
.status-pill.revoked i { background: var(--red); }

.device-tags { display: flex; gap: 7px; margin: 19px 0; }
.device-tags span { overflow: hidden; max-width: 50%; padding: 5px 8px; border-radius: 7px; color: var(--muted-dark); background: #f2f6f9; font-size: 9px; font-weight: 700; letter-spacing: .035em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.compact-metrics { display: grid; gap: 13px; padding: 17px; border-radius: 14px; background: #f7fafc; }
.compact-metrics > div { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 5px 12px; }
.compact-metrics span { color: var(--muted); font-size: 10px; }
.compact-metrics strong { font-size: 11px; }
.compact-metrics i { grid-column: 1 / -1; height: 4px; overflow: hidden; border-radius: 99px; background: #e4ebf1; }
.compact-metrics b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-dark), var(--accent-light)); }
.compact-metrics > div:nth-child(3) b { background: linear-gradient(90deg, #16a975, var(--green)); }
.compact-metrics b.is-warning { background: linear-gradient(90deg, #e7a62c, var(--amber)); }
.compact-metrics b.is-danger { background: linear-gradient(90deg, #db4355, var(--red)); }
.bar-0 { width: 0; }.bar-5 { width: 5%; }.bar-10 { width: 10%; }.bar-15 { width: 15%; }.bar-20 { width: 20%; }
.bar-25 { width: 25%; }.bar-30 { width: 30%; }.bar-35 { width: 35%; }.bar-40 { width: 40%; }.bar-45 { width: 45%; }
.bar-50 { width: 50%; }.bar-55 { width: 55%; }.bar-60 { width: 60%; }.bar-65 { width: 65%; }.bar-70 { width: 70%; }
.bar-75 { width: 75%; }.bar-80 { width: 80%; }.bar-85 { width: 85%; }.bar-90 { width: 90%; }.bar-95 { width: 95%; }.bar-100 { width: 100%; }
.device-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.last-seen { display: grid; min-width: 0; }
.last-seen span { color: #94a3b8; font-size: 9px; text-transform: uppercase; }
.last-seen strong { overflow: hidden; margin-top: 3px; color: var(--muted-dark); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.details-button { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; color: var(--accent-dark); background: none; font-size: 10px; font-weight: 800; }
.details-button:hover { color: var(--accent); }
.details-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 2; }

.empty-state { display: grid; min-height: 310px; place-items: center; align-content: center; padding: 45px; border: 1px dashed #cbd5e1; border-radius: var(--radius); text-align: center; }
.empty-state > div { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 18px; color: var(--accent); background: #eaf8fe; }
.empty-state svg { width: 27px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.empty-state h3 { margin: 17px 0 5px; font-family: Onest, sans-serif; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

.footer { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 25px 30px; border-top: 1px solid var(--line); color: #94a3b8; background: #fff; font-size: 10px; }
.footer a { margin-left: 15px; color: var(--accent-dark); font-weight: 700; text-decoration: none; }

/* Detail dialog */
.device-dialog { width: min(1080px, calc(100% - 32px)); max-width: none; max-height: min(900px, calc(100vh - 32px)); padding: 0; overflow: hidden; border: 0; border-radius: 25px; color: var(--ink); background: #fff; box-shadow: 0 40px 120px rgba(7, 26, 47, .35); }
.device-dialog::backdrop { background: rgba(4, 15, 27, .72); backdrop-filter: blur(5px); }
.dialog-shell { max-height: min(900px, calc(100vh - 32px)); overflow: auto; }
.dialog-header { position: sticky; z-index: 4; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 25px 30px; border-bottom: 1px solid rgba(226, 232, 240, .8); background: rgba(255, 255, 255, .94); backdrop-filter: blur(15px); }
.dialog-title-group { display: flex; align-items: center; gap: 15px; }
.dialog-title-group h2 { margin: 3px 0 3px; font-family: Onest, sans-serif; font-size: 24px; letter-spacing: -.025em; }
.dialog-title-group p { margin: 0; color: var(--muted); font-size: 11px; }
.dialog-kicker { display: flex; align-items: center; gap: 7px; color: #13825f; font-size: 9px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.dialog-kicker > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.dialog-kicker.offline { color: var(--muted); }.dialog-kicker.offline > span:first-child { background: #94a3b8; }
.dialog-kicker.attention { color: #a36e09; }.dialog-kicker.attention > span:first-child { background: var(--amber); }
.dialog-kicker.revoked { color: #b43d4b; }.dialog-kicker.revoked > span:first-child { background: var(--red); }
.dialog-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.management-button { display: inline-flex; height: 40px; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid #cceaf7; border-radius: 11px; color: var(--accent-dark); background: #f2fbff; font-size: 10px; font-weight: 800; transition: border-color .2s, background .2s, transform .2s; }
.management-button:hover { border-color: #8ed8f7; background: #e8f8ff; transform: translateY(-1px); }
.management-button.danger { border-color: #ffd6dc; color: #b43d4b; background: var(--red-soft); }
.management-button.danger:hover { border-color: #f5a8b2; background: #ffe7ea; }
.management-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dialog-close { display: grid; flex: 0 0 auto; width: 40px; height: 40px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: #fff; }
.dialog-close:hover { color: var(--ink); background: #f8fafc; }
.dialog-close svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.dialog-body { display: grid; gap: 36px; padding: 28px 30px 38px; }
.detail-meta { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: #fafcfe; }
.detail-meta > div { min-width: 0; padding: 15px 17px; border-right: 1px solid var(--line); }
.detail-meta > div:last-child { border: 0; }
.detail-meta span { display: block; margin-bottom: 5px; color: #94a3b8; font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-meta strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.detail-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.detail-section-heading span { color: var(--accent-dark); font-size: 9px; font-weight: 800; letter-spacing: .10em; text-transform: uppercase; }
.detail-section-heading h3 { margin: 4px 0 0; font-family: Onest, sans-serif; font-size: 19px; }
.detail-section-heading small { color: #94a3b8; font-size: 9px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.metric-card { position: relative; min-height: 158px; padding: 18px; overflow: hidden; border: 1px solid #e5edf3; border-radius: 16px; background: #fbfdff; }
.metric-card::after { position: absolute; right: -35px; bottom: -50px; width: 100px; height: 100px; border: 1px solid rgba(14, 165, 233, .08); border-radius: 50%; content: ""; }
.metric-card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-card-header > span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.metric-card-icon { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 9px; color: var(--accent); background: #eaf8fe; }
.metric-card-icon svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.metric-card-value { display: flex; align-items: baseline; gap: 4px; margin-top: 15px; }
.metric-card-value strong { font-family: Onest, sans-serif; font-size: 27px; letter-spacing: -.035em; }
.metric-card-value span { color: var(--muted); font-size: 11px; }
.metric-card > p { margin: 6px 0 13px; color: #94a3b8; font-size: 9px; }
.metric-track { height: 5px; overflow: hidden; border-radius: 99px; background: #e6edf3; }
.metric-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-dark), var(--accent-light)); }
.metric-track i.is-warning { background: linear-gradient(90deg, #e7a62c, var(--amber)); }
.metric-track i.is-danger { background: linear-gradient(90deg, #db4355, var(--red)); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.chart-card { min-width: 0; padding: 16px 18px 13px; border: 1px solid #e5edf3; border-radius: 16px; background: #fbfdff; }
.chart-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.chart-card-header span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.chart-card-header strong { font-family: Onest, sans-serif; font-size: 17px; }
.chart-card-header small { color: #94a3b8; font-size: 8px; }
.chart-card svg { display: block; width: 100%; height: 90px; margin-top: 8px; overflow: visible; }
.chart-card .chart-grid-line { stroke: #e8eef3; stroke-width: 1; }
.chart-card .chart-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-card .chart-area { fill: url(#chartGradient); opacity: .18; }
.chart-card .chart-dot { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.chart-loading { grid-column: 1 / -1; display: grid; min-height: 170px; place-items: center; align-content: center; color: var(--muted); }
.chart-loading span { width: 27px; height: 27px; border: 3px solid #dceaf2; border-top-color: var(--accent); border-radius: 50%; animation: rotate .8s linear infinite; }
.chart-loading p { margin: 10px 0 0; font-size: 11px; }
.chart-empty { grid-column: 1 / -1; padding: 35px; border: 1px dashed #cbd5e1; border-radius: 14px; color: var(--muted); text-align: center; font-size: 11px; }
.info-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.info-card { padding: 18px; border: 1px solid #e5edf3; border-radius: 16px; background: #fbfdff; }
.info-card h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 15px; font-family: Onest, sans-serif; font-size: 13px; }
.info-card h4 svg { width: 18px; fill: none; stroke: var(--accent); stroke-width: 1.8; }
.info-row { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; padding: 9px 0; border-top: 1px solid #edf2f6; }
.info-row span { color: var(--muted); font-size: 9px; }
.info-row strong { overflow: hidden; max-width: 65%; font-size: 10px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.map-link { display: inline-flex; align-items: center; gap: 5px; margin-top: 12px; color: var(--accent-dark); font-size: 10px; font-weight: 800; text-decoration: none; }
.map-link:hover { color: var(--accent); }

/* Management confirmation dialogs */
.action-dialog { width: min(500px, calc(100% - 32px)); max-width: none; padding: 0; overflow: hidden; border: 0; border-radius: 23px; color: var(--ink); background: #fff; box-shadow: 0 35px 100px rgba(7, 26, 47, .38); }
.action-dialog::backdrop { background: rgba(4, 15, 27, .56); backdrop-filter: blur(3px); }
.action-dialog-card { padding: 31px; }
.action-dialog-icon { display: grid; width: 48px; height: 48px; margin-bottom: 20px; place-items: center; border-radius: 15px; color: var(--accent-dark); background: #eaf8fe; }
.action-dialog-icon.danger { color: #c44352; background: var(--red-soft); }
.action-dialog-icon svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.action-dialog-card h2 { margin: 9px 0 8px; font-family: Onest, sans-serif; font-size: 25px; letter-spacing: -.03em; }
.action-dialog-card > p { margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.action-dialog-card > label { display: block; margin-bottom: 8px; color: var(--muted-dark); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.action-dialog-card > input { width: 100%; height: 49px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; outline: 0; color: var(--ink); background: #fbfdff; transition: border-color .2s, box-shadow .2s; }
.action-dialog-card > input:focus { border-color: #7dd3fc; box-shadow: 0 0 0 4px rgba(14, 165, 233, .09); }
.danger-card > input:focus { border-color: #f3a2ad; box-shadow: 0 0 0 4px rgba(238, 100, 116, .10); }
.danger-label { color: #c44352; }
.delete-target { display: grid; gap: 4px; margin: 0 0 20px; padding: 13px 15px; border: 1px solid #ffd9de; border-radius: 11px; background: #fff7f8; }
.delete-target span { color: #a46a72; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.delete-target strong { overflow-wrap: anywhere; font-size: 13px; }
.action-message { min-height: 18px; margin-top: 9px; color: #c44352; font-size: 10px; }
.action-dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 17px; }
.primary-button.compact, .secondary-button, .danger-button { width: auto; min-width: 125px; height: 44px; padding: 0 16px; border-radius: 11px; font-size: 11px; font-weight: 800; }
.secondary-button { border: 1px solid var(--line); color: var(--muted-dark); background: #fff; }
.secondary-button:hover { border-color: #cbd5e1; background: #f8fafc; }
.danger-button { border: 0; color: #fff; background: linear-gradient(135deg, #ee6474, #c73f50); box-shadow: 0 10px 24px rgba(199, 63, 80, .20); }
.danger-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 13px 28px rgba(199, 63, 80, .27); }
.danger-button:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(380px, calc(100% - 44px)); padding: 13px 17px; border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px; opacity: 0; color: #fff; background: #102842; box-shadow: var(--shadow-md); font-size: 11px; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: #9f3340; }

@media (max-width: 1180px) {
  .login-shell { grid-template-columns: minmax(0, 1fr) minmax(390px, .8fr); padding-right: 5vw; padding-left: 5vw; }
  .login-intro { padding-right: 5vw; }
  .floating-stat-top { left: -25px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 850px) {
  .login-shell { display: block; padding: 38px 22px 65px; }
  .login-intro { max-width: 620px; padding: 0; }
  .login-intro .brand { margin-bottom: 50px; }
  .login-intro h1 { font-size: clamp(40px, 11vw, 65px); }
  .login-intro > p { font-size: 15px; }
  .login-card-wrap { width: min(100%, 560px); margin: 70px auto 0; justify-self: auto; }
  .floating-stat-top { top: -34px; left: 18px; }
  .floating-stat-bottom { right: 16px; }
  .topbar-inner, .main-content { width: min(100% - 32px, 1440px); }
  .topbar-inner { height: 70px; }
  .api-state span:last-child, .logout-button span { display: none; }
  .api-state { width: 41px; height: 41px; justify-content: center; margin: 0; padding: 0; }
  .logout-button { width: 41px; padding: 0; }
  .overview-heading { align-items: flex-start; }
  .update-stamp { min-width: 190px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .toolbar { width: 100%; }
  .search-field { flex: 1; }
  .search-field input { width: 100%; }
  .info-columns { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .login-intro .eyebrow, .intro-badges { display: none; }
  .login-intro .brand { margin-bottom: 38px; }
  .login-intro h1 { font-size: 42px; }
  .login-intro > p { margin-top: 20px; line-height: 1.6; }
  .login-card-wrap { margin-top: 55px; }
  .login-card { padding: 31px 24px; border-radius: 24px; }
  .floating-stat { display: none; }
  .brand-copy small { display: none; }
  .main-content { padding-top: 35px; }
  .overview-heading { display: block; }
  .overview-heading h1 { font-size: 33px; }
  .overview-heading p { line-height: 1.5; }
  .update-stamp { justify-items: start; margin-top: 22px; }
  .summary-grid { grid-template-columns: 1fr; margin-bottom: 42px; }
  .summary-card { min-height: 130px; }
  .section-heading > div:first-child { align-items: flex-start; flex-direction: column; gap: 8px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .select-field { width: 100%; }
  .select-field select { flex: 1; }
  .device-grid { grid-template-columns: 1fr; }
  .footer { flex-wrap: wrap; }
  .footer a { width: 100%; margin: 2px 0 0; text-align: center; }
  .device-dialog { width: 100%; max-height: 100vh; margin: 0; border-radius: 0; }
  .dialog-shell { max-height: 100vh; }
  .dialog-header { padding: 20px 18px; }
  .dialog-body { padding: 22px 18px 30px; }
  .dialog-title-group h2 { max-width: 200px; overflow: hidden; font-size: 19px; text-overflow: ellipsis; white-space: nowrap; }
  .management-button { width: 40px; padding: 0; justify-content: center; }
  .management-button span { display: none; }
  .action-dialog-card { padding: 25px 21px; }
  .action-dialog-buttons { align-items: stretch; flex-direction: column-reverse; }
  .primary-button.compact, .secondary-button, .danger-button { width: 100%; }
  .detail-meta { grid-template-columns: repeat(2, 1fr); }
  .detail-meta > div:nth-child(2) { border-right: 0; }
  .detail-meta > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metric-grid, .chart-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 145px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
