.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 15px; }
.sb-brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: #fff; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text);
  text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--panel-2); }
.nav a.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .me { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 1.15rem; }
.content { padding: 20px 24px 60px; }
.menu-btn { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 95; left: 0; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 10px 0 40px rgba(0,0,0,.2); }
  .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.demo-accounts { font-size: 12px; margin-top: 16px; }
.demo-accounts button { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }

/* calendar */
.cal-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.cal-toolbar .date-label { font-weight: 700; font-size: 1.05rem; min-width: 200px; }
.cal-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 190px); }
.cal { display: grid; position: relative; min-width: max-content; }
.cal-head { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 8px; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.cal-head.today { color: var(--brand); }
.cal-corner { position: sticky; left: 0; top: 0; z-index: 6; background: var(--panel); border-bottom: 1px solid var(--line); }
.cal-gutter { position: sticky; left: 0; z-index: 4; background: var(--panel); border-right: 1px solid var(--line); }
.cal-gutter div { position: absolute; right: 6px; font-size: 11px; color: var(--muted); transform: translateY(-7px); }
.cal-col { position: relative; border-right: 1px solid var(--line); cursor: copy;
  background-color: var(--off);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 63px, var(--line) 63px, var(--line) 64px); }
.cal-col .work { position: absolute; left: 0; right: 0; background: var(--panel); pointer-events: none;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 63px, var(--line) 63px, var(--line) 64px),
                    repeating-linear-gradient(to bottom, transparent 0, transparent 31px, color-mix(in srgb, var(--line) 50%, transparent) 31px, color-mix(in srgb, var(--line) 50%, transparent) 32px); }
.cal-col .off { position: absolute; left: 0; right: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--muted) 18%, transparent) 6px 8px); }
.cal-col .off span { font-size: 11px; color: var(--muted); padding: 2px 6px; display: block; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.evt { position: absolute; border-radius: 6px; padding: 3px 6px; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer;
  border-left: 4px solid var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 14%, var(--panel));
  color: var(--text); z-index: 2; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.evt:hover { z-index: 4; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.evt .t { font-weight: 700; }
.evt .s { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evt.st-cancelled { opacity: .5; text-decoration: line-through; }
.evt.st-no_show { background: var(--danger-50); }
.evt.st-pending { border-left-style: dashed; opacity: .75; }
.evt.st-completed { opacity: .7; }
.evt .flag { position: absolute; top: 3px; right: 4px; font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }

/* patient search */
.search-results { border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; max-height: 220px; overflow-y: auto; }
.search-results button { display: block; width: 100%; text-align: left; padding: 8px 10px; background: var(--panel);
  border: 0; border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; color: var(--text); }
.search-results button:hover { background: var(--panel-2); }
.chosen { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border: 1px solid var(--brand);
  background: var(--brand-50); border-radius: 8px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; max-height: 160px; overflow-y: auto; }
.slots button { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); cursor: pointer;
  font: inherit; font-size: 13px; color: var(--text); }
.slots button.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.shade-delta { font-weight: 700; color: var(--ok); }
.sched-grid { display: grid; grid-template-columns: 110px 1fr 1fr 60px; gap: 6px 8px; align-items: center; }
.workflow { display: flex; gap: 6px; flex-wrap: wrap; }
.flags { display: flex; flex-direction: column; gap: 6px; }
.invoice-box table td, .invoice-box table th { padding: 6px 8px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
#sq-card { min-height: 90px; }
