/* ==========================================================================
   PRTY OS — Base, shell layout, utilities
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-13);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; font-weight: 600; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { flex-shrink: 0; }
img { max-width: 100%; }
::selection { background: rgba(138, 164, 242, 0.3); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-1); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100%;
  transition: grid-template-columns var(--dur-2) var(--ease);
}
.shell.is-collapsed { grid-template-columns: 56px minmax(0, 1fr); }

.shell__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}
.shell__scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: auto;
}

/* Sidebar */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--line-soft);
}
.brandmark {
  width: 24px; height: 24px;
  border-radius: 5px;
  background: var(--inverse);
  color: var(--on-inverse);
  display: grid; place-items: center;
  font: 700 9px/1 var(--mono);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.sidebar__name { font-weight: 600; font-size: var(--fs-14); letter-spacing: -0.01em; white-space: nowrap; }
.sidebar__name span { color: var(--text-3); font-weight: 500; }
.sidebar__nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }
.sidebar__group { font-size: var(--fs-11); color: var(--text-4); text-transform: uppercase; letter-spacing: 0.08em; padding: 14px 10px 6px; white-space: nowrap; }
.navlink {
  display: flex; align-items: center; gap: 10px;
  height: 30px; padding: 0 10px;
  border-radius: var(--r-2);
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-1), color var(--dur-1);
}
.navlink:hover { background: var(--hover); color: var(--text); }
.navlink.is-active { background: var(--press); color: var(--text); }
.navlink .icon { color: var(--text-3); }
.navlink.is-active .icon { color: var(--text); }
.navlink__count { margin-left: auto; font: 500 var(--fs-11)/1 var(--font); color: var(--text-3); font-variant-numeric: tabular-nums; }
.navlink__count.is-alert { color: var(--red); }
.navlink.is-disabled { color: var(--text-4); cursor: default; }
.navlink.is-disabled:hover { background: none; color: var(--text-4); }
.sidebar__foot { border-top: 1px solid var(--line-soft); padding: 8px; display: flex; flex-direction: column; gap: 1px; }

/* Personal primary-menu editor. */
.navlink--edit { width: 100%; border: none; background: none; cursor: pointer; margin-top: 4px; color: var(--text-3); }
.navlink--edit:hover { color: var(--text); }
.navedit { display: flex; flex-direction: column; gap: 2px; }
.navedit__head { display: flex; align-items: center; gap: 6px; padding: 4px 6px 8px; }
.navedit__head .push, .navedit__head span:first-child { margin-right: auto; }
.navedit__row { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px; border-radius: var(--r-2); background: var(--surface-2, rgba(127,127,127,0.06)); color: var(--text-2); cursor: grab; }
.navedit__row:active { cursor: grabbing; }
.navedit__grip { color: var(--text-4); flex: 0 0 auto; }
.navedit__label { flex: 1; font-size: var(--fs-13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navedit__btn { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: var(--r-2); border: 1px solid var(--line-soft); background: var(--surface); color: var(--text-2); cursor: pointer; flex: 0 0 auto; }
.navedit__btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.navedit__btn:disabled { opacity: 0.35; cursor: default; }
.shell.is-collapsed .sidebar__name,
.shell.is-collapsed .sidebar__group,
.shell.is-collapsed .navlink__label,
.shell.is-collapsed .navlink__count,
.shell.is-collapsed .sidebar__user-meta { display: none; }
.shell.is-collapsed .navlink { justify-content: center; padding: 0; }
.shell.is-collapsed .sidebar__brand { padding: 0; justify-content: center; }

.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-2); }
.sidebar__user-meta { min-width: 0; line-height: 1.25; }
.sidebar__user-meta b { display: block; font-weight: 500; font-size: var(--fs-13); }
.sidebar__user-meta span { font-size: var(--fs-11); color: var(--text-3); }

