/* Loopin – modern SaaS UI
   Inspired by Linear / Vercel / Stripe – dark first, glassmorphism subtle.
*/

/* ---------- Tokens ---------- */
:root {
  --bg:            #0a0b10;
  --bg-elev:       #10131b;
  --bg-elev-2:     #161a24;
  --surface:       #11141d;
  --border:        #1e2230;
  --border-strong: #2a2f40;
  --text:          #e8eaf0;
  --text-muted:    #9097a6;
  --text-dim:      #6b7280;
  --primary:       #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft:  rgba(99,102,241,.12);
  --success:       #22c55e;
  --success-soft:  rgba(34,197,94,.12);
  --warning:       #f59e0b;
  --warning-soft:  rgba(245,158,11,.12);
  --danger:        #ef4444;
  --danger-soft:   rgba(239,68,68,.12);
  --info:          #38bdf8;
  --info-soft:     rgba(56,189,248,.12);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
  --shadow:    0 4px 16px rgba(0,0,0,.25);
  --shadow-lg: 0 24px 48px rgba(0,0,0,.35);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --sidebar-w: 248px;
  --header-h:  64px;

  --font-sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --transition: 180ms cubic-bezier(.2,.8,.2,1);
}

/* light theme override */
[data-theme="light"] {
  --bg:            #f7f8fa;
  --bg-elev:       #ffffff;
  --bg-elev-2:     #ffffff;
  --surface:       #ffffff;
  --border:        #e5e7eb;
  --border-strong: #d1d5db;
  --text:          #0f172a;
  --text-muted:    #475569;
  --text-dim:      #94a3b8;
  --primary-soft:  rgba(99,102,241,.08);
  --shadow:    0 4px 16px rgba(15,23,42,.06);
  --shadow-lg: 0 20px 40px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Subtle background accent */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(800px 400px at 80% -10%, rgba(99,102,241,.10), transparent 60%),
    radial-gradient(600px 400px at -10% 110%, rgba(56,189,248,.06), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] body::before { display: none; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px;
  font-size: 15px; font-weight: 600;
  letter-spacing: -.01em;
}
.sidebar__brand .logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.sidebar__nav {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
}
.sidebar__group {
  margin-bottom: 16px;
}
.sidebar__title {
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim);
  padding: 10px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .ic { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.nav-item.active .badge { background: rgba(99,102,241,.18); color: var(--primary); border-color: transparent; }

.sidebar__footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 10px;
  transition: background var(--transition);
}
.user-card:hover { background: var(--surface); }
.user-card .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #d946ef);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: white;
}
.user-card .meta { line-height: 1.2; min-width: 0; }
.user-card .meta strong { font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .meta span { font-size: 11.5px; color: var(--text-dim); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(10,11,16,.7);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
[data-theme="light"] .topbar { background: rgba(255,255,255,.75); }
.topbar h1 {
  font-size: 16px; font-weight: 600; margin: 0;
  letter-spacing: -.01em;
}
.topbar .breadcrumb { color: var(--text-dim); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .coin-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  font-size: 13px; font-weight: 600;
}
.topbar .coin-pill .coin {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-size: 12px;
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }

.content {
  padding: 28px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.page-head { margin-bottom: 24px; }
.page-head h2 {
  font-size: 24px; font-weight: 600; margin: 0 0 6px;
  letter-spacing: -.02em;
}
.page-head p { color: var(--text-muted); margin: 0; font-size: 14px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-strong); }
.card__head { padding: 20px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.card__head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.card__head .desc { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.card__body { padding: 22px; }
.card__foot { padding: 14px 22px; border-top: 1px solid var(--border); }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative; overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}
.stat:hover { border-color: var(--border-strong); }
.stat .stat-label {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 12.5px; font-weight: 500;
}
.stat .stat-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.stat .stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat .stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat .stat-icon.blue  { background: var(--info-soft); color: var(--info); }
.stat .stat-value {
  font-size: 28px; font-weight: 600; letter-spacing: -.025em;
  margin-top: 12px;
}
.stat .stat-trend {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 8px;
  font-size: 12px; font-weight: 500;
}
.stat .stat-trend.up   { color: var(--success); }
.stat .stat-trend.down { color: var(--danger); }
.stat .stat-trend.flat { color: var(--text-dim); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-elev-2); border-color: var(--border-strong); }
.btn--primary {
  background: var(--primary); color: white; border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(99,102,241,.25);
}
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface); color: var(--text); }
.btn--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn--danger:hover { background: rgba(239,68,68,.18); }
.btn--success { background: var(--success); color: white; border-color: var(--success); }
.btn--success:hover { background: #16a34a; border-color: #16a34a; }
.btn--sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn--lg { padding: 12px 22px; font-size: 14.5px; border-radius: 12px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field__label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 6px;
}
.field__hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.input--with-prefix { padding-left: 40px; }
.input-wrap { position: relative; }
.input-wrap .prefix {
  position: absolute; top: 50%; left: 12px;
  transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
  display: inline-flex;
}
.field--row { display: flex; gap: 12px; align-items: flex-end; }
.field--row .field { flex: 1; margin: 0; }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table thead th {
  background: var(--bg-elev-2);
  font-size: 11.5px; font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em;
}
[data-theme="light"] .table thead th { background: #f9fafb; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--bg-elev); }
[data-theme="light"] .table tbody tr:hover { background: #f9fafb; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .cell-strong { font-weight: 600; color: var(--text); }
.table .cell-dim { color: var(--text-muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  font-size: 11.5px; font-weight: 500;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { color: var(--success); background: var(--success-soft); border-color: transparent; }
.badge--warning { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.badge--danger  { color: var(--danger);  background: var(--danger-soft);  border-color: transparent; }
.badge--info    { color: var(--info);    background: var(--info-soft);    border-color: transparent; }
.badge--primary { color: var(--primary); background: var(--primary-soft); border-color: transparent; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; top: 18px; right: 18px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 360px;
}
.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in 240ms cubic-bezier(.2,.8,.2,1);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.info    { border-left: 3px solid var(--info);    }
.toast .ic { color: var(--text-dim); }
@keyframes toast-in {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elev) 0%, var(--bg-elev-2) 50%, var(--bg-elev) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty .ic-wrap {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.empty h4 { color: var(--text); font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.empty p { font-size: 13px; margin: 0 0 18px; }

/* ---------- Auth ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative; z-index: 1;
}
.auth__visual {
  background: linear-gradient(135deg, #1e1b4b 0%, #0a0b10 70%);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px;
}
.auth__visual::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 300px at 20% 20%, rgba(99,102,241,.35), transparent 60%),
    radial-gradient(500px 250px at 80% 80%, rgba(217,70,239,.18), transparent 70%);
}
.auth__visual > * { position: relative; }
.auth__brand { display: flex; align-items: center; gap: 10px; color: white; font-weight: 600; }
.auth__brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), #8b5cf6); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; }
.auth__quote { color: rgba(255,255,255,.85); max-width: 460px; }
.auth__quote h3 { font-size: 26px; font-weight: 600; line-height: 1.3; letter-spacing: -.02em; margin: 0 0 12px; }
.auth__quote p { color: rgba(255,255,255,.6); margin: 0; line-height: 1.6; }
.auth__form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth__form { width: 100%; max-width: 380px; }
.auth__form h2 { font-size: 24px; margin: 0 0 6px; letter-spacing: -.02em; }
.auth__form > p { color: var(--text-muted); margin: 0 0 28px; }
.auth__alt { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 13px; }
.auth__alt a { color: var(--primary); font-weight: 500; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__visual { display: none; }
}

/* ---------- Misc ---------- */
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-gap-8 { display: flex; gap: 8px; align-items: center; }
.flex-gap-12 { display: flex; gap: 12px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mt-0 { margin-top: 0; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ---------- Verify FB widget ---------- */
.fb-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface), var(--bg-elev));
}
.fb-card .avatar {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.fb-card .meta { flex: 1; min-width: 0; }
.fb-card .meta strong { display: block; font-size: 14.5px; }
.fb-card .meta span { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Task picker ---------- */
.type-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.type-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--bg-elev);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  position: relative;
}
.type-tile:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.type-tile.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.type-tile .label { font-weight: 600; font-size: 13.5px; }
.type-tile .cost { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.type-tile .ic { width: 22px; height: 22px; color: var(--text-muted); margin-bottom: 8px; }
.type-tile.selected .ic { color: var(--primary); }

/* ---------- Progress ---------- */
.progress { height: 6px; border-radius: 999px; background: var(--bg-elev-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #a855f7); border-radius: inherit; transition: width var(--transition); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a {
  padding: 10px 14px;
  font-size: 13.5px; color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  transition: color var(--transition), border-color var(--transition);
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-color: var(--primary); }

/* ---------- Responsive ---------- */
/* Desktop: hide menu toggle */
@media (min-width: 881px) {
  .menu-toggle { display: none !important; }
}
/* Mobile: hide sidebar entirely, hide menu toggle, use bottom-nav instead */
@media (max-width: 880px) {
  .menu-toggle { display: none !important; }
  .sidebar { display: none !important; }
  .sidebar-backdrop { display: none !important; }
}

/* Tablet */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .content { padding: 22px 20px; }
  .topbar { padding: 0 22px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile drawer + adjustments */
@media (max-width: 880px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: min(86vw, 280px);
    height: 100dvh;
    transform: translateX(-100%);
    z-index: 1000;
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 998;
    display: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    touch-action: manipulation;
  }
  .sidebar-backdrop.show { display: block; }
  html.drawer-open, body.drawer-open { overflow: hidden; touch-action: none; }
  body.drawer-open .bottom-nav { display: none; }

  .topbar { padding: 0 14px; height: 56px; gap: 10px; }
  .topbar h1 { font-size: 15px; }
  .topbar .breadcrumb { font-size: 12px; }
  .topbar .coin-pill { padding: 5px 12px 5px 6px; font-size: 12.5px; }
  .topbar .coin-pill .coin { width: 20px; height: 20px; font-size: 11px; }

  .content { padding: 16px 14px 92px; max-width: 100%; }
  .page-head h2 { font-size: 20px; }
  .page-head p { font-size: 13px; }

  /* Layout collapse */
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11.5px; }
  .stat-trend { font-size: 11px; }

  /* Cards */
  .card__head { padding: 14px 16px; gap: 8px; flex-wrap: wrap; }
  .card__head h3 { font-size: 13.5px; }
  .card__head .desc { font-size: 11.5px; }
  .card__body { padding: 16px; }
  .card__foot { padding: 12px 16px; }

  /* Tables → mobile cards */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 0 0 10px;
    padding: 6px 8px;
  }
  .table tr:hover { background: var(--bg-elev); }
  .table td {
    padding: 8px 10px;
    border-bottom: 1px dashed var(--border);
    text-align: left;
    font-size: 13px;
  }
  .table td:last-child { border-bottom: 0; text-align: right; }
  .table td[style*="text-align:right"] { text-align: right; }
  .table-wrap { border: 0; background: transparent; padding: 0; }

  /* Type tiles */
  .type-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .type-tile { padding: 12px; }
  .type-tile .label { font-size: 12.5px; }
  .type-tile .cost { font-size: 11px; }

  /* Forms */
  .field--row { flex-direction: column; gap: 10px; }
  .input, .select, .textarea { font-size: 14px; }
  .btn { font-size: 13px; padding: 10px 14px; }
  .btn--lg { padding: 12px 18px; font-size: 14px; }
  .btn--sm { padding: 7px 12px; font-size: 12.5px; }

  /* Modals */
  .modal, .flashModal, .annModal { width: calc(100% - 24px); max-width: 100%; }
  .modal__inner, .flashModal__inner, .annModal__inner { padding: 20px; border-radius: 16px; }
  .annModal__head { padding: 18px 18px 14px; }
  .annModal__body { padding: 16px 18px; font-size: 13.5px; max-height: 55vh; }
  .annModal__foot { padding: 12px 18px; }

  /* Filterbar */
  .filterbar { padding: 12px; gap: 6px; flex-wrap: wrap; }
  .chip { font-size: 12px; padding: 5px 10px; }

  /* Banner / images */
  .banner-wrap { margin-bottom: 16px; border-radius: 12px; }

  /* Pager */
  .pager { padding: 10px 14px; }

  /* Task grid → 1 column */
  .task-grid { grid-template-columns: 1fr; padding: 12px; gap: 10px; }
  .task-card__foot .btn { flex: 1 1 auto; min-width: 0; }
  .task-card__head { padding: 12px 14px; }
  .task-card__body { padding: 12px 14px; }
  .task-card__foot { padding: 10px 14px; }

  /* Charts */
  .bars { height: 130px; }
  .bars__lbl { font-size: 9.5px; }

  /* Checkin grid stays 7-col but smaller */
  .checkin { gap: 4px; }
  .checkin__day { padding: 8px 4px; font-size: 11px; }
  .checkin__day strong { font-size: 14px; }

  /* Auth */
  .auth__form-wrap { padding: 22px 18px; }
  .auth__form { max-width: none; }
  .auth__form h2 { font-size: 21px; }

  /* Footer */
  .main > footer {
    padding: 14px 16px;
    font-size: 11.5px;
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Small phones */
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: 1fr; }
  .ach-grid { grid-template-columns: 1fr; }
  .topbar h1 { display: none; }
  .topbar .breadcrumb { display: none; }
  .page-head { margin-bottom: 16px; }
  .page-head h2 { font-size: 18px; }
}

/* ─── Mobile bottom nav ─── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding: 6px 6px max(6px, env(safe-area-inset-bottom));
}
.bottom-nav__inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  font-size: 10.5px;
  color: var(--text-muted);
  border-radius: 10px;
  transition: background var(--transition), color var(--transition);
  text-align: center;
  line-height: 1.2;
}
.bottom-nav a:hover { background: var(--surface); color: var(--text); }
.bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }
.bottom-nav a svg { width: 20px; height: 20px; }
@media (max-width: 880px) {
  .bottom-nav { display: block; }
}


/* ---------- Alerts ---------- */
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: flex-start; gap: 10px;
  line-height: 1.5;
}
.alert--success { color: var(--success); background: var(--success-soft); border-color: transparent; }
.alert--danger  { color: var(--danger);  background: var(--danger-soft);  border-color: transparent; }
.alert--warning { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.alert--info    { color: var(--info);    background: var(--info-soft);    border-color: transparent; }

.hint-box {
  margin-top: 24px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  font-size: 12.5px; color: var(--text-muted);
}
.hint-box strong { color: var(--text); }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 18px; }
.pager__btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border); border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); background: var(--surface);
  transition: all var(--transition);
}
.pager__btn:hover { border-color: var(--border-strong); color: var(--text); }
.pager__btn.is-disabled { opacity: .4; pointer-events: none; }
.pager__info { font-size: 12.5px; color: var(--text-muted); padding: 0 8px; }

/* ---------- Sparkline ---------- */
.spark { width: 100%; height: 60px; }

/* ---------- Achievement / level ---------- */
.ach-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); }
.ach {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface);
  transition: all var(--transition);
}
.ach:hover { border-color: var(--border-strong); }
.ach.locked { opacity: .55; }
.ach__icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ach.locked .ach__icon { background: var(--bg-elev-2); color: var(--text-dim); }
.ach__name { font-weight: 600; font-size: 13.5px; }
.ach__desc { font-size: 12px; color: var(--text-muted); }

