/* Account portal stylesheet. Hand-written on purpose: the portal is small,
   ships zero third-party CSS, and must not touch the admin Tailwind build. */

:root {
  --blue: #3772a3;
  --blue-dark: #244c6e;
  --blue-tint: #eaf1f7;
  --yellow: #f7c600;
  --ink: #1a2733;
  --muted: #5b6b7a;
  --line: #dfe6ec;
  --bg: #f4f6f8;
  --card: #ffffff;
  --green: #1a7f4b;
  --green-bg: #e5f5ec;
  --red: #b91c1c;
  --red-bg: #fdecec;
  --amber: #92600a;
  --amber-bg: #fdf3dd;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(26, 39, 51, .08);
  --focus: 0 0 0 3px rgba(55, 114, 163, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

h1, h2, h3 { color: var(--blue-dark); line-height: 1.25; }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 16px; }
h3 { font-size: 16px; margin: 0 0 10px; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(26, 39, 51, .04);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; text-decoration: none; flex: none; }
.brand-logo { height: 38px; width: auto; display: block; }
.portal-tag {
  color: var(--blue-dark); background: var(--blue-tint);
  border-radius: 999px; padding: 3px 12px;
  font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
}
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; }
.topbar-email { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; flex: none;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--blue-dark); cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.nav-toggle:focus-visible { outline: none; box-shadow: var(--focus); }

.preview-banner {
  background: var(--amber-bg); color: var(--amber);
  text-align: center; font-size: 13px; font-weight: 600;
  padding: 7px 16px; border-bottom: 1px solid #eed9a9;
}

/* ── Buttons, inputs ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  font: inherit; font-weight: 600; padding: 9px 16px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not([disabled]) { background: var(--blue-dark); }
.btn-ghost { background: transparent; color: var(--blue); border-color: var(--line); }
.btn-ghost:hover:not([disabled]) { border-color: var(--blue); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not([disabled]) { background: #8f1414; }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: var(--line); }
.btn-danger-ghost:hover:not([disabled]) { border-color: var(--red); background: var(--red-bg); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }

input[type="text"], input[type="email"], input[type="tel"], select, textarea {
  width: 100%; padding: 9px 12px; margin: 4px 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--blue); box-shadow: var(--focus);
}
textarea { min-height: 130px; resize: vertical; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.code-input {
  letter-spacing: 8px; font-size: 22px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Boot / login ────────────────────────────────────────────────────── */
.boot { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--blue-tint); border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .skeleton { animation: none; }
}

.login { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.login-card {
  width: 100%; max-width: 420px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px;
}
.login-sub { color: var(--muted); margin: 0 0 18px; }
.login-tabs {
  display: flex; gap: 4px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 4px;
  margin: 4px 0 18px;
}
.login-tab {
  flex: 1; border: none; border-radius: 6px; padding: 7px 10px;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--muted);
}
.login-tab.active { background: var(--card); color: var(--blue-dark); box-shadow: var(--shadow); }
.login-tab:focus-visible { outline: none; box-shadow: var(--focus); }
.login-links { margin: 14px 0 0; font-size: 14px; text-align: center; }
.login-links a { text-decoration: none; }
.dot-sep { color: var(--line); margin: 0 6px; }
.login-foot {
  margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px; text-align: center;
}

