/* ── PSYCHO 444s RESELLER PORTAL — THEME STYLESHEET ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Manrope:wght@600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

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

/* ── ROOT & DARK THEME (DEFAULT) — gold / magenta / black from the crest ── */
:root, [data-theme="dark"] {
  --bg: #07060b;
  --bg-page: #07060b;
  --bg-card: #121018;
  --bg-card-hover: #1a1624;
  --bg-surface: #221c2e;
  --bg-input: #0c0a12;
  --bg-input-focus: #16121e;
  --border: rgba(245, 197, 24, 0.16);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-focus: #f5c518;
  
  --text: #f3f0f8;
  --text-heading: #ffffff;
  --text-sec: #c8c2d4;
  --text-muted: #8e879c;
  
  --primary: #f5c518;
  --primary-hover: #ffd84a;
  --primary-light: #ffe58a;
  --primary-glow: rgba(224, 64, 251, 0.22);
  --primary-pale: rgba(224, 64, 251, 0.14);
  --primary-pale2: rgba(245, 197, 24, 0.08);
  --accent: #e040fb;
  
  --sidebar-bg: #05040a;
  --sidebar-border: rgba(224, 64, 251, 0.22);
  --sidebar-text: #f4f2f8;
  --sidebar-sub: #9a93a8;
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --info: #0ea5e9;
  --info-bg: rgba(14, 165, 233, 0.12);
  
  --shadow: 0 1px 0 rgba(255, 247, 237, 0.04);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.35);
  --shadow-glow: none;
  
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

/* ── LIGHT THEME (DAY MODE) ── */
[data-theme="light"] {
  --bg: #f6f3fb;
  --bg-page: #fbf8ff;
  --bg-card: #ffffff;
  --bg-card-hover: #fcfaff;
  --bg-surface: #f3eef8;
  --bg-input: #ffffff;
  --bg-input-focus: #ffffff;
  --border: #eadff4;
  --border-subtle: #f3eaf8;
  --border-focus: #c026d3;
  
  --text: #1a1224;
  --text-heading: #100818;
  --text-sec: #5c5168;
  --text-muted: #8d8498;
  
  --primary: #d4a017;
  --primary-hover: #e6b422;
  --primary-light: #f5c518;
  --primary-glow: rgba(192, 38, 211, 0.22);
  --primary-pale: #f8e8ff;
  --primary-pale2: #fbf4ff;
  --accent: #c026d3;
  
  --sidebar-bg: #fcfaff;
  --sidebar-border: #eadff4;
  --sidebar-text: #1a1224;
  --sidebar-sub: #8d8498;
  
  --success: #15803d;
  --success-bg: #eafbf0;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: #0284c7;
  --info-bg: #e0f2fe;
  
  --shadow: 0 4px 20px rgba(80, 20, 120, 0.06);
  --shadow-lg: 0 12px 48px rgba(192, 38, 211, 0.12), 0 4px 16px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(224, 64, 251, 0.28);
}

/* ── BASE STYLES ── */
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

html, body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--primary-light);
  text-decoration: underline;
}

code, kbd, samp, pre {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ── LAYOUT ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 270px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.35rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  background: transparent;
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  flex-shrink: 0;
  overflow: visible;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

.sidebar-brand-name {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--sidebar-text);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.sidebar-brand-name em {
  font-style: normal;
  background: linear-gradient(90deg, #ffd000 0%, #e040fb 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-brand-sub {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--sidebar-sub);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 2px;
}

.sidebar-brand-sub::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* Sidebar Credit Card */
.sidebar-credit-box {
  margin: 1.1rem 1.1rem 0.5rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, rgba(255,106,0,0.14) 0%, rgba(255,106,0,0.04) 100%);
  border: 1px solid rgba(224, 64, 251, 0.28);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.sidebar-credit-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-sub);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-credit-val {
  font-family: 'Manrope', sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--sidebar-text);
  line-height: 1.15;
  margin: 0.35rem 0 0.65rem;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.sidebar-credit-val span {
  font-size: 0.82rem;
  color: var(--primary-light);
  font-weight: 600;
}

.sidebar-credit-action {
  display: flex;
  gap: 0.5rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.nav-section-label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-sub);
  padding: 0.85rem 1.35rem 0.35rem;
  font-weight: 700;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1.35rem;
  margin: 0.15rem 0.75rem;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  border-left: 0;
  cursor: pointer;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--primary-pale2);
  color: var(--sidebar-text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary-pale);
  color: var(--sidebar-text);
  font-weight: 600;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
  background: transparent;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f5c518, #e040fb);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 2px 10px rgba(224, 64, 251, 0.3);
  flex-shrink: 0;
}

