/* =============================================================================
   OG — shared design system for the backoffices (admin + owner)
   Premium SaaS look. Light + dark. No build step, no dependencies.
   Theme accent is overridable via --brand on :root (set from BRAND settings).
   ============================================================================= */

:root{
  --brand:#4f46e5;
  --brand-600:#4338ca;
  --brand-50:#eef2ff;
  --brand-rgb:79,70,229;

  --bg:#f4f5fb;
  --surface:#ffffff;
  --surface-2:#f8fafc;
  --surface-3:#f1f5f9;
  --elevated:#ffffff;
  --line:#e6e8f0;
  --line-2:#eef1f6;
  --text:#0f172a;
  --text-2:#475569;
  --muted:#7c879b;
  --muted-2:#9aa6b8;

  --ok:#16a34a;  --ok-bg:#ecfdf3;
  --warn:#d97706; --warn-bg:#fffbeb;
  --err:#dc2626; --err-bg:#fef2f2;
  --info:#0ea5e9; --info-bg:#eff8ff;

  --shadow-sm:0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow:0 4px 14px rgba(15,23,42,.07);
  --shadow-lg:0 18px 50px rgba(15,23,42,.16);
  --ring:0 0 0 3px rgba(var(--brand-rgb),.18);

  --r-sm:8px; --r:12px; --r-lg:16px; --r-xl:22px;
  --side-w:248px;
  --font:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
}

