:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #14202b;
  --muted: #5d6873;
  --line: #e1e5ea;
  /* Brand colors: replaced at runtime from the BRAND_COLOR / BRAND_HEADER_COLOR settings */
  --accent: #0071a8;
  --accent-hover: #00608f;
  --accent-ink: #ffffff;
  --accent-soft: #e0eef5;
  --accent-text: #0071a8;
  --brand2: #00bf63;
  --brand2-ink: #14202b;
  --brand2-text: #007a3f;
  --brand2-soft: #dbf6e8;
  --display: "Montserrat", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --header-bg: #ffffff;
  --header-ink: #14202b;
  --header-muted: #5d6873;
  --header-hover: #f2f4f7;
  --header-active-bg: #e0eef5;
  --header-active-ink: #0071a8;
  --header-border: #e3e6ea;
  --warn: #9a5b13;
  --warn-soft: #fbf0df;
  --danger: #a3352b;
  --danger-soft: #f8e5e2;
  --info: #2b5c8a;
  --info-soft: #e3edf6;
  --ok: #2d6a3e;
  --ok-soft: #e2f1e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 2px 8px rgba(20, 30, 25, .04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent-text); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-family: var(--display); font-weight: 700; text-wrap: balance; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ---------- Header ---------- */
.topbar { background: var(--header-bg); border-bottom: 1px solid var(--header-border); box-shadow: inset 0 -3px 0 var(--brand2); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; min-height: 58px; }
.brand { color: var(--header-ink); text-decoration: none; display: flex; align-items: center; gap: 10px; white-space: nowrap; min-width: 0; }
.brand-divider { width: 1px; height: 26px; background: var(--header-border); }
.brand-logo { height: 40px; width: auto; max-width: 150px; object-fit: contain; display: block; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-size: 14px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-family: var(--display); font-size: .72rem; color: var(--header-muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.auth-brand { margin-bottom: 22px; }
.auth-brand .brand { color: var(--ink); }
.auth-brand .brand-sub { color: var(--muted); }
.auth-brand .brand-logo { height: 56px; max-width: 220px; }
.auth .card { border-top: 4px solid var(--accent); }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { font-family: var(--display); font-size: .9rem; padding: 8px 12px; border-radius: 8px; color: var(--header-muted); text-decoration: none; white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--header-hover); color: var(--header-ink); }
.nav a.active { color: var(--header-active-ink); background: var(--header-active-bg); }
.nav .sep { width: 1px; background: var(--header-border); opacity: .6; margin: 8px 6px; flex: none; }
.topbar .avatar { background: var(--header-active-bg); color: var(--header-active-ink); }
.userbox { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 12px; text-decoration: none; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 0 12px; padding-top: 8px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; margin: 4px -8px 6px; }
  .brand-logo { height: 34px; }
  .brand-divider, .topbar .brand-sub { display: none; }
}

