/* calendar-web: one stylesheet for the login page and the app. Light and dark follow the OS. */
:root {
  --bg: #f5f5f5; --surface: #ffffff; --surface-2: #fafafa; --ink: #242424; --mute: #616161; --faint: #8a8a8a;
  --line: #e0e0e0; --line-soft: #ededed; --accent: #5b5fc7; --accent-ink: #ffffff; --accent-soft: #e8ebfa;
  --accent-strong: #4f52b2; --danger: #c4314b; --danger-soft: #fdf3f4; --ok: #0f7b6c; --warn: #b5550b;
  --shadow: 0 8px 28px rgba(0,0,0,.14), 0 2px 6px rgba(0,0,0,.08); --radius: 8px; --topbar: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1f; --surface: #292929; --surface-2: #2e2e2e; --ink: #f0f0f0; --mute: #adadad; --faint: #8a8a8a;
    --line: #3d3d3d; --line-soft: #333333; --accent: #7f85f5; --accent-ink: #141414; --accent-soft: #2f2f4a;
    --accent-strong: #9299f7; --danger: #f1707b; --danger-soft: #3b2426; --ok: #4fc3a1; --warn: #f0a050;
    --shadow: 0 8px 28px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
code { font: 12.5px ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-2);
  border: 1px solid var(--line-soft); padding: 1px 5px; border-radius: 4px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; font: 12.5px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
  margin: 12px 0 0; }
.muted { color: var(--mute); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }

/* ---------- controls */
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 5px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.wide { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; border: 0;
  background: transparent; cursor: pointer; font-size: 18px; line-height: 1; color: var(--mute);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; font-size: 12.5px; }
.link.danger { color: var(--danger); }
.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--mute); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 14px; }
label.check.inline { align-self: end; min-height: 34px; }
input[type=text], input:not([type]), input[type=password], input[type=date], input[type=time],
input[type=number], select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); font-weight: 400; font-size: 14px; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.form-error { margin: 0; padding: 8px 12px; border-radius: 6px; background: var(--danger-soft); color: var(--danger);
  font-size: 13px; }
.note { margin: 0; padding: 8px 12px; border-radius: 6px; background: var(--accent-soft); font-size: 13px; }

/* ---------- login */
.login-body { display: grid; place-items: center; padding: 24px 16px; min-height: 100%;
  background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; margin-top: 14px; }
.login-card p { margin: 4px 0 20px; }
.login-card form { display: grid; gap: 14px; }
.login-mark, .brand-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 9px;
  background: var(--accent); position: relative; }
.login-mark span, .brand-mark::after { content: ""; width: 18px; height: 16px; border: 2px solid var(--accent-ink);
  border-top-width: 5px; border-radius: 3px; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; margin-right: 10px; }
.brand-mark::after { width: 12px; height: 11px; border-width: 1.5px; border-top-width: 3.5px; border-radius: 2px; }

/* ---------- app shell */
.app { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.topbar { flex: none; height: var(--topbar); display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; font-weight: 700; font-size: 15px; margin-right: 18px; }
.tabs { display: flex; height: 100%; gap: 4px; }
.tabs a { display: flex; align-items: center; padding: 0 12px; color: var(--mute); text-decoration: none;
  font-weight: 600; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.who { color: var(--mute); font-size: 13px; }
.rail-toggle { display: none; }
.view { flex: 1; min-height: 0; }

/* ---------- calendar view */
.cal-view { display: flex; }
.rail { flex: none; width: 260px; overflow-y: auto; padding: 14px 12px 24px; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; }
.rail-sec h3 { display: flex; justify-content: space-between; align-items: center; font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--mute); margin-bottom: 6px; }
.rail-scrim { display: none; }
.cal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.cal-toolbar { flex: none; display: flex; align-items: center; gap: 6px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.cal-toolbar h2 { font-size: 18px; margin-left: 8px; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; font-weight: 600;
  color: var(--mute); border-left: 1px solid var(--line); min-height: 30px; }
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--ink); background: var(--surface-2); }
.seg button.active { background: var(--accent-soft); color: var(--accent); }
.cal-wrap { flex: 1; min-height: 0; padding: 0 8px 8px 0; }
#calendar { height: 100%; }

