/* Nuvio Customer Portal — mobile-first, theme-aware. */

:root {
  color-scheme: light dark;

  --purple: #6d40e8;
  --purple-press: #5b32cf;
  --purple-soft: rgba(109, 64, 232, 0.12);
  --green: #2fb457;
  --amber: #eba30c;
  --red: #e8453c;

  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --border: #e4e4e9;
  --text: #17171c;
  --text-muted: #6c6c78;
  --text-faint: #9a9aa6;
  --shadow: 0 1px 2px rgba(16, 16, 24, .06), 0 8px 24px rgba(16, 16, 24, .05);

  --radius: 14px;
  --radius-lg: 18px;
  --nav-h: 62px;
  --pad: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0b0b0e;
  --surface: #141419;
  --surface-2: #1b1b21;
  --border: #26262e;
  --text: #f3f3f6;
  --text-muted: #9a9aa6;
  --text-faint: #6a6a76;
  --purple-soft: rgba(124, 77, 255, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0e;
    --surface: #141419;
    --surface-2: #1b1b21;
    --border: #26262e;
    --text: #f3f3f6;
    --text-muted: #9a9aa6;
    --text-faint: #6a6a76;
    --purple-soft: rgba(124, 77, 255, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--purple); text-decoration: none; }

/* ---------- shell ---------- */

#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  padding: 0 var(--pad) calc(var(--nav-h) + 28px);
  max-width: 560px; width: 100%; margin: 0 auto;
}

.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px var(--pad) 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  max-width: 560px; margin: 0 auto; width: 100%;
}
.appbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; letter-spacing: -.02em; }
.appbar .brand svg { width: 26px; height: 26px; }
.appbar .spacer { flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; color: var(--text-muted);
}
.icon-btn:active { background: var(--surface-2); }

.page-title { font-size: 27px; font-weight: 700; letter-spacing: -.03em; margin: 4px 0 14px; }
.section-title { font-size: 15px; font-weight: 650; margin: 20px 0 9px; letter-spacing: -.01em; }
.subtle { color: var(--text-muted); font-size: 13px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 12px var(--pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  max-width: 560px; margin: 0 auto; width: 100%;
}
.topbar .title { font-weight: 650; font-size: 17px; flex: 1; text-align: center; }
.topbar .title + .icon-btn, .topbar .icon-btn:first-child { flex: none; }
.topbar .ghost { width: 36px; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 10px; }
.card-pad { padding: 14px; }

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; width: 100%; text-align: left;
  background: var(--surface);
}
.row + .row { border-top: 1px solid var(--border); }
.row:active { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .label { font-weight: 550; }
.row .sub { font-size: 12.5px; color: var(--text-muted); }
.chev { color: var(--text-faint); flex: none; }

/* ---------- status ---------- */

.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.s-operational { --sc: var(--green); }
.s-degraded    { --sc: var(--amber); }
.s-outage      { --sc: var(--red); }
.s-maintenance { --sc: var(--purple); }
.s-unknown     { --sc: var(--text-faint); }

.badge.s-operational, .badge.s-degraded, .badge.s-outage, .badge.s-maintenance, .badge.s-unknown {
  color: var(--sc);
  background: color-mix(in srgb, var(--sc) 12%, transparent);
  border-color: color-mix(in srgb, var(--sc) 26%, transparent);
}
.status-dot.s-operational, .status-dot.s-degraded, .status-dot.s-outage,
.status-dot.s-maintenance, .status-dot.s-unknown { background: var(--sc); }

.state-icon {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 700;
  background: var(--sc);
}
.state-icon.s-unknown { color: var(--text); }

.overview-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.overview-head h1 { flex: 1; margin: 0; font-size: 25px; font-weight: 700; letter-spacing: -.03em; }

.product-body { border-top: 1px solid var(--border); background: var(--surface-2); }
.group { padding: 12px 14px; }
.group + .group { border-top: 1px solid var(--border); }
.group-head { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 13.5px; }
.comp-list { margin: 9px 0 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.comp {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--text);
}
.comp .sub { font-size: 12px; color: var(--text-muted); }

.expand { transition: transform .18s ease; color: var(--text-faint); }
.expand.open { transform: rotate(90deg); }

/* ---------- buttons ---------- */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 16px; border-radius: 12px;
  font-weight: 620; font-size: 15px;
  background: var(--purple); color: #fff;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.985); background: var(--purple-press); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.outline { background: transparent; color: var(--purple); border: 1px solid color-mix(in srgb, var(--purple) 40%, transparent); }
.btn.danger { background: transparent; color: var(--red); }
.btn.small { width: auto; padding: 9px 14px; font-size: 13.5px; border-radius: 10px; }

/* ---------- inputs ---------- */

.field { display: block; margin-bottom: 12px; }
.field .lbl { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.input, .select {
  width: 100%; padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 11px;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); }
.input::placeholder { color: var(--text-faint); }

.search-row { display: flex; gap: 9px; align-items: center; margin-bottom: 12px; }
.search-wrap { position: relative; flex: 1; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.search-wrap .input { padding-left: 38px; border-radius: 12px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 15px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13.5px; font-weight: 550; color: var(--text);
}
.chip.active { background: var(--purple); border-color: var(--purple); color: #fff; }

.seg {
  display: flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 3px; gap: 3px; margin-bottom: 14px;
}
.seg button { flex: 1; padding: 9px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.seg button.active { background: var(--purple); color: #fff; }

/* ---------- toggles ---------- */

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--border); transition: background .18s ease; pointer-events: none;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .18s ease; pointer-events: none;
}
.switch input:checked ~ .track { background: var(--green); }
.switch input:checked ~ .thumb { transform: translateX(18px); }

/* ---------- bottom nav ---------- */

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-faint); font-size: 10.5px; font-weight: 550;
}
.nav button.active { color: var(--purple); }
.nav svg { width: 21px; height: 21px; }

/* ---------- avatars ---------- */

.avatar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.avatar-cell {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); border: 2px solid transparent;
}
.avatar-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-cell.selected { border-color: var(--purple); }
.avatar-cell .gif-tag {
  position: absolute; right: 5px; top: 5px; font-size: 9px; font-weight: 700;
  padding: 2px 5px; border-radius: 5px; background: rgba(0,0,0,.6); color: #fff;
}

