/*
 * 1ERP design system — mobile-first.
 * Used by every page (landing + ERP cabinet + mobile WebView).
 * Tenant-themed pages override `--brand` and `--accent` inline via base_themed.html.
 */

:root {
  /* ---- brand (defaults — overridden per-tenant) ---- */
  --brand:        #0F172A;       /* primary */
  --brand-dark:   #0B1322;
  --accent:       #FF385C;       /* accent */
  --accent-dark:  #E11D48;
  --accent-soft:  #FFF1F4;
  --accent-tint:  #FFE4EA;

  /* ---- neutrals ---- */
  --bg:           #FAFBFB;
  --surface:      #FFFFFF;
  --surface-2:    #F4F5F7;
  --hover:        #F1F2F5;
  --border:       #E5E8EC;
  --border-strong:#D6DAE0;
  --divider:      #EEF0F3;
  --text:         #0B0F1A;
  --text-2:       #4A5160;
  --text-3:       #8B92A1;

  /* ---- semantic ---- */
  --success:      #15803D;
  --success-soft: rgba(34, 197, 94, 0.10);
  --warning:      #B45309;
  --warning-soft: rgba(245, 158, 11, 0.10);
  --danger:       #B91C1C;
  --danger-soft:  rgba(239, 68, 68, 0.10);
  --orange:       #F97316;
  --orange-tint:  #FFEDD5;
  --indigo-light: #E0E7FF;

  /* ---- radii ---- */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-2xl:  32px;
  --r-pill: 999px;

  /* ---- shadows ---- */
  --shadow-sm: 0 1px 3px rgba(15,23,42,.04), 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.04);
  --shadow-xl: 0 24px 64px rgba(15,23,42,.10), 0 8px 24px rgba(15,23,42,.04);

  /* ---- spacing ---- */
  --gap-xs:  4px;
  --gap-sm:  8px;
  --gap-md:  16px;
  --gap-lg:  24px;
  --gap-xl:  32px;
  --gap-2xl: 48px;

  /* ---- typography ---- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ---- motion ---- */
  --ease: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="dark"] {
  --bg:           #0E1116;
  --surface:      #161A21;
  --surface-2:    #1B2027;
  --hover:        #1F262F;
  --border:       #232934;
  --border-strong:#2E3540;
  --divider:      #1E232C;
  --text:         #F3F4F6;
  --text-2:       #C7CCD3;
  --text-3:       #9CA3AF;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 16px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
  --shadow-xl: 0 24px 64px rgba(0,0,0,.7);
}

/* ============ reset ============ */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ============ typography ============ */
h1, h2, h3, h4 {
  margin: 0 0 var(--gap-md);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }
p  { margin: 0 0 var(--gap-md); color: var(--text-2); }
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
}

@media (min-width: 720px) {
  h1 { font-size: 36px; }
  h2 { font-size: 26px; }
  h3 { font-size: 20px; }
}

/* ============ layout ============ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
.narrow {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 720px) {
  .container, .narrow { padding: 0 32px; }
}

main {
  padding: var(--gap-lg) 0;
}
@media (min-width: 720px) {
  main { padding: var(--gap-xl) 0; }
}

.row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  flex-wrap: wrap;
}
.row-end { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: var(--gap-md); }
.grid {
  display: grid;
  gap: var(--gap-md);
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

/* ============ topbar ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 12px 16px;
  background: rgba(255, 255, 255, .85);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .topbar { background: rgba(14, 17, 22, .85); }
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--brand);
}
.topbar .brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.topbar .brand img {
  height: 28px;
  width: auto;
  border-radius: 6px;
}
.topbar nav {
  display: none;
  gap: var(--gap-md);
  margin-left: auto;
}
.topbar nav a {
  color: var(--text-2);
  padding: 8px 12px;
  border-radius: var(--r-pill);
  font-weight: 500;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.topbar nav a:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
.topbar .topbar-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
  font-size: 13px;
}
.topbar-studio {
  position: relative;
  margin-left: auto;
}
.topbar-studio + .topbar-meta {
  margin-left: 0;
}
.topbar-studio summary {
  height: 34px;
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.topbar-studio summary::-webkit-details-marker { display: none; }
.topbar-studio summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  flex: 0 0 auto;
}
.topbar-studio summary::after {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.18s var(--ease);
}
.topbar-studio[open] summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 12%, transparent);
}
.topbar-studio[open] summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
  border-color: var(--accent);
}
.topbar-studio__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-studio__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 70;
  width: min(260px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.topbar-studio__menu a {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.topbar-studio__menu a:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
.topbar-studio__menu a.is-active {
  background: color-mix(in oklch, var(--accent) 12%, var(--surface));
  color: var(--accent);
}
.topbar-meta__name {
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-weight: 500;
}
.topbar-meta__logout {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background 0.15s var(--ease);
}
.topbar-meta__logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
  text-decoration: none;
}
@media (max-width: 719px) {
  .topbar-meta__name { display: none; }
  .topbar-studio summary {
    max-width: 44vw;
    padding: 0 10px;
  }
  .topbar-studio__menu {
    right: -56px;
  }
}

/* hamburger for mobile (collapsed nav) */
.topbar .menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.topbar .menu-toggle::before {
  content: "≡";
  font-size: 22px;
  line-height: 1;
}

