:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --primary: #0071e3;
  --primary-h: #0077ed;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --border: #d2d2d7;
  --err: #ff3b30;
  --ok: #34c759;
  --warn: #ff9f0a;
  --r: 12px;
  --r-lg: 18px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

/* ── Layouts ── */
.layout-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.layout-app { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Card ── */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: 0 4px 32px rgba(0,0,0,0.09);
  padding: 40px;
  width: 100%;
  max-width: 440px;
}

/* ── Brand ── */
.brand { text-align: center; margin-bottom: 32px; }
.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px; height: 52px;
  background: var(--primary);
  border-radius: 14px;
  margin-bottom: 12px;
}
.brand-logo svg { width: 28px; height: 28px; fill: white; }
.brand h1 { font-size: 21px; font-weight: 700; letter-spacing: -.3px; }
.brand p { color: var(--text-2); font-size: 14px; margin-top: 4px; }

/* ── Form fields ── */
.field { margin-bottom: 16px; }
.field-label {
  display: block; font-size: 14px; font-weight: 500;
  margin-bottom: 6px; color: var(--text);
}
input[type=email], input[type=password], input[type=text] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,113,227,.14);
}
.field-err { display: block; font-size: 13px; color: var(--err); margin-top: 5px; }

/* ── Checkboxes ── */
.check-group { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-start; }
.check-group input[type=checkbox] {
  width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px;
  border: 1.5px solid var(--border); border-radius: 5px;
  cursor: pointer; accent-color: var(--primary);
}
.check-group label { font-size: 14px; line-height: 1.45; cursor: pointer; color: var(--text); }
.check-group a { color: var(--primary); text-decoration: none; }
.check-group a:hover { text-decoration: underline; }

/* ── Buttons ── */
.btn {
  display: block; width: 100%;
  padding: 13px; border: none; border-radius: var(--r);
  font-size: 16px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-align: center; text-decoration: none;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-h); }
