:root {
  --paper: #fbf8f3;
  --card: #ffffff;
  --ink: #1c1611;
  --muted: #857a6e;
  --faint: #b3a99c;
  --line: #eae3d6;
  --line-soft: #f2ede3;
  --heat: #e8590c;
  --heat-deep: #b93206;
  --amber: #eb9d0e;
  --safe: #1f7a5c;
  --safe-soft: #e3f2ea;
  --warn-soft: #fdf1da;
  --danger-soft: #fde6dc;
  --cool: #3b6ea5;
  --thermal: linear-gradient(90deg, #f2b53a 0%, #e8590c 55%, #b93206 100%);
  --radius: 16px;
  --shadow: 0 1px 2px rgba(28, 22, 17, 0.04), 0 8px 24px -12px rgba(28, 22, 17, 0.12);
  --shadow-lift: 0 2px 4px rgba(28, 22, 17, 0.05), 0 18px 40px -18px rgba(185, 50, 6, 0.22);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Archivo", "Helvetica Neue", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(232, 89, 12, 0.18); }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; }

input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.thermal-strip {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--thermal);
  z-index: 100;
}

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

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 32px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 36px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 2px;
  padding: 0 10px;
}

.brand .word {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand .degree {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--heat);
  transform: translateY(-8px);
  display: inline-block;
}

.brand-sub {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 10px 0;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-label {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 12px;
  margin: 18px 0 8px;
}

.nav-label:first-child { margin-top: 0; }

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav a svg { width: 18px; height: 18px; stroke: currentColor; flex-shrink: 0; }

.nav a:hover { background: var(--paper); color: var(--ink); transform: translateX(2px); }

.nav a[aria-current="page"] {
  background: var(--ink);
  color: #fff;
}

.nav a[aria-current="page"]:hover { transform: none; }

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--thermal);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who strong { display: block; font-size: 13.5px; font-weight: 600; }
.sidebar-foot .who span { font-size: 12px; color: var(--muted); }

.logout {
  background: none;
  border: none;
  color: var(--faint);
  padding: 6px;
  border-radius: 8px;
  transition: color 0.18s ease, background 0.18s ease;
}
.logout svg { width: 17px; height: 17px; stroke: currentColor; display: block; }
.logout:hover { color: var(--heat-deep); background: var(--danger-soft); }

.main {
  padding: 44px 52px 80px;
  max-width: 1180px;
  width: 100%;
}

/* ---------- Page header ---------- */

.page-head { margin-bottom: 36px; }

.crumb {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--heat);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crumb::before {
  content: "";
  width: 22px; height: 2px;
  background: var(--thermal);
  border-radius: 2px;
}

.page-head h1 { font-size: 40px; }

.page-head .lede { color: var(--muted); margin-top: 10px; max-width: 560px; }

.head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.btn:active { transform: translateY(0); }

.btn.hot { background: var(--heat); border-color: var(--heat); }
.btn.hot:hover { background: var(--heat-deep); border-color: var(--heat-deep); }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover { border-color: var(--ink); box-shadow: none; }

.btn.small { padding: 8px 16px; font-size: 13px; }

.btn svg { width: 15px; height: 15px; stroke: currentColor; }

/* ---------- Cards & panels ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card.pad { padding: 28px; }

.panel-title {
  font-size: 19px;
  margin-bottom: 4px;
}

.panel-sub { font-size: 13.5px; color: var(--muted); }

/* ---------- Stat tiles ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }

.stat .k {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.stat .v {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 500;
  line-height: 1.1;
  margin-top: 8px;
}

.stat .v sup { font-size: 20px; color: var(--heat); }

.stat .d { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.stat.alert { border-color: rgba(232, 89, 12, 0.35); background: linear-gradient(180deg, #fff, #fef7f2); }
.stat.alert .v { color: var(--heat-deep); }

/* ---------- Status pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.pill.ok { background: var(--safe-soft); color: var(--safe); }
.pill.warm { background: var(--warn-soft); color: #9a6605; }
.pill.cut { background: var(--danger-soft); color: var(--heat-deep); }
.pill.cut::before { animation: blink 1.4s ease infinite; }
.pill.off { background: var(--line-soft); color: var(--muted); }

@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- Temp bar ---------- */

.temp-bar {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #d8e6d8 0%, #f2b53a 60%, #e8590c 82%, #b93206 100%);
  margin-top: 10px;
}

.temp-bar .marker {
  position: absolute;
  top: 50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  transform: translate(-50%, -50%);
}

.temp-bar .cutline {
  position: absolute;
  top: -5px; bottom: -5px;
  width: 2px;
  background: var(--heat-deep);
  border-radius: 1px;
}

.temp-read {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  white-space: nowrap;
}
.temp-read .deg { color: var(--heat); }