/* Topbar */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--page-pad);
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg);
}
.topbar__crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-3); font-size: var(--fs-13); white-space: nowrap; overflow: hidden; }
.topbar__crumbs a:hover { color: var(--text); }
.topbar__crumbs .is-current { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.topbar__search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  height: 32px; width: 320px; max-width: 40vw;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--text-3);
  transition: border-color var(--dur-1), background var(--dur-1);
}
.topbar__search:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--text-2); }
.topbar__search span { flex: 1; text-align: left; }
.topbar .topbar__menu { display: none; }
.topbar__today { font-size: var(--fs-12); color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Mobile shell */
@media (max-width: 900px) {
  .shell, .shell.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 60;
    transform: translateX(-102%);
    transition: transform var(--dur-2) var(--ease);
    padding-top: env(safe-area-inset-top, 0px);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.is-collapsed .sidebar__name, .shell.is-collapsed .sidebar__group,
  .shell.is-collapsed .navlink__label, .shell.is-collapsed .navlink__count,
  .shell.is-collapsed .sidebar__user-meta { display: revert; }
  .shell.is-collapsed .navlink { justify-content: flex-start; padding: 0 10px; }
  .nav-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 55; }
  .topbar .topbar__menu { display: inline-flex; }
  .topbar__search { width: 36px; padding: 0; justify-content: center; }
  .topbar__search span, .topbar__search .kbd, .topbar__today, .topbar .topbar__collapse { display: none; }
  .topbar__crumbs > :not(:last-child) { display: none; }
}

/* ---------- Page scaffolding ---------- */

.page { padding: 0 var(--page-pad) var(--s-10); max-width: 1680px; margin: 0 auto; }
.page--narrow { max-width: 1180px; }
.page-head { padding: var(--s-6) 0 var(--s-5); display: flex; gap: var(--s-4); align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.page-head__main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.page-head__eyebrow { font-size: var(--fs-11); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; display: flex; gap: 8px; align-items: center; }
.page-title { font-size: var(--fs-20); line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
.page-head__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; color: var(--text-2); font-size: var(--fs-13); }
.page-head__meta > * { display: inline-flex; align-items: center; gap: 6px; }
.page-head__actions { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.page-section { margin-top: var(--s-8); }
.page-section:first-child { margin-top: 0; }

/* ---------- Layout utilities ---------- */

.row { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.row--top { align-items: flex-start; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); } .gap-6 { gap: var(--s-6); } .gap-8 { gap: var(--s-8); }
.grow { flex: 1; min-width: 0; }
.push { margin-left: auto; }
.grid { display: grid; gap: var(--s-4); }
.grid-2 { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--s-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--s-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

.hide-mobile { }
@media (max-width: 720px) { .hide-mobile { display: none !important; } }
@media (min-width: 721px) { .only-mobile { display: none !important; } }

/* ---------- Text utilities ---------- */

.t-11 { font-size: var(--fs-11); } .t-12 { font-size: var(--fs-12); } .t-13 { font-size: var(--fs-13); }
.t-14 { font-size: var(--fs-14); } .t-16 { font-size: var(--fs-16); } .t-20 { font-size: var(--fs-20); }
.t-2 { color: var(--text-2); } .t-3 { color: var(--text-3); } .t-4 { color: var(--text-4); }
.t-strong { color: var(--text); font-weight: 500; }
.t-semibold { font-weight: 600; }
.t-caps { text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--fs-11); font-weight: 500; }
.t-right { text-align: right; }
.t-center { text-align: center; }
.t-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--mono); font-size: 0.94em; letter-spacing: -0.01em; }
.c-green { color: var(--green); } .c-red { color: var(--red); } .c-amber { color: var(--amber); }
.c-blue { color: var(--blue); } .c-purple { color: var(--purple); } .c-grey { color: var(--grey); }
.c-tone { color: var(--c); }

.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--text-2); }
.rowlink { color: inherit; }
.rowlink:hover { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

.divider { height: 1px; background: var(--line-soft); border: 0; margin: 0; }
.vr { width: 1px; align-self: stretch; background: var(--line); }

/* Motion helpers */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 45%, transparent); } 100% { box-shadow: 0 0 0 6px transparent; } }
.anim-rise { animation: rise-in var(--dur-3) var(--ease) both; }
.grid-span-2 { grid-column: span 2; }
@media (max-width: 720px) { .grid-span-2 { grid-column: auto; } }
.sidebar__user { width: 100%; text-align: left; transition: background var(--dur-1); }
.sidebar__user:hover { background: var(--hover); }
.sidebar__user-caret { margin-left: auto; color: var(--text-3); }
.shell.is-collapsed .sidebar__user-caret { display: none; }
.sidebar__foot > div[style] { display: flex !important; }
.review-flow { list-style: none; margin: 0; padding: 6px 0; }
.review-flow li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; padding: 8px var(--s-4); border-bottom: 1px solid var(--line-soft); }
.review-flow li:last-child { border-bottom: 0; }

.demo-banner { background: #b45309; color: #fff; text-align: center; font-size: 13px; font-weight: 600; padding: 6px 12px; letter-spacing: 0.02em; }