.user-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--sidebar-text);
  line-height: 1.2;
}

.user-role {
  font-size: 0.72rem;
  color: var(--sidebar-sub);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.logout-btn {
  margin-top: 0.85rem;
  width: 100%;
  padding: 0.6rem;
  border: 1px solid rgba(224, 64, 251, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(224, 64, 251, 0.06);
  color: var(--primary-light);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.logout-btn:hover {
  background: rgba(224, 64, 251, 0.2);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(224, 64, 251, 0.25);
}

/* ── MAIN CONTENT AREA ── */
.main-content {
  margin-left: 270px;
  flex: 1;
  padding: 2rem 2.5rem 3rem;
  min-width: 0;
  background: var(--bg);
}

/* ── TOP HEADER BAR ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  gap: 1rem;
  flex-wrap: wrap;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.top-bar-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 1.65rem;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.top-bar-sub { display: block; color: var(--text-muted); font-size: 0.82rem; margin-top: 0.15rem; }

.crumbs { display: flex; align-items: baseline; gap: 0.45rem; font-size: 1.15rem; }
.crumb-brand { letter-spacing: 0.04em; }
.crumb-sep, .crumb-page { color: var(--text-muted); font-weight: 600; }
.sb-quick { display: flex; gap: 0.5rem; padding: 0 0.9rem 0.8rem; }
.sb-quick .btn { flex: 1; }

.dash-head, .dash-actions, .toolbar, .pills { display: flex; gap: 0.85rem; align-items: center; flex-wrap: wrap; }
.dash-head { justify-content: space-between; margin-bottom: 1.25rem; }
.dash-eyebrow { color: var(--text-muted); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 0.35rem; }
.dash-title { font-family: Manrope, sans-serif; font-size: 1.7rem; letter-spacing: -0.03em; line-height: 1.2; }
.dash-sub, .card-hint, .mk-sub, .kpi-foot, .notif-time { color: var(--text-muted); font-size: 0.86rem; line-height: 1.45; }
.dash-sub { margin-top: 0.35rem; }
.credit-note { color: var(--text-muted); font-size: 0.86rem; line-height: 1.5; padding: 0.15rem 0.1rem 0.9rem; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; margin-bottom: 1.15rem; }
.kpi, .mk-card, .notif-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; }
.kpi { padding: 1.15rem 1.25rem 1.2rem; }
.kpi-value { font-family: Manrope, sans-serif; font-size: 1.7rem; font-weight: 800; line-height: 1.15; margin: 0.45rem 0 0.3rem; }
.kpi-top { display: flex; justify-content: space-between; gap: 0.6rem; color: var(--text-sec); font-size: 0.82rem; line-height: 1.3; }
.kpi-foot { margin-top: 0.15rem; }
.status { display: inline-flex; align-items: center; gap: 0.3rem; }
.status i { width: 7px; height: 7px; border-radius: 99px; background: #34d399; display: inline-block; }
.week-svg { width: 100%; height: auto; display: block; }
.g-grid { stroke: var(--border); stroke-width: 1; }
.g-axis, .g-day, .g-count { font-family: Manrope, sans-serif; }
.g-axis { fill: var(--text-muted); font-size: 12px; text-anchor: end; }
.g-area { fill: rgba(224, 138, 98, 0.28); }
.g-line { fill: none; stroke: #e040fb; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.g-dot { fill: var(--bg-card); stroke: #e040fb; stroke-width: 2; }
.g-day { fill: var(--text-muted); font-size: 11px; font-weight: 700; text-anchor: middle; }
.g-count { fill: var(--text-heading); font-size: 12px; font-weight: 700; text-anchor: middle; }
.week-total { display: inline-flex; align-items: baseline; gap: 0.35rem; color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; }
.week-total b { font-family: Manrope, sans-serif; font-size: 1.15rem; color: var(--text-heading); letter-spacing: -0.03em; }

.toolbar { margin-bottom: 0.85rem; }
.search-bar { flex: 1; min-width: 220px; }
.search-bar .form-control { padding: 0.8rem 1rem; }
.pills { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; flex-wrap: wrap; }
.pill { border: 0; background: transparent; color: var(--text-sec); border-radius: 999px; padding: 0.5rem 0.9rem; cursor: pointer; font-weight: 600; font-size: 0.82rem; line-height: 1.2; }
.pill.on { background: var(--primary); color: #1a100c; }
.pill em { font-style: normal; margin-left: 0.4rem; opacity: 0.7; }
.pad-0 { padding: 0; }
.kt { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, .75fr) minmax(0, .7fr) minmax(0, .85fr) minmax(0, .45fr) minmax(0, .7fr); gap: 0.65rem 0.8rem; align-items: center; padding: 0.95rem 1.15rem; border-top: 1px solid var(--border-subtle); min-width: 0; }
.kt-act { grid-column: 1 / -1; }
.kt-head { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; border-top: 0; padding-top: 0.85rem; padding-bottom: 0.85rem; }
.kt-code { display: flex; flex-direction: column; gap: 0.28rem; min-width: 0; }
.kt-code em, .muted { color: var(--text-muted); font-size: 0.78rem; font-style: normal; line-height: 1.4; }
.code-btn { border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; padding: 0.1rem 0; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; line-height: 1.4; }
.kt-badge, .key-badge { display: inline-flex; border-radius: 999px; padding: 0.22rem 0.6rem; font-size: 0.75rem; line-height: 1.2; background: rgba(255,255,255,0.06); }
.key-badge.active, .key-badge.unused { color: #86efac; }
.key-badge.disabled, .key-badge.expired, .key-badge.removed { color: #fca5a5; }
.kt-act, .pager { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.pager { padding: 0.9rem 1.15rem 1.05rem; }
.ib { border: 1px solid var(--border); background: var(--bg-surface); color: var(--text); border-radius: 8px; padding: 0.45rem 0.7rem; font-size: 0.75rem; line-height: 1.2; cursor: pointer; }
.ib.warn { color: #fdba74; }
.ib.bad { color: #fca5a5; }

.mk-card { padding: 1.35rem 1.45rem 1.5rem; max-width: 780px; }
.mk-pop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 7, 6, 0.62);
  backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
.mk-pop.open { opacity: 1; visibility: visible; pointer-events: auto; }
.mk-sheet {
  width: min(740px, 100%);
  max-height: min(860px, calc(100vh - 2.4rem));
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.mk-pop.open .mk-sheet { transform: none; }
.mk-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.25rem 0.35rem; }
.mk-kicker { font-size: 0.68rem; letter-spacing: 0.14em; color: #f5c518; font-weight: 700; }
.mk-sheet-head h2 { margin: 0.15rem 0 0; font-family: 'Manrope', sans-serif; font-size: 1.45rem; color: var(--text-heading); }
.mk-sub { margin: 0.3rem 0 0; color: var(--text-muted); font-size: 0.84rem; line-height: 1.4; }
.mk-sheet-body { overflow: auto; padding: 0.35rem 1.25rem 0.4rem; }
.mk-sheet-foot { padding: 0.15rem 1.25rem 1.15rem; background: linear-gradient(to top, var(--bg-card) 70%, transparent); }
.mk-loading { display: flex; justify-content: center; padding: 3rem 0; }
.mk-made { margin-top: 0.9rem; display: grid; gap: 0.45rem; }
.mk-made-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-sec); font-size: 0.84rem; }
html[data-theme="light"] .mk-pop { background: rgba(48, 34, 24, 0.28); }
.mk-head { margin-bottom: 0.35rem; }
.mk-step { display: flex; align-items: center; gap: 0.65rem; margin: 1.15rem 0 0.7rem; font-size: 0.84rem; color: var(--text-sec); line-height: 1.3; }
.mk-step i { width: 24px; height: 24px; border-radius: 99px; display: grid; place-items: center; background: #f5c518; color: #1a1008; font-style: normal; font-size: 0.7rem; font-weight: 800; }
.mk-step b { margin-left: auto; color: var(--text); }
.dur-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; }
.dur-btn { text-align: left; background: var(--bg-surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 0.85rem 0.95rem; cursor: pointer; }
.dur-btn.selected { border-color: #f5c518; background: rgba(245, 197, 24, 0.14); }
.dur-code { display: block; font-weight: 700; line-height: 1.3; }
.dur-price { display: block; color: #f5c518; font-size: 0.8rem; margin-top: 0.28rem; line-height: 1.3; }
.qty-row { display: flex; gap: 0.5rem; align-items: center; max-width: 260px; }
.qty-row input { text-align: center; width: 76px; padding: 0.7rem 0.5rem; background: var(--bg-input); color: var(--text-heading); border: 1px solid var(--border); border-radius: 10px; font: inherit; }
.mini-btn, .qchip { border: 1px solid var(--border); background: var(--bg-surface); color: var(--text); border-radius: 10px; min-width: 40px; height: 40px; padding: 0 0.7rem; cursor: pointer; }
.qty-chips { display: flex; gap: 0.45rem; margin-top: 0.7rem; flex-wrap: wrap; }
.qchip.on { background: var(--primary); color: #1a100c; }
.sum-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; margin: 1.05rem 0 0.85rem; }
.ss-cell { background: var(--bg-surface); border-radius: 12px; padding: 0.85rem 0.95rem; }
.ss-cell span { display: block; color: var(--text-muted); font-size: 0.75rem; line-height: 1.3; }
.ss-cell b { display: block; margin-top: 0.3rem; line-height: 1.3; }
.sum-warn { color: #fca5a5; margin-bottom: 0.7rem; line-height: 1.4; }
.btn-full { width: 100%; }
.notif-item { display: flex; gap: 0.85rem; align-items: flex-start; padding: 1.05rem 1.2rem; margin-bottom: 0.7rem; }
.notif-dot { width: 8px; height: 8px; border-radius: 99px; background: #f5c518; margin-top: 0.45rem; flex: none; }
.notif-dot.read { background: #3f3f46; }
.notif-title { font-weight: 700; line-height: 1.35; }
.notif-text { white-space: pre-wrap; color: var(--text-sec); margin-top: 0.35rem; line-height: 1.5; }
.notif-time { margin-top: 0.4rem; }
.pin { color: #f5c518; margin-right: 0.4rem; font-size: 0.75rem; }
.plan-table th, .plan-table td { padding: 0.7rem 0.5rem; vertical-align: middle; }
.plan-table .form-control { padding: 0.55rem 0.7rem; }
.sb-quick { padding: 0.15rem 1rem 0.85rem; }
.sb-quick .btn { padding: 0.6rem 0.7rem; }

@media (max-width: 900px) {
  .kpi-row, .dur-grid, .sum-strip { grid-template-columns: 1fr 1fr; }
  .kt-head { display: none; }
  .kt { grid-template-columns: 1fr 1fr; }
  .kt-code, .kt-act { grid-column: 1 / -1; }
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── THEME SEGMENT CONTROL (DAY / NIGHT) ── */
.theme-seg {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn[aria-pressed="true"], .seg-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(224, 64, 251, 0.4);
}

.seg-ic {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Live Status Indicator Pill */
.api-status-pill { display: none; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.card:hover {
  border-color: rgba(224, 64, 251, 0.32);
}

.card-accent {
  height: 3px;
  background: linear-gradient(90deg, #f5c518 0%, #e040fb 55%, #a855f7 100%);
  width: 100%;
}

.card-header {
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-heading);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.4rem;
}

/* ── STAT CARDS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.4rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(224, 64, 251, 0.4);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #f5c518, transparent);
  opacity: 0.6;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-pale);
  border: 1px solid rgba(224, 64, 251, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--primary);
}

.stat-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-family: 'Manrope', sans-serif;
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--text-heading);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-value.orange {
  color: var(--primary);
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-sec);
  margin-top: 0.45rem;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #1a100c;
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #1a100c;
  text-decoration: none;
}

.btn-primary:active {
  transform: none;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-pale);
  color: #ffffff;
  text-decoration: none;
  box-shadow: 0 0 14px rgba(224, 64, 251, 0.2);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--text-heading);
  text-decoration: none;
}

.btn-sm {
  padding: 0.38rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: 1rem;
  border-radius: var(--radius);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: var(--success);
  color: #ffffff;
}

/* ── HIGH-CONVERTING SUBMIT & GENERATE BUTTONS ── */
.submit-btn, .btn-generate, button.btn-generate {
  width: 100% !important;
  min-height: 52px;
  padding: 1rem 1.75rem !important;
  border: none !important;
  border-radius: 10px !important;
  background: linear-gradient(135deg, #f5c518 0%, #e040fb 100%) !important;
  color: #140c18 !important;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.75rem !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  letter-spacing: 0.02em !important;
  box-shadow: 0 6px 24px rgba(224, 64, 251, 0.45) !important;
  margin-top: 1.5rem !important;
  box-sizing: border-box !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.submit-btn:hover, .btn-generate:hover, button.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(224, 64, 251, 0.65) !important;
  background: linear-gradient(135deg, #ffd84a 0%, #d946ef 100%) !important;
  color: #140c18 !important;
}

.submit-btn:active, .btn-generate:active, button.btn-generate:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(224, 64, 251, 0.35) !important;
}

.submit-btn:disabled, .btn-generate:disabled, button.btn-generate:disabled {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  background: #33271f !important;
  color: #88786d !important;
}

.btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── FORMS & INPUTS ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.15rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.form-label span.req {
  color: var(--primary);
  margin-left: 2px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  color: var(--text-heading);
  background: var(--bg-input);
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-pale);
  background: var(--bg-input-focus);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f5c518' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

select.form-control option {
  background: var(--bg-card);
  color: var(--text-heading);
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
}

/* ── DURATION PRESET CARDS (KEY CREATOR) ── */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.preset-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  user-select: none;
  position: relative;
}

.preset-card:hover {
  border-color: rgba(224, 64, 251, 0.45);
  background: var(--primary-pale2);
  transform: translateY(-2px);
}

.preset-card.active {
  border-color: var(--primary);
  background: var(--primary-pale);
  box-shadow: 0 0 16px rgba(224, 64, 251, 0.25);
}

.preset-card.active::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary);
}

.preset-time {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-heading);
}

.preset-cost {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.25rem;
  display: inline-block;
  background: rgba(255,106,0,0.12);
  padding: 2px 8px;
  border-radius: 12px;
}

/* ── NUMBER STEPPER BUTTONS ── */
.stepper-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stepper-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-heading);
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.stepper-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.quick-chips {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.quick-chip {
  padding: 0.25rem 0.65rem;
  border-radius: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-sec);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-pale);
}