@media (min-width: 720px) {
  .topbar { padding: 14px clamp(20px, 4vw, 40px); gap: var(--gap-md); }
  .topbar nav { display: flex; }
  .topbar .menu-toggle { display: none; }
  .topbar .topbar-meta { margin-left: var(--gap-md); }
  .topbar-studio + .topbar-meta { margin-left: 0; }
}
@media (min-width: 1024px) {
  .topbar { padding-left: 80px; padding-right: 80px; }
}

/* mobile menu drawer */
.mobile-menu {
  display: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.mobile-menu.is-open { display: block; }
.mobile-menu nav { display: flex; flex-direction: column; padding: 8px 16px 16px; gap: 4px; }
.mobile-menu nav a {
  padding: 12px 14px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
}
.mobile-menu nav a:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
@media (min-width: 720px) {
  .mobile-menu, .mobile-menu.is-open { display: none; }
}

/* ============ app shell ============ */
.has-app-shell .topbar nav { display: none; }
.has-app-shell .topbar .menu-toggle {
  display: inline-flex;
  margin-left: 0;
}
@media (min-width: 720px) {
  .has-app-shell .topbar {
    padding-left: 20px;
    padding-right: 24px;
  }
  .has-app-shell .topbar .brand {
    min-width: 208px;
  }
}

.app-sidebar {
  position: fixed;
  left: 0;
  top: 65px;
  bottom: 0;
  z-index: 40;
  width: 248px;
  padding: 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: width 0.18s var(--ease), transform 0.18s var(--ease);
}
.app-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 12px;
}
.app-sidebar__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.app-sidebar__collapse {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.app-sidebar__collapse::before {
  content: "‹";
  font-size: 22px;
  line-height: 1;
}
.app-sidebar__studio {
  display: none;
  padding: 0 4px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.app-sidebar__studio summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.app-sidebar__studio summary::-webkit-details-marker { display: none; }
.app-sidebar__studio summary::after {
  content: "";
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.18s var(--ease);
}
.app-sidebar__studio[open] summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}
.app-sidebar__studio[open] summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 12%, transparent);
}
.app-sidebar__studio-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.app-sidebar__studio .app-sidebar__label {
  display: block;
}
.app-sidebar__studio-current {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-sidebar__studio-list {
  display: grid;
  gap: 2px;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.app-sidebar__studio-list a {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.app-sidebar__studio-list a:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
.app-sidebar__studio-list a.is-active {
  background: color-mix(in oklch, var(--accent) 12%, var(--surface));
  color: var(--accent);
}
.app-sidebar__nav {
  display: grid;
  gap: 4px;
}
.app-sidebar__nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.app-sidebar__nav a:hover {
  background: var(--hover);
  color: var(--text);
}
.app-sidebar__nav a.is-active {
  background: color-mix(in oklch, var(--accent) 12%, var(--surface));
  color: var(--accent);
}
.app-sidebar__icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-2);
}
.app-sidebar__icon .nav-icon {
  width: 18px;
  height: 18px;
}
.app-sidebar__nav a.is-active .app-sidebar__icon {
  background: var(--accent);
  color: var(--surface);
}
.app-sidebar-backdrop {
  display: none;
}
.mobile-bottom-nav {
  display: none;
}

@media (min-width: 720px) {
  .has-app-shell .app-sidebar {
    transform: translateX(0);
  }
  .has-app-shell main {
    margin-left: 248px;
    padding: 24px 0;
    transition: margin-left 0.18s var(--ease);
  }
  .has-app-shell.is-sidebar-collapsed .app-sidebar {
    width: 72px;
  }
  .has-app-shell.is-sidebar-collapsed main {
    margin-left: 72px;
  }
  .has-app-shell.is-sidebar-collapsed .app-sidebar__label,
  .has-app-shell.is-sidebar-collapsed .app-sidebar__text {
    display: none;
  }
  .has-app-shell.is-sidebar-collapsed .app-sidebar__head {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
  .has-app-shell.is-sidebar-collapsed .app-sidebar__collapse::before {
    content: "›";
  }
  .has-app-shell.is-sidebar-collapsed .app-sidebar__nav a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 719px) {
  .has-app-shell {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }
  .has-app-shell main {
    padding-top: var(--gap-sm);
  }
  .has-app-shell .topbar-studio {
    display: none;
  }
  .has-app-shell .app-sidebar__studio {
    display: block;
  }
  .has-app-shell .topbar .menu-toggle {
    display: none;
  }
  .has-app-shell .topbar .topbar-meta {
    margin-left: auto;
  }
  .has-app-shell .app-sidebar {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(76vh, 560px);
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 18px 56px rgba(15, 23, 42, 0.24);
    transform: translateY(calc(100% + 24px));
    overflow-y: auto;
  }
  .has-app-shell .app-sidebar::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    margin: 2px auto 10px;
    border-radius: 999px;
    background: var(--border-strong);
  }
  .has-app-shell.is-sidebar-open .app-sidebar {
    transform: translateY(0);
  }
  .has-app-shell.is-sidebar-open .app-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(2px);
  }
  .has-app-shell .app-sidebar__head {
    padding: 0 2px 10px;
  }
  .has-app-shell .app-sidebar__label {
    font-size: 13px;
    color: var(--text);
  }
  .has-app-shell .app-sidebar__collapse::before {
    content: "×";
    font-size: 18px;
  }
  .has-app-shell .app-sidebar__nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .has-app-shell .app-sidebar__nav a {
    min-height: 54px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    background: var(--surface);
  }
  .has-app-shell .app-sidebar__nav a:hover {
    background: var(--hover);
  }
  .has-app-shell .topbar .brand span:last-child {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-bottom-nav {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 34;
    min-height: 60px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: color-mix(in oklch, var(--surface) 94%, transparent);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(16px);
  }
  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    min-width: 0;
    min-height: 48px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--text-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-bottom-nav a.is-active {
    background: color-mix(in oklch, var(--accent) 12%, var(--surface));
    color: var(--accent);
  }
  .mobile-bottom-nav__icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    line-height: 1;
  }
  .mobile-bottom-nav__icon .nav-icon {
    width: 20px;
    height: 20px;
  }
  .mobile-bottom-nav a.is-active .mobile-bottom-nav__icon {
    background: var(--accent);
    color: var(--surface);
  }
  .has-app-shell.is-sidebar-open .mobile-bottom-nav__menu {
    color: var(--accent);
    background: color-mix(in oklch, var(--accent) 12%, var(--surface));
  }
  .has-app-shell.is-sidebar-open .mobile-bottom-nav__menu .mobile-bottom-nav__icon {
    background: var(--accent);
    color: var(--surface);
  }
}