/* mini month */
.mini { user-select: none; }
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.mini-head strong { font-size: 13px; }
.mini-head .icon-btn { width: 26px; height: 26px; font-size: 15px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.mini-grid .dow { font-size: 11px; color: var(--faint); padding: 2px 0; font-weight: 600; }
.mini-grid button { border: 0; background: none; padding: 0; height: 28px; border-radius: 50%; cursor: pointer;
  font-size: 12px; color: var(--ink); }
.mini-grid button.other { color: var(--faint); }
.mini-grid button.in-range { background: var(--accent-soft); border-radius: 0; }
.mini-grid button:hover { background: var(--surface-2); border-radius: 50%; }
.mini-grid button.today { background: var(--accent); color: var(--accent-ink); border-radius: 50%; font-weight: 700; }

/* calendar list */
.cal-list, .task-list { list-style: none; margin: 0; padding: 0; }
.cal-list li label { display: flex; align-items: center; gap: 10px; padding: 5px 4px; border-radius: 6px;
  font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; }
.cal-list li label:hover { background: var(--surface-2); }
.cal-list input { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; border-radius: 4px;
  border: 2px solid var(--c); background: var(--c); display: grid; place-items: center; cursor: pointer; }
.cal-list input:not(:checked) { background: transparent; }
.cal-list input:checked::after { content: ""; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px); }

/* tasks */
.task-list li { display: flex; align-items: flex-start; gap: 8px; padding: 6px 4px; border-radius: 6px; }
.task-list li:hover { background: var(--surface-2); }
.task-list li.group { padding: 10px 4px 2px; font-size: 12px; font-weight: 700; color: var(--mute); background: none; }
.task-list .tk-check { appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px;
  border-radius: 50%; border: 1.5px solid var(--faint); margin-top: 1px; cursor: pointer; background: transparent; }
.task-list .tk-check:hover { border-color: var(--accent); background: var(--accent-soft); }
.task-list .tk-check:checked { background: var(--accent); border-color: var(--accent); }
.task-list .tk-body { flex: 1; min-width: 0; cursor: pointer; }
.task-list .tk-title { display: block; overflow-wrap: anywhere; }
.task-list .tk-meta { font-size: 12px; color: var(--mute); }
.task-list .overdue .tk-meta { color: var(--danger); font-weight: 600; }
.task-list li.done { opacity: .45; text-decoration: line-through; transition: opacity .3s; }

/* FullCalendar theme */
.fc {
  --fc-border-color: var(--line-soft); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2);
  --fc-today-bg-color: color-mix(in srgb, var(--accent) 7%, transparent); --fc-now-indicator-color: var(--danger);
  --fc-list-event-hover-bg-color: var(--surface-2); --fc-highlight-color: color-mix(in srgb, var(--accent) 18%, transparent);
  --fc-event-text-color: #fff; --fc-non-business-color: color-mix(in srgb, var(--ink) 3%, transparent);
  font-size: 13px;
}
.fc .fc-scrollgrid { border-left: 0; border-top: 0; }
.fc .fc-col-header-cell { padding: 8px 0 6px; font-weight: 600; color: var(--mute); }
.fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number { color: inherit; text-decoration: none; }
.fc .fc-day-today .fc-col-header-cell-cushion { color: var(--accent); }
.fc .fc-timegrid-slot { height: 2.6em; }
.fc .fc-timegrid-slot-label-cushion { color: var(--faint); font-size: 11.5px; }
.fc .fc-timegrid-slot-minor { border-top-style: dotted; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--line-soft); }
.fc .fc-event { border-radius: 4px; border-width: 0 0 0 4px; cursor: pointer; }
/* Teams-style tinted blocks with a solid left bar; --ev is the calendar colour, set per event by app.js */
.fc .fc-list-event-dot { border-color: var(--ev, var(--accent)) !important; }
.fc .fc-timegrid-event, .fc .fc-daygrid-block-event {
  background: color-mix(in srgb, var(--ev, var(--accent)) 22%, var(--surface)) !important;
  border-color: transparent !important;
  border-left: 4px solid var(--ev, var(--accent)) !important;
}
.fc .fc-daygrid-event-dot { border-color: var(--ev, var(--accent)) !important; }
.fc .fc-timegrid-event .fc-event-main, .fc .fc-daygrid-block-event .fc-event-main { color: var(--ink); padding: 2px 4px; }
.fc .fc-event-title { font-weight: 600; }
.fc .fc-event-time { color: var(--mute); }
.fc .fc-daygrid-dot-event { color: var(--ink); }
.fc .fc-daygrid-dot-event:hover { background: var(--surface-2); }
.fc .fc-task .fc-event-title::before { content: "☐ "; font-weight: 400; }
.fc .fc-overdue .fc-event-title { color: var(--danger); }
.fc .fc-list-day-cushion { background: var(--surface-2); }
.fc .fc-list-event td { border-color: var(--line-soft); }
.fc .fc-list-event:hover td { background: var(--surface-2); }
.fc .fc-popover { background: var(--surface); box-shadow: var(--shadow); border-color: var(--line); }
.fc .fc-popover-header { background: var(--surface-2); }
.fc .fc-more-link { color: var(--accent); font-weight: 600; }
.fc a { color: inherit; }