/* ── TABLES ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

thead th {
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

tbody td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  vertical-align: middle;
}

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

tbody tr:hover td {
  background: var(--primary-pale2);
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-active {
  background: var(--success-bg);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-expired {
  background: var(--danger-bg);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-disabled {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-orange {
  background: var(--primary-pale);
  color: var(--primary);
  border: 1px solid rgba(224, 64, 251, 0.25);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(14, 165, 233, 0.25);
}

/* ── MONOSPACE KEY BOX ── */
.key-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--primary-light);
  margin-bottom: 0.65rem;
  transition: border-color 0.15s ease;
}

.key-box:hover {
  border-color: var(--primary);
}

.key-box code {
  user-select: all;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ── MODALS ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 1.35rem 1.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-heading);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--primary-pale);
  color: var(--primary);
}

.modal-body {
  padding: 1.65rem;
}

.modal-footer {
  padding: 1.15rem 1.65rem;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.1);
}

/* ── ALERTS & TOASTS ── */
.alert {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  line-height: 1.45;
}

.alert-error {
  background: var(--danger-bg);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.alert-success {
  background: var(--success-bg);
  color: #86efac;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.alert-info {
  background: var(--primary-pale);
  color: var(--primary-light);
  border: 1px solid rgba(224, 64, 251, 0.35);
}

/* Toast container */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  color: var(--text-heading);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 280px;
  max-width: 420px;
  animation: slide-up 0.25s ease;
  transition: all 0.2s ease;
}

