/* =====================================================================
   Kitchen Platform — design system v2 + app shell
   Light / dark tokens · SVG icons · responsive tables · command palette
   Legacy class names (.card .btn .pill .kpi table …) are preserved.
   ===================================================================== */

:root{
  color-scheme: light;
  --bg:#f3f4fa;        --bg-2:#e9ebf4;
  --surface:#ffffff;   --surface-2:#f8f9fd;  --surface-3:#f0f2fa;
  --border:#e4e7f1;    --border-2:#eef0f7;
  --text:#0f1226;      --text-2:#4a5070;     --muted:#6b7194;
  --primary:#4f46e5;   --primary-d:#4338ca;  --primary-soft:#eef0ff; --primary-ink:#ffffff;
  --accent:#7c3aed;
  --grad:linear-gradient(135deg,#4f46e5 0%,#7c3aed 100%);
  --ok:#0f9f6e;   --ok-soft:#e6f7f0;
  --err:#e03e3e;  --err-soft:#fdeded;
  --warn:#c77700; --warn-soft:#fff4e0;
  --info:#2563eb; --info-soft:#e8f0ff;
  --sidebar-bg:#0e1124; --sidebar-bg-2:#141834; --sidebar-text:#b9bfd9; --sidebar-muted:#6d7399; --sidebar-active:rgba(129,140,248,.16);
  --shadow-sm:0 1px 2px rgba(15,18,38,.05),0 1px 1px rgba(15,18,38,.03);
  --shadow:0 8px 24px -6px rgba(15,18,38,.10),0 2px 6px rgba(15,18,38,.04);
  --shadow-lg:0 24px 60px -12px rgba(15,18,38,.30);
  --radius:16px; --radius-sm:10px; --radius-xs:7px;
  --sidebar-w:248px; --sidebar-w-collapsed:68px; --topbar-h:64px; --bottomnav-h:64px;
  --font:"Inter","Segoe UI Variable","Segoe UI",system-ui,-apple-system,Roboto,Helvetica,Arial,sans-serif;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    color-scheme: dark;
    --bg:#0a0c16;        --bg-2:#10131f;
    --surface:#141826;   --surface-2:#1a1f30;  --surface-3:#202639;
    --border:#272d44;    --border-2:#1f2438;
    --text:#e9ebf5;      --text-2:#a0a8c6;     --muted:#7f88aa;
    --primary:#818cf8;   --primary-d:#6d78f0;  --primary-soft:#1d2142; --primary-ink:#0a0c16;
    --accent:#a78bfa;
    --grad:linear-gradient(135deg,#6366f1 0%,#8b5cf6 100%);
    --ok:#3ecf94;   --ok-soft:#0f2b21;
    --err:#f87878;  --err-soft:#341a1d;
    --warn:#f0b24b; --warn-soft:#322613;
    --info:#6aa8ff; --info-soft:#12253f;
    --sidebar-bg:#080a14; --sidebar-bg-2:#0d1020; --sidebar-text:#b4bbd6; --sidebar-muted:#6c7396; --sidebar-active:rgba(129,140,248,.18);
    --shadow-sm:0 1px 2px rgba(0,0,0,.45);
    --shadow:0 8px 24px -6px rgba(0,0,0,.55);
    --shadow-lg:0 24px 60px -12px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"]{
  color-scheme: dark;
  --bg:#0a0c16;        --bg-2:#10131f;
  --surface:#141826;   --surface-2:#1a1f30;  --surface-3:#202639;
  --border:#272d44;    --border-2:#1f2438;
  --text:#e9ebf5;      --text-2:#a0a8c6;     --muted:#7f88aa;
  --primary:#818cf8;   --primary-d:#6d78f0;  --primary-soft:#1d2142; --primary-ink:#0a0c16;
  --accent:#a78bfa;
  --grad:linear-gradient(135deg,#6366f1 0%,#8b5cf6 100%);
  --ok:#3ecf94;   --ok-soft:#0f2b21;
  --err:#f87878;  --err-soft:#341a1d;
  --warn:#f0b24b; --warn-soft:#322613;
  --info:#6aa8ff; --info-soft:#12253f;
  --sidebar-bg:#080a14; --sidebar-bg-2:#0d1020; --sidebar-text:#b4bbd6; --sidebar-muted:#6c7396; --sidebar-active:rgba(129,140,248,.18);
  --shadow-sm:0 1px 2px rgba(0,0,0,.45);
  --shadow:0 8px 24px -6px rgba(0,0,0,.55);
  --shadow-lg:0 24px 60px -12px rgba(0,0,0,.7);
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
html{-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{
  font:14px/1.55 var(--font);
  color:var(--text);background:var(--bg);
  -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;
  font-feature-settings:"cv11","ss01";
}
a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3,h4{margin:0 0 .6rem;line-height:1.25;color:var(--text);letter-spacing:-.012em}
h1{font-size:1.6rem;font-weight:700}
h2{font-size:1.25rem;font-weight:650}
h3{font-size:1.02rem;font-weight:650}
hr{border:none;border-top:1px solid var(--border);margin:1rem 0}
p{margin:.4rem 0}
.inline{display:inline}
.muted{color:var(--muted)}
[hidden]{display:none!important}
::selection{background:var(--primary-soft);color:var(--text)}
:focus-visible{outline:2px solid var(--primary);outline-offset:2px;border-radius:6px}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:10px;border:2px solid transparent;background-clip:content-box}
::-webkit-scrollbar-thumb:hover{background:var(--muted);background-clip:content-box;border:2px solid transparent}

/* icons */
.ico{width:1.15em;height:1.15em;vertical-align:-.2em;flex-shrink:0;display:inline-block}

/* ---------- Auth (split) ---------- */
.auth-body{min-height:100vh;display:grid;grid-template-columns:minmax(0,1.05fr) minmax(0,1fr);background:var(--bg)}
.auth-hero{
  position:relative;overflow:hidden;color:#fff;padding:3rem 3.2rem;display:flex;flex-direction:column;justify-content:space-between;
  background:radial-gradient(900px 500px at 10% -10%,rgba(255,255,255,.18),transparent 60%),
             radial-gradient(700px 500px at 100% 100%,rgba(124,58,237,.55),transparent 55%),
             linear-gradient(135deg,#312e81 0%,#4f46e5 45%,#7c3aed 100%);
}
.auth-hero .brand{display:flex;align-items:center;gap:.7rem;font-weight:750;font-size:1.15rem}
.auth-hero .brand .mark{width:40px;height:40px;border-radius:12px;background:rgba(255,255,255,.18);display:grid;place-items:center;backdrop-filter:blur(6px)}
.auth-hero h2{color:#fff;font-size:2.1rem;line-height:1.15;margin:0 0 1rem;max-width:20ch}
.auth-hero p{color:rgba(255,255,255,.82);max-width:42ch;font-size:1rem}
.auth-hero ul{list-style:none;margin:1.6rem 0 0;padding:0;display:grid;gap:.7rem}
.auth-hero li{display:flex;gap:.65rem;align-items:center;color:rgba(255,255,255,.92)}
.auth-hero li .ico{background:rgba(255,255,255,.16);border-radius:8px;padding:5px;width:28px;height:28px}
.auth-hero .foot{font-size:.8rem;color:rgba(255,255,255,.6)}
.auth-hero::after{content:"";position:absolute;right:-90px;bottom:-90px;width:340px;height:340px;border-radius:50%;border:48px solid rgba(255,255,255,.07)}
.auth-side{display:flex;align-items:center;justify-content:center;padding:2rem 1.2rem}
.auth-card{width:420px;max-width:100%}
.auth-brand{display:none}
.auth-card h1{font-size:1.7rem;margin-bottom:.3rem}
.auth-card .sub{color:var(--muted);margin-bottom:1.2rem}
.auth-card .btn-block{padding:.75rem 1rem;font-size:.95rem}
.demo-logins{margin-top:1.4rem;padding-top:1.1rem;border-top:1px dashed var(--border);display:grid;gap:.5rem}
.demo-head{display:flex;justify-content:space-between;align-items:baseline;gap:.6rem;font-size:.85rem}
.demo-head .muted{font-size:.75rem}
.demo-card{display:grid;grid-template-columns:1fr auto;gap:.1rem .6rem;text-align:left;width:100%;padding:.6rem .8rem;background:var(--surface-2);color:var(--text);border:1px solid var(--border);border-radius:var(--radius-sm,8px);cursor:pointer;font:inherit}
.demo-card:hover,.demo-card:focus-visible,.demo-card.on{border-color:var(--primary);background:var(--primary-soft);outline:none}
.demo-role{font-weight:650;font-size:.88rem}
.demo-note{font-size:.75rem;color:var(--muted);text-align:right}
.demo-cred{grid-column:1/-1;font-size:.72rem;color:var(--muted);font-family:ui-monospace,Menlo,Consolas,monospace;overflow-wrap:anywhere}

/* ---------- App shell ---------- */
.app{display:flex;min-height:100vh}

.sidebar{
  width:var(--sidebar-w);flex-shrink:0;display:flex;flex-direction:column;
  background:linear-gradient(180deg,var(--sidebar-bg) 0%,var(--sidebar-bg-2) 100%);color:var(--sidebar-text);
  position:sticky;top:0;height:100vh;transition:width .2s ease,transform .22s ease;z-index:60;
}
.sidebar-head{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:0 1rem;height:var(--topbar-h);flex-shrink:0}
.sidebar-brand{display:flex;align-items:center;gap:.65rem;font-weight:750;color:#fff;font-size:1.02rem;white-space:nowrap;overflow:hidden;letter-spacing:-.01em}
.sidebar-brand:hover{text-decoration:none}
.brand-mark{width:34px;height:34px;border-radius:10px;flex-shrink:0;display:grid;place-items:center;background:var(--grad);box-shadow:0 6px 16px -4px rgba(99,102,241,.6);color:#fff}
.brand-mark .ico{width:19px;height:19px}
.sidebar-collapse{background:transparent;border:none;color:var(--sidebar-muted);cursor:pointer;padding:.35rem;border-radius:8px;line-height:1;flex-shrink:0;display:grid;place-items:center}
.sidebar-collapse:hover{background:rgba(255,255,255,.08);color:#fff}
.sidebar-collapse .ico{transition:transform .2s}
.sidebar-nav{padding:.3rem .65rem 1rem;overflow-y:auto;flex:1;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.14) transparent}
.nav-section{font-size:.64rem;text-transform:uppercase;letter-spacing:.1em;color:var(--sidebar-muted);padding:1.1rem .75rem .4rem;font-weight:700}
.nav-link{
  position:relative;display:flex;align-items:center;gap:.75rem;padding:.55rem .75rem;border-radius:10px;
  color:var(--sidebar-text);font-size:.875rem;white-space:nowrap;margin-bottom:2px;transition:background .12s,color .12s;
}
.nav-link:hover{background:rgba(255,255,255,.06);color:#fff;text-decoration:none}
.nav-link.active{background:var(--sidebar-active);color:#fff;font-weight:600}
.nav-link.active::before{content:"";position:absolute;left:-.65rem;top:22%;bottom:22%;width:3px;border-radius:0 3px 3px 0;background:#a5b4fc}
.nav-ico{width:20px;height:20px;display:grid;place-items:center;flex-shrink:0;opacity:.85}
.nav-ico .ico{width:18px;height:18px}
.nav-link.active .nav-ico{opacity:1;color:#c7d2fe}
.nav-txt{overflow:hidden;text-overflow:ellipsis}
.sidebar-foot{
  margin:.6rem;padding:.65rem;border-radius:12px;background:rgba(255,255,255,.05);
  display:flex;align-items:center;gap:.65rem;font-size:.82rem;color:var(--sidebar-text);white-space:nowrap;overflow:hidden;
}
.sidebar-foot .who{display:flex;flex-direction:column;line-height:1.25;min-width:0}
.sidebar-foot .who b{color:#fff;font-weight:600;overflow:hidden;text-overflow:ellipsis}
.sidebar-foot .who small{color:var(--sidebar-muted);overflow:hidden;text-overflow:ellipsis}
.avatar{
  width:32px;height:32px;border-radius:50%;flex-shrink:0;display:grid;place-items:center;
  background:var(--grad);color:#fff;font-weight:700;font-size:.74rem;letter-spacing:.02em;
}

/* collapsed (desktop) */
.app[data-sidebar="collapsed"] .sidebar{width:var(--sidebar-w-collapsed)}
.app[data-sidebar="collapsed"] .sidebar .brand-text,
.app[data-sidebar="collapsed"] .sidebar .nav-txt,
.app[data-sidebar="collapsed"] .sidebar .nav-section,
.app[data-sidebar="collapsed"] .sidebar-foot .who{display:none}
.app[data-sidebar="collapsed"] .nav-link{justify-content:center;padding:.65rem}
.app[data-sidebar="collapsed"] .sidebar-head{justify-content:center;padding:0}
.app[data-sidebar="collapsed"] .sidebar-collapse{display:none}
.app[data-sidebar="collapsed"] .sidebar-foot{justify-content:center;padding:.5rem}
.app[data-sidebar="collapsed"] .nav-section{display:block;height:1px;background:rgba(255,255,255,.07);margin:.7rem .8rem;padding:0;font-size:0}
.app[data-sidebar="collapsed"] .nav-link.active::before{left:-.65rem}

.app-main{flex:1;display:flex;flex-direction:column;min-width:0}

.topbar{
  display:flex;align-items:center;gap:.9rem;padding:0 1.4rem;height:var(--topbar-h);
  background:var(--surface);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:50;
}
@supports (backdrop-filter:blur(8px)){
  .topbar{background:color-mix(in srgb,var(--surface) 82%,transparent);backdrop-filter:saturate(160%) blur(12px)}
}
.topbar-burger{display:none;background:transparent;border:none;color:var(--text);cursor:pointer;padding:.4rem;border-radius:8px}
.topbar-burger .ico{width:22px;height:22px}
.crumbs{display:flex;align-items:center;gap:.4rem;min-width:0;font-size:.86rem;color:var(--muted);white-space:nowrap;overflow:hidden}
.crumbs a{color:var(--muted)}
.crumbs a:hover{color:var(--text);text-decoration:none}
.crumbs .ico{width:14px;height:14px;opacity:.6}
.crumbs .cur{color:var(--text);font-weight:600;overflow:hidden;text-overflow:ellipsis}
.topbar-spacer{flex:1}
.search-pill{
  display:flex;align-items:center;gap:.6rem;min-width:min(340px,38vw);padding:.5rem .75rem;border-radius:999px;
  background:var(--surface-2);border:1px solid var(--border);color:var(--muted);cursor:pointer;font:inherit;text-align:left;
}
.search-pill:hover{border-color:var(--primary);color:var(--text)}
.search-pill .txt{flex:1;white-space:nowrap}
.kbd{font:600 .7rem var(--font);padding:.12rem .4rem;border-radius:6px;border:1px solid var(--border);background:var(--surface);color:var(--muted);box-shadow:0 1px 0 var(--border)}
.topbar-actions{display:flex;align-items:center;gap:.45rem;flex-shrink:0}
.icon-btn{
  width:38px;height:38px;display:grid;place-items:center;border:1px solid var(--border);
  background:var(--surface);border-radius:10px;cursor:pointer;color:var(--text-2);transition:background .12s,color .12s,border-color .12s;
}
.icon-btn:hover{background:var(--surface-2);color:var(--text);border-color:var(--muted)}
.icon-btn .ico{width:18px;height:18px}
.search-btn{display:none}
.user-menu{position:relative}
.user-btn{
  display:flex;align-items:center;gap:.5rem;border:1px solid var(--border);background:var(--surface);
  border-radius:999px;padding:.2rem .6rem .2rem .25rem;cursor:pointer;color:var(--text);font:inherit;
}
.user-btn:hover{background:var(--surface-2)}
.user-btn .ico{width:14px;height:14px;opacity:.6}
.user-drop{
  position:absolute;right:0;top:calc(100% + .5rem);background:var(--surface);border:1px solid var(--border);
  border-radius:14px;box-shadow:var(--shadow-lg);min-width:220px;padding:.4rem;z-index:70;
}
.user-drop a,.user-drop button{
  display:flex;align-items:center;gap:.6rem;width:100%;text-align:left;padding:.55rem .65rem;border-radius:8px;background:transparent;
  border:none;color:var(--text);font:inherit;cursor:pointer;
}
.user-drop a:hover,.user-drop button:hover{background:var(--surface-2);text-decoration:none}
.user-drop .dd-name{padding:.55rem .65rem;color:var(--muted);font-size:.78rem;border-bottom:1px solid var(--border);margin-bottom:.3rem}

.content{padding:1.7rem 1.8rem 2.4rem;flex:1;max-width:1480px;width:100%;margin:0 auto;animation:fadeUp .25s ease both}
@keyframes fadeUp{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.sidebar-backdrop{display:none;position:fixed;inset:0;background:rgba(8,10,20,.55);z-index:55;backdrop-filter:blur(2px)}

/* ---------- Page header ---------- */
.page-head{display:flex;justify-content:space-between;align-items:center;gap:1rem;margin-bottom:1.3rem;flex-wrap:wrap}
.page-head h1{margin:0;display:flex;align-items:center;gap:.7rem;flex-wrap:wrap}
.page-head > div:last-child{display:flex;gap:.5rem;flex-wrap:wrap;align-items:center}
.page-head .page-ico{width:42px;height:42px;border-radius:12px;display:grid;place-items:center;background:var(--primary-soft);color:var(--primary);flex-shrink:0}
.page-head .page-ico .ico{width:22px;height:22px}

/* ---------- Cards ---------- */
.card{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:1.3rem;margin-bottom:1.2rem;box-shadow:var(--shadow-sm);
}
.card > h3:first-child,.card > h2:first-child{margin-top:0}
/* filter / toolbar card = first card holding only a GET form */
.card > form.form-row:only-child{align-items:flex-end}
.card > form.form-row:only-child > div{min-width:170px}

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex;align-items:center;gap:.45rem;justify-content:center;
  padding:.55rem 1rem;border-radius:var(--radius-sm);border:1px solid transparent;
  background:var(--grad);color:#fff;cursor:pointer;font-size:.87rem;font-weight:600;font-family:inherit;line-height:1.2;
  transition:transform .08s,box-shadow .15s,filter .15s,background .15s;white-space:nowrap;
  box-shadow:0 4px 12px -4px rgba(79,70,229,.55);
}
.btn:hover{filter:brightness(1.07);text-decoration:none;box-shadow:0 8px 18px -6px rgba(79,70,229,.6)}
.btn:active{transform:translateY(1px)}
.btn .ico{width:1.05em;height:1.05em}
.btn-sm{padding:.34rem .7rem;font-size:.8rem;border-radius:8px;gap:.35rem}
.btn-lg{padding:.7rem 1.3rem;font-size:.95rem}
.btn-ghost{background:var(--surface);color:var(--text);border-color:var(--border);box-shadow:none}
.btn-ghost:hover{background:var(--surface-2);border-color:var(--muted);filter:none;box-shadow:none;color:var(--text)}
.btn-soft{background:var(--primary-soft);color:var(--primary);box-shadow:none}
.btn-soft:hover{filter:none;background:var(--primary-soft);box-shadow:none}
.btn-danger{background:var(--err);border-color:var(--err);box-shadow:0 4px 12px -4px rgba(224,62,62,.5)}
.btn-danger:hover{filter:brightness(.94)}
.btn-block{display:flex;width:100%}
.btn:disabled,.btn.is-loading{opacity:.6;cursor:not-allowed;pointer-events:none}
.btn.is-loading::after{content:"";width:.9em;height:.9em;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------- Forms ---------- */
label{display:block;font-weight:600;margin:.8rem 0 .32rem;font-size:.8rem;color:var(--text-2)}
input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],input[type=datetime-local],
input[type=search],input[type=tel],input[type=url],select,textarea{
  width:100%;padding:.6rem .75rem;border:1px solid var(--border);border-radius:var(--radius-sm);
  font:inherit;background:var(--surface);color:var(--text);transition:border-color .12s,box-shadow .12s;
}
input::placeholder,textarea::placeholder{color:var(--muted);opacity:.75}
input:hover,select:hover,textarea:hover{border-color:var(--muted)}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 4px var(--primary-soft)}
select{appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right .7rem center;padding-right:2.1rem}
textarea{min-height:92px;resize:vertical}
input[type=color]{padding:3px;height:40px;cursor:pointer}
input[type=checkbox],input[type=radio]{accent-color:var(--primary);width:1.05rem;height:1.05rem}
.form-row{display:flex;gap:1rem;flex-wrap:wrap}
.form-row>div{flex:1;min-width:190px}
.field-error{color:var(--err);font-size:.8rem;margin-top:.25rem}
.checkbox-row{display:flex;align-items:center;gap:.5rem;font-weight:500;margin:.35rem 0;color:var(--text)}
.checkbox-row input{width:auto}

/* ---------- Tables ---------- */
table{width:100%;border-collapse:separate;border-spacing:0;background:var(--surface);font-size:.875rem}
th,td{text-align:left;padding:.8rem 1rem;border-bottom:1px solid var(--border-2);vertical-align:middle}
thead th{
  background:var(--surface-2);font-size:.68rem;text-transform:uppercase;letter-spacing:.06em;
  color:var(--muted);font-weight:700;white-space:nowrap;border-bottom:1px solid var(--border);
}
.card[style*="padding:0"] > table thead th:first-child,.table-wrap > table thead th:first-child{border-top-left-radius:var(--radius)}
.card[style*="padding:0"] > table thead th:last-child,.table-wrap > table thead th:last-child{border-top-right-radius:var(--radius)}
tbody tr:last-child td{border-bottom:none}
tbody tr{transition:background .1s}
tbody tr:hover td{background:var(--surface-2)}
td a{font-weight:550}
td.muted,td .muted{font-size:.84rem}
.card[style*="padding:0"]{overflow:hidden}
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
.empty{
  display:flex;flex-direction:column;align-items:center;gap:.5rem;padding:2.6rem 1rem;text-align:center;color:var(--muted);
}
.empty .ico{width:42px;height:42px;padding:10px;border-radius:14px;background:var(--surface-3);color:var(--muted)}
.empty b{color:var(--text-2);font-weight:600}

/* ---------- Flash / toasts ---------- */
.flash{padding:.75rem 1rem;border-radius:var(--radius-sm);margin-bottom:1rem;font-size:.88rem;border:1px solid var(--border);border-left-width:4px;display:flex;gap:.6rem;align-items:center}
.flash-ok{background:var(--ok-soft);color:var(--ok);border-left-color:var(--ok)}
.flash-err{background:var(--err-soft);color:var(--err);border-left-color:var(--err)}
.flash-warn{background:var(--warn-soft);color:var(--warn);border-left-color:var(--warn)}
.flash-info{background:var(--info-soft);color:var(--info);border-left-color:var(--info)}
.toasts{position:fixed;right:1.2rem;bottom:1.2rem;display:flex;flex-direction:column;gap:.6rem;z-index:200;max-width:min(380px,calc(100vw - 2rem))}
.toast{
  display:flex;gap:.7rem;align-items:flex-start;padding:.8rem .95rem;border-radius:14px;background:var(--surface);
  border:1px solid var(--border);box-shadow:var(--shadow-lg);animation:toastIn .25s ease both;font-size:.88rem;
}
.toast .ico{width:20px;height:20px;margin-top:1px}
.toast.ok .ico{color:var(--ok)} .toast.err .ico{color:var(--err)} .toast.warn .ico{color:var(--warn)} .toast.info .ico{color:var(--info)}
.toast .x{margin-left:auto;background:none;border:none;color:var(--muted);cursor:pointer;padding:0;display:grid}
.toast.out{animation:toastOut .2s ease both}
@keyframes toastIn{from{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}
@keyframes toastOut{to{opacity:0;transform:translateX(12px)}}

/* ---------- Pills / badges ---------- */
.pill{display:inline-flex;align-items:center;gap:.38rem;padding:.2rem .65rem;border-radius:999px;font-size:.72rem;font-weight:650;background:var(--surface-3);color:var(--text-2);white-space:nowrap;text-transform:capitalize}
.pill::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.7}
.pill-active,.pill.s-ok{background:var(--ok-soft);color:var(--ok)}
.pill-disabled,.pill.s-err{background:var(--err-soft);color:var(--err)}
.pill.s-warn{background:var(--warn-soft);color:var(--warn)}
.pill.s-info{background:var(--info-soft);color:var(--info)}
.pill.s-violet{background:rgba(124,58,237,.12);color:var(--accent)}
.pill.s-muted{background:var(--surface-3);color:var(--muted)}

/* ---------- KPI / stats ---------- */
.kpi-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:1rem}
.kpi{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:1.1rem;box-shadow:var(--shadow-sm)}
.kpi .n{font-size:1.75rem;font-weight:750;letter-spacing:-.02em}
.kpi .l{color:var(--muted);font-size:.78rem;margin-top:.15rem}
.kpi .na{color:var(--muted);font-size:.95rem;font-style:italic}
.stat-group{margin-bottom:1.6rem}
.stat-group > h3{display:flex;align-items:center;gap:.5rem;font-size:.78rem;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);margin:0 0 .7rem;font-weight:700}
.stat-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:1rem}
.stat{
  --tone:var(--primary);position:relative;display:flex;gap:.9rem;align-items:center;padding:1rem 1.1rem;border-radius:var(--radius);
  background:var(--surface);border:1px solid var(--border);box-shadow:var(--shadow-sm);transition:transform .15s,box-shadow .15s,border-color .15s;color:inherit;
}
a.stat:hover{transform:translateY(-3px);box-shadow:var(--shadow);border-color:var(--tone);text-decoration:none}
.stat .bubble{width:46px;height:46px;border-radius:14px;display:grid;place-items:center;flex-shrink:0;background:color-mix(in srgb,var(--tone) 14%,transparent);color:var(--tone)}
.stat .bubble .ico{width:22px;height:22px}
.stat .num{font-size:1.55rem;font-weight:750;letter-spacing:-.025em;line-height:1.1;color:var(--text)}
.stat .lbl{font-size:.78rem;color:var(--muted);margin-top:.2rem}
.stat.warn{--tone:var(--warn)} .stat.err{--tone:var(--err)} .stat.ok{--tone:var(--ok)} .stat.info{--tone:var(--info)} .stat.violet{--tone:var(--accent)}
.stat .alert-dot{position:absolute;top:.8rem;right:.8rem;width:9px;height:9px;border-radius:50%;background:var(--err);box-shadow:0 0 0 4px color-mix(in srgb,var(--err) 20%,transparent)}
.skel{background:linear-gradient(90deg,var(--surface-3) 25%,var(--surface-2) 37%,var(--surface-3) 63%);background-size:400% 100%;animation:shimmer 1.3s ease infinite;border-radius:8px;display:block}
@keyframes shimmer{0%{background-position:100% 50%}100%{background-position:0 50%}}

/* hero + quick actions */
.hero{
  position:relative;overflow:hidden;border-radius:20px;padding:1.6rem 1.8rem;margin-bottom:1.4rem;color:#fff;
  background:radial-gradient(600px 260px at 0% 0%,rgba(255,255,255,.18),transparent 60%),var(--grad);
  box-shadow:0 18px 40px -14px rgba(79,70,229,.55);
}
.hero h1{color:#fff;font-size:1.65rem;margin-bottom:.25rem}
.hero p{color:rgba(255,255,255,.85);margin:0;max-width:58ch}
.hero::after{content:"";position:absolute;right:-60px;top:-60px;width:260px;height:260px;border-radius:50%;border:40px solid rgba(255,255,255,.08)}
.quick{display:flex;gap:.6rem;flex-wrap:wrap;margin-top:1.1rem;position:relative;z-index:1}
.quick a{
  display:inline-flex;align-items:center;gap:.5rem;padding:.55rem .9rem;border-radius:12px;background:rgba(255,255,255,.16);
  color:#fff;font-weight:600;font-size:.85rem;backdrop-filter:blur(6px);border:1px solid rgba(255,255,255,.18);transition:background .15s,transform .1s;
}
.quick a:hover{background:rgba(255,255,255,.28);text-decoration:none;transform:translateY(-1px)}
.panel-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,400px),1fr));gap:1.2rem;margin-bottom:1.2rem}
.panel-grid .card{margin:0}
.panel-head{display:flex;align-items:center;justify-content:space-between;gap:.6rem;margin-bottom:.8rem}
.panel-head h3{margin:0;display:flex;align-items:center;gap:.5rem}
.panel-head .ico{color:var(--primary)}
.list-rows{list-style:none;margin:0;padding:0}
.list-rows li{display:flex;align-items:center;gap:.8rem;padding:.65rem 0;border-bottom:1px solid var(--border-2)}
.list-rows li:last-child{border-bottom:none}
.list-rows .lead{width:38px;height:38px;border-radius:11px;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;flex-shrink:0}
.list-rows .txt{flex:1;min-width:0}
.list-rows .txt b{display:block;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.list-rows .txt small{color:var(--muted)}

/* ---------- Pagination ---------- */
.pagination{display:flex;gap:.35rem;margin-top:1.1rem;flex-wrap:wrap}
.pagination a,.pagination span{padding:.38rem .72rem;border:1px solid var(--border);border-radius:9px;background:var(--surface);color:var(--text);font-size:.83rem;font-weight:550}
.pagination a:hover{background:var(--surface-2);text-decoration:none}
.pagination .current{background:var(--primary);color:#fff;border-color:var(--primary)}

.perm-group{border:1px solid var(--border);border-radius:var(--radius-sm);padding:.8rem;margin-bottom:.7rem;background:var(--surface)}
.perm-group h4{margin:0 0 .5rem;font-size:.85rem;text-transform:capitalize}
.perm-group .checkbox-row{display:inline-flex;margin-right:1rem}

/* bare / setup */
.bare{background:var(--bg)}
.bare-main{max-width:760px;margin:3rem auto;padding:0 1.2rem}
.bare-main .card{margin-top:1rem}
.check-ok{color:var(--ok);font-weight:700}
.check-bad{color:var(--err);font-weight:700}
pre.output,pre{background:#0d1020;color:#c7ccd6;padding:1rem;border-radius:var(--radius-sm);overflow:auto;font-size:.82rem}

/* charts pick up theme */
[data-chart] svg rect{fill:url(#barGrad)}
[data-chart] svg .chart-grid{stroke:var(--border)}
[data-chart] svg .chart-lbl{fill:var(--muted)}

/* ---------- Modal (confirm) ---------- */
.modal-back{position:fixed;inset:0;background:rgba(8,10,20,.55);z-index:300;display:flex;align-items:center;justify-content:center;padding:1rem;backdrop-filter:blur(3px);animation:fadeIn .15s ease both}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.modal{background:var(--surface);border:1px solid var(--border);border-radius:20px;box-shadow:var(--shadow-lg);width:min(440px,100%);padding:1.5rem;animation:pop .18s ease both}
@keyframes pop{from{opacity:0;transform:scale(.96) translateY(6px)}to{opacity:1;transform:none}}
.modal .m-ico{width:46px;height:46px;border-radius:14px;display:grid;place-items:center;background:var(--warn-soft);color:var(--warn);margin-bottom:.8rem}
.modal .m-ico.danger{background:var(--err-soft);color:var(--err)}
.modal .m-ico .ico{width:22px;height:22px}
.modal h3{font-size:1.15rem;margin-bottom:.3rem}
.modal p{color:var(--text-2)}
.modal .m-actions{display:flex;justify-content:flex-end;gap:.6rem;margin-top:1.3rem}

/* ---------- Command palette ---------- */
.cmdk-back{position:fixed;inset:0;background:rgba(8,10,20,.55);z-index:400;display:flex;justify-content:center;align-items:flex-start;padding:min(14vh,110px) 1rem 1rem;backdrop-filter:blur(3px);animation:fadeIn .12s ease both}
.cmdk{width:min(640px,100%);background:var(--surface);border:1px solid var(--border);border-radius:20px;box-shadow:var(--shadow-lg);overflow:hidden;animation:pop .16s ease both;display:flex;flex-direction:column;max-height:min(72vh,560px)}
.cmdk-input{display:flex;align-items:center;gap:.7rem;padding:.9rem 1.1rem;border-bottom:1px solid var(--border)}
.cmdk-input .ico{width:20px;height:20px;color:var(--muted)}
.cmdk-input input{border:none;background:transparent;padding:.2rem 0;font-size:1.02rem;box-shadow:none!important;flex:1}
.cmdk-input input:focus{box-shadow:none;border:none}
.cmdk-list{overflow-y:auto;padding:.5rem}
.cmdk-label{font-size:.66rem;text-transform:uppercase;letter-spacing:.08em;color:var(--muted);padding:.7rem .7rem .3rem;font-weight:700}
.cmdk-item{display:flex;align-items:center;gap:.8rem;padding:.6rem .7rem;border-radius:11px;color:var(--text);cursor:pointer}
.cmdk-item:hover,.cmdk-item.is-active{background:var(--primary-soft);text-decoration:none}
.cmdk-item .ci{width:34px;height:34px;border-radius:10px;background:var(--surface-3);display:grid;place-items:center;color:var(--text-2);flex-shrink:0}
.cmdk-item.is-active .ci{background:var(--primary);color:#fff}
.cmdk-item .ct{flex:1;min-width:0}
.cmdk-item .ct b{display:block;font-weight:600;font-size:.9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cmdk-item .ct small{color:var(--muted);font-size:.78rem}
.cmdk-item .go{opacity:0;color:var(--primary)}
.cmdk-item.is-active .go{opacity:1}
.cmdk-empty{padding:1.6rem;text-align:center;color:var(--muted)}
.cmdk-foot{display:flex;gap:1rem;align-items:center;padding:.55rem 1rem;border-top:1px solid var(--border);color:var(--muted);font-size:.75rem;background:var(--surface-2)}

/* ---------- Bottom navigation (mobile) ---------- */
.bottom-nav{
  display:none;position:fixed;left:0;right:0;bottom:0;height:var(--bottomnav-h);z-index:45;
  background:var(--surface);border-top:1px solid var(--border);padding:0 .4rem env(safe-area-inset-bottom,0);
  grid-template-columns:repeat(5,1fr);box-shadow:0 -6px 24px -10px rgba(15,18,38,.2);
}
.bn-item{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:var(--muted);font-size:.66rem;font-weight:600;background:none;border:none;cursor:pointer;font-family:inherit;padding:.3rem 0;min-width:0}
.bn-item .ico{width:22px;height:22px}
.bn-item.active{color:var(--primary)}
.bn-item:hover{text-decoration:none;color:var(--text)}
.bn-fab{position:relative;top:-14px}
.bn-fab span{display:grid;place-items:center;width:52px;height:52px;border-radius:50%;background:var(--grad);color:#fff;box-shadow:0 10px 22px -6px rgba(79,70,229,.7);margin:0 auto}
.bn-fab .ico{width:24px;height:24px}

/* ---------- Responsive ---------- */
@media (max-width:1100px){
  .content{padding:1.3rem 1.2rem 2rem}
  .search-pill{min-width:0}
  .search-pill .txt,.search-pill .kbd{display:none}
  .search-pill{padding:.5rem;border-radius:10px;width:38px;height:38px;justify-content:center}
}
@media (max-width:960px){
  .auth-body{grid-template-columns:1fr}
  .auth-hero{display:none}
  .auth-brand{display:flex;align-items:center;gap:.6rem;font-weight:750;font-size:1.1rem;margin-bottom:1.4rem}
  .sidebar{position:fixed;left:0;top:0;height:100dvh;transform:translateX(-102%);box-shadow:var(--shadow-lg);width:min(300px,86vw)}
  .app[data-drawer="open"] .sidebar{transform:none}
  .app[data-drawer="open"] .sidebar-backdrop{display:block}
  .app[data-sidebar="collapsed"] .sidebar{width:min(300px,86vw)}
  .app[data-sidebar="collapsed"] .sidebar .brand-text,.app[data-sidebar="collapsed"] .sidebar .nav-txt,.app[data-sidebar="collapsed"] .sidebar-foot .who{display:revert}
  .app[data-sidebar="collapsed"] .sidebar .nav-section{display:block;height:auto;background:none;margin:0;padding:1.1rem .75rem .4rem;font-size:.64rem}
  .app[data-sidebar="collapsed"] .nav-link{justify-content:flex-start;padding:.55rem .75rem}
  .sidebar-collapse{display:none}
  .topbar-burger{display:grid}
  .bottom-nav{display:grid}
  .app-main{padding-bottom:var(--bottomnav-h)}
  .toasts{bottom:calc(var(--bottomnav-h) + .8rem)}
  .user-btn .user-name,.user-btn > .ico{display:none}
  .user-btn{padding:.2rem}
}
@media (max-width:720px){
  html{font-size:15px}
  .content{padding:1rem .85rem 1.6rem}
  .topbar{padding:0 .8rem;gap:.5rem}
  .crumbs a,.crumbs .ico{display:none}
  .crumbs .cur{font-size:1rem}
  .page-head .page-ico{display:none}
  .card{padding:1rem;border-radius:14px}
  .hero{padding:1.2rem;border-radius:16px}
  .hero h1{font-size:1.35rem}
  .stat-grid{grid-template-columns:1fr 1fr;gap:.7rem}
  .stat{flex-direction:column;align-items:flex-start;gap:.6rem;padding:.9rem}
  .stat .num{font-size:1.35rem}
  .page-head > div:last-child{width:100%}
  .page-head > div:last-child .btn{flex:1}
  .form-row{gap:.2rem 1rem}
  .form-row>div{min-width:calc(50% - .5rem)}
  .form-row:has(input:not([type=checkbox]):not([type=radio]),textarea)>div{min-width:100%}
  .card > form.form-row:only-child > div{min-width:calc(50% - .5rem)}
  .card > form.form-row:only-child .btn{width:100%}
  .modal{padding:1.2rem}
  .modal .m-actions .btn{flex:1}
  /* tables become cards */
  table.rt{border:none;background:transparent}
  table.rt thead{display:none}
  table.rt,table.rt tbody,table.rt tr,table.rt td{display:block;width:100%}
  table.rt tr{background:var(--surface);border:1px solid var(--border);border-radius:14px;margin:.65rem .65rem;width:auto;padding:.55rem .9rem;box-shadow:var(--shadow-sm)}
  table.rt tbody tr:hover td{background:transparent}
  table.rt td{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem;padding:.4rem 0;border:none;text-align:right;word-break:break-word}
  table.rt td::before{content:attr(data-label);font-weight:700;color:var(--muted);text-align:left;font-size:.68rem;text-transform:uppercase;letter-spacing:.05em;padding-top:.15rem;flex-shrink:0;max-width:42%}
  table.rt td:not([data-label])::before,table.rt td[data-label=""]::before{content:none}
  table.rt td[colspan]{display:block;text-align:center}
  table.rt td[colspan]::before{content:none}
  table.rt td:first-child{font-weight:600}
  .card[style*="padding:0"]{overflow:visible;background:transparent;border:none;box-shadow:none}
  .card[style*="padding:0"] > div:first-child:not(.table-wrap){padding-left:.3rem!important}
}
@media (hover:none){
  .btn:active,.nav-link:active{transform:scale(.98)}
}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
@media print{
  .sidebar,.topbar,.bottom-nav,.toasts,.sidebar-backdrop{display:none!important}
  .content{padding:0;max-width:none;animation:none}
  .card{box-shadow:none;border-color:#ccc}
  body{background:#fff;color:#000}
}