/* ---------- pages */
.page { overflow-y: auto; }
.page-inner { max-width: 900px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; }
.page-head h1 { font-size: 22px; }
.status { font-size: 13px; color: var(--mute); }
.status b { color: var(--ink); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.dot.bad { background: var(--danger); }
.card-stack { display: grid; gap: 16px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px;
  margin-bottom: 16px; }
.card-stack .card { margin: 0; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); margin-bottom: 12px; }
.card.hero { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card p { margin: 0 0 10px; }
.hero-line { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; font-size: 15px; }
.hero-line input[type=time] { width: 140px; font-size: 18px; font-weight: 600; min-height: 42px; }
.row { display: grid; grid-template-columns: 240px 1fr; gap: 6px 20px; padding: 12px 0;
  border-top: 1px solid var(--line-soft); align-items: start; }
.row:first-of-type { border-top: 0; padding-top: 0; }
.row .name { display: block; font-weight: 600; color: var(--ink); font-size: 14px; }
.row .help { color: var(--mute); font-size: 12.5px; margin-top: 2px; }
.row input[type=time], .row input[type=number], .row input:not([type]) { max-width: 200px; }
.src { display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 9px; background: var(--surface-2);
  border: 1px solid var(--line-soft); color: var(--mute); margin-left: 6px; font-weight: 500; vertical-align: 1px; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { display: inline-flex; align-items: center; gap: 0; padding: 0; color: var(--ink); }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span { display: inline-grid; place-items: center; min-width: 44px; height: 32px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 16px; cursor: pointer; font-weight: 600; font-size: 13px; }
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: var(--ink); font-weight: 500;
  font-size: 14px; }
.toggle input { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: 11px;
  background: var(--line); position: relative; cursor: pointer; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { left: 21px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.save-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--mute); font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .04em; padding: 0 10px 8px 0; white-space: nowrap; }
td { padding: 8px 10px 8px 0; border-top: 1px solid var(--line-soft); vertical-align: top; }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 9px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }

/* ---------- dialogs */
.dlg { border: 0; padding: 0; border-radius: 10px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dlg.narrow { width: min(440px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(0,0,0,.35); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 18px; border-bottom: 1px solid var(--line-soft); }
.dlg-swatch { flex: none; width: 4px; align-self: stretch; border-radius: 2px; background: var(--accent); }
.title-input { border: 0 !important; box-shadow: none !important; font-size: 18px !important; font-weight: 600 !important;
  padding: 4px 0 !important; background: transparent !important; }
.dlg-body { padding: 14px 18px; display: grid; gap: 12px; overflow-y: auto; }
.dlg-foot { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line-soft);
  flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.grid-times { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 8px 10px; }
.dlg-body label, .dlg-body input, .dlg-body select { min-width: 0; }
.dlg-body { overflow-x: hidden; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.detail-list dt { color: var(--mute); font-weight: 600; font-size: 12.5px; padding-top: 1px; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

/* ---------- toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow);
  font-weight: 500; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- narrow screens */
@media (max-width: 900px) {
  .seg button { padding: 5px 9px; }
  .seg button[data-view="timeGridWeek"] { display: none; }
}
@media (max-width: 760px) {
  .rail-toggle { display: inline-grid; }
  .topbar { gap: 4px; padding: 0 6px; }
  .brand, .who { display: none; }
  .tabs { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .tabs a { padding: 0 8px; }
  .rail { position: fixed; z-index: 30; top: var(--topbar); bottom: 0; left: 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow); }
  .app.rail-open .rail { transform: none; }
  .app.rail-open .rail-scrim { display: block; position: fixed; inset: var(--topbar) 0 0 0; z-index: 25;
    background: rgba(0,0,0,.3); }
  .cal-toolbar { padding: 8px 10px; }
  .cal-toolbar h2 { font-size: 16px; margin-left: 2px; }
  .seg { order: 10; width: 100%; }
  .seg button { flex: 1; padding: 5px 4px; }
  .seg button[data-view="workWeek"] { display: none; }
  .cal-wrap { padding: 0; }
  .row { grid-template-columns: 1fr; }
  .grid-times { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  #logoutBtn { padding: 5px 8px; }
}
@media (max-width: 420px) {
  .grid2 { grid-template-columns: 1fr; }
}