.toast.toast-success { border-left: 4px solid #10b981; }
.toast.toast-error { border-left: 4px solid #ef4444; }
.toast.toast-info { border-left: 4px solid var(--primary); }

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── EMPTY STATE ── */
.empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
}

.empty svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 1.5;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.empty h3 {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

/* ── PAGINATION ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.page-btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sec);
  transition: all 0.15s;
}

.page-btn:hover {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary-pale);
}

.page-btn.active {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 0 10px rgba(224, 64, 251, 0.4);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── LOADING SPINNER ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(224, 64, 251, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── RESPONSIVE ── */
.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-heading);
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-nav-toggle svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.card, .stat-card {
  animation: rise 0.35s ease both;
}

.stats-grid .stat-card:nth-child(2) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.15s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.tabbar {
  display: none;
}

.tabbar-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: #bdbdbd;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.45rem 0.2rem 0.2rem;
  cursor: pointer;
}

.tabbar-btn.active {
  color: var(--primary-light);
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
  }
  .main-content {
    margin-left: 0;
    padding: 1.1rem 0.9rem 6.2rem;
  }
  .mobile-nav-toggle {
    display: inline-flex;
  }
  .top-bar-sub,
  .api-status-pill,
  .top-bar-actions .btn {
    display: none;
  }
  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 220;
    background: var(--sidebar-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.25rem 0.2rem calc(0.35rem + env(safe-area-inset-bottom));
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.admin-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 1.35rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: var(--bg-card);
  animation: rise 0.35s ease both;
}