/* ---------- Streak / checkin ---------- */
.checkin {
  display: grid; gap: 8px;
  grid-template-columns: repeat(7, 1fr);
}
.checkin__day {
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 12px;
  background: var(--surface);
}
.checkin__day.done {
  background: var(--primary-soft); border-color: var(--primary); color: var(--primary);
}
.checkin__day.today {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.checkin__day strong { display: block; font-size: 16px; margin-top: 4px; }

/* ---------- Charts ---------- */
.bars {
  display: flex; align-items: flex-end; gap: 6px;
  height: 140px;
  padding: 8px 0;
}
.bars__col {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.bars__bar {
  width: 80%; max-width: 24px;
  background: linear-gradient(180deg, var(--primary), #8b5cf6);
  border-radius: 6px 6px 0 0;
  min-height: 3px;
  transition: all var(--transition);
}
.bars__bar.out { background: linear-gradient(180deg, var(--danger), #f97316); opacity: .7; }
.bars__lbl { font-size: 10.5px; color: var(--text-dim); }

/* ---------- Rank list ---------- */
.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.rank-list li:last-child { border-bottom: 0; }
.rank-list .rk {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-elev-2); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.rank-list .rk-1 { background: linear-gradient(135deg,#fbbf24,#f59e0b); color: white; }
.rank-list .rk-2 { background: linear-gradient(135deg,#cbd5e1,#94a3b8); color: white; }
.rank-list .rk-3 { background: linear-gradient(135deg,#d97706,#b45309); color: white; }
.rank-list .nm { flex: 1; font-weight: 500; }
.rank-list .vl { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Filter bar ---------- */
.filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px; color: var(--text-muted);
  transition: all var(--transition);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

/* ---------- Misc additions ---------- */
.kbd {
  background: var(--surface); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 6px;
  font-size: 11.5px; color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.row-actions { display: flex; gap: 6px; }

/* Verify code box */
.code-box {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  background: var(--bg-elev);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  letter-spacing: .04em;
}
.code-box .val { font-size: 16px; font-weight: 600; color: var(--text); }


/* ---------- Modal (dialog) ---------- */
.modal {
  border: none; padding: 0;
  background: transparent;
  max-width: 460px; width: calc(100% - 32px);
}
.modal::backdrop { background: rgba(2,4,12,.65); backdrop-filter: blur(6px); }
.modal__inner {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}


/* ---------- Task grid (earn) ---------- */
.task-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  padding: 18px;
}
.task-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex; flex-direction: column;
  transition: all var(--transition);
}
.task-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.task-card__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.task-card__body { padding: 14px 16px; flex: 1; }
.task-card__foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.task-card__foot .btn { flex: 1; }


/* ---------- Generic flash modal ---------- */
.flashModal { padding: 0; border: none; background: transparent; max-width: 440px; width: calc(100% - 32px); }
.flashModal::backdrop { background: rgba(2,4,12,.65); backdrop-filter: blur(6px); }
.flashModal__inner {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 26px 22px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  text-align: center;
}
.flashModal__icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.flashModal__icon.success { background: var(--success-soft); color: var(--success); }
.flashModal__icon.info    { background: var(--info-soft);    color: var(--info); }
.flashModal__icon.warning { background: var(--warning-soft); color: var(--warning); }
.flashModal__icon.danger,
.flashModal__icon.error   { background: var(--danger-soft);  color: var(--danger); }
.flashModal h3 { font-size: 18px; margin: 0 0 8px; letter-spacing: -.01em; }
.flashModal p  { color: var(--text-muted); margin: 0 0 18px; font-size: 14px; line-height: 1.55; }
.flashModal .btn { min-width: 120px; }

/* Announcement modal - bigger */
.annModal { padding: 0; border: none; background: transparent; max-width: 540px; width: calc(100% - 32px); }
.annModal::backdrop { background: rgba(2,4,12,.65); backdrop-filter: blur(6px); }
.annModal__inner {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  overflow: hidden;
}
.annModal__head {
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
}
.annModal__head .icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.annModal__head h3 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.annModal__head .when { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.annModal__body { padding: 22px 26px; line-height: 1.65; font-size: 14px; max-height: 50vh; overflow: auto; }
.annModal__body a { color: var(--primary); text-decoration: underline; }
.annModal__foot { padding: 14px 26px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }


/* ---------- Banner ---------- */
.banner-wrap {
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  transition: transform var(--transition), border-color var(--transition);
}
.banner-wrap:hover { border-color: var(--border-strong); }
.banner-wrap img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}


/* ---------- Mobile bottom sheet (more menu) ---------- */
.mobileSheet { padding: 0; border: 0; background: transparent; max-width: 100%; width: 100%; margin: 0; }
.mobileSheet::backdrop { background: rgba(0,0,0,.55); }
.mobileSheet[open] {
  position: fixed; inset: auto 0 0 0;
  margin: 0;
  width: 100%;
  border-radius: 18px 18px 0 0;
  animation: sheetUp 220ms cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.mobileSheet__inner {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 8px 0 max(12px, env(safe-area-inset-bottom));
  max-height: 70vh;
  overflow-y: auto;
}
.mobileSheet__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--border);
}
.mobileSheet__head strong { font-size: 15px; }
.mobileSheet__list { display: flex; flex-direction: column; padding: 6px; }
.mobileSheet__list a, .mobileSheet__list button {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: transparent; border: 0; color: var(--text);
  font-size: 14.5px; font-weight: 500;
  width: 100%; text-align: left;
  cursor: pointer;
}
.mobileSheet__list a:active, .mobileSheet__list button:active { background: var(--surface); }
.mobileSheet__list svg { color: var(--text-muted); flex-shrink: 0; }
