:root {
    --ink: #1c2430;
    --muted: #6b7684;
    --line: #e3e7ec;
    --bg: #f4f6f9;
    --card: #fff;
    --brand: #1f3a5f;
    --brand-ink: #fff;
    --accent: #2f6fb3;
    --ok: #1e7f4f;
    --danger: #b3261e;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }

.muted { color: var(--muted); }
.right { text-align: right; }

/* Shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--brand);
    color: var(--brand-ink);
    display: flex;
    flex-direction: column;
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: inherit; padding: 0 8px 18px; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center;
    width: 32px; height: 32px; border-radius: 6px;
    background: var(--brand-ink); color: var(--brand);
    font-size: 13px; font-weight: 700;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { color: rgba(255,255,255,.82); padding: 7px 10px; border-radius: 6px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.sidebar nav a.sub { padding-left: 20px; }
.nav-group { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.5); }

.sidebar-foot { border-top: 1px solid rgba(255,255,255,.15); padding: 12px 10px 0; font-size: 13px; }
.sidebar-foot .who { font-weight: 600; }
.sidebar-foot a { color: rgba(255,255,255,.75); }

.main { flex: 1; min-width: 0; padding: 24px 32px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.stat-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* Tables */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-inactive td { color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: #e3f4ea; color: var(--ok); }
.badge-off { background: #eef0f3; color: var(--muted); }

/* Buttons */
.btn {
    display: inline-block; padding: 7px 14px; border-radius: 6px;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { text-decoration: none; background: #f7f8fa; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #285f9a; }
.btn-block { width: 100%; }

/* Flashes */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash-success { background: #e3f4ea; color: var(--ok); }
.flash-error { background: #fbe9e7; color: var(--danger); }

/* Forms */
.form-card { max-width: 560px; }
.form-card form > div > div, .form-card form > div > fieldset { margin-bottom: 14px; }
label { display: block; font-weight: 500; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #cdd3da; border-radius: 6px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,111,179,.35); border-color: var(--accent); }
input[type=checkbox] { margin-right: 6px; }
input[type=checkbox] + label, label.check { display: inline; font-weight: 400; }
.help-text { color: var(--muted); font-size: 12px; margin-top: 2px; }
ul:has(> li) { color: var(--danger); padding-left: 18px; margin: 4px 0; }

/* Sign-in: hero panel beside the form */
body.auth { margin: 0; background: #fff; }
.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-hero { position: relative; overflow: hidden; background: linear-gradient(160deg, #162b47 0%, #0d1b2e 100%); color: #fff; }
.login-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .7; }
.login-hero-shade { position: absolute; inset: 0; background: rgba(13, 27, 46, .72); }
.login-hero:not(.has-image) .login-hero-shade { background: radial-gradient(circle at 20% 15%, rgba(47,111,179,.35), transparent 55%); }
.login-hero-body { position: relative; display: flex; flex-direction: column; justify-content: space-between; height: 100%; padding: 32px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-mark { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--accent); font-weight: 700; font-size: 14px; }
.login-brand-name { display: flex; flex-direction: column; line-height: 1.2; font: 18px Georgia, "Times New Roman", serif; }
.login-brand-name small { font: 10px system-ui, sans-serif; text-transform: uppercase; letter-spacing: .18em; color: rgba(255,255,255,.6); }
.login-pitch { max-width: 380px; }
.login-pitch h2 { margin: 0; font: 36px/1.15 Georgia, "Times New Roman", serif; }
.login-pitch p { margin: 16px 0 0; font-size: 14px; color: rgba(255,255,255,.8); }
.login-foot { margin: 0; font-size: 10px; text-transform: uppercase; letter-spacing: .18em; color: rgba(255,255,255,.5); }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.login-form { width: 100%; max-width: 320px; }
.login-form h1 { margin: 4px 0 24px; font: 32px/1.2 Georgia, "Times New Roman", serif; }
.login-form .overline { display: block; margin: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.login-form form input:not([type=checkbox]) { margin-bottom: 16px; }
.login-form .check { display: block; margin: 0 0 20px; }
.login-brand-mobile { display: none; margin-bottom: 24px; font: 22px Georgia, "Times New Roman", serif; color: var(--brand); }
.login-help { margin: 24px 0 0; font-size: 12px; color: var(--muted); }

@media (max-width: 900px) {
    .login { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .login-brand-mobile { display: block; }
}

.login-preview { display: block; width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; height: auto; position: static; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .nav-group { display: none; }
    .sidebar nav a.sub { padding-left: 10px; }
    .main { padding: 20px 16px; }
}

/* Lists */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.filters input[type=search] { flex: 1 1 280px; max-width: 420px; }
.filters select { width: auto; }
.filters .count { margin-left: auto; }
.table-hover tbody tr:hover td { background: #f8fafc; }
.table td.empty { text-align: center; color: var(--muted); padding: 32px; }
.sort { color: inherit; }
.sort.is-asc::after { content: " ▲"; font-size: 9px; }
.sort.is-desc::after { content: " ▼"; font-size: 9px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }

.badge-registered { background: #e3f4ea; color: var(--ok); }
.badge-pending { background: #fff4d6; color: #8a5a00; }
.badge-waitlisted { background: #e6eefb; color: var(--accent); }
.badge-cancelled { background: #eef0f3; color: var(--muted); }

/* Detail pages */
.details { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.notes { white-space: normal; }
.meta-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; font-size: 13px; }
.btn-danger-link { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; padding: 0; }
.btn-danger-link:hover { text-decoration: underline; }

/* Sectioned forms */
.form-grid { max-width: 760px; display: flex; flex-direction: column; gap: 6px; }
.form-grid fieldset { border: 0; padding: 0; margin: 0 0 10px; }
.form-grid legend { font-weight: 600; font-size: 15px; margin-bottom: 10px; }
.form-grid .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .row-city { grid-template-columns: 2fr 1fr 1fr; }
.form-grid fieldset > div, .form-grid .row > div { margin-bottom: 12px; }
@media (max-width: 600px) { .form-grid .row, .form-grid .row-city { grid-template-columns: 1fr; } }
.stat-value a { color: inherit; }

/* Tables, forms and shared helpers */
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.wrap { white-space: normal; min-width: 160px; }
.section-gap { margin-top: 16px; }
.form-narrow { max-width: 520px; }
.add-row { margin-bottom: 16px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-form > div { margin: 0; }
.inline-form > div:first-child { flex: 1 1 260px; }
.inline-form > div:not(:first-child):not(:last-child) { flex: 0 1 170px; }
.inline-form ul { margin: 4px 0 0; }
.small { font-size: 12px; margin: 10px 0 0; }
.row-actions { display: inline-flex; gap: 12px; align-items: center; }
.row-actions form { display: inline; }
.input-group, .form-grid .input-group { display: flex; align-items: center; gap: 6px; }

/* Inline add forms (contact log) */
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 12px; }
.inline-form > div { margin: 0; }
.inline-form select, .inline-form input { min-width: 160px; }
.inline-form ul { color: var(--danger); margin: 0; padding-left: 16px; }

/* Bar chart (single series) */
.chart-summary { margin: -6px 0 14px; font-size: 13px; }
.chart-summary strong { color: var(--ink); }
.bar-chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; height: 200px; margin-bottom: 8px; }
.bar-col { position: relative; display: flex; flex-direction: column; outline: none; }
.bar-track { flex: 1; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--line); }
.bar { width: 70%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-col:hover .bar, .bar-col:focus .bar { background: #285f9a; }
.bar-col:hover, .bar-col:focus { background: rgba(47,111,179,.06); border-radius: 4px; }
.bar-label { text-align: center; font-size: 11px; color: var(--muted); padding-top: 4px; }
.bar-tip {
    display: none; position: absolute; bottom: calc(100% - 20px); left: 50%; transform: translateX(-50%);
    background: var(--ink); color: #fff; font-size: 12px; line-height: 1.4; padding: 6px 9px; border-radius: 6px;
    white-space: nowrap; z-index: 2; pointer-events: none;
}
.bar-col:first-child .bar-tip { left: 0; transform: none; }
.bar-col:last-child .bar-tip { left: auto; right: 0; transform: none; }
.bar-col:hover .bar-tip, .bar-col:focus .bar-tip { display: block; }
.chart-table { margin-top: 6px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--accent); }
.chart-table .table { margin-top: 8px; }

/* Contact picker (search-as-you-type) */
.picker { position: relative; min-width: 280px; flex: 1 1 280px; }
.picker-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 280px; overflow-y: auto; }
.picker-results li { padding: 7px 12px; cursor: pointer; }
.picker-results li:hover, .picker-results li.is-active { background: rgba(47,111,179,.1); }
.picker-results .picker-empty { color: var(--muted); cursor: default; }
.picker-results .picker-empty:hover { background: none; }
.picker input[type=search] { width: 100%; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: inherit; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Reports */
.report-form { max-width: 1100px; }
.report-filters { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 18px; }
.report-filters > div { min-width: 240px; }
.report-columns { border: 0; padding: 0; margin: 0 0 16px; }
.report-columns legend { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 0; margin-bottom: 10px; }
.report-columns .all-none { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 8px; }
.column-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; margin-bottom: 8px; }
.report-actions { display: flex; gap: 8px; }
.column-subhead { margin: 14px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.column-subhead .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* Contact tags */
.tag { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-upcoming { background: #e6eefb; color: var(--accent); }
.tag-count { background: #eef0f3; color: #4a5565; }


.tag-warn { background: #fff4d6; color: #8a5a00; }
.feed { list-style: none; margin: 0; padding: 0; color: inherit; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--line); color: inherit; }
.feed li:last-child { border-bottom: 0; }
.tag-role { background: #f1e9fb; color: #5b3a8c; }
.check-cell { text-align: center; color: var(--ok); font-weight: 600; }

/* Contact log: date and type stay narrow, description takes the remaining width.
   Selectors are doubled up to beat the generic .inline-form column rules. */
.inline-form.log-form > div:first-child { flex: 0 1 170px; }
.inline-form.log-form > div:nth-child(3) { flex: 1 1 520px; }
.log-form input, .log-form select, .log-form textarea { box-sizing: border-box; height: 40px; }
.log-form textarea { display: block; width: 100%; resize: none; line-height: 1.3; }

.notes-form textarea { display: block; width: 100%; resize: vertical; margin-bottom: 10px; }

.muted-on-btn { opacity: .75; font-weight: 400; }


/* Dashboard announcements */
.announcements { margin-bottom: 16px; }
.announcements h2 .small-link { font-size: 13px; font-weight: 400; margin-left: 8px; }
.announcement + .announcement { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.announcement { display: flex; gap: 16px; align-items: flex-start; }
.announcement-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.announcement-head { margin-bottom: 2px; }
.date-tile { flex: none; display: flex; flex-direction: column; align-items: center; width: 64px; padding: 6px 4px 5px; border: 1px solid var(--line); border-radius: 8px; background: #fff; line-height: 1.1; text-align: center; }
.date-dow { font-size: 12px; color: var(--muted); }
.date-day { font-size: 28px; font-weight: 700; color: var(--ink); margin: 2px 0; }
.date-year { font-size: 12px; color: var(--muted); }

/* "?" help notes beside headings */
.help { position: relative; display: inline-block; margin-left: 4px; vertical-align: middle; font-weight: 400; }
.help-btn { width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--accent); font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer; }
.help-btn:hover, .help-btn[aria-expanded=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.help-popup { position: absolute; z-index: 20; top: calc(100% + 8px); left: -4px; width: 300px; max-width: 80vw; padding: 12px 14px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(28,36,48,.15); font-size: 13px; line-height: 1.45; white-space: normal; }
.help-popup[hidden] { display: none; }
.help-popup > strong { display: block; margin-bottom: 4px; font-size: 13px; }

/* Message board */
.board-compose textarea { display: block; width: 100%; resize: vertical; }
.board-actions { margin-top: 10px; }
.board { display: grid; gap: 12px; margin-top: 16px; }
.board-post-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 6px; }
.board-delete { margin: 0 0 0 auto; }
.board-post-body { overflow-wrap: anywhere; }

.sidebar nav .nav-count { font-weight: 700; color: #ffd666; }
.board-seen { margin-top: 8px; font-size: 12px; }
.board-seen .seen-yes { color: var(--ok); font-weight: 600; }

/* Staff online, under Message Board in the sidebar */
.nav-online { margin: 2px 10px 6px 20px; font-size: 12px; color: rgba(255,255,255,.7); }
.nav-online-title { text-transform: uppercase; letter-spacing: .05em; font-size: 10px; color: rgba(255,255,255,.5); margin-bottom: 3px; }
.nav-online-user { display: flex; align-items: center; gap: 6px; padding: 1px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-online-user .dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #4cd08a; }
.nav-online-user .you { opacity: .6; }
@media (max-width: 760px) { .nav-online { display: none; } }

/* @-mentions on the message board */
.mention-menu { position: absolute; z-index: 20; left: 0; right: auto; min-width: 240px; max-width: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(28,36,48,.15); }
.mention-menu[hidden] { display: none; }
.mention-menu li { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.mention-menu li.is-active, .mention-menu li:hover { background: #e6eefb; color: var(--accent); }
.mention { display: inline-block; padding: 0 6px; border-radius: 4px; background: #e6eefb; color: var(--accent); font-weight: 600; }
.mention-me { background: #fff1b8; color: #7a5200; }
.board-post-for-me { border-left: 4px solid #e0a800; }
.board-more { text-align: center; }
.board-post[hidden], .board-more[hidden] { display: none; }