.btn-ghost {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── OAuth buttons ── */
.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0; color: var(--text-2); font-size: 13px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.oauth-list { display: flex; flex-direction: column; gap: 10px; }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px; border: 1.5px solid var(--border); border-radius: var(--r);
  font-size: 15px; font-family: inherit; color: var(--text-2);
  background: white; cursor: not-allowed; opacity: .5; position: relative;
}
.oauth-icon {
  width: 22px; height: 22px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: white;
}
.oi-ya { background: #fc3f1d; }
.oi-vk { background: #0077ff; }
.oi-sb { background: #21a038; }
.badge-soon {
  position: absolute; right: 12px;
  font-size: 11px; background: #f0f0f3; color: var(--text-2);
  padding: 2px 8px; border-radius: 20px;
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px; border-radius: var(--r);
  font-size: 14px; margin-bottom: 20px; line-height: 1.45;
}
.alert-err  { background: #fff5f4; border: 1px solid #ffc9c7; color: #b91c1c; }
.alert-ok   { background: #f0faf3; border: 1px solid #bbf7d0; color: #166534; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ── Toast notifications (Django messages) ── */
@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope/Manrope-VariableFont_wght.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Century Gothic";
  src: url("../fonts/century-gothic/centurygothic.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Century Gothic";
  src: url("../fonts/century-gothic/centurygothic_bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

.lk-toast-stack {
  position: fixed;
  right: clamp(1rem, 3vw, 1.5rem);
  bottom: clamp(1rem, 3vw, 1.5rem);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  max-width: min(22.5rem, calc(100vw - 2rem));
  pointer-events: none;
}

.lk-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid #3f3fe6;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 0 10px rgba(69, 22, 200, 0.18);
  box-sizing: border-box;
  animation: lk-toast-in 0.25s ease-out;
}

.lk-toast--error {
  border-color: #ff6e6e;
  box-shadow: 0 0 10px rgba(255, 110, 110, 0.18);
}

.lk-toast--leaving {
  animation: lk-toast-out 0.22s ease-in forwards;
}

@keyframes lk-toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes lk-toast-out {
  to {
    opacity: 0;
    transform: translateY(0.35rem);
  }
}

.lk-toast__icon {
  flex-shrink: 0;
  align-self: center;
  display: block;
  width: 2rem;
  height: 2rem;
}

.lk-toast__icon--error {
  object-fit: contain;
}

.lk-toast__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}

.lk-toast__title {
  margin: 0;
  font-family: "Century Gothic", "CenturyGothic", sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
  color: #000;
}

.lk-toast__text {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  color: #000;
}

/* ── Code input ── */
.code-wrap { text-align: center; margin: 20px 0; }
input.code-input {
  font-size: 28px; letter-spacing: .5em; text-align: center;
  width: 230px; padding: 14px 8px;
  border: 1.5px solid var(--border); border-radius: var(--r);
  font-family: 'SF Mono', 'Fira Code', 'Menlo', monospace;
}

/* ── Debug banner ── */
.debug-banner {
  background: #1d1d1f; color: #f5f5f7;
  padding: 12px 18px; border-radius: var(--r);
  font-family: 'SF Mono', monospace; font-size: 13px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.debug-code { font-size: 22px; font-weight: 700; letter-spacing: .2em; color: #ffd60a; }

/* ── Nav ── */
.nav {
  padding: 14px 24px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--text); }
.nav-right { display: flex; gap: 8px; align-items: center; }
.nav-link { font-size: 14px; color: var(--primary); text-decoration: none; padding: 6px 12px; border-radius: 8px; }
.nav-link:hover { background: var(--bg); }
.nav-btn-sm {
  font-size: 14px; padding: 7px 14px;
  background: var(--primary); color: white;
  border: none; border-radius: 8px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.nav-btn-sm:hover { background: var(--primary-h); }

/* ── Profile ── */
.main { flex: 1; padding: 40px 24px; }
.profile-wrap { max-width: 560px; margin: 0 auto; }
.profile-card {
  background: var(--card); border-radius: var(--r-lg);
  box-shadow: 0 2px 16px rgba(0,0,0,.07); padding: 32px;
}
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #0071e3, #00c2ff);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: white; font-weight: 700;
}
.profile-meta { flex: 1; min-width: 0; }
.profile-email { font-size: 18px; font-weight: 600; margin-bottom: 6px; word-break: break-all; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.badge-ok   { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef9c3; color: #854d0e; }
.divider-h { height: 1px; background: var(--border); margin: 20px 0; }
.profile-action { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Sidebar ── */
.layout-profile {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.profile-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-section {
  padding: 0 16px;
  margin-bottom: 8px;
}
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  padding: 0 12px;
  margin-bottom: 4px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 0 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background .12s;
}
.sidebar-item:hover { background: var(--bg); }
.sidebar-item.active {
  background: rgba(0,113,227,.08);
  color: var(--primary);
}
.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-icon svg { width: 18px; height: 18px; }
.sidebar-item.active .sidebar-icon svg { stroke: var(--primary); }
.profile-content {
  flex: 1;
  padding: 32px 24px;
  min-width: 0;
  overflow-y: auto;
}
.profile-content-inner {
  max-width: 640px;
  margin: 0 auto;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 199;
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text);
}
.sidebar-toggle svg { width: 22px; height: 22px; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; }
  .profile-content { padding: 24px 16px; }
}

/* ── Section titles ── */
.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -.2px;
}
.section-card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: 0 2px 16px rgba(0,0,0,.07);
  padding: 24px;
  margin-bottom: 20px;
}
.section-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}
.section-card-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 16px;
}

/* ── Empty states ── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-2);
  font-size: 14px;
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: .5;
}

/* ── Session cards ── */
.session-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.session-card:last-child { border-bottom: none; }
.session-card.current {
  background: rgba(0,122,255,.06);
  margin: 0 -16px;
  padding: 14px 16px;
  border-radius: 10px;
  border-bottom-color: transparent;
}
.session-device-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.session-device-icon svg { width: 20px; height: 20px; color: var(--text-2); }
.session-info { flex: 1; min-width: 0; }
.session-name { font-size: 14px; font-weight: 500; }
.session-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.session-current {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--ok);
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 6px;
}

/* ── Subscription / billing cards ── */
.billing-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.billing-item:last-child { border-bottom: none; }
.billing-item-info { flex: 1; min-width: 0; }
.billing-item-title { font-size: 14px; font-weight: 500; }
.billing-item-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.billing-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
}
.billing-status-active { background: #dcfce7; color: #166534; }
.billing-status-canceled { background: #fef9c3; color: #854d0e; }
.billing-status-expired { background: #f3f4f6; color: #6b7280; }

/* ── Transaction table ── */
.txn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.txn-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-2);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.txn-table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.txn-status { font-size: 12px; font-weight: 500; }
.txn-success { color: #166534; }
.txn-pending { color: #854d0e; }
.txn-canceled { color: #b91c1c; }
.txn-failed { color: #b91c1c; }

/* ── Inline action buttons ── */
.btn-danger-sm {
  font-size: 13px;
  padding: 6px 14px;
  background: transparent;
  color: var(--err);
  border: 1px solid var(--err);
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s;
  white-space: nowrap;
}
.btn-danger-sm:hover { background: #fff5f4; }
.btn-sm {
  font-size: 13px;
  padding: 6px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn-sm:hover { background: var(--primary-h); }

/* ── Stub badge ── */
.stub-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #f0f0f3;
  color: var(--text-2);
}

/* ── Utilities ── */
.text-center { text-align: center; }
.text-sm { font-size: 14px; color: var(--text-2); }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.link { color: var(--primary); text-decoration: none; font-size: 14px; }
.link:hover { text-decoration: underline; }