[data-theme="dark"]{
  --bg:#0b1020;
  --surface:#121a2e;
  --surface-2:#0f1727;
  --surface-3:#1a2440;
  --elevated:#16203a;
  --line:#243049;
  --line-2:#1c2640;
  --text:#eaf0fb;
  --text-2:#aab6cd;
  --muted:#8593ad;
  --muted-2:#6b7794;
  --brand-50:#1b2342;
  --ok-bg:#08301f; --warn-bg:#2e2207; --err-bg:#350f12; --info-bg:#07263a;
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --shadow:0 6px 20px rgba(0,0,0,.45);
  --shadow-lg:0 24px 60px rgba(0,0,0,.6);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;font-family:var(--font);background:var(--bg);color:var(--text);
  font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;
}
a{color:var(--brand);text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3,h4{margin:0;font-weight:700;letter-spacing:-.01em;color:var(--text)}
h1{font-size:24px} h2{font-size:19px} h3{font-size:16px} h4{font-size:14px}
p{margin:0 0 10px}
.muted{color:var(--muted)} .small{font-size:12.5px} .tiny{font-size:11.5px}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
/* global icon size — every inline SVG carries class "ic"; specific contexts override */
.ic{width:18px;height:18px;flex:0 0 auto;display:inline-block;vertical-align:middle}
.hidden{display:none!important}
.spacer{flex:1}
.nowrap{white-space:nowrap}
.center{display:flex;align-items:center;justify-content:center}
.scroll{overflow:auto}
hr{border:none;border-top:1px solid var(--line);margin:18px 0}

/* ---- App shell ---------------------------------------------------------- */
.og-app{display:grid;grid-template-columns:var(--side-w) 1fr;min-height:100vh}
.og-side{
  background:var(--surface);border-right:1px solid var(--line);
  display:flex;flex-direction:column;padding:16px 12px;position:sticky;top:0;height:100vh;
}
.og-brand{display:flex;align-items:center;gap:10px;padding:6px 8px 16px}
.og-brand .logo{width:34px;height:34px;border-radius:10px;background:linear-gradient(135deg,var(--brand),#9333ea);
  display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:16px;box-shadow:var(--shadow-sm)}
.og-brand .name{font-weight:800;font-size:15px;letter-spacing:-.02em}
.og-brand .tag{font-size:11px;color:var(--muted);margin-top:-2px}
.og-nav{display:flex;flex-direction:column;gap:2px;margin-top:6px}
.og-nav .label{font-size:10.5px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted-2);
  font-weight:700;padding:14px 10px 6px}
.og-nav button{
  display:flex;align-items:center;gap:11px;width:100%;text-align:left;border:none;background:transparent;
  color:var(--text-2);padding:9px 11px;border-radius:10px;cursor:pointer;font:inherit;font-weight:600;font-size:13.5px;
}
.og-nav button .ic{width:18px;height:18px;flex:0 0 18px;opacity:.85}
.og-nav button:hover{background:var(--surface-3);color:var(--text)}
.og-nav button.active{background:var(--brand-50);color:var(--brand)}
[data-theme="dark"] .og-nav button.active{color:#c7d0ff}
.og-nav button .count{margin-left:auto;font-size:11px;background:var(--surface-3);color:var(--muted);
  padding:1px 7px;border-radius:20px;font-weight:700}
.og-side .foot{margin-top:auto;border-top:1px solid var(--line);padding-top:10px}

.og-main{min-width:0;display:flex;flex-direction:column}
.og-topbar{
  position:sticky;top:0;z-index:30;background:color-mix(in srgb,var(--bg) 86%,transparent);
  backdrop-filter:saturate(150%) blur(8px);border-bottom:1px solid var(--line);
  display:flex;align-items:center;gap:14px;padding:12px 26px;
}
.og-topbar .crumbs{display:flex;align-items:center;gap:8px;font-weight:600;color:var(--text-2);min-width:0}
.og-topbar .crumbs b{color:var(--text)}
.og-content{padding:24px 26px 60px;max-width:1240px;width:100%;margin:0 auto}

/* ---- Buttons ------------------------------------------------------------ */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;border:1px solid transparent;
  background:var(--brand);color:#fff;font:inherit;font-weight:650;font-size:13.5px;
  padding:9px 15px;border-radius:10px;cursor:pointer;transition:.15s;white-space:nowrap;
}
.btn:hover{background:var(--brand-600)}
.btn:active{transform:translateY(1px)}
.btn:disabled{opacity:.5;cursor:default;transform:none}
.btn .ic{width:16px;height:16px}
.btn.ghost{background:var(--surface);color:var(--text);border-color:var(--line)}
.btn.ghost:hover{background:var(--surface-3)}
.btn.subtle{background:var(--surface-3);color:var(--text);border-color:transparent}
.btn.subtle:hover{background:var(--line)}
.btn.danger{background:var(--err)} .btn.danger:hover{filter:brightness(.93)}
.btn.success{background:var(--ok)}
.btn.sm{padding:6px 11px;font-size:12.5px;border-radius:8px}
.btn.lg{padding:12px 20px;font-size:15px;border-radius:12px}
.btn.icon{padding:8px;width:36px;height:36px}
.btn.block{width:100%}
.btn-link{background:none;border:none;color:var(--brand);font:inherit;font-weight:600;cursor:pointer;padding:0}

/* ---- Cards -------------------------------------------------------------- */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:20px;box-shadow:var(--shadow-sm)}
.card + .card{margin-top:16px}
.card .card-h{display:flex;align-items:center;gap:12px;margin:-2px 0 16px}
.card .card-h h3{font-size:15px}
.card .card-h .sub{color:var(--muted);font-size:12.5px}
.card.pad-0{padding:0;overflow:hidden}
.grid{display:grid;gap:16px}
.grid.cols-2{grid-template-columns:repeat(2,1fr)}
.grid.cols-3{grid-template-columns:repeat(3,1fr)}
.grid.cols-4{grid-template-columns:repeat(4,1fr)}
.row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}
.row.tight{gap:8px}
.col{display:flex;flex-direction:column;gap:6px}
.between{display:flex;align-items:center;justify-content:space-between;gap:12px}

/* ---- KPI tiles ---------------------------------------------------------- */
.kpi{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:16px 18px;box-shadow:var(--shadow-sm);position:relative;overflow:hidden}
.kpi .k-top{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:12.5px;font-weight:600}
.kpi .k-ic{width:30px;height:30px;border-radius:9px;background:var(--brand-50);color:var(--brand);display:flex;align-items:center;justify-content:center}
.kpi .k-ic .ic{width:17px;height:17px}
.kpi .k-val{font-size:27px;font-weight:800;letter-spacing:-.02em;margin-top:8px}
.kpi .k-sub{font-size:12px;color:var(--muted);margin-top:2px}
.kpi .k-trend{font-size:11.5px;font-weight:700;padding:2px 7px;border-radius:20px}
.kpi .k-trend.up{color:var(--ok);background:var(--ok-bg)}
.kpi .k-trend.down{color:var(--err);background:var(--err-bg)}