.admin-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary-light);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.admin-hero h2 {
  font-family: 'Manrope', sans-serif;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.admin-hero p {
  color: var(--text-sec);
  max-width: 46rem;
  margin-top: 0.35rem;
}

.admin-hero-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin-top: 1rem;
}

.admin-action {
  text-align: left;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.admin-action:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 176, 122, 0.45);
}

.admin-action strong {
  display: block;
  margin-bottom: 0.25rem;
}

.admin-action span {
  color: var(--text-muted);
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .admin-actions { grid-template-columns: 1fr 1fr; }
  .admin-hero h2 { font-size: 1.35rem; }
}

.bell-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.bell-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.bell-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-pill {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-sec);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.filter-pill.active {
  background: var(--text-heading);
  color: var(--bg);
  border-color: transparent;
}

.plan-table input[type="text"],
.plan-table input[type="number"] {
  width: 100%;
  min-width: 72px;
}

.update-list { display: flex; flex-direction: column; gap: 0.75rem; }

.update-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  background: var(--bg-surface);
}

.update-card.unread { border-left: 3px solid #e879f9; }

.update-card h3 { margin: 0 0 0.35rem; font-size: 1rem; }

.update-card p { margin: 0; white-space: pre-wrap; color: var(--text-sec); }

.key-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.top-bar-title.crumbs { font-size: 1.05rem; font-weight: 700; }
.crumb-page { color: var(--text-heading); font-weight: 800; }
.card.pad-0 { overflow: hidden; }
.card.pad-0 .credit-note { padding: 1rem 1.15rem 0.2rem; }
.kt-head span:last-child { display: none; }
.kt-c { min-width: 0; line-height: 1.35; }
.mono { word-break: break-all; }
.create-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.mk-card { max-width: none; }
.mk-card .form-group { margin-top: 0.85rem; }
.form-group { margin-bottom: 0.9rem; }
.form-label { display: block; margin-bottom: 0.4rem; line-height: 1.3; }
.btn-sm { padding: 0.45rem 0.75rem; line-height: 1.2; }
.sidebar-footer .logout-btn + .logout-btn { margin-top: 0.5rem; }
.week-card .card-header { align-items: baseline; }

@media (max-width: 1100px) {
  .create-layout { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 1.4rem 1.2rem 2rem; }
}

@media (max-width: 900px) {
  .kt { grid-template-columns: 1fr 1fr; }
  .kt-code, .kt-act { grid-column: 1 / -1; }
  .card-body { padding: 1rem 0.95rem; }
  .card-header { padding: 0.95rem 0.95rem; }
}

.sidebar-credit-box::after { content: none; }
.card:hover { border-color: rgba(255, 247, 237, 0.16); }
#main-content.page-in { animation: page-in 0.32s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.btn:active { transform: scale(0.98); }
.sidebar-scrim { display: none; }

.tabbar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  min-height: 54px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.18s ease, transform 0.18s ease;
}
.tabbar-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar-btn.active { color: var(--primary-light); }
.tabbar-btn:active { transform: scale(0.96); }