/* ---------- Tables ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }

.table th {
  text-align: left;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tbody tr { transition: background 0.15s ease; }
.table tbody tr:hover { background: var(--paper); }

.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; color: var(--muted); font-size: 13px; }

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
}

.field .hint { font-weight: 400; color: var(--faint); font-size: 12px; }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  font-size: 14.5px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--heat);
  box-shadow: 0 0 0 3px rgba(232, 89, 12, 0.12);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--muted);
}

.check input { accent-color: var(--heat); width: 16px; height: 16px; }

/* ---------- Toggle switch ---------- */

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}
.switch input:checked + .track { background: var(--safe); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* ---------- Range slider ---------- */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #d8e6d8, #f2b53a 55%, #e8590c 80%, #b93206);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--ink);
  cursor: grab;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }

input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--ink);
  cursor: grab;
}

/* ---------- Reveal animations ---------- */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1), transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--d, 0s);
}

.reveal.in { opacity: 1; transform: none; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 80px);
  background: var(--ink);
  color: #fff;
  padding: 13px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(90vw, 480px);
}

.toast::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--thermal);
  flex-shrink: 0;
}

.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Login page ---------- */

.login-wrap {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  min-height: 100vh;
}

.login-brand {
  position: relative;
  overflow: hidden;
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(ellipse 90% 60% at 15% 110%, rgba(242, 181, 58, 0.35), transparent 60%),
    radial-gradient(ellipse 70% 55% at 85% 105%, rgba(232, 89, 12, 0.22), transparent 65%),
    var(--paper);
}

.login-brand::after {
  content: "";
  position: absolute;
  right: 42px;
  top: 8%;
  bottom: 8%;
  width: 1px;
  background: repeating-linear-gradient(to bottom, var(--faint) 0 10px, transparent 10px 26px);
  opacity: 0.5;
}

.heat-orb {
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(242, 181, 58, 0.5), rgba(232, 89, 12, 0.28) 45%, transparent 70%);
  filter: blur(30px);
  bottom: -180px;
  left: -120px;
  animation: breathe 7s ease-in-out infinite;
  pointer-events: none;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 1; }
}

.login-brand .brand .word { font-size: 44px; }
.login-brand .brand .degree { font-size: 30px; transform: translateY(-12px); }

.login-hero { position: relative; z-index: 1; max-width: 520px; }

.login-hero h1 {
  font-size: clamp(42px, 4.6vw, 64px);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.015em;
}

.login-hero h1 em {
  font-style: italic;
  background: var(--thermal);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-hero p { color: var(--muted); margin-top: 22px; font-size: 16px; max-width: 420px; }

.login-stats { display: flex; gap: 36px; position: relative; z-index: 1; flex-wrap: wrap; }

.login-stats div strong {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
}

.login-stats div span { font-size: 12.5px; color: var(--muted); }

.login-form-side {
  background: var(--card);
  border-left: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.login-card { width: 100%; max-width: 380px; }

.login-card h2 { font-size: 28px; margin-bottom: 6px; }
.login-card > p { color: var(--muted); font-size: 14px; margin-bottom: 30px; }

.login-foot { margin-top: 26px; font-size: 13px; color: var(--muted); text-align: center; }
.login-foot a { color: var(--heat-deep); font-weight: 600; }
.login-foot a:hover { text-decoration: underline; }

.proto-note {
  margin-top: 34px;
  padding: 12px 16px;
  border: 1px dashed var(--line);
  border-radius: 11px;
  font-size: 12.5px;
  color: var(--faint);
  text-align: center;
}

/* ---------- Dashboard ---------- */

.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.ambient {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 24px;
  box-shadow: var(--shadow);
}

.ambient .big {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
}

.ambient .big .deg { color: var(--heat); }

.ambient .lbl { font-size: 12.5px; color: var(--muted); max-width: 130px; }

.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  gap: 16px;
}

.card-head .link {
  font-size: 13px;
  font-weight: 600;
  color: var(--heat-deep);
  white-space: nowrap;
}
.card-head .link:hover { text-decoration: underline; }

.reading-row { display: flex; align-items: center; gap: 16px; }
.reading-row .name { font-weight: 600; font-size: 14px; }
.reading-row .loc { font-size: 12.5px; color: var(--muted); }

.event-list { list-style: none; padding: 8px 24px 20px; }

.event-list li {
  display: flex;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}

.event-list li:last-child { border-bottom: none; }

.event-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.event-dot.cut { background: var(--heat-deep); box-shadow: 0 0 0 4px var(--danger-soft); }
.event-dot.warm { background: var(--amber); box-shadow: 0 0 0 4px var(--warn-soft); }
.event-dot.ok { background: var(--safe); box-shadow: 0 0 0 4px var(--safe-soft); }

.event-list .when { color: var(--faint); font-size: 12px; margin-top: 2px; }

/* ---------- Devices grid ---------- */

.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.18s ease;
}