.alert { border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-top: 14px; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-warn { background: var(--amber-bg); color: var(--amber); }
.alert-info { background: var(--blue-tint); color: var(--blue-dark); }

/* ── App layout ──────────────────────────────────────────────────────── */
.app {
  flex: 1; width: 100%; max-width: 1100px; margin: 0 auto;
  display: flex; gap: 28px; padding: 28px 20px 56px; align-items: flex-start;
}
.sidenav {
  width: 210px; flex: none; position: sticky; top: 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; text-decoration: none;
  color: var(--ink); font-weight: 500; font-size: 14px;
}
.nav-ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; opacity: .75;
}
.nav-item:hover { background: var(--blue-tint); color: var(--blue-dark); }
.nav-item.active { background: var(--blue); color: #fff; font-weight: 600; }
.nav-item.active .nav-ico { opacity: 1; }
.nav-mobile-extra { display: none; }
.content { flex: 1; min-width: 0; }
.section { animation: fadein .15s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.section-head { margin-bottom: 18px; }
.section-head h2 { margin-bottom: 2px; }
.section-sub { margin: 0; color: var(--muted); font-size: 14px; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.card-title { font-size: 16px; font-weight: 700; color: var(--blue-dark); margin: 0; }
.card-sub { color: var(--muted); font-size: 13px; margin: 0; }
.card-row { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 8px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.kv { min-width: 120px; }
.kv .k { display: block; font-size: 12px; color: var(--muted); }
.kv .v { font-weight: 600; font-size: 14px; }

.badge {
  display: inline-block; border-radius: 999px; padding: 2px 10px;
  font-size: 12px; font-weight: 700; vertical-align: middle;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-tint); color: var(--blue-dark); }
.badge-gray { background: #eef1f4; color: var(--muted); }

.license-key {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  background: var(--blue-tint); border-radius: 8px; padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px;
  word-break: break-all;
}
.copy-btn {
  border: none; background: var(--card); color: var(--blue);
  border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 700;
  cursor: pointer; flex: none;
}
.copy-btn:hover { color: var(--blue-dark); }
.copy-btn:focus-visible { outline: none; box-shadow: var(--focus); }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ── Devices ─────────────────────────────────────────────────────────── */
.devices-box { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.devices-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px;
}
.devices-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.devices-slots { font-size: 12px; color: var(--muted); }
.devices-slots.full { color: var(--amber); font-weight: 700; }
.device-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 6px; background: #fbfcfd;
}
.device-name {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.device-meta { color: var(--muted); font-size: 12px; margin-left: auto; flex: none; }
.device-row .btn { flex: none; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line); }
tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--blue-tint); }

/* ── Forms ───────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26, 39, 51, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60;
}
.modal {
  background: var(--card); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.2);
  width: 100%; max-width: 460px; padding: 22px 24px; max-height: 90vh; overflow-y: auto;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── Toasts ──────────────────────────────────────────────────────────── */
.toast-region { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 70; }
.toast {
  background: var(--blue-dark); color: #fff; border-radius: 8px;
  padding: 10px 16px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  animation: fadein .2s ease;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }

/* ── Skeletons ───────────────────────────────────────────────────────── */
.skeleton-stack { display: flex; flex-direction: column; gap: 12px; }
.skeleton {
  height: 88px; border-radius: var(--radius);
  background: linear-gradient(90deg, #e8edf2 25%, #f3f6f9 50%, #e8edf2 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
.skeleton.short { height: 48px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Empty states / footer ───────────────────────────────────────────── */
.empty {
  text-align: center; color: var(--muted); padding: 36px 16px;
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
}
.foot {
  border-top: 1px solid var(--line); background: var(--card);
  color: var(--muted); font-size: 13px;
}
.foot-inner {
  max-width: 1100px; margin: 0 auto; padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px 24px; flex-wrap: wrap;
}
.foot-brand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.foot-company { color: var(--ink); font-weight: 600; }
.foot-sep { color: var(--line); }
.foot-links { display: flex; gap: 18px; flex-wrap: wrap; }
.foot-links a { color: var(--muted); text-decoration: none; }
.foot-links a:hover { color: var(--blue-dark); text-decoration: underline; }

/* ── Mobile ──────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .app { flex-direction: column; gap: 0; padding: 14px 12px 40px; }
  /* The sidenav becomes a hamburger-opened dropdown panel under the topbar. */
  .nav-toggle { display: inline-flex; }
  .nav-toggle.hidden { display: none; }
  .topbar-right { display: none; }
  .sidenav {
    display: none; position: fixed; top: 62px; left: 10px; right: 10px;
    z-index: 55; width: auto;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: 0 10px 30px rgba(26, 39, 51, .18);
    padding: 8px; flex-direction: column;
  }
  .sidenav.open { display: flex; }
  .nav-item { font-size: 14px; padding: 11px 12px; }
  .nav-mobile-extra {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 12px 4px;
  }
  .nav-mobile-email {
    color: var(--muted); font-size: 13px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
  }
  .brand-logo { height: 30px; }
  .portal-tag { display: none; }
  .device-meta { display: none; }
  th, td { padding: 9px 10px; }
  .foot-inner { flex-direction: column; align-items: flex-start; }
}