@media (max-width: 900px) {
  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 90;
  }
  .sidebar-scrim.show { opacity: 1; pointer-events: auto; }
  .sidebar { z-index: 120; transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1); }
  .tabbar {
    background: rgba(16, 16, 15, 0.92);
    backdrop-filter: blur(18px);
    border-top: 1px solid rgba(255, 247, 237, 0.08);
    padding: 0.15rem 0.25rem calc(0.2rem + env(safe-area-inset-bottom));
  }
  .main-content { padding: 0.9rem 0.85rem calc(5.4rem + env(safe-area-inset-bottom)); }
  .top-bar { margin-bottom: 1rem; padding-bottom: 0.8rem; gap: 0.6rem; }
  .form-control, .btn, .dur-btn, .pill { min-height: 44px; }
  .kpi { padding: 1rem 1rem 1.05rem; }
  .dash-title { font-size: 1.35rem; }
  .mk-card { padding: 1.05rem 1rem 1.15rem; }
}

@media (max-width: 640px) {
  .mk-pop { padding: 0.55rem; align-items: flex-end; }
  .mk-sheet { max-height: calc(100vh - 1rem); border-radius: 18px; }
  .kpi-row, .sum-strip { grid-template-columns: 1fr; }
  .dur-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; }
  .search-bar { min-width: 0; width: 100%; }
  .pills { width: 100%; justify-content: flex-start; }
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="button"]):not([type="submit"]):not([type="hidden"]),
textarea,
select {
  background-color: var(--bg-input);
  color: var(--text-heading);
  border-color: var(--border);
}
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text-heading);
  caret-color: var(--text-heading);
  box-shadow: 0 0 0 1000px var(--bg-input) inset;
}
html[data-theme="light"] .tabbar {
  background: rgba(251, 248, 255, 0.94);
  border-top-color: #eadff4;
}
html[data-theme="light"] .tabbar-btn { color: #8d8498; }
html[data-theme="light"] .tabbar-btn.active { color: #f5c518; }

@media (max-width: 700px) {
  html, body { overflow-x: hidden; }
  .main-content {
    margin-left: 0;
    padding: 0.75rem 0.75rem calc(4.7rem + env(safe-area-inset-bottom));
  }
  .top-bar {
    margin: 0 0 0.85rem;
    padding-bottom: 0.7rem;
    gap: 0.4rem;
    align-items: center;
  }
  .top-bar-left { min-width: 0; flex: 1; gap: 0.55rem; }
  .top-bar-title, .top-bar-title.crumbs {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .crumb-brand, .crumb-sep { display: none; }
  .top-bar-actions { gap: 0.4rem; }
  .dash-head { flex-direction: column; align-items: stretch; gap: 0.7rem; margin-bottom: 0.85rem; }
  .dash-actions, .dash-actions .btn { width: 100%; }
  .dash-title { font-size: 1.28rem; }
  .dash-sub { font-size: 0.86rem; }
  .kpi-row, .stats-grid { grid-template-columns: 1fr; gap: 0.65rem; }
  .kpi, .stat-card { padding: 0.8rem 0.75rem; }
  .kpi-value, .stat-value { font-size: 1.25rem; }
  .card-body, .card-header { padding: 1rem; }
  .card { margin-bottom: 0.85rem; }
  .credit-note { padding: 0 0 0.85rem; }
  .prefix-field { max-width: none; }
  .settings-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.35rem; }
  .settings-actions .btn { width: 100%; }
  .seg-btn { padding: 0.4rem 0.55rem; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 0.55rem; width: 100%; }
  .search-bar { min-width: 0; width: 100%; flex: none; }
  .pills {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-radius: 14px;
    -webkit-overflow-scrolling: touch;
  }
  .pill { flex: none; }
  .kt { padding: 0.8rem 0.75rem; gap: 0.5rem 0.65rem; }
  .kt-c::before {
    content: attr(data-l);
    display: block;
    margin-bottom: 0.12rem;
    color: var(--text-muted);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .kt-act { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
  .kt-act .ib { width: 100%; text-align: center; min-height: 40px; }
  .main-content { padding: 1rem 1rem calc(5rem + env(safe-area-inset-bottom)); }
  .sum-strip { grid-template-columns: 1fr; gap: 0.45rem; }
  .dur-grid { grid-template-columns: 1fr 1fr; gap: 0.45rem; }
  .qty-row { max-width: none; }
  .modal-backdrop { padding: 0.55rem; align-items: flex-end; }
  .modal { border-radius: 16px; max-height: calc(100vh - 1rem); }
  .modal-header, .modal-body, .modal-footer { padding: 0.85rem 0.9rem; }
  .sidebar { z-index: 260; padding-bottom: calc(0.8rem + env(safe-area-inset-bottom)); }
  .sidebar-scrim { z-index: 240; }
  .mk-pop { padding: 0.4rem; }
  .mk-sheet { width: 100%; max-height: calc(100vh - 0.8rem); border-radius: 16px; }
  .mk-sheet-head, .mk-sheet-body { padding-left: 0.85rem; padding-right: 0.85rem; }
  .mk-sheet-foot { padding: 0.2rem 0.85rem calc(0.85rem + env(safe-area-inset-bottom)); }
  .table-wrap { max-width: 100%; }
  table { font-size: 0.8rem; }
  .g-axis, .g-count { font-size: 11px; }
  .g-day { font-size: 10px; }
}

.plan-grid {
  display: grid;
  grid-template-columns: minmax(8rem, 1.3fr) minmax(5rem, 0.8fr) minmax(5rem, 0.7fr) minmax(6rem, 0.9fr) minmax(4.5rem, 0.6fr) auto auto;
  gap: 0.45rem 0.65rem;
  align-items: center;
}
.plan-head {
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-bottom: 0.2rem;
}
.plan-row { padding: 0.45rem 0; border-top: 1px solid var(--border-subtle); }
.pf { display: block; min-width: 0; }
.pf em { display: none; }
.pf input, .plan-dur {
  width: 100%;
  min-height: 40px;
  background: var(--bg-input);
  color: var(--text-heading);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
}
.plan-dur { display: flex; align-items: center; color: var(--text-sec); }
.plan-on { display: flex; align-items: center; gap: 0.45rem; white-space: nowrap; }
.plan-sale { color: var(--text-heading); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .plan-head { display: none; }
  .plan-grid { grid-template-columns: 1fr 1fr; }
  .plan-row { padding: 0.8rem 0; }
  .pf-name, .plan-on { grid-column: 1 / -1; }
  .pf em { display: block; margin-bottom: 0.25rem; font-style: normal; font-size: 0.72rem; color: var(--text-muted); }
}
.prefix-field { max-width: 220px; }
.settings-actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }
@media (max-width: 700px) {
  .plan-head { display: none; }
  .plan-grid.plan-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "name name"
      "dur del"
      "cost price"
      "dev sale";
    gap: 0.55rem 0.6rem;
    align-items: end;
    margin: 0 0 0.7rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-surface);
  }
  .plan-row .pf-name { grid-area: name; }
  .plan-row .plan-dur,
  .plan-row >.pf:nth-child(2) { grid-area: dur; align-self: center; }
  .plan-row >.pf:nth-child(3) { grid-area: cost; }
  .plan-row >.pf:nth-child(4) { grid-area: price; }
  .plan-row >.pf:nth-child(3),
  .plan-row >.pf:nth-child(4),
  .plan-row >.pf:nth-child(5),
  .plan-row .plan-on { min-width: 0; }
  .plan-row >.pf:nth-child(5) { grid-area: dev; }
  .plan-row .plan-on {
    grid-area: sale;
    min-height: 44px;
    padding: 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-input);
  }
  .plan-row >.mini-btn { grid-area: del; justify-self: end; }
  .plan-row .plan-dur {
    width: auto;
    min-height: 0;
    justify-self: start;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
  }
}
