:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --surface-strong: #111827;
  --text: #111318;
  --muted: #707784;
  --muted-2: #9aa1ad;
  --border: #e8ebf0;
  --border-strong: #d9dde5;
  --primary: #3157f6;
  --primary-soft: #edf2ff;
  --cyan: #22b8d8;
  --yellow: #f5c518;
  --yellow-soft: #fff8d8;
  --purple: #7c6cf2;
  --green: #1fbf75;
  --green-soft: #eaf9f1;
  --orange: #ff9d2e;
  --orange-soft: #fff4e6;
  --red: #ef5350;
  --red-soft: #fff0ef;
  --blue-soft: #eef4ff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .03);
  --shadow-sm: 0 8px 20px rgba(16, 24, 40, .04);
  --sidebar-width: 232px;
  --topbar-height: 64px;
  --page-padding: 20px;
  --gap: 14px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; color-scheme: light; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
html.dark body, body.dark {
  --bg: #0d1118;
  --surface: #151a23;
  --surface-soft: #11161e;
  --surface-strong: #05080d;
  --text: #f2f4f7;
  --muted: #a0a7b4;
  --muted-2: #7f8794;
  --border: #252c38;
  --border-strong: #343c49;
  --primary-soft: #16214c;
  --yellow-soft: #3b3210;
  --green-soft: #0d3324;
  --orange-soft: #3b2711;
  --red-soft: #3b1719;
  --blue-soft: #17233e;
  color-scheme: dark;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
img { max-width: 100%; display: block; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.app-main { min-width: 0; }
.main-content { padding: var(--page-padding); max-width: 1900px; margin: 0 auto; width: 100%; }

.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 50; min-width: 0; transition: width .2s ease, transform .2s ease; }
.sidebar-brand { position: relative; height: var(--topbar-height); padding: 8px 14px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 42px minmax(0, 1fr) 30px; align-items: center; gap: 9px; }
.sidebar-logo { width: 42px; height: 42px; object-fit: contain; mix-blend-mode: multiply; }
.dark .sidebar-logo { background: white; border-radius: 8px; }
.sidebar-brand strong { display: block; font-size: 14px; letter-spacing: .02em; }
.sidebar-brand span { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.sidebar-collapse { position: absolute; right: -15px; top: 17px; z-index: 4; border: 1px solid var(--border); background: var(--surface); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; cursor: pointer; box-shadow: var(--shadow-xs); }
.sidebar-collapse:hover { background: var(--surface-soft); }
.sidebar-collapse svg { width: 16px; height: 16px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; scrollbar-width: thin; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-group-label { color: var(--muted-2); text-transform: uppercase; font-size: 10px; letter-spacing: .1em; font-weight: 700; padding: 0 10px 6px; }
.nav-item { min-height: 36px; border-radius: 9px; display: flex; align-items: center; gap: 10px; padding: 0 10px; color: #4e5664; font-weight: 500; position: relative; transition: background .16s ease, color .16s ease, transform .16s ease; }
.dark .nav-item { color: #c2c8d1; }
.nav-item:hover { background: var(--surface-soft); color: var(--text); }
.nav-item.active { background: #f1f3f7; color: var(--text); font-weight: 650; }
.dark .nav-item.active { background: #222936; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 999px; background: var(--yellow); }
.nav-item svg { width: 17px; height: 17px; flex: 0 0 auto; }
.sidebar-footer { padding: 12px 16px 15px; border-top: 1px solid var(--border); }
.company-mini strong { display: block; font-size: 13px; }
.company-mini span { display: block; font-size: 10px; line-height: 1.45; color: var(--muted); margin-top: 4px; }
.yellow-rule { height: 3px; width: 100%; background: var(--yellow); margin-top: 12px; border-radius: 999px; }

body.sidebar-collapsed { --sidebar-width: 68px; }
body.sidebar-collapsed .sidebar-brand { grid-template-columns: 42px; padding-inline: 12px; }
body.sidebar-collapsed .sidebar-brand > div, body.sidebar-collapsed .nav-group-label, body.sidebar-collapsed .nav-item span, body.sidebar-collapsed .sidebar-footer { display: none; }
body.sidebar-collapsed .sidebar-collapse { display: grid; right: -15px; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
body.sidebar-collapsed .nav-item.active::before { left: -10px; }

.topbar { position: sticky; top: 0; z-index: 40; min-height: var(--topbar-height); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); padding: 0 var(--page-padding); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.mobile-brand { display: none; align-items: center; gap: 9px; }
.global-search-wrap { width: min(520px, 50vw); height: 38px; position: relative; display: flex; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.global-search-wrap:focus-within { border-color: #b8c6ff; box-shadow: 0 0 0 3px rgba(49, 87, 246, .08); background: var(--surface); }
.global-search-wrap > svg { color: var(--muted); width: 16px; height: 16px; }
.global-search-wrap input { border: 0; outline: none; min-width: 0; flex: 1; background: transparent; color: var(--text); }
.global-search-wrap input::placeholder { color: var(--muted-2); }
kbd { border: 1px solid var(--border); color: var(--muted); background: var(--surface); border-radius: 6px; padding: 2px 5px; font-size: 10px; box-shadow: var(--shadow-xs); }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 18px 40px rgba(16, 24, 40, .12); padding: 6px; max-height: 420px; overflow-y: auto; }
.search-group-label { padding: 7px 10px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); font-weight: 700; }
.search-result-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 8px; border-radius: 8px; }
.search-result-item:hover { background: var(--surface-soft); }
.search-result-item .result-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--blue-soft); color: var(--primary); display: grid; place-items: center; }
.search-result-item strong, .search-result-item small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-item small { color: var(--muted); margin-top: 2px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.user-menu-trigger { border: 0; background: transparent; display: flex; align-items: center; gap: 9px; padding: 4px 6px; border-radius: 10px; cursor: pointer; }
.user-menu-trigger:hover { background: var(--surface-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #171d28; color: white; font-weight: 700; }
.user-copy { text-align: left; min-width: 118px; }
.user-copy strong, .user-copy small { display: block; }
.user-copy strong { font-size: 12px; }
.user-copy small { color: var(--muted); font-size: 10px; margin-top: 1px; }
.user-menu-trigger > svg { width: 14px; height: 14px; color: var(--muted); }
.notification-button { position: relative; }
.notification-count { position: absolute; top: -4px; right: -3px; background: var(--yellow); color: #111; font-size: 9px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; display: grid; place-items: center; font-weight: 700; box-shadow: 0 0 0 2px var(--surface); }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); backdrop-filter: blur(2px); z-index: 45; }

.page-header { margin: 2px 0 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-heading { min-width: 0; }
.page-title-row { display: flex; align-items: center; gap: 11px; }
.page-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text); box-shadow: var(--shadow-xs); }
.page-title-row h1 { margin: 0; font-size: clamp(22px, 2vw, 28px); line-height: 1.1; letter-spacing: -.035em; }
.page-title-row p { margin: 5px 0 0; color: var(--muted); font-size: 12px; max-width: 680px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.breadcrumb { min-height: 22px; display: flex; align-items: center; gap: 4px; color: var(--muted-2); font-size: 11px; margin-bottom: 8px; }
.breadcrumb svg { width: 12px; height: 12px; }
.breadcrumb span:last-child { color: var(--muted); font-weight: 600; }

.grid { display: grid; gap: var(--gap); min-width: 0; }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack-sm > * + * { margin-top: 8px; }
.stack-md > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 16px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mb-14 { margin-bottom: 14px; }
.muted { color: var(--muted); }
.xs { font-size: 10px; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.login-body { min-height: 100vh; background: #f5f6f8; display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(1020px, 100%); min-height: 620px; background: white; border: 1px solid #e6e8ed; border-radius: 20px; display: grid; grid-template-columns: 1.15fr .85fr; overflow: hidden; box-shadow: 0 24px 70px rgba(16,24,40,.08); }
.login-brand { background: #0b0f16; color: white; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, rgba(245,197,24,.18), transparent 65%); right: -120px; bottom: -100px; }
.login-brand img { width: 210px; background: white; border-radius: 12px; padding: 12px; }
.login-brand .eyebrow { display: inline-block; color: var(--yellow); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 800; margin-bottom: 12px; }
.login-brand h1 { font-size: 38px; line-height: 1.08; max-width: 520px; letter-spacing: -.045em; margin: 0; }
.login-brand p { color: #aeb5c0; max-width: 500px; }
.login-card { padding: 70px 54px; display: flex; flex-direction: column; justify-content: center; }
.login-card-head { margin-bottom: 28px; }
.brand-mark { font-size: 18px; font-weight: 900; letter-spacing: .04em; }
.brand-mark span { color: var(--yellow); }
.login-card h2 { font-size: 28px; margin: 22px 0 4px; letter-spacing: -.03em; }
.login-card p { color: var(--muted); margin: 0; }
.login-demo { margin-top: 16px !important; font-size: 11px; text-align: center; }
.setup-body { min-height: 100vh; background: var(--bg); display: grid; place-items: center; padding: 24px; }
.setup-card { width: min(620px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 30px; box-shadow: var(--shadow-sm); }
.setup-card img { width: 160px; margin-bottom: 18px; }
.setup-card h1 { margin: 0 0 8px; }
.setup-card p { color: var(--muted); }
.setup-card code { background: var(--surface-soft); padding: 2px 5px; border-radius: 5px; }

@media (max-width: 1380px) {
  :root { --sidebar-width: 218px; --page-padding: 16px; --gap: 12px; }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1120px) {
  .grid-5, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-copy { display: none; }
  .user-menu-trigger > svg { display: none; }
}
@media (max-width: 920px) {
  :root { --sidebar-width: 0px; --page-padding: 14px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 250px; box-shadow: 18px 0 40px rgba(15,23,42,.12); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-collapse { display: none; }
  .mobile-brand { display: flex; }
  .global-search-wrap { width: min(430px, 55vw); }
  .topbar { gap: 10px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { padding: 48px 36px; }
}
@media (max-width: 680px) {
  :root { --page-padding: 12px; --gap: 10px; }
  .topbar { padding-inline: 10px; }
  .global-search-wrap { width: auto; flex: 1; }
  .global-search-wrap kbd { display: none; }
  .topbar-actions #themeToggle { display: none; }
  .page-header { align-items: flex-start; flex-direction: column; margin-bottom: 12px; }
  .page-actions { width: 100%; justify-content: flex-start; }
  .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .page-title-row h1 { font-size: 22px; }
  .page-title-row p { font-size: 11px; }
  .page-icon { width: 34px; height: 34px; }
  .login-body { padding: 0; }
  .login-shell { min-height: 100vh; border-radius: 0; border: 0; }
  .login-card { padding: 36px 24px; }
}


/* Demo mode */
.demo-banner{height:38px;display:flex;align-items:center;justify-content:center;gap:8px;padding:0 16px;background:#fff8d7;border-bottom:1px solid #f2d45d;color:#594600;font-size:12px;position:sticky;top:0;z-index:70}.demo-banner svg{width:15px;height:15px}.demo-banner+ .app-shell{min-height:calc(100vh - 38px)}body:has(.demo-banner) .sidebar{top:38px;height:calc(100vh - 38px)}@media(max-width:680px){.demo-banner{height:auto;min-height:42px;text-align:center;padding:8px 12px}.demo-banner span{line-height:1.3}}


/* v1.4.7: desktop app shell owns the viewport; only main content scrolls. */
@media (min-width: 761px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { height: 100dvh; min-height: 100dvh; overflow: hidden; align-items: stretch; }
  .sidebar { position: sticky; top: 0; height: 100dvh; min-height: 100dvh; max-height: 100dvh; align-self: start; overflow: hidden; }
  .sidebar-nav { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .app-main { height: 100dvh; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; }
}
