/* ------------------------------------------------------------------ app shell */
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; transition: margin-left .25s var(--ease); }
.app.collapsed .app-main { margin-left: var(--side-w-collapsed); }

/* ------------------------------------------------------------------ sidebar */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 60;
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; padding: 14px 12px 12px;
  transition: width .25s var(--ease), transform .25s var(--ease);
}
.app.collapsed .side { width: var(--side-w-collapsed); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; min-height: 52px; }
.side-logo {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; background: var(--grad);
  display: grid; place-items: center; color: #fff; box-shadow: 0 6px 18px rgba(192, 38, 211, .45);
}
.side-logo .icon { width: 20px; height: 20px; }
.side-brand-text { min-width: 0; line-height: 1.15; }
.side-brand-text b { display: block; color: #fff; font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.side-brand-text small { display: block; margin-top: 3px; font-size: 8.5px; letter-spacing: .2em; color: #e9a5f0; font-weight: 600; white-space: nowrap; }
.app.collapsed .side-brand-text { display: none; }

.side-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 0 4px 8px; scrollbar-width: none; }
.side-nav::-webkit-scrollbar { display: none; }
.side-group { margin: 16px 8px 6px; font-size: 10px; font-weight: 600; letter-spacing: .16em; color: var(--side-muted); text-transform: uppercase; white-space: nowrap; }
.app.collapsed .side-group { visibility: hidden; height: 6px; margin: 8px 0 2px; }
.side-item {
  position: relative; display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 11px; margin: 2px 0;
  border-radius: 10px; color: var(--side-text); font-size: 13.2px; font-weight: 500; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, color .15s;
}
.side-item .icon { width: 18px; height: 18px; flex: 0 0 auto; opacity: .9; }
.side-item span.lbl { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.side-item:hover { background: var(--side-hover); color: #fff; }
.side-item.active { background: #fff; color: #1e1b3a; font-weight: 600; box-shadow: 0 6px 16px rgba(0, 0, 0, .22); }
.side-item.active .icon { color: var(--primary); opacity: 1; }
.side-badge {
  flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--pink); color: #fff;
  font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center; font-family: var(--font-display);
}
.side-badge.live { background: var(--pink); font-size: 9.5px; letter-spacing: .02em; padding: 0 7px; }
.side-badge.purple { background: #7c3aed; }
.app.collapsed .side-item { justify-content: center; padding: 0; }
.app.collapsed .side-item span.lbl { display: none; }
.app.collapsed .side-item .side-badge { position: absolute; top: 3px; right: 6px; min-width: 16px; height: 16px; font-size: 9px; padding: 0 4px; }

.side-status {
  flex: 0 0 auto; margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--side-text);
}
.side-status b { display: block; color: #fff; font-weight: 600; font-size: 11.5px; }
.side-status small { color: var(--side-muted); font-size: 10.5px; }
.side-status .dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulseDot 2s infinite; }
.app.collapsed .side-status > div { display: none; }
.app.collapsed .side-status { justify-content: center; padding: 12px 0; }

.side-overlay { display: none; }
@media (max-width: 1023px) {
  .app-main, .app.collapsed .app-main { margin-left: 0; }
  .side, .app.collapsed .side { width: 268px; transform: translateX(-102%); box-shadow: none; }
  .app.side-open .side { transform: none; box-shadow: var(--shadow-lg); }
  .app.collapsed .side-brand-text, .app.collapsed .side-item span.lbl, .app.collapsed .side-status > div { display: revert; }
  .app.collapsed .side-group { visibility: visible; height: auto; margin: 16px 8px 6px; }
  .app.collapsed .side-item { justify-content: flex-start; padding: 0 11px; }
  .app.side-open .side-overlay { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 10, 40, .5); animation: fadeIn .2s; }
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.tb-btn {
  flex: 0 0 auto; height: 38px; min-width: 38px; padding: 0 10px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 500;
  transition: border-color .15s, background .15s, color .15s; position: relative;
}
.tb-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.tb-btn .icon { width: 17px; height: 17px; }
.tb-btn .dot-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff;
  font: 700 10.5px/18px var(--font-display); text-align: center; border: 2px solid var(--surface);
}
.tb-search {
  flex: 0 1 380px; height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: text; text-align: left;
}
.tb-search:hover { border-color: var(--primary); }
.tb-search .icon { width: 16px; height: 16px; flex: 0 0 auto; }
.tb-search span.ph { flex: 1 1 auto; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd { font: 600 10.5px var(--font-display); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted); }
.tb-spacer { flex: 1 1 auto; }
.tb-select { position: relative; }
.tb-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; padding: 6px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: pop .16s var(--ease); z-index: 80;
}
.tb-menu button, .tb-menu a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2);
  font-size: 13px; text-align: left; text-decoration: none !important;
}
.tb-menu button:hover, .tb-menu a:hover { background: var(--primary-50); color: var(--primary); }
.tb-menu button.on { color: var(--primary); font-weight: 600; }
.tb-menu hr { margin: 6px 0; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 2px 0 4px; border: 0; background: transparent; text-align: left; }
.user-chip .meta { line-height: 1.2; }
.user-chip .meta b { display: block; font-size: 12.5px; font-weight: 600; }
.user-chip .meta small { color: var(--muted); font-size: 11px; }
@media (max-width: 1200px) { .tb-hide-md { display: none !important; } }
@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .tb-search { flex: 1 1 auto; min-width: 0; }
  .tb-search .kbd, .tb-hide-sm { display: none !important; }
  .user-chip .meta { display: none; }
}

/* ------------------------------------------------------------------ page */
.page { padding: 20px 24px 40px; animation: fadeUp .35s var(--ease); }
@media (max-width: 760px) { .page { padding: 16px 12px 32px; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.crumbs { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }
.crumbs b { color: var(--primary); font-weight: 500; }
.page-title { font-size: 27px; font-weight: 700; letter-spacing: -.01em; }
.page-sub { margin-top: 5px; font-size: 12.5px; color: var(--text-2); }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ auth layout (login / register / forgot) */
.auth-wrap { 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: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 10% -10%, #7c3aed 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #c026d3 0%, transparent 55%), linear-gradient(160deg, #1b1445, #2a1c78);
}
.auth-hero::after { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M48 0H0v48' fill='none' stroke='white' stroke-opacity='.05'/%3E%3C/svg%3E"); pointer-events: none; }
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero h1 { color: #fff; font-size: 40px; line-height: 1.15; font-weight: 700; max-width: 520px; }
.auth-hero p.lead { margin-top: 16px; color: rgba(255, 255, 255, .78); max-width: 480px; font-size: 15px; }
.hero-steps { display: grid; gap: 12px; margin-top: 34px; max-width: 480px; }
.hero-step { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-radius: 16px; background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .12); backdrop-filter: blur(6px); }
.hero-step .n { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: rgba(255, 255, 255, .16); font: 700 14px var(--font-display); }
.hero-step b { display: block; color: #fff; font-weight: 600; font-size: 13.5px; }
.hero-step small { color: rgba(255, 255, 255, .68); font-size: 12px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 24px; overflow-y: auto; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 760px; }
.auth-card h2 { font-size: 26px; font-weight: 700; }
.auth-card .lead { color: var(--muted); margin: 6px 0 24px; }
@media (max-width: 960px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { align-items: flex-start; padding-top: 40px; }
}