/* ---------- Layout ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.page.narrow { max-width: 720px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.flush { padding: 0; }
.card > h2 { display: flex; align-items: center; gap: 8px; }
.card-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-head h2 { margin: 0; }
.count { background: var(--bg); color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: .78rem; font-weight: 600; }

.stat { padding: 16px 18px; }
.stat .num { font-family: var(--display); font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat a { text-decoration: none; color: inherit; display: block; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 14px 18px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.item { display: flex; gap: 14px; align-items: flex-start; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; color: var(--ink); text-decoration: none; }
a.item-title:hover { color: var(--accent-text); }
.item-meta { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.datebox { width: 52px; flex: none; text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 5px 0 6px; background: var(--surface); }
.datebox .m { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-text); font-weight: 700; }
.datebox .d { font-family: var(--display); font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.empty { padding: 26px 18px; text-align: center; color: var(--muted); }
@media (max-width: 600px) {
  .item { flex-wrap: wrap; }
  .item-actions { flex-basis: 100%; padding-left: 66px; }
}

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.s-invited { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.s-accepted { background: var(--info-soft); color: var(--info); border-color: transparent; }
.s-attended { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.s-completed { background: #efe6f6; color: #6b3f8c; border-color: transparent; }
.s-approved { background: var(--brand2-soft); color: var(--brand2-text); border-color: transparent; }
.s-declined, .s-no_show, .s-cancelled { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.s-full { background: var(--brand2-soft); color: var(--brand2-text); border-color: transparent; }
.s-open { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.slots { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.meter { width: 70px; height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; display: inline-block; }
.meter span { display: block; height: 100%; background: var(--brand2); border-radius: 4px; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 8px 14px; font: inherit; font-weight: 600; font-size: .9rem; text-decoration: none; cursor: pointer; white-space: nowrap; min-height: 38px; }
.btn:hover { border-color: #cfccc2; background: #faf9f6; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #e9c3bd; }
.btn.ok { background: var(--brand2); color: var(--brand2-ink); border-color: var(--brand2); }
.btn.ok:hover { filter: brightness(.95); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .84rem; }
.btn.link { border: 0; background: none; color: var(--accent-text); padding: 0; min-height: 0; font-weight: 600; }
.btn.block { width: 100%; }
form.inline { display: inline; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: .82rem; font-weight: 400; margin-top: 5px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid #d6d3ca; border-radius: 9px; padding: 9px 11px; min-height: 40px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=file] { font: inherit; font-size: .9rem; max-width: 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .fields-2 { grid-template-columns: 1fr; } }
.picker { border: 1px solid var(--line); border-radius: 10px; max-height: 300px; overflow: auto; }
.picker label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); margin: 0; font-weight: 500; cursor: pointer; }
.picker label:first-child { border-top: 0; }
.picker label:hover { background: var(--bg); }
.picker input { width: 17px; height: 17px; accent-color: var(--accent); }
details.inline-form summary { cursor: pointer; list-style: none; display: inline-flex; }
details.inline-form summary::-webkit-details-marker { display: none; }
details.inline-form[open] summary { margin-bottom: 10px; }
details.inline-form .panel { background: var(--bg); border-radius: 10px; padding: 12px; width: 100%; }

/* ---------- Flash ---------- */
.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.info { background: var(--info-soft); color: var(--info); }
.notice { background: var(--warn-soft); color: #6d4210; border-radius: 10px; padding: 12px 14px; font-size: .9rem; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); font-size: 1rem; user-select: all; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--accent-text); border-color: var(--accent); }

/* ---------- Task detail ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; font-weight: 500; }
.description { white-space: pre-wrap; word-wrap: break-word; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.files li:first-child { border-top: 0; }
.files .ficon { width: 32px; height: 32px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-size: .65rem; font-weight: 700; color: var(--muted); text-transform: uppercase; flex: none; }
.files a { font-weight: 600; text-decoration: none; word-break: break-all; }
.steps { display: flex; gap: 0; margin: 4px 0 16px; }
.steps .st { flex: 1; text-align: center; position: relative; font-size: .75rem; color: var(--muted); }
.steps .st::before { content: ""; display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--line); margin: 0 auto 6px; position: relative; z-index: 1; }
.steps .st::after { content: ""; position: absolute; top: 5px; left: 50%; width: 100%; height: 2px; background: var(--line); }
.steps .st:last-child::after { display: none; }
.steps .st.done { color: var(--accent-text); font-weight: 600; }
.steps .st.done::before, .steps .st.done::after { background: var(--brand2); }
.note { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: .88rem; margin-top: 6px; white-space: pre-wrap; }
.note.warn { background: var(--warn-soft); color: #6d4210; }

/* ---------- Schedule ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 150px; display: flex; flex-direction: column; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day-head { padding: 8px 10px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.day-head .dn { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.day-head .dd { font-weight: 700; }
.day.today .dn, .day.today .dd { color: var(--accent-text); }
.day-body { padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.chip { display: block; text-decoration: none; color: var(--ink); background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px; padding: 6px 8px; font-size: .82rem; line-height: 1.3; }
.chip:hover { filter: brightness(.97); }
.chip .t { font-weight: 700; color: var(--accent-text); font-size: .76rem; }
.chip.invited { background: var(--warn-soft); border-color: var(--warn); }
.chip.invited .t { color: var(--warn); }
.chip.completed, .chip.approved { background: var(--ok-soft); border-color: var(--ok); }
.chip.completed .t, .chip.approved .t { color: var(--ok); }
.chip .p { color: var(--muted); font-size: .76rem; margin-top: 2px; }
@media (max-width: 860px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .day-head { justify-content: flex-start; gap: 8px; }
  .day.empty-day .day-body { display: none; }
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: top; }
tr:first-child td { border-top: 0; }
tr.inactive td { opacity: .55; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; }