.messages {
  padding: 0 16px;
  margin-top: var(--gap-md);
}
@media (min-width: 720px) {
  .messages { padding: 0 32px; }
}
@media (min-width: 1024px) {
  .messages { padding: 0 80px; }
}

/* ============ buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  font: 600 15px/1 var(--font-sans);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), filter .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--brand); }
.btn--accent  { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); border-radius: var(--r-pill); }
.btn--ghost   { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn--ghost:hover { background: var(--hover); filter: none; }
.btn--sm   { height: 36px; padding: 0 14px; font-size: 14px; border-radius: var(--r-sm); }
.btn--lg   { height: 52px; padding: 0 24px; font-size: 16px; }
.btn--xl   { height: 56px; padding: 0 28px; font-size: 16px; }
.btn--pill { border-radius: var(--r-pill); }
.btn--block { width: 100%; }

/* ============ pills ============ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
}
.pill--accent  { background: var(--accent); color: #fff; border-color: transparent; }
.pill--ok      { background: var(--success-soft); color: var(--success); border-color: transparent; }
.pill--warn    { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.pill--off     { background: var(--surface-2); color: var(--text-3); border-color: transparent; }

/* ============ cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--gap-md);
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
@media (min-width: 720px) {
  .card { padding: var(--gap-lg); }
}
.card.is-hoverable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card + .card { margin-top: var(--gap-md); }
.card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-md);
  margin-bottom: var(--gap-md);
}
.card__title h3 { margin: 0; }

.table-card { padding: 0; overflow: hidden; }

/* ============ tables ============ */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
}
@media (min-width: 720px) {
  th, td { padding: 14px 20px; }
}
thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  font-weight: 600;
  background: var(--hover);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 720px) {
  thead th { font-size: 12px; }
}
tbody tr + tr td { border-top: 1px solid var(--divider); }
tbody tr:hover td { background: var(--hover); }

