/* Clentavo Admin: brand tokens shared with the app and website. */
@font-face { font-family: "Jakarta"; src: url("../assets/fonts/PlusJakartaSans-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Jakarta"; src: url("../assets/fonts/PlusJakartaSans-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../assets/fonts/Inter-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../assets/fonts/Inter-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../assets/fonts/Inter-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }

:root {
  --emerald: #0E9F6E; --emerald-bright: #34D399; --mint: #D1FAE5; --forest: #064E3B;
  --midnight: #0B1B33; --midnight-deep: #071226;
  --coral: #FF7A59; --sky: #3B82F6; --violet: #8B5CF6; --amber: #F59E0B; --red: #EF4444;
  --bg: #F4F7FA; --surface: #FFFFFF; --surface-2: #F8FAFC; --text: #0B1B33; --muted: #5B6B82; --faint: #94A3B8;
  --outline: #E2E8F0; --outline-strong: #CBD5E1; --hover: #F1F5F9;
  --primary: var(--emerald); --primary-ink: #FFFFFF; --focus: rgba(14, 159, 110, .35);
  --danger-bg: #FEF2F2; --danger-ink: #B91C1C; --warn-bg: #FFFBEB; --warn-ink: #92400E;
  --ok-bg: #ECFDF5; --ok-ink: #047857; --info-bg: #EFF6FF; --info-ink: #1D4ED8; --neutral-bg: #F1F5F9; --neutral-ink: #475569;
  --shadow: 0 1px 2px rgba(11, 27, 51, .06), 0 4px 16px rgba(11, 27, 51, .05);
  --shadow-lg: 0 20px 50px rgba(7, 18, 38, .25);
  --radius: 14px; --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Jakarta", "Inter", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #071226; --surface: #0D1D36; --surface-2: #0A1830; --text: #E6EEF8; --muted: #9FB1C8; --faint: #6B7F99;
  --outline: #1C2E48; --outline-strong: #2A3F5F; --hover: #13263F;
  --primary: var(--emerald-bright); --primary-ink: #052E22; --focus: rgba(52, 211, 153, .35);
  --danger-bg: rgba(239, 68, 68, .14); --danger-ink: #FCA5A5; --warn-bg: rgba(245, 158, 11, .14); --warn-ink: #FCD34D;
  --ok-bg: rgba(52, 211, 153, .14); --ok-ink: #6EE7B7; --info-bg: rgba(59, 130, 246, .16); --info-ink: #93C5FD;
  --neutral-bg: rgba(148, 163, 184, .14); --neutral-ink: #CBD5E1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.01em; margin: 0; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--midnight-deep); color: #C7D3E3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; }
.brand img { width: 30px; height: 30px; padding: 5px; border-radius: 9px; background: var(--emerald); }
.brand b { font-family: var(--font-head); font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.brand small { display: block; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--coral); font-weight: 700; margin-top: -2px; }
.nav { padding: 6px 10px 20px; flex: 1; }
.nav__group { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #5D7190; font-weight: 700; padding: 16px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 9px; color: #C7D3E3; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(52, 211, 153, .14); color: var(--emerald-bright); }
.nav svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar__foot { padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 12px; }
.sidebar__foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__foot .row { display: flex; gap: 6px; margin-top: 10px; }
.sidebar__foot button { flex: 1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--outline); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar .crumbs { color: var(--muted); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .crumbs a { color: var(--muted); }
.topbar .crumbs b { color: var(--text); }
.godmode { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--coral); background: rgba(255, 122, 89, .12); border: 1px solid rgba(255, 122, 89, .35); padding: 3px 10px; border-radius: 99px; }
.godmode::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 3px rgba(255, 122, 89, .25); }
.btn.menu-btn { display: none; }
.content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card__bd { padding: 16px 18px 18px; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid, .callout + .grid, .callout + .card { margin-top: 16px; }
.grid > .card, .grid > div > .card:first-child { margin-top: 0; }
.page-head + .callout { margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-family: var(--font-head); font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat .sub b { color: var(--ok-ink); font-weight: 600; }
.stat.accent { background: linear-gradient(135deg, var(--midnight) 0%, #12345A 100%); color: #fff; border-color: transparent; }
.stat.accent .label, .stat.accent .sub { color: #A9BCD6; }
.stat.accent .value { color: var(--emerald-bright); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--outline-strong); background: var(--surface); color: var(--text); font: 600 13px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-ghost { color: var(--danger-ink); border-color: color-mix(in srgb, var(--red) 40%, var(--outline)); }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; height: 42px; }
.sidebar .btn { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .1); color: #C7D3E3; }
.sidebar .btn:hover { background: rgba(255, 255, 255, .12); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral-ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.danger { background: var(--danger-bg); color: var(--danger-ink); }
.badge.info { background: var(--info-bg); color: var(--info-ink); }
.badge.violet { background: rgba(139, 92, 246, .14); color: var(--violet); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label-sm { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.field .err { font-size: 12px; color: var(--danger-ink); }
.input, select.input, textarea.input { height: 38px; padding: 0 12px; border: 1px solid var(--outline-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: 14px var(--font); width: 100%; }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.input.code { font: 600 22px/1 var(--mono); letter-spacing: .4em; text-align: center; height: 50px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--emerald); }
.switch { position: relative; display: flex; width: fit-content; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--outline-strong); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked { background: var(--emerald); }
.switch input:checked::after { transform: translateX(16px); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }

/* Toolbar + tables */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--outline); }
.toolbar .input { width: auto; min-width: 140px; height: 34px; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; padding-left: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394A3B8' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 11px center; }
.toolbar .grow { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--outline); white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--outline); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .primary-text { font-weight: 600; }
td .secondary-text { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
td.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--outline); color: var(--muted); font-size: 12.5px; }
.pager .btns { display: flex; gap: 6px; }

/* Key/value lists */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--outline); }
.list li:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.stack > * + * { margin-top: 10px; }
.row-flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--emerald), var(--sky)); font-family: var(--font-head); flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; border-radius: 16px; }
.danger-zone { border-color: color-mix(in srgb, var(--red) 35%, var(--outline)); }
.danger-zone .card__hd h2 { color: var(--danger-ink); }
.callout { padding: 12px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; }
.callout.info { background: var(--info-bg); color: var(--info-ink); }
.callout.danger { background: var(--danger-bg); color: var(--danger-ink); }
pre.json { margin: 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--outline); border-radius: 10px; font: 12px/1.5 var(--mono); max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.secret { font: 600 14px var(--mono); letter-spacing: .08em; background: var(--surface-2); border: 1px dashed var(--outline-strong); border-radius: 10px; padding: 10px; text-align: center; word-break: break-all; user-select: all; }

/* Charts */
.chart { width: 100%; height: 200px; display: block; }
.chart .bar { fill: var(--emerald); opacity: .85; }
.chart .bar:hover { opacity: 1; fill: var(--emerald-bright); }
.chart .bar.alt { fill: var(--sky); }
.chart .grid-line { stroke: var(--outline); stroke-dasharray: 3 4; }
.chart text { fill: var(--faint); font-size: 10px; font-family: var(--font); }
.split-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--neutral-bg); }
.split-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Overlays */
.overlay { position: fixed; inset: 0; background: rgba(7, 18, 38, .55); backdrop-filter: blur(2px); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .12s ease-out; }
.modal { background: var(--surface); color: var(--text); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: calc(100vh - 40px); overflow: auto; animation: pop .16s ease-out; }
.modal.wide { max-width: 720px; }
.modal__hd { padding: 20px 22px 4px; }
.modal__hd p { color: var(--muted); margin: 6px 0 0; }
.modal__bd { padding: 14px 22px; }
.modal__ft { padding: 12px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--midnight); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: 380px; font-weight: 500; animation: pop .16s ease-out; border-left: 4px solid var(--emerald-bright); }
.toast.error { border-left-color: var(--red); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--outline); border-top-color: var(--emerald); animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--outline) 0%, var(--hover) 50%, var(--outline) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth__art { background: radial-gradient(circle at 20% 20%, rgba(52, 211, 153, .25), transparent 45%), radial-gradient(circle at 80% 90%, rgba(255, 122, 89, .22), transparent 40%), var(--midnight-deep); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth__art h1 { font-size: 40px; line-height: 1.1; max-width: 460px; }
.auth__art h1 em { font-style: normal; color: var(--emerald-bright); }
.auth__art p { color: #A9BCD6; max-width: 420px; font-size: 15px; }
.auth__art ul { list-style: none; padding: 0; margin: 24px 0 0; color: #C7D3E3; }
.auth__art li { padding: 6px 0 6px 26px; position: relative; }
.auth__art li::before { content: ""; position: absolute; left: 0; top: 11px; width: 14px; height: 8px; border-left: 2.5px solid var(--emerald-bright); border-bottom: 2.5px solid var(--emerald-bright); transform: rotate(-45deg); }
.auth__form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth__card { width: 100%; max-width: 380px; }
.auth__card h2 { font-size: 24px; font-weight: 800; }
.auth__card > p { color: var(--muted); margin: 6px 0 24px; }
.qr { display: flex; justify-content: center; padding: 14px; background: #fff; border-radius: 14px; border: 1px solid var(--outline); margin-bottom: 12px; }
.qr svg { width: 196px; height: 196px; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { height: 4px; flex: 1; border-radius: 99px; background: var(--outline); }
.steps span.on { background: var(--emerald); }

/* Plans editor */
.plan-card { display: flex; flex-direction: column; }
.plan-card .price { font-family: var(--font-head); font-size: 24px; font-weight: 800; }
.feature-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 30px; gap: 8px; align-items: center; margin-bottom: 8px; }
.feature-row .input { height: 32px; font-size: 13px; }

/* Responsive */
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.side, .grid.cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .btn.menu-btn { display: inline-flex; }
  .content { padding: 18px 16px 48px; }
  .topbar { padding: 12px 16px; }
  .auth { grid-template-columns: 1fr; } .auth__art { display: none; }
  .grid.cols-2, .form-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
}
@media (max-width: 520px) { .grid.cols-4 { grid-template-columns: 1fr; } }
