/* Base: reset, typography and shared components used by app, admin and kasa. Tokens come from themes.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); color: var(--c-ink); background: var(--c-bg);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: var(--display-weight); line-height: 1.15; letter-spacing: var(--display-tracking); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
::selection { background: var(--c-accent-soft); }

/* icons */
.ic { display: inline-flex; width: 20px; height: 20px; flex: none; vertical-align: middle; }
.ic svg { width: 100%; height: 100%; }
.ic-sm { width: 16px; height: 16px; } .ic-lg { width: 24px; height: 24px; } .ic-xl { width: 32px; height: 32px; }

/* type */
.t-display { font-family: var(--font-display); font-size: 34px; line-height: 1.05; font-weight: var(--display-weight); }
.t-h1 { font-family: var(--font-display); font-size: 28px; line-height: 1.1; }
.t-h2 { font-family: var(--font-display); font-size: 22px; line-height: 1.15; }
.t-h3 { font-family: var(--font-display); font-size: 18px; line-height: 1.2; }
.t-label { font-size: 11px; letter-spacing: var(--label-tracking); text-transform: uppercase; font-weight: 600; color: var(--c-muted); }
.t-sm { font-size: 13px; } .t-xs { font-size: 12px; } .t-lg { font-size: 17px; }
.muted { color: var(--c-muted); } .ink2 { color: var(--c-ink-2); } .accent { color: var(--c-accent); } .primary-c { color: var(--c-primary); }
.success-c { color: var(--c-success); } .danger-c { color: var(--c-danger); } .warning-c { color: var(--c-warning); }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; } .right { text-align: right; }
.strong { font-weight: 600; } .bold { font-weight: 700; }
.nowrap { white-space: nowrap; } .ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* layout helpers */
.row { display: flex; align-items: center; gap: 12px; }
.row-between { justify-content: space-between; } .row-top { align-items: flex-start; } .row-end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-xs { gap: 4px; } .stack-sm { gap: 8px; } .stack-lg { gap: 20px; } .stack-xl { gap: 28px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grow { flex: 1; min-width: 0; } .wrap { flex-wrap: wrap; } .gap-sm { gap: 8px; } .gap-xs { gap: 4px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.w-100 { width: 100%; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: var(--r-btn);
  font-family: var(--font-body); font-size: var(--btn-size); font-weight: var(--btn-weight);
  letter-spacing: var(--btn-tracking); text-transform: var(--btn-case); line-height: 1.1;
  transition: transform .18s var(--ease-out), background-color .2s, color .2s, box-shadow .2s, border-color .2s;
  white-space: nowrap; user-select: none; border: 1px solid transparent;
}
.btn:active { transform: scale(.97); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-accent { background: var(--c-accent); color: var(--c-on-accent); }
.btn-outline { border-color: var(--c-line-strong); color: var(--c-ink); background: transparent; }
.btn-outline:hover { border-color: var(--c-ink); }
.btn-ghost { color: var(--c-ink); background: transparent; }
.btn-soft { background: var(--c-surface-2); color: var(--c-ink); }
.btn-light { background: #fff; color: #141211; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger-outline { border-color: var(--c-danger); color: var(--c-danger); background: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: calc(var(--btn-size) - 1px); }
.btn-lg { min-height: 56px; padding: 0 26px; }
.btn-icon { width: 44px; min-height: 44px; height: 44px; padding: 0; border-radius: var(--r-pill); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.link { color: var(--c-accent); font-weight: 600; }

/* chips & badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--r-chip); border: 1px solid var(--c-line-strong); font-size: 13px; font-weight: 500;
  background: var(--c-elevated); color: var(--c-ink); white-space: nowrap; transition: background .2s, color .2s, border-color .2s;
}
.chip .ic { width: 16px; height: 16px; }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-chip);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; background: var(--c-surface-2); color: var(--c-ink-2); white-space: nowrap;
}
.badge .ic { width: 13px; height: 13px; }
.badge-accent { background: var(--c-accent-soft); color: var(--c-accent); }
.badge-primary { background: var(--c-primary); color: var(--c-on-primary); }
.badge-success { background: var(--c-success-soft); color: var(--c-success); }
.badge-warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge-danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-info { background: var(--c-info-soft); color: var(--c-info); }
.badge-dark { background: var(--c-ink); color: var(--c-bg); }
.badge-outline { background: transparent; border: 1px solid currentColor; }

.tier-badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-chip);
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
  background: var(--tier-standard); color: var(--tier-standard-ink);
}
.tier-badge .ic { width: 13px; height: 13px; }
.tier-badge[data-tier="gold"] { background: var(--tier-gold); color: var(--tier-gold-ink); }
.tier-badge[data-tier="platinum"] { background: var(--tier-platinum); color: var(--tier-platinum-ink); }

.phase-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--r-chip, 999px); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.phase-badge.phase-1 { background: var(--c-success-soft); color: var(--c-success); }
.phase-badge.phase-2 { background: var(--c-info-soft); color: var(--c-info); }
.phase-badge.phase-3 { background: var(--c-warning-soft); color: var(--c-warning); }

/* cards & surfaces */
.card { background: var(--c-elevated); border-radius: var(--r-card); border: 1px solid var(--c-line); }
:where(a.card, a.list, a.surface) { display: block; } /* zero specificity: page classes may still set flex */
.li-body > span { display: block; }
.tier-badge > svg { width: 13px; height: 13px; flex: none; }

/* feature flag: e-commerce module (Faz 2) can be switched off per brand from the admin panel */
[data-ecommerce="off"] .only-ecom { display: none !important; }
[data-ecommerce="on"] .only-no-ecom { display: none !important; }
.card-pad { padding: 16px; }
.card-soft { background: var(--c-surface); border-color: transparent; }
.surface { background: var(--c-surface); }
.divider { height: 1px; background: var(--c-line); border: 0; margin: 0; }
.dashed { border-top: 1px dashed var(--c-line-strong); }

/* lists */
.list { background: var(--c-elevated); border: 1px solid var(--c-line); border-radius: var(--r-card); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 58px; width: 100%; text-align: left; }
.list-item + .list-item { border-top: 1px solid var(--c-line); }
a.list-item, button.list-item { transition: background .15s; }
a.list-item:active, button.list-item:active { background: var(--c-surface); }
.list-item > .ic:last-child, .list-item .chev { color: var(--c-muted); margin-left: auto; }
.li-icon { width: 38px; height: 38px; border-radius: var(--r-sm); background: var(--c-surface-2); display: grid; place-items: center; color: var(--c-accent); flex: none; }
.li-body { flex: 1; min-width: 0; }
.li-title { font-weight: 500; line-height: 1.3; }
.li-sub { font-size: 12.5px; color: var(--c-muted); line-height: 1.35; margin-top: 2px; }
.li-end { margin-left: auto; text-align: right; flex: none; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--c-ink-2); }
.field-hint { font-size: 12px; color: var(--c-muted); }
.field-error { font-size: 12px; color: var(--c-danger); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--c-line-strong); border-radius: var(--r-sm);
  background: var(--c-elevated); transition: border-color .2s, box-shadow .2s; font-size: 15px;
}
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--c-ink); box-shadow: 0 0 0 3px var(--c-accent-soft); }
.textarea { min-height: 100px; resize: vertical; }
.input-icon { position: relative; } .input-icon > .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--c-muted); }
.input-icon > .input { padding-left: 42px; }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.checkbox, .radio {
  appearance: none; width: 22px; height: 22px; margin: 1px 0 0; flex: none; display: grid; place-content: center;
  border: 1.5px solid var(--c-line-strong); background: var(--c-elevated); transition: background .15s, border-color .15s; cursor: pointer;
}
.checkbox { border-radius: min(var(--r-xs), 6px); }
.radio { border-radius: 50%; }
.checkbox:checked { background: var(--c-primary); border-color: var(--c-primary); }
.checkbox:checked::after { content: ""; width: 6px; height: 11px; border: solid var(--c-on-primary); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.radio:checked { border-color: var(--c-primary); }
.radio:checked::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c-primary); }

