* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; font-family: var(--font); color: var(--text); background: var(--workspace-bg); font-size: 14px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip-link { position: fixed; left: 12px; top: -100px; z-index: 1000; padding: 10px 14px; background: var(--accent); color: var(--accent-contrast); border-radius: var(--radius-sm); text-decoration: none; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.icon { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 30px; height: 30px; }
.icon-xl { width: 44px; height: 44px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
.app-shell.sidebar-collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; min-width: 0; display: flex; flex-direction: column; padding: 14px 12px 12px; background: var(--sidebar-bg); color: #f7f7f7; border-right: 1px solid rgba(255,255,255,.04); z-index: 30; overflow: hidden; }
.brand-row { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-title); font-weight: 700; letter-spacing: -.03em; }
.brand-mark { flex: 0 0 auto; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-contrast); font-family: var(--font-title); font-size: 16px; font-weight: 800; }
.brand-mark-large { width: 42px; height: 42px; border-radius: 12px; font-size: 21px; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; }
.icon-button:hover { background: rgba(127,127,127,.14); }
.sidebar .icon-button { width: 34px; height: 34px; color: #aaa; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 3px; margin: 24px 0 12px; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.nav-item { position: relative; display: flex; align-items: center; min-height: 42px; gap: 12px; padding: 10px 11px; border-radius: 10px; color: #d8d8da; text-decoration: none; white-space: nowrap; }
.nav-item:hover { background: rgba(255,255,255,.055); color: white; }
.nav-item-accent .icon { color: var(--accent); }
.nav-applications .nav-item-accent .icon { color: var(--application-accent); }
.nav-tools .nav-item-accent .icon { color: var(--accent); }
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-tools { display: flex; flex-direction: column; min-width: 0; }
.nav-tools-row { display: grid; grid-template-columns: minmax(0, 1fr) 32px; align-items: center; gap: 2px; }
.nav-tools-link { min-width: 0; }
.nav-tools-toggle { display: grid; place-items: center; width: 32px; height: 36px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: #bfc9d8; cursor: pointer; }
.nav-tools-toggle:hover { background: rgba(255,255,255,.055); color: white; }
.nav-tools-toggle .icon { width: 17px; height: 17px; transition: transform .18s ease; }
.tools-submenu-open .nav-tools-toggle .icon { transform: rotate(180deg); }
.nav-tools-submenu { display: flex; flex-direction: column; gap: 2px; padding: 3px 4px 5px 43px; }
.nav-tools-submenu[hidden] { display: none; }
.nav-tools-category { display: block; min-height: 32px; padding: 7px 9px; border-radius: 8px; color: #bfc9d8; font-size: 12px; line-height: 1.35; text-decoration: none; white-space: normal; overflow-wrap: anywhere; }
.nav-tools-category:hover { background: rgba(255,255,255,.055); color: white; }
.nav-separator { height: 1px; margin: 10px 6px; background: rgba(255,255,255,.08); }
.sidebar-footer { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.07); }
.version-chip { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 12px; color: #8d8d92; font-size: 11px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(85,200,139,.12); }
.sidebar-icon-expand { display: none; }
.sidebar-collapsed .brand, .sidebar-collapsed .nav-item span, .sidebar-collapsed .version-chip span:last-child { display: none; }
.sidebar-collapsed .sidebar-icon-collapse { display: none; }
.sidebar-collapsed .sidebar-icon-expand { display: block; }
.sidebar-collapsed .brand-row { justify-content: center; }
.sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.sidebar-collapsed .nav-tools-row { display: block; }
.sidebar-collapsed .nav-tools-toggle, .sidebar-collapsed .nav-tools-submenu { display: none !important; }
.sidebar-collapsed .version-chip { justify-content: center; padding-inline: 0; }
.sidebar-collapsed .nav-item::after { content: attr(data-tooltip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); padding: 6px 8px; border-radius: 6px; background: #111; color: white; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .12s; box-shadow: var(--shadow); }
.sidebar-collapsed .nav-item:hover::after { opacity: 1; }

.workspace { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; background: var(--workspace-bg); }
.topbar { position: sticky; top: 0; z-index: 20; min-height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 18px 6px 22px; background: var(--topbar-bg); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.topbar-title { font-weight: 600; font-family: var(--font-title); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar form { margin: 0; }
.user-pill { display: flex; align-items: center; gap: 8px; max-width: 220px; padding: 4px 8px 4px 4px; border-radius: 12px; color: var(--muted); }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px; background: var(--surface-3); color: var(--text); font-weight: 700; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: block; }
.content { width: min(100%, 1320px); flex: 1; align-self: center; display: flex; flex-direction: column; gap: 24px; padding: 38px 44px 56px; }
.page-heading, .catalog-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.page-heading h1, .catalog-header h1 { margin: 2px 0 8px; font: 700 clamp(25px, 2.5vw, 38px)/1.14 var(--font-title); letter-spacing: -.04em; }
.page-heading p, .catalog-header p { margin: 0; color: var(--muted); line-height: 1.55; max-width: 760px; }
.eyebrow { margin: 0 0 6px !important; color: var(--accent) !important; font-size: 11px !important; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }
.section-block { display: flex; flex-direction: column; gap: 14px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font: 650 17px var(--font-title); }
.section-heading a { color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 650; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat-card, .panel, .narrow-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 1px 0 rgba(255,255,255,.02); }
.stat-card { display: flex; flex-direction: column; gap: 8px; min-height: 132px; padding: 20px; }
.stat-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { font: 700 20px var(--font-title); }
.stat-note { margin-top: auto; color: var(--muted); font-size: 12px; }
.panel { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.panel-heading h2 { margin: 0 0 6px; font: 650 17px var(--font-title); }
.panel-heading p { margin: 0; color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.narrow-panel { width: min(100%, 720px); padding: 28px; }
.narrow-panel h1 { margin: 2px 0 10px; font: 700 28px var(--font-title); }
.code-chip { display: inline-flex; align-self: flex-start; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font: 600 12px ui-monospace, SFMono-Regular, Consolas, monospace; }

.auth-body { background: var(--bg); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(330px, .85fr) minmax(420px, 1.15fr); }
.auth-brand-panel { padding: clamp(36px, 6vw, 76px); display: flex; flex-direction: column; justify-content: space-between; gap: 50px; background: var(--sidebar-bg); color: white; border-right: 1px solid rgba(255,255,255,.06); }
.auth-brand { display: flex; align-items: center; gap: 12px; font: 700 19px var(--font-title); }
.auth-brand.inline { margin-bottom: 18px; }
.auth-brand-panel h1 { max-width: 540px; margin: 8px 0 16px; font: 700 clamp(34px, 4vw, 58px)/1.02 var(--font-title); letter-spacing: -.055em; }
.auth-brand-panel p:not(.eyebrow) { max-width: 530px; margin: 0; color: #a8a8ad; line-height: 1.7; }
.auth-version { color: #727277; font-size: 12px; }
.auth-form-panel { position: relative; display: grid; place-items: center; padding: 36px; background: var(--workspace-bg); }
.auth-theme { position: absolute; top: 18px; right: 18px; }
.auth-card { width: min(100%, 430px); }
.auth-card.wide { width: min(100%, 620px); }
.auth-card h2, .auth-card h1 { margin: 4px 0 8px; font: 700 30px var(--font-title); letter-spacing: -.035em; }
.auth-card > p { line-height: 1.55; }
.auth-help { margin-top: 18px; color: var(--muted); font-size: 12px; }
.auth-help a { color: var(--accent); }
.auth-centered { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: var(--workspace-bg); }

@media (max-width: 940px) {
  .content { padding: 30px 24px 44px; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: 300px; padding: 36px; }
}
@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: auto 0 0 0; width: 100%; height: 62px; flex-direction: row; align-items: center; padding: 6px 10px; border: 0; border-top: 1px solid rgba(255,255,255,.08); }
  .brand-row, .sidebar-footer, .nav-separator { display: none; }
  .sidebar-nav { width: 100%; flex-direction: row; justify-content: space-around; margin: 0; overflow: visible; }
  .sidebar-nav .nav-item { min-width: 46px; flex: 1; padding: 8px; }
  .sidebar-nav > .nav-tools { min-width: 46px; flex: 1; }
  .nav-tools-row { display: block; }
  .nav-tools-toggle, .nav-tools-submenu { display: none !important; }
  .nav-tools-link { width: 100%; }
  .sidebar-nav .nav-item:nth-of-type(n+5) { display: none; }
  .workspace { padding-bottom: 62px; }
  .topbar { padding-inline: 14px; }
  .user-name { display: none; }
  .content { padding: 24px 16px 36px; }
  .page-heading, .catalog-header { align-items: stretch; flex-direction: column; }
  .auth-form-panel { padding: 28px 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; } }