.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-top: 26px;
}

.device-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.device-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
  border-color: rgba(232, 89, 12, 0.4);
}

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

.device-card h3 { font-size: 19px; }
.device-card .serial { font-size: 12px; color: var(--faint); margin-top: 3px; letter-spacing: 0.03em; }

.device-card .foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- Device detail ---------- */

.gauge-wrap { text-align: center; padding: 10px 0 4px; }

.gauge { width: 220px; height: 132px; margin: 0 auto; display: block; }

.gauge .track-arc { stroke: var(--line); }
.gauge .value-arc {
  stroke: url(#thermalGrad);
  stroke-dasharray: 264;
  stroke-dashoffset: 264;
  animation: sweep 1.4s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards;
}

@keyframes sweep { to { stroke-dashoffset: var(--sweep, 120); } }

.gauge-read { margin-top: -58px; position: relative; }

.gauge-read .now {
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 600;
  line-height: 1;
}

.gauge-read .now .deg { color: var(--heat); font-size: 30px; }

.gauge-read .sub { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
}

.setting-row:last-child { border-bottom: none; padding-bottom: 4px; }
.setting-row:first-child { padding-top: 4px; }

.setting-row .info strong { display: block; font-size: 14px; font-weight: 600; }
.setting-row .info span { font-size: 12.5px; color: var(--muted); }

.threshold-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  min-width: 74px;
  text-align: right;
}
.threshold-value .deg { color: var(--heat); }

.recipient-row td .contact { font-size: 12.5px; color: var(--muted); }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--line-soft);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 4px;
}

.tag.sms { background: #e8eff7; color: var(--cool); }
.tag.email { background: var(--safe-soft); color: var(--safe); }
.tag.call { background: var(--warn-soft); color: #9a6605; }

.icon-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--faint);
  transition: all 0.18s ease;
}
.icon-btn svg { width: 14px; height: 14px; stroke: currentColor; display: block; }
.icon-btn:hover { color: var(--heat-deep); border-color: var(--heat-deep); background: var(--danger-soft); }

/* ---------- Connect page ---------- */

.connect-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.or-divider {
  display: none;
}