.switch { appearance: none; position: relative; width: 50px; height: 30px; border-radius: 999px; background: var(--c-line-strong); flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .28s var(--ease-spring); }
.switch:checked { background: var(--c-accent); }
.switch:checked::after { transform: translateX(20px); }

/* segmented & tabs (role="tablist" + role="tab" data-target="panelId"; core.js wires them) */
.segmented { display: flex; padding: 4px; background: var(--c-surface-2); border-radius: var(--r-pill); gap: 4px; }
.segmented [role="tab"] { flex: 1; height: 38px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; color: var(--c-ink-2); transition: background .2s, color .2s; }
.segmented [role="tab"][aria-selected="true"] { background: var(--c-elevated); color: var(--c-ink); box-shadow: var(--shadow-1); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--c-line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] { padding: 12px 0; font-size: 14px; color: var(--c-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs [role="tab"][aria-selected="true"] { color: var(--c-ink); border-color: var(--c-ink); font-weight: 600; }

/* progress */
.progress { height: 6px; background: var(--c-surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: var(--p, 0%); background: var(--c-accent); border-radius: inherit; transition: width 1.1s var(--ease-out); }
.progress-lg { height: 10px; }

/* avatar */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--c-surface-2); color: var(--c-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; overflow: hidden; flex: none; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }

/* empty state */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 32px 24px; color: var(--c-ink-2); }
.empty .empty-art { width: 180px; height: 120px; }

/* overlays (core.js adds .backdrop and toggles .is-open) */
.backdrop { position: fixed; inset: 0; background: rgba(12, 12, 12, .45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 60; }
.backdrop.is-open { opacity: 1; pointer-events: auto; }

/* toast */
.toast-wrap { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); width: min(440px, calc(100% - 32px)); z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: var(--r-md); background: var(--c-ink); color: var(--c-bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-2); animation: toast-in .4s var(--ease-spring); }
.toast .ic { width: 18px; height: 18px; flex: none; }
.toast-success .ic { color: #7BD29B; } .toast-warning .ic { color: #F2C46D; } .toast-danger .ic { color: #F29A8E; }
.toast.is-out { opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* reveal on load: add .reveal and style="--i:n" for stagger */
.reveal { opacity: 0; transform: translateY(14px); animation: reveal .7s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes reveal { to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* tour bar (demo scenarios) */
.tourbar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1500;
  display: flex; align-items: center; gap: 14px; width: min(920px, calc(100vw - 24px));
  padding: 10px 10px 10px 18px; border-radius: 16px; background: #0E0E0E; color: #F4F1EC;
  font-family: var(--font-ui); box-shadow: 0 18px 50px rgba(0, 0, 0, .45); border: 1px solid rgba(255, 255, 255, .08);
  animation: toast-in .45s var(--ease-spring);
}
.tourbar-step { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(255, 255, 255, .08); font-weight: 800; font-size: 13px; }
.tourbar-body { flex: 1; min-width: 0; }
.tourbar-title { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #A9A39B; font-weight: 700; }
.tourbar-note { font-size: 14px; line-height: 1.35; margin-top: 2px; }
.tourbar-actions { display: flex; gap: 6px; flex: none; }
.tourbar a, .tourbar button { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 10px; font-size: 13px; font-weight: 700; color: #F4F1EC; background: rgba(255, 255, 255, .08); }
.tourbar a.is-next { background: #F4F1EC; color: #0E0E0E; }
.tourbar .ic { width: 16px; height: 16px; }

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