/* ============ forms ============ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
input, select, textarea {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font: 400 16px/1 var(--font-sans);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
input[type="color"] { padding: 4px; height: 48px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] {
  width: auto;
  height: auto;
  -webkit-appearance: auto;
  appearance: auto;
}
textarea {
  height: auto;
  padding: 12px 14px;
  min-height: 96px;
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}
@media (min-width: 720px) {
  input, select, textarea { height: 44px; font-size: 15px; }
  input[type="color"] { height: 44px; }
}

/* ============ alerts ============ */
.alert {
  padding: 12px 14px;
  border-radius: var(--r-md);
  margin-bottom: var(--gap-md);
  font-size: 14px;
  border: 1px solid transparent;
}
.alert--success { background: var(--success-soft); color: var(--success); border-color: rgba(34, 197, 94, .3); }
.alert--error,
.alert--danger  { background: var(--danger-soft); color: var(--danger); border-color: rgba(239, 68, 68, .3); }
.alert--info,
.alert--warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(245, 158, 11, .3); }
.field--error input,
.field--error select,
.field--error textarea { border-color: #EF4444; }
.field .error { color: var(--danger); font-size: 13px; }

/* ============ utility ============ */
.muted     { color: var(--text-3); }
.text-soft { color: var(--text-2); }
.small     { font-size: 13px; }
.mt-0  { margin-top: 0 !important; }
.mt-md { margin-top: var(--gap-md); }
.mt-lg { margin-top: var(--gap-lg); }
.mt-xl { margin-top: var(--gap-xl); }
.mb-0  { margin-bottom: 0 !important; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.eyebrow--gradient {
  background: linear-gradient(135deg, var(--accent), var(--orange));
  color: #fff;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, .08);
  vertical-align: -2px;
}

.stat-num {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
@media (min-width: 720px) {
  .stat-num { font-size: 32px; }
}
.stat-lbl {
  color: var(--text-3);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}

.empty {
  padding: var(--gap-2xl) var(--gap-lg);
  text-align: center;
  color: var(--text-3);
}
.empty h3 { color: var(--text); }

.danger-link { color: var(--danger); }
.danger-link:hover { color: #991B1B; }

.palette { display: flex; gap: 6px; }
.palette i {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* ---- dashboard ---- */
.dash { padding-top: var(--gap-xl); padding-bottom: var(--gap-2xl); }

.dash__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap-md);
  flex-wrap: wrap;
  margin-bottom: var(--gap-xl);
}
.dash__eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 6px;
}
.dash__eyebrow::first-letter { text-transform: uppercase; }
.dash__title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}
.dash__cta { display: flex; gap: var(--gap-sm); flex-wrap: wrap; }

.dash__hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-lg);
  padding: var(--gap-xl);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  margin-bottom: var(--gap-xl);
}
.dash__hero-lbl {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
}
.dash__hero-num {
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text);
  margin: 8px 0 6px;
  font-variant-numeric: tabular-nums;
}
.dash__hero-delta {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.dash__hero-delta--up { color: var(--success); }
.dash__hero-delta--down { color: var(--danger); }
.dash__hero-delta--flat { color: var(--text-3); font-weight: 500; }
.dash__hero-delta .small { color: var(--text-3); font-weight: 500; }

.dash__sparkline {
  width: 100%;
  height: 64px;
  display: block;
  align-self: end;
}
.dash__sparkbar {
  fill: var(--brand);
  opacity: 0.18;
  transition: opacity 0.15s var(--ease);
}
.dash__sparkbar.is-today { fill: var(--accent); opacity: 0.9; }

.dash__hero-side {
  border-top: 1px solid var(--border);
  padding-top: var(--gap-lg);
  display: flex;
  flex-direction: column;
}
.dash__hero-side-num {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.dash__hero-side-lbl {
  font-size: 14px;
  color: var(--text-2);
  margin: 2px 0 0;
}

@media (min-width: 720px) {
  .dash__hero {
    grid-template-columns: 1.4fr 1fr 0.8fr;
    align-items: end;
  }
  .dash__hero-side {
    border-top: 0;
    border-left: 1px solid var(--border);
    padding-top: 0;
    padding-left: var(--gap-lg);
    align-self: stretch;
    justify-content: end;
  }
  .dash__sparkline { height: 72px; }
}

.dash__section-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 var(--gap-md);
}

.dash__actions { margin-bottom: var(--gap-xl); }
.dash__actions--ok p {
  font-size: 15px;
  color: var(--text-2);
  padding: var(--gap-md) var(--gap-lg);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  margin: 0;
}
.dash__action-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.dash__action {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  padding: 14px var(--gap-lg);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s var(--ease);
}
.dash__action:hover {
  background: var(--hover);
  text-decoration: none;
}
.dash__action-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  min-width: 2ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dash__action-text {
  flex: 1;
  font-size: 15px;
  color: var(--text-2);
}
.dash__action-chev {
  color: var(--text-3);
  font-size: 18px;
  transition: transform 0.15s var(--ease);
}
.dash__action:hover .dash__action-chev {
  color: var(--accent);
  transform: translateX(2px);
}

.dash__sales-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--gap-md);
  gap: var(--gap-md);
}
.dash__sales-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.dash__sales-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px var(--gap-md);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.dash__sales-table th.num,
.dash__sales-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dash__sales-table td {
  padding: 12px var(--gap-md);
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--divider);
}
.dash__sales-table tr:last-child td { border-bottom: 0; }
.dash__sales-table tbody tr:hover { background: var(--hover); }
.dash__sales-table a { color: var(--text); }
.dash__sales-table a:hover { color: var(--accent); }