/* ---- Forms -------------------------------------------------------------- */
.field{display:block;margin-bottom:14px}
.field > .lab{display:block;font-size:12.5px;font-weight:650;color:var(--text-2);margin-bottom:6px}
.field > .hint{font-size:11.5px;color:var(--muted);margin-top:5px}
.inp,select,textarea{
  width:100%;font:inherit;font-size:13.5px;color:var(--text);background:var(--surface);
  border:1px solid var(--line);border-radius:10px;padding:9px 12px;transition:.15s;
}
.inp:focus,select:focus,textarea:focus{outline:none;border-color:var(--brand);box-shadow:var(--ring)}
textarea{resize:vertical;min-height:84px;line-height:1.55}
select{appearance:none;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c879b' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");background-repeat:no-repeat;background-position:right 11px center;padding-right:32px}
.inp::placeholder,textarea::placeholder{color:var(--muted-2)}
.inp.sm{padding:7px 10px;font-size:12.5px}
.input-group{display:flex;align-items:stretch}
.input-group .inp{border-radius:10px 0 0 10px}
.input-group .btn{border-radius:0 10px 10px 0}
.with-icon{position:relative}
.with-icon .ic{position:absolute;left:11px;top:50%;transform:translateY(-50%);width:16px;height:16px;color:var(--muted)}
.with-icon .inp{padding-left:34px}

/* toggle */
.tgl{position:relative;display:inline-flex;align-items:center;gap:10px;cursor:pointer;user-select:none}
.tgl input{position:absolute;opacity:0;width:0;height:0}
.tgl .track{width:40px;height:23px;border-radius:30px;background:var(--line);transition:.2s;flex:0 0 40px}
.tgl .track::after{content:"";position:absolute;width:17px;height:17px;border-radius:50%;background:#fff;top:3px;left:3px;transition:.2s;box-shadow:0 1px 3px rgba(0,0,0,.3)}
.tgl input:checked + .track{background:var(--brand)}
.tgl input:checked + .track::after{transform:translateX(17px)}
.tgl .t-lab{font-size:13px;font-weight:600;color:var(--text-2)}

/* range */
input[type=range]{-webkit-appearance:none;width:100%;height:5px;border-radius:5px;background:var(--line);outline:none}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:17px;height:17px;border-radius:50%;background:var(--brand);cursor:pointer;border:2px solid var(--surface);box-shadow:var(--shadow-sm)}
input[type=range]::-moz-range-thumb{width:15px;height:15px;border-radius:50%;background:var(--brand);cursor:pointer;border:2px solid var(--surface)}

/* color input */
.color-row{display:flex;align-items:center;gap:10px}
.color-swatch{width:38px;height:34px;border-radius:9px;border:1px solid var(--line);padding:0;cursor:pointer;background:none;overflow:hidden;flex:0 0 38px}
.color-swatch::-webkit-color-swatch-wrapper{padding:0}
.color-swatch::-webkit-color-swatch{border:none;border-radius:8px}

/* segmented control */
.seg{display:inline-flex;background:var(--surface-3);border-radius:10px;padding:3px;gap:2px}
.seg button{border:none;background:transparent;color:var(--text-2);font:inherit;font-weight:600;font-size:12.5px;
  padding:6px 12px;border-radius:8px;cursor:pointer;transition:.15s;display:flex;align-items:center;gap:6px}
.seg button.active{background:var(--surface);color:var(--text);box-shadow:var(--shadow-sm)}
.seg.block{display:flex} .seg.block button{flex:1;justify-content:center}

/* chips / pills / badges */
.badge{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:700;padding:3px 9px;border-radius:20px;background:var(--surface-3);color:var(--text-2)}
.badge.ok{background:var(--ok-bg);color:var(--ok)}
.badge.warn{background:var(--warn-bg);color:var(--warn)}
.badge.err{background:var(--err-bg);color:var(--err)}
.badge.info{background:var(--info-bg);color:var(--info)}
.badge.brand{background:var(--brand-50);color:var(--brand)}
.dot{width:7px;height:7px;border-radius:50%;background:var(--muted);display:inline-block}
.dot.ok{background:var(--ok)} .dot.err{background:var(--err)} .dot.warn{background:var(--warn)}
.chip{display:inline-flex;align-items:center;gap:6px;background:var(--surface-3);border:1px solid var(--line);border-radius:20px;padding:4px 10px;font-size:12px;font-weight:600}
.chip .x{cursor:pointer;color:var(--muted);font-weight:700}

/* ---- Tables ------------------------------------------------------------- */
.table{width:100%;border-collapse:collapse;font-size:13px}
.table th{text-align:left;font-weight:650;color:var(--muted);font-size:11.5px;text-transform:uppercase;letter-spacing:.04em;padding:11px 14px;border-bottom:1px solid var(--line);background:var(--surface-2)}
.table td{padding:12px 14px;border-bottom:1px solid var(--line-2);vertical-align:middle}
.table tr:last-child td{border-bottom:none}
.table tr.click{cursor:pointer}
.table tr.click:hover td{background:var(--surface-2)}
.table .row-main{font-weight:650}
.table .row-sub{color:var(--muted);font-size:12px}

/* ---- Tabs --------------------------------------------------------------- */
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);margin-bottom:20px;overflow-x:auto;scrollbar-width:none}
.tabs::-webkit-scrollbar{display:none}
.tabs button{border:none;background:none;color:var(--muted);font:inherit;font-weight:600;font-size:13.5px;
  padding:10px 14px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;white-space:nowrap;display:flex;align-items:center;gap:7px}
