:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d2430;
  --ink-2: #4b5563;
  --muted: #7a8190;
  --line: #e3e0d9;
  --line-2: #efece6;
  --accent: #1f3a5f;
  --accent-ink: #ffffff;
  --accent-soft: #e6edf6;
  --danger: #b42318;
  --today: #fff6d6;
  --weekend: #f8f6f2;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(20, 28, 40, .18), 0 2px 6px rgba(20, 28, 40, .08);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --panel: #1b1f26; --ink: #e8eaee; --ink-2: #c3c8d0; --muted: #8c93a0;
    --line: #2c323c; --line-2: #232830; --accent: #7aa7e0; --accent-ink: #0f1520; --accent-soft: #22324a;
    --danger: #ff8a7a; --today: #2b2a1d; --weekend: #181b21; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --panel: #1b1f26; --ink: #e8eaee; --ink-2: #c3c8d0; --muted: #8c93a0;
  --line: #2c323c; --line-2: #232830; --accent: #7aa7e0; --accent-ink: #0f1520; --accent-soft: #22324a;
  --danger: #ff8a7a; --today: #2b2a1d; --weekend: #181b21; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1em; margin: 6px 0 0; font-size: 13px; }
.grow { flex: 1; }

/* Buttons */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; padding: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; border-radius: 6px; padding: 6px; cursor: pointer; display: inline-grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

/* Auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.auth-card h1 { margin: 12px 0 2px; font-size: 22px; }
.auth-card label { display: block; margin-top: 14px; font-weight: 500; font-size: 13px; }
.auth-card input { display: block; width: 100%; margin-top: 5px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }

input:not([type=checkbox]):not([type=radio]), select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 9px; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }

/* Layout */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.scope { display: flex; gap: 4px; background: var(--line-2); padding: 3px; border-radius: 8px; }
.scope button { border: 0; background: transparent; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.scope button .sw { width: 8px; height: 8px; border-radius: 2px; }
.scope button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.nav { display: flex; align-items: center; gap: 4px; }
.range-title { font-size: 16px; margin: 0 0 0 8px; font-weight: 600; white-space: nowrap; }
.views { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; margin-left: auto; }
.views button { border: 0; background: var(--panel); padding: 6px 10px; cursor: pointer; color: var(--ink-2); border-right: 1px solid var(--line); }
.views button:last-child { border-right: 0; }
.views button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.search input { width: 170px; }
.user { position: relative; display: flex; gap: 8px; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.menu { position: absolute; right: 0; top: 40px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); min-width: 200px; padding: 6px; z-index: 50; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--line-2); }
.menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.menu-head b { display: block; color: var(--ink); font-size: 14px; }

.body { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 250px; flex: none; overflow-y: auto; padding: 14px 12px 24px; border-right: 1px solid var(--line); background: var(--panel); }
.jump { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.side-section { margin-bottom: 16px; }
.side-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 2px 6px; }
.side-head > :first-child { min-width: 0; }
.side-head button { flex: none; margin-left: 8px; border: 0; background: none; color: var(--accent); font-size: 11px; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 600; }
.sub { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; cursor: pointer; user-select: none; }
.sub:hover { background: var(--line-2); }
.sub .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 2px solid var(--c); background: var(--c); }
.sub.off .sw { background: transparent; }
.sub.off .nm { color: var(--muted); }
.sub .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub .only { opacity: 0; font-size: 11px; color: var(--accent); border: 0; background: none; cursor: pointer; padding: 0 2px; }
.sub:hover .only { opacity: 1; }
#staffFilter { width: 100%; }

.main { flex: 1; min-width: 0; position: relative; background: var(--panel); }
#calendar { height: 100%; }
.load-bar { position: absolute; top: 0; left: 0; height: 2px; width: 30%; background: var(--accent); animation: load 1s infinite ease-in-out; }
@keyframes load { 0% { left: -30%; } 100% { left: 100%; } }

/* FullCalendar tuning — dense, Teamup-like */
.fc { --fc-border-color: var(--line); --fc-page-bg-color: var(--panel); --fc-neutral-bg-color: var(--weekend); --fc-today-bg-color: var(--today);
      --fc-event-border-color: transparent; --fc-list-event-hover-bg-color: var(--line-2); font-size: 12px; height: 100%; }
