/* =====================================================================
   Televentry design system — shared by website, auth and dashboards.
   Brand colours (--brand / --accent) are injected from Admin → Settings.
   ===================================================================== */

:root {
  --brand-base: #1A5FD6;
  --brand: var(--brand-base);
  --accent: #17A44C;

  --bg: #F4F8FF;
  --bg-2: #EAF1FC;
  --surface: #FFFFFF;
  --surface-2: #F7FAFE;
  --surface-3: #EEF3FA;
  --ink: #0F2340;
  --text: #1B2E4A;
  --muted: #5D7288;
  --faint: #8A9BB0;
  --line: #DCE6F2;
  --line-strong: #C8D6E8;

  --brand-deep: color-mix(in srgb, var(--brand) 72%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 11%, var(--surface));
  --brand-ring: color-mix(in srgb, var(--brand) 28%, transparent);
  --accent-deep: color-mix(in srgb, var(--accent) 75%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));

  --danger: #D93A3A;
  --danger-soft: color-mix(in srgb, var(--danger) 11%, var(--surface));
  --warning: #C98A0B;
  --warning-soft: color-mix(in srgb, var(--warning) 13%, var(--surface));

  --shadow-lg: 0 24px 50px -24px rgba(15, 62, 154, .32);
  --shadow: 0 14px 32px -18px rgba(15, 62, 154, .28);
  --shadow-sm: 0 6px 16px -12px rgba(15, 62, 154, .30);
  --glass: rgba(244, 248, 255, .82);

  --font-d: "Sora", system-ui, sans-serif;
  --font-b: "Inter", system-ui, sans-serif;
  --font-m: "JetBrains Mono", ui-monospace, monospace;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0A1220;
  --bg-2: #0D1728;
  --surface: #111C2E;
  --surface-2: #142137;
  --surface-3: #1A2A43;
  --ink: #EDF3FC;
  --text: #C8D5E8;
  --muted: #8699B3;
  --faint: #62768F;
  --line: #22334D;
  --line-strong: #2E4262;

  --brand: color-mix(in srgb, var(--brand-base, #1A5FD6) 78%, #fff);
  --brand-soft: color-mix(in srgb, var(--brand) 16%, var(--surface));
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface));
  --danger-soft: color-mix(in srgb, var(--danger) 18%, var(--surface));
  --warning-soft: color-mix(in srgb, var(--warning) 18%, var(--surface));

  --shadow-lg: 0 24px 50px -24px rgba(0, 0, 0, .7);
  --shadow: 0 14px 32px -18px rgba(0, 0, 0, .6);
  --shadow-sm: 0 6px 16px -12px rgba(0, 0, 0, .6);
  --glass: rgba(10, 18, 32, .78);

  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, h5 { font-family: var(--font-d); color: var(--ink); line-height: 1.15; letter-spacing: -.02em; }
::selection { background: var(--brand-ring); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-m); }
.muted { color: var(--muted); }
.eyebrow { font-family: var(--font-m); font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--brand); font-weight: 500; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.wa-glyph { width: 18px; height: 18px; fill: currentColor; flex: none; }
.icon-lg { width: 22px; height: 22px; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 11px; font-family: var(--font-d); font-weight: 800; font-size: 1.22rem; color: var(--ink); letter-spacing: -.01em; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(145deg, var(--brand), var(--accent)); box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--brand) 60%, transparent); }
.brand-mark .icon { width: 19px; height: 19px; stroke-width: 2.2; }
.brand-text small { display: block; margin-top: -2px; font-family: var(--font-m); font-weight: 400; font-size: .58rem; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.brand-logo { height: 38px; width: auto; }
.brand-logo.dark-only { display: none; }
[data-theme="dark"] .brand-logo.has-dark.light-only { display: none; }
[data-theme="dark"] .brand-logo.dark-only { display: block; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-d); font-weight: 600; font-size: .9rem;
  padding: 10px 18px; border-radius: 11px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; line-height: 1.2;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background-color .18s ease, border-color .18s ease, color .18s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: #fff; box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--brand) 80%, transparent); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -12px color-mix(in srgb, var(--brand) 85%, transparent); }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff; box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--accent) 80%, transparent); }
.btn-accent:hover { transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--brand); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); }
.btn-subtle { background: transparent; color: var(--muted); }
.btn-subtle:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: .8rem; border-radius: 9px; }
.btn-lg { padding: 14px 26px; font-size: 1rem; border-radius: 13px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.btn-icon.btn-sm { width: 32px; height: 32px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- theme toggle ---------- */
.theme-toggle { position: relative; width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); display: grid; place-items: center; cursor: pointer; overflow: hidden; transition: color .2s, border-color .2s; }
.theme-toggle:hover { color: var(--brand); border-color: var(--brand); }
.theme-toggle .icon { position: absolute; transition: transform .45s var(--ease), opacity .3s; }
.theme-toggle .i-moon { transform: translateY(0) rotate(0); }
.theme-toggle .i-sun { transform: translateY(140%) rotate(90deg); opacity: 0; }
[data-theme="dark"] .theme-toggle .i-moon { transform: translateY(-140%) rotate(-90deg); opacity: 0; }
[data-theme="dark"] .theme-toggle .i-sun { transform: translateY(0) rotate(0); opacity: 1; }

/* ---------- cards / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 1rem; font-weight: 600; }
.panel-head p { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-m); font-size: .68rem; font-weight: 500; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; text-transform: uppercase; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 22%, transparent); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.label { font-size: .82rem; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.label .opt { font-weight: 400; color: var(--faint); }
.help { font-size: .76rem; color: var(--muted); line-height: 1.45; }
.error { font-size: .76rem; color: var(--danger); font-weight: 500; }
.input, .select, .textarea { width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 13px; font-size: .9rem;
  color: var(--ink); transition: border-color .15s, box-shadow .15s, background-color .25s; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.textarea.code { font-family: var(--font-m); font-size: .82rem; min-height: 280px; }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A9BB0' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }
.input-group { position: relative; }
.input-group > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-group .input { padding-left: 38px; }
.input-group .reveal-pass { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--faint); padding: 6px; cursor: pointer; border-radius: 6px; }
.input-group .reveal-pass:hover { color: var(--brand); }

.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type=color] { width: 46px; height: 42px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; }
.color-field .input { font-family: var(--font-m); text-transform: uppercase; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 23px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; transition: background-color .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .22s var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--brand-ring); }
.switch.sm .track { width: 34px; height: 20px; }
.switch.sm .track::after { width: 14px; height: 14px; }
.switch.sm input:checked + .track::after { transform: translateX(14px); }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.switch-row strong { display: block; font-size: .88rem; color: var(--ink); font-weight: 600; }
.switch-row span.help { display: block; margin-top: 2px; }

.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .86rem; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }

/* file / image upload */
.upload { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); transition: border-color .2s; }
.upload:hover { border-color: var(--brand); }
.upload-preview { width: 76px; height: 56px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface) repeating-conic-gradient(var(--surface-3) 0 25%, transparent 0 50%) 0 0/14px 14px;
  display: grid; place-items: center; overflow: hidden; flex: none; color: var(--faint); }