.qr-frame {
  position: relative;
  width: 210px;
  height: 210px;
  margin: 26px auto;
  background:
    repeating-conic-gradient(var(--line-soft) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px,
    #fff;
  border-radius: 14px;
  overflow: hidden;
}

.qr-frame .corner {
  position: absolute;
  width: 30px; height: 30px;
  border: 3px solid var(--ink);
}
.qr-frame .corner.tl { top: 10px; left: 10px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.qr-frame .corner.tr { top: 10px; right: 10px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.qr-frame .corner.bl { bottom: 10px; left: 10px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.qr-frame .corner.br { bottom: 10px; right: 10px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }

.scan-line {
  position: absolute;
  left: 14px; right: 14px;
  height: 3px;
  background: var(--thermal);
  border-radius: 2px;
  box-shadow: 0 0 16px rgba(232, 89, 12, 0.55);
  animation: scan 2.6s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { top: 16px; }
  50% { top: calc(100% - 19px); }
}

.serial-input {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  font-size: 17px !important;
  font-weight: 600;
}

.steps { display: flex; gap: 0; margin-bottom: 34px; }

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--faint);
  position: relative;
}

.step::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  margin: 0 14px;
}

.step:last-child::after { display: none; }
.step:last-child { flex: 0 0 auto; }

.step .n {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  flex-shrink: 0;
  background: var(--card);
}

.step.on { color: var(--ink); }
.step.on .n { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Subscriptions ---------- */

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 26px;
}

.plan {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 28px;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.plan:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }

.plan.featured {
  border-color: var(--heat);
  border-width: 2px;
  box-shadow: var(--shadow-lift);
}

.plan .flag {
  position: absolute;
  top: -12px;
  left: 26px;
  background: var(--thermal);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 13px;
  border-radius: 999px;
}

.plan h3 { font-size: 22px; }
.plan .plan-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.plan .price {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
  margin: 22px 0 4px;
}

.plan .price small { font-family: var(--font-body); font-size: 13px; font-weight: 400; color: var(--muted); }

.plan ul { list-style: none; margin: 20px 0 26px; flex: 1; }

.plan li {
  padding: 8px 0 8px 26px;
  font-size: 13.5px;
  color: var(--muted);
  position: relative;
}

.plan li::before {
  content: "";
  position: absolute;
  left: 2px; top: 14px;
  width: 12px; height: 6px;
  border-left: 2px solid var(--safe);
  border-bottom: 2px solid var(--safe);
  transform: rotate(-45deg);
}

.current-plan-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
  background: linear-gradient(120deg, #fff 55%, #fef4ec);
  flex-wrap: wrap;
}

.current-plan-banner .left { display: flex; align-items: center; gap: 18px; }

.plan-mark {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--thermal);
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---------- Order page ---------- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.product {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }

.device-art {
  height: 150px;
  border-radius: 12px;
  background: linear-gradient(160deg, #f6f1e8, #efe7d8);
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  overflow: hidden;
  position: relative;
}

.ted-unit {
  width: 88px; height: 110px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 24px -10px rgba(28, 22, 17, 0.25);
  position: relative;
}

.ted-unit::before {
  content: "";
  position: absolute;
  top: 18px; left: 50%;
  transform: translateX(-50%);
  width: 44px; height: 22px;
  border-radius: 6px;
  background: var(--ink);
}

.ted-unit::after {
  content: "TED°";
  position: absolute;
  top: 22px; left: 50%;
  transform: translateX(-50%);
  color: #ffb35c;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-body);
  letter-spacing: 0.08em;
}

.ted-unit .socket {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line);
}

.ted-unit .socket::before, .ted-unit .socket::after {
  content: "";
  position: absolute;
  background: var(--ink);
  width: 3px; height: 9px;
  top: 7px;
  border-radius: 1px;
}
.ted-unit .socket::before { left: 8px; transform: rotate(28deg); }
.ted-unit .socket::after { right: 8px; transform: rotate(-28deg); }

.ted-unit.wide { width: 130px; height: 74px; border-radius: 14px; }
.ted-unit.wide::before { width: 30px; height: 15px; top: 12px; left: 14px; transform: none; }
.ted-unit.wide::after { font-size: 8px; top: 15px; left: 29px; transform: translateX(-50%); }
.ted-unit.wide .socket { width: 26px; height: 26px; bottom: 12px; left: auto; right: 14px; transform: none; }
.ted-unit.wide .socket::before { left: 5px; top: 5px; height: 7px; }
.ted-unit.wide .socket::after { right: 5px; top: 5px; height: 7px; }
.ted-unit.wide .socket2 {
  position: absolute;
  bottom: 12px; right: 48px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
}

.ted-unit.pro { background: var(--ink); border-color: var(--ink); }
.ted-unit.pro::before { background: #2e261e; }
.ted-unit.pro .socket { border-color: #4a4036; }
.ted-unit.pro .socket::before, .ted-unit.pro .socket::after { background: #ffb35c; }

.product h3 { font-size: 20px; }
.product .prod-sub { font-size: 13px; color: var(--muted); margin: 4px 0 14px; min-height: 40px; }

.product .price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}

.product .price {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
}

.product .price small {
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.qty button {
  background: none;
  border: none;
  width: 34px; height: 34px;
  font-size: 17px;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.qty button:hover { background: var(--paper); color: var(--ink); }

.qty .q {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.order-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}

.order-summary-row:last-of-type { border-bottom: none; }

.order-summary-row.total {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 16px;
  font-weight: 700;
  font-size: 16px;
}

/* ---------- Users page ---------- */

.role-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 30px; }

.role-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--card);
  font-size: 13px;
  color: var(--muted);
}

.role-card strong { display: block; color: var(--ink); font-size: 14.5px; margin-bottom: 5px; }

.user-cell { display: flex; align-items: center; gap: 13px; }
.user-cell .avatar { width: 36px; height: 36px; font-size: 12px; }
.user-cell .avatar.a2 { background: linear-gradient(135deg, #3b6ea5, #1f7a5c); }
.user-cell .avatar.a3 { background: linear-gradient(135deg, #1f7a5c, #f2b53a); }
.user-cell .avatar.a4 { background: linear-gradient(135deg, #857a6e, #1c1611); }
.user-cell strong { display: block; font-size: 14px; }
.user-cell span { font-size: 12.5px; color: var(--muted); }

.role-select {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Two-column layout helper ---------- */

.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }

.stack > * + * { margin-top: 20px; }

/* ---------- Section spacing ---------- */

.section { margin-top: 44px; }

.section-title {
  font-size: 24px;
  margin-bottom: 6px;
}

.section-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .split { grid-template-columns: 1fr; }
  .plan-grid, .product-grid, .role-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 20px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .brand-sub { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav-label { display: none; }
  .nav a { padding: 8px 12px; font-size: 13px; }
  .sidebar-foot { border-top: none; padding-top: 0; margin-left: auto; }
  .sidebar-foot .who { display: none; }
  .main { padding: 32px 22px 64px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { min-height: 46vh; padding: 40px 28px; gap: 40px; }
  .login-form-side { border-left: none; border-top: 1px solid var(--line); padding: 40px 24px; }
  .connect-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 32px; }
}

@media (max-width: 560px) {
  .stats, .plan-grid, .product-grid, .role-cards { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}