.tabs button .ic{width:16px;height:16px}
.tabs button:hover{color:var(--text)}
.tabs button.active{color:var(--brand);border-bottom-color:var(--brand)}

/* ---- Accordion (designer sections) -------------------------------------- */
.acc{border:1px solid var(--line);border-radius:var(--r);overflow:hidden;margin-bottom:10px;background:var(--surface)}
.acc > .acc-h{display:flex;align-items:center;gap:10px;padding:13px 15px;cursor:pointer;user-select:none;font-weight:650;font-size:13.5px}
.acc > .acc-h .ic{width:17px;height:17px;color:var(--brand)}
.acc > .acc-h .chev{margin-left:auto;transition:.2s;color:var(--muted)}
.acc.open > .acc-h .chev{transform:rotate(90deg)}
.acc > .acc-b{padding:4px 15px 16px;border-top:1px solid var(--line-2);display:none}
.acc.open > .acc-b{display:block}

/* ---- Avatars ------------------------------------------------------------ */
.av{width:38px;height:38px;border-radius:11px;background:var(--brand-50);color:var(--brand);display:flex;align-items:center;justify-content:center;font-weight:800;font-size:15px;overflow:hidden;flex:0 0 auto}
.av img{width:100%;height:100%;object-fit:cover}
.av.sm{width:30px;height:30px;border-radius:9px;font-size:12px}
.av.lg{width:52px;height:52px;border-radius:14px;font-size:19px}

/* ---- Empty + skeleton --------------------------------------------------- */
.empty{text-align:center;padding:50px 20px;color:var(--muted)}
.empty .e-ic{width:54px;height:54px;border-radius:16px;background:var(--surface-3);display:flex;align-items:center;justify-content:center;margin:0 auto 14px;color:var(--muted-2)}
.empty .e-ic .ic{width:26px;height:26px}
.empty h3{margin-bottom:5px}
.skel{background:linear-gradient(90deg,var(--surface-3) 25%,var(--line-2) 37%,var(--surface-3) 63%);background-size:400% 100%;animation:sk 1.3s ease infinite;border-radius:8px}
@keyframes sk{0%{background-position:100% 50%}100%{background-position:0 50%}}

/* ---- Chat transcript bubbles (review) ----------------------------------- */
.bubble{max-width:78%;padding:10px 13px;border-radius:14px;font-size:13.5px;line-height:1.5;white-space:pre-wrap;word-wrap:break-word}
.bubble.user{background:var(--brand);color:#fff;margin-left:auto;border-bottom-right-radius:5px}
.bubble.bot{background:var(--surface-3);color:var(--text);border-bottom-left-radius:5px}
.msg-row{display:flex;flex-direction:column;margin:8px 0}

/* ---- Toast -------------------------------------------------------------- */
.og-toasts{position:fixed;right:18px;bottom:18px;z-index:9999;display:flex;flex-direction:column;gap:10px}
.og-toast{background:var(--elevated);border:1px solid var(--line);border-left:4px solid var(--brand);
  box-shadow:var(--shadow-lg);border-radius:12px;padding:12px 15px;min-width:260px;max-width:380px;
  display:flex;gap:10px;align-items:flex-start;animation:slideIn .25s ease}
.og-toast.ok{border-left-color:var(--ok)} .og-toast.err{border-left-color:var(--err)} .og-toast.warn{border-left-color:var(--warn)}
.og-toast .t-ic{width:18px;height:18px;margin-top:1px}
.og-toast .t-title{font-weight:700;font-size:13px}
.og-toast .t-msg{font-size:12.5px;color:var(--text-2)}
@keyframes slideIn{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:none}}

