@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

/* Brand tokens — matched to the ACS Quality Management System / Absolute
   Care Portal Project: public-site purple, Poppins type, spacious rounded
   surfaces. Kept as the same variable names across ACS's internal tools so
   a future shared stylesheet is a drop-in. */
:root {
    --brand-purple: #562075;
    --brand-purple-dark: #3f1558;
    --brand-lilac: #f1eaf5;
    --brand-lilac-deep: #e5d6ec;
    --page-background: #f3f2f5;
    --surface: #ffffff;
    --surface-soft: #faf9fb;
    --design-line: #e7e0eb;
    --design-radius: 12px;
    --design-radius-small: 8px;
    --design-shadow: 0 8px 26px rgba(86, 32, 117, .06);
    --ink: #2f2733;
    --muted: #8b828f;
    --green: #24845c;
    --green-bg: #e8f5ec;
    --amber: #b87918;
    --amber-bg: #fff4df;
    --red: #bc5148;
    --red-bg: #fbeae7;
    --critical: #7a1620;
    --critical-bg: #f6dbdd;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    background: var(--page-background);
    color: var(--ink);
    font-family: 'Poppins', sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
a { color: var(--brand-purple); }

/* ===================== Shared: brand mark, buttons, pills ===================== */

.brand-mark {
    width: 40px; height: 40px; flex-shrink: 0;
    background: var(--brand-purple); color: #fff;
    border-radius: 50%; display: grid; place-items: center;
    font-weight: 700; font-size: 15px;
}

.button {
    border-radius: 24px; border: 1px solid transparent; padding: 11px 18px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px;
    font-weight: 700; white-space: nowrap; font-family: 'Poppins', sans-serif;
    text-decoration: none; min-height: 44px;
}
.button-dark { background: var(--brand-purple); color: #fff; }
.button-dark:hover { background: var(--brand-purple-dark); }
.button-outline { color: var(--brand-purple); background: var(--surface); border-color: #cbb5d5; }
.button-outline:hover { background: var(--brand-lilac); }
.button-danger { color: var(--red); background: var(--red-bg); border-color: transparent; }
.button[disabled] { opacity: .5; cursor: not-allowed; }
.button-block { width: 100%; }
.button-lg { padding: 16px 20px; font-size: 15px; min-height: 56px; border-radius: 16px; }

.status-pill { display: inline-flex; align-items: center; justify-content: center; border-radius: 20px; padding: 5px 10px; font-size: 10px; line-height: 1; font-weight: 700; white-space: nowrap; text-transform: capitalize; }
.status-pill.amber { color: var(--amber); background: var(--amber-bg); }
.status-pill.green { color: var(--green); background: var(--green-bg); }
.status-pill.red { color: var(--red); background: var(--red-bg); }
.status-pill.lilac { color: var(--brand-purple); background: var(--brand-lilac); }
.status-pill.grey { color: #6d6870; background: #efeef0; }

.chip { display: inline-flex; align-items: center; background: var(--brand-lilac); color: var(--brand-purple); border-radius: 20px; padding: 5px 11px; font-size: 11px; font-weight: 600; }

.summary-button { list-style: none; cursor: pointer; }
.summary-button::-webkit-details-marker { display: none; }

.error, .banner-error {
    color: var(--red); background: var(--red-bg); border-radius: var(--design-radius-small);
    padding: 12px 14px; font-size: 13px; margin-bottom: 16px;
}
.banner-warning {
    color: var(--amber); background: var(--amber-bg); border: 1px solid #f0d9a8; border-radius: var(--design-radius);
    padding: 14px 16px; font-size: 13px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start;
}
.banner-warning strong { display: block; color: var(--amber); font-size: 13px; margin-bottom: 3px; }
.banner-success { color: var(--green); background: var(--green-bg); border-radius: var(--design-radius); padding: 14px 16px; font-size: 13px; margin-bottom: 16px; }

label { display: grid; gap: 6px; color: #6d6870; font-size: 12px; font-weight: 600; margin-bottom: 14px; }
input, select, textarea {
    width: 100%; border: 1px solid var(--design-line); border-radius: var(--design-radius-small);
    background: #fff; color: var(--ink); padding: 12px 13px; font-size: 15px;
    outline-color: var(--brand-purple); font-family: 'Poppins', sans-serif; min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }

.panel {
    background: var(--surface); border: 1px solid var(--design-line);
    border-radius: var(--design-radius); box-shadow: var(--design-shadow);
    padding: 18px 20px;
}

/* ===================== Manager / admin shell (sidebar layout) ===================== */

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 240px; background: var(--surface); border-right: 1px solid var(--design-line);
    padding: 28px 16px 18px; display: flex; flex-direction: column; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 26px; }
.brand strong { display: block; font-size: 13px; }
.brand span { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.primary-nav { display: grid; gap: 4px; }
.nav-item {
    appearance: none; border: 0; background: transparent; color: #6d6870; display: flex; align-items: center;
    text-align: left; gap: 12px; border-radius: var(--design-radius-small); padding: 12px 13px; font-size: 13px;
    text-decoration: none;
}
.nav-item:hover, .nav-item.active { background: var(--brand-lilac); color: var(--brand-purple); }
.nav-item.active { font-weight: 700; }
.sidebar-footer { margin-top: auto; display: grid; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 14px 8px 0; border-top: 1px solid var(--design-line); color: var(--muted); }
.user-chip strong { display: block; font-size: 12px; color: var(--ink); }
.user-chip span { display: block; font-size: 10px; margin-top: 2px; text-transform: capitalize; }
.avatar {
    width: 32px; height: 32px; flex-shrink: 0; background: var(--brand-lilac-deep); color: var(--brand-purple);
    border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.logout-form button {
    width: 100%; background: transparent; border: 1px solid var(--design-line); color: var(--muted);
    border-radius: var(--design-radius-small); padding: 9px; font-size: 11px;
}

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    min-height: 68px; padding: 14px 32px; background: var(--surface); border-bottom: 1px solid var(--design-line);
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.page-wrap { max-width: 1100px; margin: 0 auto; padding: 30px 32px 60px; width: 100%; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { text-transform: uppercase; letter-spacing: 1.4px; font-size: 10px; font-weight: 700; color: var(--brand-purple); margin-bottom: 8px; display: block; }
h1 { font: 700 24px 'Poppins', sans-serif; letter-spacing: -.3px; }
h2 { font: 600 15px 'Poppins', sans-serif; }
.page-header p { font-size: 12px; color: var(--muted); margin-top: 6px; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 26px; }
.portal-tile {
    display: block; background: var(--surface); border: 1px solid var(--design-line); border-radius: var(--design-radius);
    box-shadow: var(--design-shadow); padding: 20px 22px; text-decoration: none; color: inherit;
}
.portal-tile:hover { border-color: var(--brand-purple); }
.portal-tile h2 { font-size: 14px; margin-bottom: 6px; color: var(--ink); }
.portal-tile .tile-stat { font-size: 12px; color: var(--muted); }
.portal-tile .tile-count { font: 700 26px 'Poppins', sans-serif; color: var(--brand-purple); }

.table-panel { background: var(--surface); border: 1px solid var(--design-line); border-radius: var(--design-radius); box-shadow: var(--design-shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; text-transform: uppercase; letter-spacing: .7px; font-size: 9px; font-weight: 700; padding: 13px 16px; white-space: nowrap; background: var(--surface-soft); color: #8b828f; }
td { border-top: 1px solid var(--design-line); padding: 13px 16px; font-size: 13px; color: #4b444e; }
tbody tr:hover { background: var(--surface-soft); }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; }
    .primary-nav { display: flex; overflow-x: auto; }
    .sidebar-footer { display: none; }
    .page-wrap { padding: 20px 16px 40px; }
}

/* ===================== Senior mobile shell ===================== */
/* Phone-first, single column, no sidebar — seniors are on shift on a
   phone, often with one hand, sometimes low signal (spec §10). */

.senior-shell { min-height: 100vh; display: flex; flex-direction: column; }
.senior-topbar {
    background: var(--surface); border-bottom: 1px solid var(--design-line);
    padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
.senior-topbar .shift-meta { flex: 1; min-width: 0; }
.senior-topbar .shift-meta strong { display: block; font-size: 14px; }
.senior-topbar .shift-meta span { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }

.senior-main { flex: 1; padding: 18px 16px 100px; max-width: 560px; width: 100%; margin: 0 auto; }

.senior-nav {
    position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--design-line);
    display: flex; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 16px rgba(86,32,117,.06); z-index: 20;
}
.senior-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px;
    text-decoration: none; color: var(--muted); font-size: 10px; font-weight: 600; border-radius: 10px;
}
.senior-nav a.active { color: var(--brand-purple); background: var(--brand-lilac); }
.senior-nav svg { width: 20px; height: 20px; }

.sync-indicator {
    display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--muted);
    background: var(--surface-soft); border: 1px solid var(--design-line); border-radius: 20px; padding: 6px 12px;
}
.sync-indicator.pending { color: var(--amber); background: var(--amber-bg); border-color: transparent; }
.sync-indicator.synced { color: var(--green); background: var(--green-bg); border-color: transparent; }
.sync-indicator .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.sync-indicator.offline { color: var(--red); background: var(--red-bg); border-color: transparent; }

/* Flat search: type-ahead, not a scroller — Belsize alone has 63 flats. */
.flat-search-wrap { position: relative; margin-bottom: 18px; }
.flat-search-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface);
    border: 1px solid var(--design-line); border-radius: var(--design-radius); box-shadow: var(--design-shadow);
    max-height: 280px; overflow-y: auto; z-index: 10;
}
.flat-search-results button {
    width: 100%; text-align: left; background: none; border: 0; padding: 14px 16px; font-size: 15px;
    min-height: 44px; border-bottom: 1px solid var(--design-line);
}
.flat-search-results button:last-child { border-bottom: 0; }
.flat-search-results button:hover, .flat-search-results button:focus { background: var(--brand-lilac); color: var(--brand-purple); }
.selected-flat-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--brand-lilac); color: var(--brand-purple); border-radius: 20px; padding: 8px 14px 8px 16px; font-weight: 700; font-size: 15px; }
.selected-flat-chip button { background: none; border: 0; color: var(--brand-purple); font-weight: 700; font-size: 16px; min-height: auto; padding: 0 2px; }

.tap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.tap-option {
    position: relative; display: flex; align-items: center; justify-content: center; text-align: center; min-height: 56px;
    border: 1.5px solid var(--design-line); border-radius: var(--design-radius); background: var(--surface);
    font-size: 13px; font-weight: 600; color: var(--ink); padding: 10px 8px;
}
.tap-option.selected { border-color: var(--brand-purple); background: var(--brand-lilac); color: var(--brand-purple); }
.tap-option input { position: absolute; opacity: 0; pointer-events: none; }

.duration-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 12px; }
.duration-grid .tap-option { min-height: 52px; font-size: 15px; }

.entry-row {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 44px;
    background: var(--surface); border: 1px solid var(--design-line); border-radius: var(--design-radius);
    margin-bottom: 10px; text-decoration: none; color: inherit;
}
.entry-row .entry-flat { font-weight: 700; font-size: 15px; color: var(--brand-purple); min-width: 52px; }
.entry-row .entry-body { flex: 1; min-width: 0; }
.entry-row .entry-type { font-size: 13px; font-weight: 600; }
.entry-row .entry-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.entry-row .entry-icon { flex-shrink: 0; width: 20px; height: 20px; color: var(--muted); }
.entry-row.added-by-manager { border-left: 3px solid var(--brand-purple); }

.summary-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.summary-compare .stat { background: var(--surface); border: 1px solid var(--design-line); border-radius: var(--design-radius); padding: 16px; text-align: center; }
.summary-compare .stat .value { font: 700 26px 'Poppins', sans-serif; color: var(--brand-purple); }
.summary-compare .stat .label { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

.date-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.date-nav .button { min-width: 44px; padding: 10px; }
.date-nav .current-date { font-weight: 700; font-size: 14px; flex: 1; text-align: center; }

.big-choice-grid { display: grid; gap: 12px; }
.big-choice {
    display: block; width: 100%; text-align: left; background: var(--surface); border: 1.5px solid var(--design-line);
    border-radius: var(--design-radius); padding: 20px; font-size: 17px; font-weight: 700; color: var(--ink); min-height: 64px;
}
.big-choice:active, .big-choice:hover { border-color: var(--brand-purple); background: var(--brand-lilac); color: var(--brand-purple); }
.big-choice span { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 3px; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; background: var(--page-background); padding: 24px 16px; }
.auth-card {
    width: min(400px, 100%); background: var(--surface); border: 1px solid var(--design-line);
    border-radius: var(--design-radius); box-shadow: var(--design-shadow); padding: 32px 26px; text-align: center;
}
.auth-card .brand-mark { margin: 0 auto 16px; width: 48px; height: 48px; font-size: 17px; }
.auth-card h1 { font-size: 19px; }
.auth-card h2 { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 6px; }
.auth-card form { display: flex; flex-direction: column; text-align: left; margin-top: 22px; }
.auth-card .button { justify-content: center; margin-top: 4px; }
.auth-card .field-link { text-align: center; margin-top: 16px; font-size: 12px; }
.pin-input { letter-spacing: 10px; font-size: 24px; text-align: center; font-weight: 700; }

/* ===================== Reporting suite ===================== */

.page-wrap.wide { max-width: 1400px; }

.tab-row { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; border-bottom: 1px solid var(--design-line); }
.tab-link {
    padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-link:hover { color: var(--brand-purple); }
.tab-link.active { color: var(--brand-purple); border-bottom-color: var(--brand-purple); }

.report-toolbar { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.report-toolbar label { margin-bottom: 0; min-width: 200px; }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.month-grid-weekday { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; padding-bottom: 6px; }
.month-grid-day {
    display: block; min-height: 76px; padding: 8px; background: var(--surface); border: 1.5px solid var(--design-line);
    border-radius: var(--design-radius-small); text-decoration: none; color: var(--ink); font-size: 12px; font-weight: 600;
}
.month-grid-day:hover { border-color: var(--brand-purple); }
.month-grid-day.out-of-month { opacity: .35; }
.month-grid-day.flagged { border-color: var(--amber); background: var(--amber-bg); }
.month-grid-day .day-number { display: block; margin-bottom: 6px; }
.month-grid-day .shift-dots { display: flex; gap: 4px; }
.month-grid-day .shift-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--design-line); }
.month-grid-day .shift-dot.present { background: var(--brand-purple); }
.month-grid-day .shift-dot.flagged { background: var(--amber); }

.chart-legend { display: flex; gap: 16px; margin-bottom: 14px; font-size: 11px; color: var(--muted); }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.swatch-planned { background: var(--brand-lilac-deep); }
.swatch-delivered { background: var(--brand-purple); }

.week-bar-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: flex-end; height: 200px; margin-bottom: 12px; padding: 0 4px; }
.bar-day { display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-group {
    display: flex; align-items: flex-end; gap: 3px; height: 100%; padding: 4px; border-radius: var(--design-radius-small);
    flex: 1; width: 100%; justify-content: center;
}
.bar-group.flagged { background: var(--amber-bg); }
.bar { width: 14px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-planned { background: var(--brand-lilac-deep); }
.bar-delivered { background: var(--brand-purple); }
.bar-day-label { font-size: 10px; color: var(--muted); margin-top: 8px; font-weight: 600; }

.report-row { background: var(--surface); border: 1px solid var(--design-line); border-radius: var(--design-radius); margin-bottom: 10px; overflow: hidden; }
.report-row-summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 14px 16px; font-size: 13px; font-weight: 600;
}
.report-row-summary::-webkit-details-marker { display: none; }
.report-row-summary .row-title { display: flex; align-items: center; gap: 10px; }
.report-row-detail { padding: 4px 16px 16px; border-top: 1px solid var(--design-line); }