.fc .fc-scrollgrid { border-left: 0; }
.fc .fc-col-header-cell-cushion { font-weight: 600; color: var(--ink-2); padding: 6px 4px; }
.fc .fc-daygrid-day-number { font-weight: 600; color: var(--ink-2); padding: 3px 6px; }
.fc .fc-day-sat, .fc .fc-day-sun { background: var(--weekend); }
.fc .fc-day-today { background: var(--today) !important; }
.fc .fc-daygrid-event { margin: 1px 3px 0; border-radius: 4px; }
.fc-event-main { overflow: hidden; }
.ev { display: flex; gap: 4px; align-items: baseline; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.ev .t { font-weight: 700; opacity: .9; flex: none; }
.ev .ti { overflow: hidden; text-overflow: ellipsis; }
.ev .st { opacity: .85; font-size: 11px; }
.ev .rep { flex: none; opacity: .75; }
.fc-timegrid-event .ev { white-space: normal; flex-wrap: wrap; }
.fc .fc-list-event-title .st { color: var(--muted); margin-left: 6px; }
.fc .fc-list-day-cushion { background: var(--line-2); }
.fc .fc-timegrid-slot { height: 22px; }
.fc .fc-daygrid-more-link { font-weight: 600; color: var(--accent); }
.fc-event.declined { outline: 2px dashed var(--danger); outline-offset: -2px; }

/* Dialogs */
.dlg { border: 0; padding: 0; border-radius: 12px; box-shadow: var(--shadow); background: var(--panel); color: var(--ink); width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); }
.dlg.small { width: min(400px, calc(100vw - 24px)); }
.dlg.wide { width: min(940px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(15, 20, 30, .45); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 0; font-size: 17px; }
.dlg-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.title-input { flex: 1; font-size: 17px !important; font-weight: 600; border-color: transparent !important; padding-left: 4px !important; }
.title-input:hover { border-color: var(--line) !important; }
.dlg-body { padding: 14px 16px; overflow-y: auto; }
.dlg-body h3 { margin: 0 0 10px; }
.dlg-body label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 12px; }
.dlg-body label input, .dlg-body label select, .dlg-body label textarea { font-weight: 400; color: var(--ink); font-size: 14px; }
.dlg-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1 1 160px; }
.row.two > label { flex: 1 1 240px; }
.row.four > label { flex: 1 1 110px; }
.row.four > label.span2 { flex: 2 1 220px; }
.row.when { align-items: flex-end; }
.row.when > label.check { flex: 0 0 auto; margin-bottom: 20px; }
.dt { display: flex; gap: 6px; }
.dt input[type=date] { flex: 1; }
.dt input[type=time] { width: 120px; }
label.check, label.radio { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; color: var(--ink) !important; cursor: pointer; }
.crem { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 0; margin: 0 0 12px; background: var(--line-2); }
.crem legend { font-size: 12px; font-weight: 700; color: var(--ink-2); padding: 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-weight: 500; font-size: 13px; color: var(--ink); background: var(--panel); user-select: none; }
.chip .sw { width: 10px; height: 10px; border-radius: 3px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .stat { font-size: 11px; }
.chip.on.accepted { background: #dcf3e3; border-color: #2d850e; color: #1f5f0a; }
.chip.on.declined { background: #fde4e1; border-color: var(--danger); color: var(--danger); }
.chips.sub-chips .chip.on { color: var(--ink); }

/* Settings */
.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.settings-body { min-height: 360px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.grid input:not([type=checkbox]), table.grid select { width: 100%; padding: 5px 7px; }
table.grid input[type=color] { width: 42px; padding: 2px; height: 30px; }
.settings-body h4 { margin: 18px 0 8px; font-size: 13px; }
.settings-body .add { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; padding: 12px; background: var(--line-2); border-radius: 8px; }
.settings-body .add label { margin: 0; flex: 1 1 150px; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--line-2); padding: 2px 5px; border-radius: 4px; word-break: break-all; }
pre.code { padding: 10px; white-space: pre-wrap; display: block; }
.keybox { border: 1px solid #2d850e; background: #e8f6ec; color: #1f5f0a; padding: 10px; border-radius: 8px; margin: 10px 0; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); }

/* Report */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { flex: 1 1 140px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 12px; }
.bars div { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.bars .lbl { width: 150px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar { height: 14px; background: var(--accent); border-radius: 3px; min-width: 2px; }
.report-filters { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.report-filters label { margin: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 100; font-weight: 500; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
.only-mobile { display: none; }

@media (max-width: 1180px) {
  .search input { width: 120px; }
  .range-title { font-size: 15px; }
}
@media (max-width: 860px) {
  .only-mobile { display: inline-grid; }
  .topbar { gap: 8px; padding: 8px 10px; }
  .brand { display: none; }
  .scope { order: 10; width: 100%; overflow-x: auto; }
  .views { order: 11; margin-left: 0; width: 100%; }
  .views button { flex: 1; padding: 6px 4px; }
  .search { order: 12; width: 100%; }
  .search input { width: 100%; }
  .nav { flex: 1 1 0; min-width: 0; }
  .nav .btn { padding: 6px 9px; }
  .range-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; min-width: 0; margin-left: 4px; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; width: 280px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  #newBtn { padding: 7px 12px; }
  .hide-mobile { display: none; }
  .user { gap: 6px; }
  .dlg { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .dlg form { max-height: 100dvh; height: 100%; }
  .dlg.small { height: auto; border-radius: 12px; margin: auto; width: calc(100vw - 24px); }
  .dt input[type=time] { width: 105px; }
}

/* Business logos */
#brandMark { display: inline-flex; align-items: center; }
.brand-logo { height: 30px; max-width: 140px; object-fit: contain; display: block; }
.tab-logo { width: 16px; height: 16px; object-fit: contain; border-radius: 3px; }
.auth-logo { max-height: 72px; max-width: 240px; object-fit: contain; display: block; }
.logo-cell { display: flex; align-items: center; gap: 6px; }
.logo-preview { height: 32px; max-width: 90px; object-fit: contain; background: var(--line-2); border-radius: 4px; padding: 2px; }