.preview-wrap { display: grid; place-items: center; padding: 8px 0 16px; }
.preview {
  width: 168px; height: 168px; border-radius: 50%;
  object-fit: cover; background: var(--surface-2);
  border: 1px solid var(--border);
}

.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid transparent; outline: 1px solid var(--border);
}
.swatch.active { border-color: var(--surface); outline: 2px solid var(--purple); }

.slider-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.slider-row .lbl { width: 62px; font-size: 12.5px; color: var(--text-muted); flex: none; }
input[type="range"] { flex: 1; accent-color: var(--purple); }

.profile-strip { display: flex; gap: 14px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.profile-strip::-webkit-scrollbar { display: none; }
.profile-pick { flex: none; width: 60px; text-align: center; }
.profile-pick .pic {
  width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 5px;
  background: var(--surface-2); border: 2px solid transparent;
  display: grid; place-items: center; overflow: hidden; font-weight: 650; color: var(--text-muted);
}
.profile-pick .pic img { width: 100%; height: 100%; object-fit: cover; }
.profile-pick.active .pic { border-color: var(--purple); }
.profile-pick .nm { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-pick.active .nm { color: var(--text); }

/* ---------- misc ---------- */

.kv { display: flex; justify-content: space-between; align-items: center; padding: 13px 14px; gap: 12px; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv .k { color: var(--text-muted); font-size: 14px; }
.kv .v { font-weight: 600; }

.timeline { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 11px; }
.timeline li { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.timeline .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.timeline .t { color: var(--text-muted); width: 74px; flex: none; }

.notice { display: flex; gap: 10px; padding: 13px 14px; border-radius: var(--radius); font-size: 13.5px; }
.notice.warn { background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--text); }
.notice.err  { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--text); }
.notice.info { background: var(--purple-soft); color: var(--text); }

.empty { text-align: center; padding: 46px 20px; color: var(--text-muted); }
.empty svg { color: var(--text-faint); margin-bottom: 10px; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner.dark { border-color: var(--border); border-top-color: var(--purple); }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 10px;
}
@keyframes sh { to { background-position: -200% 0; } }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0; padding: 8px var(--pad) calc(20px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto; animation: rise .22s ease;
}
.sheet .handle { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 6px auto 14px; }
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(24px) } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%);
  z-index: 60; background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 550;
  box-shadow: 0 6px 24px rgba(0,0,0,.3); animation: rise .2s ease;
  max-width: calc(100% - 32px); text-align: center;
}

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { display: flex; align-items: center; justify-content: center; gap: 9px; font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.login-card .brand svg { width: 34px; height: 34px; }

.steps { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 7px; font-size: 13.5px; }
.steps li { padding-left: 3px; }

.hidden { display: none !important; }