/* ============ schedule ============ */
.sched { padding-top: var(--gap-lg); padding-bottom: var(--gap-2xl); }

.sched__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap-md);
  flex-wrap: wrap;
  margin-bottom: var(--gap-md);
}
.sched__eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 6px;
}
.sched__title {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.sched__head-actions { display: flex; gap: var(--gap-sm); flex-wrap: wrap; }

.has-app-shell .sched.container {
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}
@media (min-width: 720px) {
  .has-app-shell .sched.container {
    padding-left: 24px;
    padding-right: 24px;
  }
}

.sched__toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  align-items: stretch;
  margin-bottom: var(--gap-md);
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.sched__toolbar-row {
  display: flex;
  gap: var(--gap-md);
  align-items: center;
  flex-wrap: wrap;
}
.sched__weeknav {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.sched__range {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.sched__filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-left: auto;
}
.sched__add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sched__add > span[aria-hidden] {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.filter-menu {
  position: relative;
}
.filter-menu summary {
  height: 36px;
  min-width: 116px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.filter-menu summary::-webkit-details-marker { display: none; }
.filter-menu summary::after {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.18s var(--ease);
}
.filter-menu[open] summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
  border-color: var(--accent);
}
.filter-menu[open] summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 12%, transparent);
}
.filter-menu summary b {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.filter-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: min(280px, calc(100vw - 32px));
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.filter-menu__search {
  width: 100%;
  height: 34px;
  margin-bottom: 6px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.filter-menu__list {
  display: grid;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}
.filter-menu__actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--divider);
}
.filter-menu__option {
  min-height: 34px;
  display: grid;
  grid-template-columns: 16px auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.filter-menu__option:hover {
  background: var(--hover);
  color: var(--text);
}
.filter-menu__option input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}
.filter-menu__option span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-menu__swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}
.filter-menu__option--plain {
  grid-template-columns: 16px minmax(0, 1fr);
}
@media (max-width: 719px) {
  .sched { padding-top: 0; }
  .sched__today-btn {
    display: none;
  }
  .sched__mobile-week {
    position: sticky;
    top: var(--topbar-h, 52px);
    z-index: 20;
    padding: 8px 0;
    margin-bottom: 0;
    background: var(--bg);
  }
  .sched__head {
    align-items: flex-start;
  }
  .sched__title {
    font-size: 22px;
  }
  .sched__toolbar {
    align-items: stretch;
    gap: 10px;
  }
  .sched__toolbar-row {
    align-items: stretch;
    gap: 10px;
  }
  .sched__weeknav {
    width: 100%;
    justify-content: center;
  }
  /* Stand-alone prev/next here are duplicated next to .sched__day-tabs;
     keep only [Today] + range in the toolbar on mobile. */
  .sched__weeknav > a[aria-label="Предыдущая неделя"],
  .sched__weeknav > a[aria-label="Следующая неделя"] {
    display: none;
  }
  .sched__range {
    order: 4;
    width: 100%;
    justify-content: center;
  }
  .sched__filters {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .sched__add {
    width: 100%;
    justify-content: center;
  }
  .filter-menu summary {
    width: 100%;
    min-width: 0;
    font-size: 12px;
  }
  .filter-menu[open]::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(2px);
  }
  .filter-menu__panel {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    max-height: min(72vh, 520px);
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -18px 56px rgba(15, 23, 42, 0.24);
    z-index: 40;
  }
  .filter-menu__panel::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    margin: 0 auto 10px;
    border-radius: 999px;
    background: var(--border-strong);
  }
  .filter-menu__list {
    max-height: min(420px, 56vh);
  }
}