/* ---- Modal -------------------------------------------------------------- */
.og-overlay{position:fixed;inset:0;background:rgba(8,12,25,.5);backdrop-filter:blur(3px);z-index:9000;
  display:flex;align-items:center;justify-content:center;padding:20px;animation:fade .15s ease}
@keyframes fade{from{opacity:0}to{opacity:1}}
.og-modal{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-xl);box-shadow:var(--shadow-lg);
  width:100%;max-width:520px;max-height:90vh;overflow:auto;animation:pop .2s ease}
@keyframes pop{from{opacity:0;transform:scale(.96) translateY(8px)}to{opacity:1;transform:none}}
.og-modal .m-h{display:flex;align-items:center;gap:12px;padding:18px 22px;border-bottom:1px solid var(--line)}
.og-modal .m-h h3{flex:1}
.og-modal .m-b{padding:20px 22px}
.og-modal .m-f{padding:14px 22px;border-top:1px solid var(--line);display:flex;gap:10px;justify-content:flex-end;background:var(--surface-2);border-radius:0 0 var(--r-xl) var(--r-xl)}
.og-modal.wide{max-width:920px}

/* ---- Login -------------------------------------------------------------- */
.og-login{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px;
  background:radial-gradient(1200px 600px at 70% -10%,var(--brand-50),transparent),var(--bg)}
.og-login .box{width:100%;max-width:400px;background:var(--surface);border:1px solid var(--line);
  border-radius:var(--r-xl);box-shadow:var(--shadow-lg);padding:32px}
.og-login .lg-brand{display:flex;align-items:center;gap:12px;margin-bottom:22px}
.og-login .logo{width:42px;height:42px;border-radius:12px;background:linear-gradient(135deg,var(--brand),#9333ea);
  display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:19px}

/* ---- Misc helpers ------------------------------------------------------- */
.divider-txt{display:flex;align-items:center;gap:12px;color:var(--muted);font-size:12px;margin:14px 0}
.divider-txt::before,.divider-txt::after{content:"";height:1px;background:var(--line);flex:1}
.iconbtn{border:1px solid var(--line);background:var(--surface);color:var(--text-2);width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;cursor:pointer}
.iconbtn:hover{background:var(--surface-3);color:var(--text)}
.iconbtn .ic{width:17px;height:17px}
.usage-bar{height:7px;border-radius:6px;background:var(--surface-3);overflow:hidden}
.usage-bar > i{display:block;height:100%;border-radius:6px;background:var(--brand)}
.usage-bar > i.warn{background:var(--warn)} .usage-bar > i.err{background:var(--err)}
.list-item{display:flex;align-items:center;gap:13px;padding:13px 15px;border:1px solid var(--line);border-radius:var(--r);background:var(--surface);transition:.15s}
.list-item:hover{border-color:color-mix(in srgb,var(--brand) 40%,var(--line));box-shadow:var(--shadow-sm)}
.list-item + .list-item{margin-top:9px}

@media (max-width:1080px){
  .grid.cols-4{grid-template-columns:repeat(2,1fr)}
  .grid.cols-3{grid-template-columns:1fr}
}
@media (max-width:860px){
  .og-app{grid-template-columns:1fr}
  .og-side{position:fixed;left:0;top:0;z-index:60;transform:translateX(-100%);transition:.25s;width:260px;box-shadow:var(--shadow-lg)}
  .og-app.nav-open .og-side{transform:none}
  .og-scrim{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:55;display:none}
  .og-app.nav-open .og-scrim{display:block}
  .grid.cols-2,.grid.cols-4{grid-template-columns:1fr}
  .og-content{padding:18px 16px 50px}
}
.menu-btn{display:none}
@media (max-width:860px){.menu-btn{display:inline-flex}}

/* accessibility focus rings + micro-interactions */
.btn:focus-visible,.iconbtn:focus-visible,.btn-link:focus-visible,.tabs button:focus-visible,.seg button:focus-visible,.og-nav button:focus-visible,.wd-preset:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
.tgl input:focus-visible + .track{box-shadow:var(--ring)}
.kpi{transition:transform .15s ease, box-shadow .15s ease}
.kpi:hover{transform:translateY(-2px);box-shadow:var(--shadow)}
.card{transition:box-shadow .15s ease}
@media (prefers-reduced-motion: reduce){*{animation-duration:.001ms!important;transition-duration:.001ms!important}}