.upload-preview img { max-width: 90%; max-height: 90%; object-fit: contain; }
.upload-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.upload-meta input[type=file] { font-size: .8rem; color: var(--muted); max-width: 100%; }
.upload-meta input[type=file]::file-selector-button { font: 600 .78rem var(--font-d); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 7px 12px; border-radius: 8px; margin-right: 10px; cursor: pointer; }

/* repeater (list / pairs settings) */
.repeater { display: flex; flex-direction: column; gap: 10px; }
.repeater-row { display: flex; gap: 10px; align-items: flex-start; }
.repeater-row .grip { font-family: var(--font-m); font-size: .7rem; color: var(--faint); padding-top: 12px; width: 22px; text-align: right; flex: none; }
.repeater-row .cols { flex: 1; display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.repeater-row .cols.single { grid-template-columns: 1fr; }

/* ---------- alerts / toasts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); font-size: .88rem; }
.alert-success { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--ink); }
.alert-success .icon { color: var(--accent); }
.alert-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); color: var(--ink); }
.alert-error .icon { color: var(--danger); }
.alert ul { margin-left: 18px; }

.toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; align-items: center; gap: 11px; padding: 13px 14px 13px 16px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); font-size: .88rem; color: var(--ink); animation: toastIn .4s var(--ease); }
.toast .dot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.toast.success .dot { background: var(--accent-soft); color: var(--accent); }
.toast.error .dot { background: var(--danger-soft); color: var(--danger); }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--faint); cursor: pointer; padding: 4px; border-radius: 6px; }
.toast.leaving { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th { text-align: left; font-family: var(--font-m); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 500;
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table .t-title { font-weight: 600; color: var(--ink); }
.table .t-sub { font-size: .78rem; color: var(--muted); }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 200px; }

/* ---------- avatar ---------- */
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; overflow: hidden; font-family: var(--font-d); font-weight: 700; font-size: .78rem;
  color: var(--brand); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 18%, transparent); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 1.2rem; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .empty-ico { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty h4 { font-size: 1rem; margin-bottom: 4px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.kbd { font-family: var(--font-m); font-size: .7rem; padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.pagination .pages { display: flex; gap: 5px; }
.pagination a, .pagination span.cur, .pagination span.dis { min-width: 34px; height: 34px; padding: 0 10px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 500; }
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination span.cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination span.dis { opacity: .45; }

/* confirm dialog */
dialog.confirm { margin: auto; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); color: var(--text); padding: 0; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
dialog.confirm::backdrop { background: rgba(8, 15, 30, .5); backdrop-filter: blur(4px); }
dialog.confirm[open] { animation: toastIn .3s var(--ease); }
.confirm-body { padding: 26px 24px 18px; display: flex; gap: 16px; }
.confirm-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); flex: none; }
.confirm-body h4 { font-size: 1.05rem; margin-bottom: 6px; }
.confirm-body p { font-size: .88rem; color: var(--muted); }
.confirm-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; background: var(--surface-2); border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .repeater-row .cols { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
