:root {
  color-scheme: light;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  color: #29243a;
  background: #f8f7f4;
  --background: #f8f7f4;
  --paper: #fff;
  --ink: #29243a;
  --muted: #666170;
  --line: #e8e4ea;
  --accent: #5b3b68;
  --accent-hover: #492c55;
  --sidebar: #28243b;
  --shadow: 0 5px 20px #30213e0b;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #9359a3; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
svg { flex-shrink: 0; }
.icon { width: 1.125rem; height: 1.125rem; vertical-align: middle; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 20; background: white; padding: .75rem; border-radius: .4rem; }
.skip-link:focus { top: 1rem; }
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 1rem; padding: 2rem; color: var(--muted); text-align: center; }

.shell { display: grid; grid-template-columns: 242px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 1.6rem 1rem 1rem; background: var(--sidebar); color: #efecf4; z-index: 4; overflow-y: auto; }
.brand { display: inline-flex; align-items: center; gap: .72rem; color: inherit; text-decoration: none; width: fit-content; line-height: 1.2; }
.brand strong { display: block; font-size: 1rem; letter-spacing: -.015em; }
.brand small { display: block; font-size: .76rem; color: #c6bfd3; margin-top: .18rem; }
.brand-mark { width: 2.55rem; height: 2.55rem; border-radius: .7rem; display: grid; place-items: center; color: #f2e3f6; background: #ffffff17; flex: none; }
.brand-mark .icon { width: 1.45rem; height: 1.45rem; }
.sidebar .brand { margin: .12rem .38rem 2.25rem; }
.nav-caption { font-size: .72rem; font-weight: 650; color: #c6bfd3; margin: 0 .58rem .55rem; }
.nav { display: grid; gap: .25rem; }
.nav a { min-height: 2.8rem; text-decoration: none; color: #d8d2e4; border-radius: .65rem; display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem; font-size: .94rem; }
.nav a[aria-current="page"] { background: #4a405c; color: #fff; font-weight: 650; }
.nav a:hover { background: #ffffff15; color: #fff; }
.side-end { margin-top: auto; padding-top: 1rem; }
.side-footer { border-top: 1px solid #ffffff22; padding: .85rem .55rem .2rem; color: #c6bfd3; font-size: .77rem; }
.mobile-header, .mobile-dim { display: none; }

.workspace { padding: 2.85rem clamp(1.4rem, 4.3vw, 4.5rem) 3.5rem; min-width: 0; }
.canvas { max-width: 1310px; margin-inline: auto; }
.page-heading { display: flex; justify-content: space-between; gap: 1.25rem; align-items: end; margin-bottom: 1.6rem; }
.page-heading h1 { font-family: Georgia, serif; font-size: clamp(2.15rem, 4vw, 3.1rem); font-weight: 500; line-height: 1.04; letter-spacing: -.067em; }
.page-heading p { color: var(--muted); margin-top: .55rem; line-height: 1.5; }
.page-heading .actions { padding-bottom: .15rem; }
.date-banner { display: inline-flex; align-items: center; gap: .4rem; color: var(--accent); font-size: .86rem; font-weight: 650; margin-bottom: .55rem; }
.date-banner .icon { width: 1rem; height: 1rem; }

.btn { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: .55rem; min-height: 2.45rem; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .45rem .75rem; line-height: 1.2; font-size: .88rem; font-weight: 650; text-decoration: none; text-align: center; }
.btn:hover { background: #f3eff4; border-color: #dfd5e1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: #9c303b; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: #f3eff4; }
.btn.icon-only { width: 2.5rem; padding-inline: 0; }
.btn.compact { min-height: 2.18rem; padding: .32rem .6rem; font-size: .82rem; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
.button-link { border: 0; padding: 0; background: none; color: var(--accent); font-weight: 660; text-align: left; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .16em; }
.button-link:hover { text-decoration-color: currentColor; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1.15rem; }
.stat { text-decoration: none; display: block; background: var(--paper); border: 1px solid var(--line); border-radius: .8rem; padding: .9rem; box-shadow: var(--shadow); min-width: 0; }
.stat:hover { border-color: #baa5bf; }
.stat-top { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .84rem; font-weight: 650; }
.stat-icon { color: #593969; background: #f0e8f3; width: 2rem; height: 2rem; border-radius: .55rem; display: grid; place-items: center; }
.stat-icon.warm { color: #78402b; background: #faede5; }
.stat-icon.green { color: #305e4c; background: #e8f1e8; }
.stat-icon.blue { color: #405375; background: #e9eff9; }
.stat-number { font-size: 1.95rem; font-weight: 650; line-height: 1.1; letter-spacing: -.055em; margin-top: .65rem; }
.stat-detail { font-size: .76rem; color: var(--muted); margin-top: .2rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.16fr) minmax(0, 1fr); align-items: start; gap: 1.05rem; }
.stack { display: grid; gap: 1.05rem; min-width: 0; }
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: .82rem; box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .9rem 1.05rem; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 1.05rem; letter-spacing: -.02em; font-weight: 680; }
.panel-heading p { color: var(--muted); font-size: .82rem; margin-top: .2rem; line-height: 1.4; }
.panel-body { padding: 1rem 1.05rem; }
.empty { padding: 1.25rem 1rem; display: grid; justify-items: start; gap: .45rem; }
.empty-icon { width: 2rem; height: 2rem; background: #f1edf3; color: var(--accent); border-radius: .5rem; display: grid; place-items: center; margin-bottom: .1rem; }
.empty h3 { font-size: .94rem; }
.empty p { color: var(--muted); font-size: .86rem; line-height: 1.45; }
.empty .btn { margin-top: .2rem; }
.row { display: flex; align-items: center; gap: .65rem; padding: .77rem 1rem; border-bottom: 1px solid var(--line); min-width: 0; }
.row:last-child { border-bottom: 0; }
.row-main { min-width: 0; flex: 1; }
.row-title { font-size: .94rem; font-weight: 660; overflow-wrap: anywhere; }
.row-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .23rem .5rem; color: var(--muted); font-size: .8rem; margin-top: .2rem; line-height: 1.4; overflow-wrap: anywhere; }
.row-meta > span { display: inline-flex; align-items: center; gap: .24rem; }
.row-meta .icon { width: .85rem; height: .85rem; }
.row-actions { margin-left: auto; justify-content: flex-end; }
.row-note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; line-height: 1.4; color: var(--muted); margin-top: .35rem; }
.date-tile { display: grid; justify-items: center; width: 2.75rem; height: 2.75rem; place-content: center; color: var(--accent); background: #f3edf4; border-radius: .55rem; flex: none; }
.date-tile strong { line-height: 1.05; font-size: 1rem; }
.date-tile span { font-size: .63rem; font-weight: 660; text-transform: uppercase; }
.person-icon { display: grid; place-content: center; width: 2.55rem; height: 2.55rem; border-radius: .6rem; color: var(--accent); background: #f3edf4; font-size: .83rem; font-weight: 700; flex: none; }
.badge { display: inline-flex; align-items: center; width: fit-content; background: #f1edf3; color: #584466; padding: .22rem .46rem; font-size: .73rem; font-weight: 650; border-radius: .34rem; white-space: nowrap; }
.badge.success { background: #e7f2e9; color: #2f6544; }
.badge.warn { background: #faebdf; color: #80482d; }
.badge.late { background: #f9e7ec; color: #8d364e; }
.badge.subtle { background: #efedf0; color: #5b5561; }

.toolbar { display: flex; gap: .7rem; align-items: end; flex-wrap: wrap; margin-bottom: .9rem; }
.control { display: grid; gap: .35rem; font-size: .86rem; font-weight: 650; min-width: 0; }
.control input, .control select, .control textarea { border: 1px solid #dcd6df; background: white; color: var(--ink); border-radius: .48rem; min-height: 2.45rem; padding: .47rem .58rem; width: 100%; min-width: 0; }
.control textarea { resize: vertical; min-height: 5.2rem; }
.control input::placeholder, .control textarea::placeholder { color: #756f7c; }
.control .hint { font-weight: 400; font-size: .77rem; color: var(--muted); line-height: 1.3; }
.control.search { width: min(100%, 320px); }
.control.checkbox { display: flex; align-items: center; gap: .5rem; }
.control.checkbox input { width: 1.05rem; min-height: 1.05rem; accent-color: var(--accent); }
.calendar-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(245px, 1fr); gap: 1.05rem; align-items: start; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday { padding: .52rem .15rem; font-size: .74rem; text-align: center; color: var(--muted); font-weight: 650; }
.day { border: 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); min-height: 4.75rem; padding: .36rem; background: var(--paper); text-align: left; display: flex; flex-direction: column; gap: .23rem; color: var(--ink); min-width: 0; }
.day:nth-child(7n) { border-right: 0; }
.day:hover { background: #faf7fb; }
.day:focus-visible { outline-offset: -3px; }
.day.outside { background: #fbfafc; color: #726d78; }
.day.selected { background: #f0e8f4; box-shadow: inset 0 0 0 1px #bda5c4; }
.day-number { font-size: .78rem; width: 1.46rem; height: 1.46rem; border-radius: 50%; display: grid; place-items: center; }
.day.today .day-number { color: #fff; background: var(--accent); }
.day-count { width: 100%; overflow: hidden; text-overflow: ellipsis; color: var(--accent); font-size: .69rem; line-height: 1.15; }
.day-count .dot { display: none; }
.calendar-heading { align-items: center; }
.calendar-heading .actions { flex-wrap: nowrap; }
.calendar-heading .btn { min-height: 2.12rem; }

.client-summary { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 1rem; }
.client-summary dl { margin: 0; }
.client-summary dt { color: var(--muted); font-size: .78rem; font-weight: 650; margin-bottom: .18rem; }
.client-summary dd { margin: 0 0 .85rem; overflow-wrap: anywhere; font-size: .91rem; }
.client-summary dd:last-child { margin-bottom: 0; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.settings-grid { max-width: 900px; }
.setting { padding: 1rem 1.05rem; display: flex; justify-content: space-between; gap: .8rem; border-bottom: 1px solid var(--line); align-items: center; }
.setting:last-child { border-bottom: 0; }
.setting h3 { font-size: .94rem; margin-bottom: .2rem; }
.setting p { color: var(--muted); font-size: .86rem; line-height: 1.45; }
.setting > .actions, .setting > .btn { flex-shrink: 0; }
.notice { border: 1px solid #e6d9e9; border-radius: .55rem; padding: .65rem .75rem; background: #f7eff8; color: #654673; font-size: .85rem; margin-bottom: .85rem; line-height: 1.45; }

.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-main { display: grid; align-content: center; justify-items: start; justify-self: center; padding: 2rem; width: min(100%, 430px); }
.auth-main .brand { margin-bottom: 3rem; }
.auth-main .brand-mark { color: #f2e3f6; background: var(--sidebar); }
.auth-main .brand small { color: var(--muted); }
.auth-main h1 { font-family: Georgia, serif; font-size: clamp(2.25rem, 5vw, 3.2rem); letter-spacing: -.065em; font-weight: 500; }
.auth-main p { color: var(--muted); margin: .55rem 0 1.55rem; line-height: 1.5; }
.auth-main form { display: grid; gap: .85rem; width: 100%; }
.auth-main .btn { min-height: 2.65rem; }
.auth-cover { min-height: 100%; background: #28243b; }
.auth-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.editor { border: 1px solid #e0d8e1; padding: 0; border-radius: .85rem; width: min(calc(100vw - 2rem), 525px); max-height: calc(100dvh - 2rem); box-shadow: 0 16px 64px #21162948; color: var(--ink); background: white; }
.editor::backdrop { background: #241932a0; }
.editor-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .8rem 1.05rem; border-bottom: 1px solid var(--line); }
.editor-header h2 { font-size: 1.13rem; }
.editor-body { padding: .95rem 1.05rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .72rem; }
.field-wide, .error-text { grid-column: 1 / -1; }
.dialog-actions { border-top: 1px solid var(--line); padding: .68rem 1.05rem; justify-content: flex-end; }
.dialog-actions .danger { margin-right: auto; }
.error-text { color: #a32d43; font-size: .85rem; line-height: 1.45; }
.toast { position: fixed; z-index: 10; right: 1rem; bottom: 1rem; background: var(--sidebar); color: white; padding: .68rem .85rem; border-radius: .55rem; box-shadow: var(--shadow); font-size: .9rem; max-width: min(25rem, calc(100vw - 2rem)); }
.toast:empty { display: none; }

@media (max-width: 1120px) {
  .shell { grid-template-columns: 204px minmax(0, 1fr); }
  .workspace { padding-inline: 1.45rem; }
  .calendar-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 178px minmax(0, 1fr); }
  .sidebar { padding-inline: .65rem; }
  .workspace { padding-inline: 1rem; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .shell { display: block; }
  .mobile-header { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; padding: .55rem .9rem; background: var(--sidebar); color: white; }
  .mobile-header .btn { background: #ffffff17; border-color: #ffffff33; color: white; }
  .mobile-header .brand-mark { width: 2rem; height: 2rem; }
  .mobile-header .brand-mark .icon { width: 1.12rem; height: 1.12rem; }
  .mobile-header .brand small { display: none; }
  .sidebar { position: fixed; width: min(245px, 82vw); inset: 0 auto 0 0; padding: 1.3rem .9rem; display: none; }
  .sidebar.is-open { display: flex; }
  .mobile-dim.is-open { display: block; position: fixed; inset: 0; background: #20162c99; z-index: 3; border: 0; width: 100%; }
  .workspace { padding: 1.55rem .8rem 2.5rem; }
  .page-heading { margin-bottom: .95rem; flex-wrap: wrap; gap: .65rem; }
  .page-heading h1 { font-size: 2.35rem; }
  .page-heading p { font-size: .91rem; }
  .page-heading .actions { padding: 0; }
  .stats-grid { gap: .55rem; margin-bottom: .72rem; }
  .stat { padding: .64rem; }
  .stat-top { gap: .34rem; font-size: .76rem; }
  .stat-icon { width: 1.72rem; height: 1.72rem; }
  .stat-icon .icon { width: .98rem; height: .98rem; }
  .stat-number { font-size: 1.66rem; }
  .dashboard-grid, .stack, .calendar-layout { gap: .72rem; }
  .panel-heading, .row, .setting { padding-inline: .75rem; }
  .row { gap: .42rem; flex-wrap: wrap; }
  .row-actions { flex-wrap: wrap; }
  .day { min-height: 3.25rem; padding: .2rem; }
  .day-count .words { display: none; }
  .day-count .dot { display: inline-block; background: var(--accent); min-width: .4rem; height: .4rem; border-radius: .5rem; }
  .setting { align-items: start; flex-wrap: wrap; }
  .client-summary { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-cover { display: none; }
  .auth-main { align-self: center; }
  .auth-main .brand { margin-bottom: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
