:root {
  color-scheme: light;
  --bg: #eef2f6;
  --bg-strong: #dfe7ef;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --panel-tint: #edf7f5;
  --text: #15202b;
  --muted: #667487;
  --line: #d8e0e9;
  --line-strong: #c4d0dc;
  --accent: #1769aa;
  --accent-dark: #0f4f85;
  --accent-soft: #e8f2fb;
  --teal: #0f766e;
  --teal-soft: #e7f5f2;
  --ok: #16784c;
  --warn: #9f5a00;
  --danger: #b42318;
  --shadow: 0 18px 55px rgba(31, 45, 61, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8fafc 0, var(--bg) 42%, #e9eef4 100%);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.client-shell {
  min-height: 100vh;
}

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

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup.compact {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.brand-lockup.compact strong {
  display: block;
  color: #fff;
  font-size: 16px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 950;
  box-shadow: 0 8px 24px rgba(15, 79, 133, 0.18);
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-card {
  width: min(920px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 1fr);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(216, 224, 233, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 34px;
  color: #fff;
  background:
    linear-gradient(145deg, #0f4f85 0%, #1769aa 52%, #0f766e 100%);
}

.auth-brand .eyebrow,
.auth-brand h1 {
  color: #fff;
}

.auth-signal {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-signal span {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 38px;
}

.auth-title {
  margin-bottom: 22px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: 0 6px 16px rgba(31, 45, 61, 0.08);
}

.auth-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

input,
button {
  min-height: 42px;
  border-radius: 6px;
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 850;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

button.ghost:hover {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

button.danger {
  border-color: #f2b8b5;
  background: #fff;
  color: var(--danger);
}

button.danger:hover {
  border-color: var(--danger);
  background: #fff0ef;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.message {
  min-height: 20px;
  margin-top: 12px;
  font-size: 13px;
}

.error {
  color: var(--danger);
}

.success {
  color: var(--ok);
}

.app-view {
  min-height: 100vh;
  padding: 22px;
}

.app-frame {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  max-width: 1360px;
  margin: 0 auto;
}

.side-panel {
  position: sticky;
  top: 22px;
  align-self: start;
  min-height: calc(100vh - 44px);
  padding: 20px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #123f68 0%, #0f4f85 52%, #0f766e 100%);
  box-shadow: 0 16px 40px rgba(15, 79, 133, 0.2);
}

.side-panel .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.side-nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.side-nav a {
  display: block;
  border-radius: 6px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  font-size: 14px;
  font-weight: 850;
}

.side-nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.content-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.topbar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  padding: 2px 2px 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.current-user {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

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

.metric,
.panel,
.client-item,
.payment-item,
.plan-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.metric:nth-child(2)::before {
  background: var(--teal);
}

.metric:nth-child(3)::before {
  background: var(--ok);
}

.metric:nth-child(4)::before {
  background: var(--warn);
}

.metric span,
.muted {
  color: var(--muted);
}

.metric span {
  display: block;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  line-height: 1.15;
}

.workspace {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 18px;
  scroll-margin-top: 22px;
}

.panel-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.detail {
  min-width: 0;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.detail span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.detail strong {
  display: block;
  min-width: 0;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

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

.plan-card {
  display: grid;
  gap: 14px;
  padding: 15px;
  background: #fff;
}

.plan-card.selected {
  border-color: rgba(22, 120, 76, 0.45);
  background: linear-gradient(180deg, #fff 0%, #f2fbf6 100%);
}

.plan-top,
.plan-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.plan-state {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
}

.selected .plan-state {
  background: #e8f6ef;
  color: var(--ok);
}

.pending-plan .plan-state {
  background: #fff8eb;
  color: var(--warn);
}

.price {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 950;
}

.plan-meta {
  color: var(--muted);
  font-size: 13px;
}

.plan-meta strong {
  color: var(--text);
}

.create-form {
  display: grid;
  grid-template-columns: minmax(220px, 300px) auto;
  gap: 8px;
}

.notice {
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid #f4d7a1;
  background: #fff8eb;
  color: var(--warn);
  border-radius: 6px;
  font-weight: 750;
}

.clients-list,
.payments-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.client-item,
.payment-item {
  display: grid;
  gap: 12px;
  align-items: center;
}

.client-item {
  grid-template-columns: minmax(170px, 1.1fr) minmax(130px, 0.75fr) minmax(170px, 0.9fr) auto;
  padding: 14px;
}

.client-item.expanded {
  border-color: var(--line-strong);
  box-shadow: 0 10px 28px rgba(31, 45, 61, 0.08);
}

.payment-item {
  grid-template-columns: 1.2fr 0.8fr 130px 170px;
  padding: 13px 14px;
}

.device-main,
.device-status,
.device-traffic,
.payment-main,
.payment-amount {
  min-width: 0;
}

.client-details {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.peer-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 238px;
  gap: 14px;
  align-items: start;
}

.peer-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.qr-panel {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.qr-panel img {
  display: block;
  width: min(212px, 100%);
  height: auto;
  image-rendering: pixelated;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.detail-loading {
  padding: 16px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.error-notice {
  color: var(--danger);
  border-color: #f2b8b5;
  background: #fff0ef;
}

.client-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.client-actions button {
  min-height: 36px;
}

.main-text {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

.sub-text {
  display: block;
  min-width: 0;
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
}

.status-pill.online,
.status-pill.active,
.status-pill.completed {
  background: #e8f6ef;
  color: var(--ok);
}

.status-pill.pending {
  background: #fff8eb;
  color: var(--warn);
}

.status-pill.offline,
.status-pill.neutral {
  background: #f2f5f8;
  color: var(--muted);
}

.status-pill.failed,
.status-pill.refunded {
  background: #fff0ef;
  color: var(--danger);
}

.traffic-bar {
  height: 8px;
  margin-top: 8px;
  background: #e8eef4;
  border-radius: 999px;
  overflow: hidden;
}

.traffic-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--teal);
  border-radius: inherit;
}

.traffic-bar span.warn {
  background: var(--warn);
}

.traffic-bar span.danger {
  background: var(--danger);
}

.empty {
  margin-top: 14px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.w-0 { width: 0; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }

@media (max-width: 1120px) {
  .app-frame {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .brand-lockup.compact {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .side-nav {
    display: flex;
    flex-wrap: wrap;
    margin-top: 0;
  }
}

@media (max-width: 940px) {
  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 220px;
  }

  .summary-grid,
  .details-grid,
  .plans-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .client-item,
  .payment-item {
    grid-template-columns: 1fr 1fr;
  }

  .peer-detail-grid,
  .peer-facts {
    grid-template-columns: 1fr;
  }

  .client-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .auth-view,
  .app-view {
    padding: 14px;
  }

  .auth-panel,
  .auth-brand,
  .panel {
    padding: 18px;
  }

  .side-panel,
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .client-actions {
    justify-content: stretch;
  }

  .topbar-actions button,
  .client-actions button,
  .create-form button,
  .plan-card button {
    width: 100%;
  }

  .summary-grid,
  .details-grid,
  .plans-grid,
  .client-item,
  .payment-item,
  .create-form {
    grid-template-columns: 1fr;
  }

  .current-user {
    width: 100%;
    justify-content: center;
  }
}