/* ---- Mobile (default): day-tabs + per-day list ---- */
.sched__mobile { display: block; }
.sched__cal-wrap { display: none; }

.sched__mobile-week {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: stretch;
  gap: 6px;
  margin-bottom: var(--gap-md);
}
.sched__week-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 22px;
  line-height: 1;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.sched__week-arrow:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
.sched__day-tabs {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 0;
}
.sched__day-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.sched__day-tab-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.sched__day-tab-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.sched__day-tab.is-today .sched__day-tab-num { color: var(--accent); }
.sched__day-tab.is-active {
  border-color: var(--text);
  background: var(--text);
}
.sched__day-tab.is-active .sched__day-tab-name,
.sched__day-tab.is-active .sched__day-tab-num { color: var(--surface); }

.sched__mobile-day { display: none; }
.sched__mobile-day.is-active { display: block; }
.sched__mobile-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.sched__mobile-day-summary {
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 650;
}
.sched__mobile-empty {
  padding: var(--gap-lg);
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
}
.sched__kind-groups {
  display: grid;
  gap: 10px;
}
.sched__kind-block {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.sched__kind-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: color-mix(in oklch, var(--kind-color, var(--accent)) 8%, var(--surface));
  border-bottom: 1px solid var(--border);
}
.sched__kind-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--kind-color, var(--accent));
  flex: 0 0 auto;
}
.sched__kind-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.sched__kind-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
}
.sched__kind-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--border);
}
.sched__kind-list > li { background: var(--surface); }
.sched__row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  align-items: center;
}
.sched__row:hover { background: var(--hover); text-decoration: none; }
.sched__row.is-canceled { opacity: 0.5; }
.sched__row-time { display: flex; flex-direction: column; gap: 2px; line-height: 1.1; }
.sched__row-time strong { font-size: 16px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.sched__row-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sched__row-meta {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sched__row-occ {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
}
.sched__row-occ.is-full { color: var(--danger); background: var(--danger-soft); }

/* ---- Desktop: time-axis grid ---- */
@media (min-width: 768px) {
  .sched__mobile { display: none; }
  .sched__cal-wrap { display: block; }
}

.sched__cal-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow-x: hidden;
  overflow-y: hidden;
}
.sched__cal {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(0, 1fr));
  min-width: 0;
  /* The body is scrollable; head is sticky inside it. */
}
.sched__cal-head {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.sched__cal-head-cell {
  min-height: 70px;
  padding: 14px 8px;
  border-right: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.sched__cal-head-cell:last-child { border-right: 0; }
.sched__cal-gutter-head { background: var(--surface-2); }
.sched__cal-head-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
}
.sched__cal-head-num {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.sched__cal-head-cell.is-today .sched__cal-head-name { color: var(--accent); }
.sched__cal-head-cell.is-today .sched__cal-head-num {
  color: var(--surface);
  background: var(--accent);
}
.sched__cal-head-cell.is-today {
  background: var(--surface);
}

.sched__cal-body {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  height: var(--grid-h, 1024px);
  overflow-y: auto;
  max-height: calc(100vh - 240px);
}

.sched__cal-gutter {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 1;
}
.sched__cal-hour-lbl {
  height: var(--hour-h, 56px);
  padding: 4px 6px 0;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.sched__cal-day {
  position: relative;
  border-right: 1px solid var(--divider);
}
.sched__cal-day:last-child { border-right: 0; }
.sched__cal-day.is-today {
  background: linear-gradient(180deg, color-mix(in oklch, var(--accent) 4%, transparent), transparent);
}
.sched__cal-cell {
  height: var(--hour-h, 56px);
  border-bottom: 1px solid var(--divider);
  display: block;
}
.sched__cal-cell--add {
  position: relative;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s var(--ease);
}
.sched__cal-cell--add:hover {
  background: color-mix(in oklch, var(--accent) 6%, transparent);
}
.sched__cal-cell--add::after {
  content: "+";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: 16px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s var(--ease);
}
.sched__cal-cell--add:hover::after {
  opacity: 1;
}
/* During drag-selection: hide the "+" affordance, switch cursor. */
.sched__cal-body.is-dragging .sched__cal-cell--add::after,
.sched__cal-body.is-dragging .sched__cal-cell--add:hover::after {
  opacity: 0;
}
.sched__cal-body.is-dragging,
.sched__cal-body.is-dragging .sched__cal-cell--add {
  cursor: ns-resize;
}
/* Drag-selection overlay: floats above the column, snaps to 15-min slots. */
.sched__sel {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 20;
  border-radius: 8px;
  background: color-mix(in oklch, var(--accent) 16%, transparent);
  border: 1.5px solid var(--accent);
  pointer-events: none;
  box-shadow: 0 2px 12px color-mix(in oklch, var(--accent) 22%, transparent);
}
.sched__sel-label {
  position: absolute;
  top: 4px;
  right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Modal — used by the schedule "new session" inline form. */
.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(560px, calc(100vw - 32px));
  width: 100%;
  max-height: calc(100vh - 32px);
  margin: auto;
  color: var(--text);
}
.modal::backdrop {
  background: color-mix(in oklch, var(--text) 38%, transparent);
  backdrop-filter: blur(2px);
}
.modal__panel {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px -12px color-mix(in oklch, var(--text) 28%, transparent);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  overflow: hidden;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal__close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.modal__close:hover {
  background: var(--surface-2);
  color: var(--text);
}
.modal__body {
  padding: 20px;
  overflow-y: auto;
}

.sched__event {
  position: absolute;
  padding: 8px 8px;
  border-radius: 9px;
  background: color-mix(in oklch, var(--kind-color, var(--accent)) 18%, var(--surface-2));
  border: 1px solid color-mix(in oklch, var(--kind-color, var(--accent)) 10%, var(--surface));
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  line-height: 1.25;
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--surface) 55%, transparent);
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease), filter 0.12s var(--ease);
}
.sched__event:hover {
  text-decoration: none;
  box-shadow: var(--shadow-md), inset 0 0 0 1px color-mix(in oklch, var(--surface) 55%, transparent);
  z-index: 5;
  transform: translateY(-1px);
  filter: saturate(1.05);
}
.sched__event-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.sched__event-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sched__event-meta {
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.sched__event-meta::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  opacity: 0.6;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.sched__event.is-compact { padding: 6px 8px; gap: 2px; }
.sched__event.is-compact .sched__event-time { font-size: 11px; }
.sched__event.is-compact .sched__event-name { font-size: 12px; -webkit-line-clamp: 1; }
.sched__event.is-compact .sched__event-meta { font-size: 10px; }
.sched__event-group {
  gap: 4px;
  padding: 7px 8px;
  background: var(--surface-2);
  border-color: var(--border);
}
.sched__event-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sched__event-group-list {
  display: grid;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}
.sched__event-group-row {
  min-height: 18px;
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 7px;
  background: color-mix(in oklch, var(--kind-color, var(--accent)) 16%, var(--surface));
  color: inherit;
  text-decoration: none;
}
.sched__event-group-row:hover {
  background: color-mix(in oklch, var(--kind-color, var(--accent)) 22%, var(--surface));
  text-decoration: none;
}
.sched__event-group-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--kind-color, var(--accent));
}
.sched__event-group-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.sched__event-group-count {
  color: var(--text-2);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sched__event-group.is-compact {
  padding: 6px;
  gap: 3px;
}
.sched__event-group.is-compact .sched__event-group-head {
  font-size: 10px;
}
.sched__event-group.is-compact .sched__event-group-row {
  min-height: 17px;
  padding: 1px 5px;
}
.sched__event-group.is-compact .sched__event-group-name {
  font-size: 11px;
}
.sched__event-group-row.is-canceled {
  opacity: 0.45;
  text-decoration: line-through;
}
.sched__event-group-row.is-past {
  background: var(--surface-2);
  border: 1px solid var(--border);
  filter: grayscale(0.7);
  opacity: 0.72;
}
.sched__event-group-row.is-past .sched__event-group-dot {
  background: var(--text-3);
  opacity: 0.65;
}
.sched__event-group-row.is-past .sched__event-group-name,
.sched__event-group-row.is-past .sched__event-group-count {
  color: var(--text-3);
}
.sched__event-group-row.is-past:hover {
  filter: none;
  opacity: 1;
}
.sched__event.is-canceled {
  opacity: 0.45;
  text-decoration: line-through;
}
.sched__event.is-past {
  background: var(--surface-2);
  border-color: var(--border);
  filter: grayscale(0.7);
  opacity: 0.72;
}
.sched__event.is-past .sched__event-name,
.sched__event.is-past .sched__event-time,
.sched__event.is-past .sched__event-meta { color: var(--text-3); }
.sched__event.is-past:hover { filter: none; opacity: 1; }

.sched__row.is-past {
  background: var(--surface-2);
  filter: grayscale(0.6);
  opacity: 0.7;
}
.sched__row.is-past .sched__row-meta,
.sched__row.is-past .sched__row-time strong { color: var(--text-3); }
.sched__row.is-past:hover { filter: none; opacity: 1; }

.sched__now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 80;
  pointer-events: none;
  box-shadow:
    0 0 0 1px color-mix(in oklch, var(--surface) 88%, transparent),
    0 0 0 3px color-mix(in oklch, var(--accent) 16%, transparent);
}
.sched__now::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}
.sched__now-label {
  position: absolute;
  left: 8px;
  top: -10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  box-shadow: 0 0 0 2px var(--surface);
}
