:root {
    --ink: #14221f;
    --ink-soft: #253a35;
    --paper: #f3f1e9;
    --surface: #fffef9;
    --line: #dcded5;
    --muted: #6b7772;
    --accent: #b9e769;
    --accent-dark: #2f675c;
    --danger: #b64037;
    --warning: #d8902f;
    --sidebar: 272px;
    --radius: 18px;
    --shadow: 0 14px 35px rgba(20, 34, 31, .07);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    color: var(--ink);
    background: var(--paper);
    font-family: Inter, Aptos, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); }

.btn {
    --bs-btn-border-radius: 10px;
    font-weight: 700;
}

.btn-primary {
    --bs-btn-color: #13211e;
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--accent-dark);
    --bs-btn-hover-border-color: var(--accent-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-active-border-color: var(--accent-dark);
}

.form-control,
.form-select {
    border: 1px solid #cdd2ca;
    border-radius: 10px;
    min-height: 45px;
    background-color: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent-dark);
    box-shadow: 0 0 0 .2rem rgba(47, 103, 92, .14);
}

.form-label { font-weight: 700; font-size: .9rem; }
.form-text { color: var(--muted); }
.min-w-0 { min-width: 0; }

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    width: var(--sidebar);
    padding: 28px 22px 20px;
    flex-direction: column;
    background:
        radial-gradient(circle at 0 0, rgba(185, 231, 105, .12), transparent 34%),
        var(--ink);
    color: #fff;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 13px 13px 13px 4px;
    background: var(--accent);
    color: var(--ink);
    font-size: 1.35rem;
    font-weight: 900;
}

.brand strong { display: block; font-size: 1.08rem; letter-spacing: .02em; }
.brand small { display: block; color: #aab8b2; font-size: .72rem; }

.side-nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    margin-top: 38px;
    overflow-y: auto;
}

.nav-caption {
    padding: 0 12px 8px;
    color: #83948d;
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.side-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #d8e0dc;
    font-size: .88rem;
    font-weight: 650;
}

.side-nav .nav-link span {
    width: 24px;
    color: #789088;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .65rem;
}

.side-nav .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.side-nav .nav-link.active { color: var(--ink); background: var(--accent); }
.side-nav .nav-link.active span { color: var(--ink-soft); }

.sidebar-user {
    position: relative;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-user-menu { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 0; border: 0; background: none; color: #fff; text-align: left; }
.sidebar-user-menu strong,
.sidebar-user-menu small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-menu strong { font-size: .82rem; }
.sidebar-user-menu small { color: #91a29b; font-size: .7rem; }
.sidebar-user-menu:focus-visible { border-radius: 8px; outline: 2px solid var(--accent); outline-offset: 5px; }
.user-menu-chevron { color: #91a29b; font-weight: 800; letter-spacing: .08em; }
.sidebar-user-dropdown { --bs-dropdown-min-width: 210px; margin-bottom: 12px !important; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 45px rgba(0, 0, 0, .22); }
.sidebar-user-dropdown .dropdown-item { padding: 9px 14px; font-size: .82rem; font-weight: 700; }
.sidebar-user-dropdown form { margin: 0; }
.user-avatar { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #60756d; border-radius: 50%; color: var(--accent); font-weight: 800; }

.content-shell { min-height: 100vh; margin-left: var(--sidebar); }
.main-content { width: min(100%, 1500px); margin: 0 auto; padding: 36px 42px 72px; }

.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.page-heading h1 { margin: 2px 0 0; font-size: clamp(1.75rem, 3vw, 2.7rem); font-weight: 800; letter-spacing: -.045em; }
.page-user-summary { display: flex; align-items: flex-end; flex-direction: column; min-width: 0; padding-bottom: 5px; }
.page-user-summary strong { max-width: 280px; overflow: hidden; font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.page-heading time { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .72rem; }
.eyebrow { display: block; color: var(--accent-dark); font-size: .68rem; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }

.content-card,
.side-card,
.tip-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.content-card { padding: clamp(20px, 3vw, 30px); }
.side-card { padding: 24px; }
.side-card h2, .tip-card h2 { margin: 5px 0 10px; font-size: 1.2rem; font-weight: 800; letter-spacing: -.025em; }
.side-card p, .tip-card p { color: var(--muted); font-size: .9rem; }

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.section-heading h2 { margin: 3px 0 0; font-size: 1.25rem; font-weight: 800; letter-spacing: -.025em; }
.section-heading small { color: var(--muted); }
.required-note { color: var(--muted); font-size: .75rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.metric-card { position: relative; display: flex; align-items: center; justify-content: center; min-height: 154px; padding: 22px; overflow: hidden; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: center; }
.metric-card::after { content: ""; position: absolute; right: -24px; bottom: -34px; width: 95px; height: 95px; border: 16px solid #edf0e8; border-radius: 50%; }
.metric-card.accent { background: var(--ink); border-color: var(--ink); color: #fff; }
.metric-card.accent::after { border-color: rgba(185, 231, 105, .16); }
.metric-card.metric-danger { border-color: #a93730; background: #b64037; color: #fff; }
.metric-card.metric-danger::after { border-color: rgba(255, 255, 255, .13); }
.metric-card.metric-danger > span, .metric-card.metric-danger small { color: #f8d9d6; }
.metric-card.metric-neutral { border-color: #c9cec9; background: #dfe2df; }
.metric-card.metric-neutral::after { border-color: rgba(20, 34, 31, .08); }
.metric-card.metric-warning { border-color: #dfa633; background: #f1c453; }
.metric-card.metric-warning::after { border-color: rgba(92, 59, 5, .1); }
.metric-card.metric-success { border-color: #34795a; background: #3f8c69; color: #fff; }
.metric-card.metric-success::after { border-color: rgba(255, 255, 255, .14); }
.metric-card.metric-info { border-color: #326f9d; background: #3d82b5; color: #fff; }
.metric-card.metric-info::after { border-color: rgba(255, 255, 255, .14); }
.metric-card.metric-success > span, .metric-card.metric-success small,
.metric-card.metric-info > span, .metric-card.metric-info small { color: rgba(255, 255, 255, .8); }
.metric-card.metric-neutral > span, .metric-card.metric-neutral small,
.metric-card.metric-warning > span, .metric-card.metric-warning small { color: #4c5853; }
.metric-card.danger-accent::after { border-color: rgba(182, 64, 55, .1); }
.metric-card > span, .metric-card small { display: block; position: relative; z-index: 1; }
.metric-card > span { color: var(--muted); font-size: .73rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.metric-card.accent > span, .metric-card.accent small { color: #aebdb7; }
.metric-card strong { display: block; position: relative; z-index: 1; margin: 8px 0 2px; font-size: 2.65rem; line-height: 1; letter-spacing: -.06em; }
.metric-card small { font-size: .75rem; }

.dashboard-charts { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .85fr); gap: 15px; }
.chart-card { min-width: 0; }
.chart-heading { margin-bottom: 15px; }
.chart-period { padding: 5px 9px; border-radius: 999px; background: #edf0e9; color: var(--muted); font-size: .66rem; font-weight: 800; white-space: nowrap; }
.chart-legend { display: flex; align-items: center; justify-content: flex-end; gap: 16px; min-height: 22px; margin-bottom: 8px; color: var(--muted); font-size: .68rem; font-weight: 750; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i, .status-chart-legend i { display: inline-block; width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; }
.chart-legend i.received { background: #3f8c69; }
.chart-legend i.withdrawn { background: #3d82b5; }
.weekly-chart { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(4px, 1vw, 11px); min-height: 238px; }
.weekly-column { display: grid; grid-template-rows: 190px auto; min-width: 0; }
.weekly-bars { display: flex; align-items: flex-end; justify-content: center; gap: clamp(2px, .5vw, 7px); height: 190px; padding: 25px 2px 0; border-bottom: 1px solid #dfe3db; background: linear-gradient(to top, rgba(220, 224, 216, .72) 1px, transparent 1px); background-size: 100% 25%; }
.weekly-bar { position: relative; width: min(32%, 24px); height: var(--bar-height); min-height: 3px; border-radius: 7px 7px 2px 2px; background: #3f8c69; box-shadow: 0 5px 14px rgba(63, 140, 105, .18); }
.weekly-bar.withdrawn { background: #3d82b5; box-shadow: 0 5px 14px rgba(61, 130, 181, .18); }
.weekly-bar.is-zero { opacity: .18; box-shadow: none; }
.weekly-bar b { position: absolute; top: -18px; left: 50%; color: var(--ink); font-size: .62rem; line-height: 1; transform: translateX(-50%); }
.weekly-label { padding-top: 9px; text-align: center; }
.weekly-label strong, .weekly-label small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weekly-label strong { font-size: .68rem; }
.weekly-label small { margin-top: 2px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .58rem; }
.status-overview-card { border-color: var(--ink); background: var(--ink); color: #fff; }
.status-overview-card .eyebrow { color: var(--accent); }
.status-overview-card .section-heading h2 { color: #fff; }
.status-chart-wrap { display: grid; grid-template-columns: 145px minmax(0, 1fr); align-items: center; gap: 23px; min-height: 240px; }
.status-donut { position: relative; display: grid; width: 145px; aspect-ratio: 1; border-radius: 50%; place-items: center; background: var(--status-donut); box-shadow: 0 14px 34px rgba(0, 0, 0, .24); }
.status-donut::before { content: ""; position: absolute; inset: 29px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
.status-donut > span { position: relative; z-index: 1; text-align: center; }
.status-donut strong, .status-donut small { display: block; }
.status-donut strong { font-size: 2rem; line-height: 1; letter-spacing: -.06em; }
.status-donut small { margin-top: 4px; color: #9eada7; font-size: .62rem; font-weight: 750; text-transform: uppercase; }
.status-chart-legend { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.status-chart-legend li { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.status-chart-legend li:last-child { border-bottom: 0; }
.status-chart-legend i { background: var(--swatch-color); }
.status-chart-legend span { overflow: hidden; color: #bdc8c4; font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.status-chart-legend strong { font-size: .76rem; }

.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.quick-action { display: flex; align-items: center; gap: 18px; min-height: 105px; padding: 20px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform .18s ease, border-color .18s ease; }
.quick-action:hover { transform: translateY(-2px); border-color: #a9b5ae; color: var(--ink); }
.quick-action.primary-action { background: var(--accent); border-color: var(--accent); }
.action-symbol { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid rgba(20, 34, 31, .25); border-radius: 50%; font-size: 1.6rem; }
.quick-action strong, .quick-action small { display: block; }
.quick-action strong { font-size: 1rem; }
.quick-action small { margin-top: 2px; color: #5f6e68; font-size: .75rem; }

.app-table { margin: 0; font-size: .86rem; }
.app-table > :not(caption) > * > * { padding: 14px 12px; border-bottom-color: #e8e9e3; background: transparent; }
.app-table thead th { color: #7a857f; font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.app-table tbody tr:last-child td { border-bottom: 0; }
.app-table td > strong, .app-table td > small { display: block; }
.app-table td > small { margin-top: 2px; color: var(--muted); font-size: .72rem; }
.recipient-link { color: inherit; text-decoration: none; }
.recipient-link:hover { color: var(--accent-dark); text-decoration: underline; }
.table-link { font-weight: 750; text-decoration: none; white-space: nowrap; }
.table-link:hover { text-decoration: underline; }
.action-badge { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 10px; border-radius: 999px; background: #3f8c69; color: #fff; font-size: .7rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.action-badge:hover, .action-badge:focus { background: #34795a; color: #fff; }

.status-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .025em;
    white-space: nowrap;
}
.status-pill.success { color: #17604e; background: #dcefe6; }
.status-pill.warning { color: #7d500d; background: #f7e7bf; }
.status-pill.info { color: #1c5870; background: #dcecf2; }
.status-pill.danger { color: #8a2925; background: #f5ddda; }
.status-pill.secondary { color: #57625e; background: #e9ebe7; }
.count-badge { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 10px; background: var(--ink); color: #fff; font-size: .78rem; font-weight: 800; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.filter-bar { display: flex; align-items: center; gap: 10px; flex: 1; }
.filter-bar > .form-control { max-width: 390px; }
.filter-bar > .form-select { max-width: 220px; }

.empty-state { padding: 58px 20px; color: var(--muted); text-align: center; }
.empty-state.compact { padding: 28px 16px; }
.empty-state h1 { color: var(--ink); font-size: 5rem; font-weight: 900; letter-spacing: -.08em; }
.empty-state h3 { color: var(--ink); font-size: 1.1rem; font-weight: 800; }
.empty-state p { margin: 0; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(250px, .7fr); align-items: start; gap: 22px; }
.form-layout.compact-sidebar { grid-template-columns: minmax(0, 1.8fr) minmax(280px, .75fr); }
.form-card { padding: clamp(22px, 4vw, 38px); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); }
.tip-card { position: sticky; top: 25px; padding: 28px; background: var(--ink); color: #fff; }
.tip-card p { color: #afbeb8; }
.tip-card hr { margin: 26px 0; border-color: rgba(255, 255, 255, .2); }
.tip-number { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .72rem; font-weight: 800; }
.ai-status { display: inline-block; margin: 10px 0 0 8px; color: var(--muted); font-size: .8rem; }

.detail-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding: 4px 4px 0; }
.detail-header h2 { margin: 10px 0 2px; font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 850; letter-spacing: -.04em; }
.detail-header p { margin: 0; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(270px, .68fr); align-items: start; gap: 22px; }
.record-number { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.1rem; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.detail-list > div { padding: 14px 0; border-bottom: 1px solid #e9eae4; }
.detail-list > div:nth-child(odd) { padding-right: 20px; }
.detail-list dt { color: var(--muted); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }
.detail-list dd { margin: 4px 0 0; font-size: .92rem; font-weight: 700; }
.note-box { margin-top: 20px; padding: 16px; border-left: 3px solid var(--accent-dark); background: #f2f5ef; }
.note-box strong { font-size: .8rem; }
.note-box p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; }

.evidence-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.evidence-item { position: relative; min-height: 150px; overflow: hidden; border-radius: 13px; background: #e8ebe5; color: #fff; cursor: zoom-in; text-decoration: none; }
.evidence-item img { width: 100%; height: 180px; object-fit: cover; transition: transform .2s ease; }
.evidence-item:hover img { transform: scale(1.03); }
.evidence-item span { position: absolute; inset: auto 8px 8px; padding: 6px 9px; border-radius: 8px; background: rgba(20, 34, 31, .84); font-size: .7rem; font-weight: 750; }
.evidence-preview-modal .modal-content { overflow: hidden; border: 0; border-radius: 18px; }
.evidence-preview-modal .modal-body { display: grid; min-height: 320px; padding: 18px; place-items: center; background: #101614; }
.evidence-preview-modal .modal-body img { display: block; width: auto; max-width: 100%; height: auto; max-height: calc(100vh - 210px); object-fit: contain; }
.success-card { border-left: 4px solid var(--accent-dark); }
.attention-card { border-color: #e7c06c; background: #fffaf0; }
.danger-zone { box-shadow: none; }
.danger-zone summary { color: var(--danger); cursor: pointer; font-size: .8rem; font-weight: 800; }

.pin-reveal { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 25px 30px; border-radius: var(--radius); background: var(--ink); color: #fff; box-shadow: var(--shadow); }
.pin-reveal .eyebrow { color: var(--accent); }
.pin-reveal p { margin: 6px 0 12px; color: #aebdb7; font-size: .82rem; }
.pin-code { display: block; margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: .18em; }
.qr-box { width: 180px; height: 180px; flex: 0 0 180px; padding: 8px; border-radius: 10px; background: #fff; }
.qr-box img, .qr-box canvas { max-width: 100%; height: auto !important; }

.proof-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.proof-options label { position: relative; cursor: pointer; }
.proof-options input { position: absolute; opacity: 0; pointer-events: none; }
.proof-options label > span { display: block; min-height: 80px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.proof-options strong, .proof-options small { display: block; }
.proof-options small { margin-top: 2px; color: var(--muted); font-size: .7rem; }
.proof-options input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); background: #f5f9ed; }
.proof-panel { padding: 20px; border-radius: 14px; background: #f0f2ec; }
.pin-input { max-width: 260px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.5rem; font-weight: 800; letter-spacing: .2em; }
.camera-reader { position: relative; margin-top: 12px; overflow: hidden; border-radius: 12px; background: #000; }
.camera-reader video { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.camera-reader button { position: absolute; top: 10px; right: 10px; }
.package-summary-card dl { margin: 25px 0; }
.package-summary-card dl div { padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.package-summary-card dt { color: #8fa199; font-size: .68rem; text-transform: uppercase; }
.package-summary-card dd { margin: 3px 0 0; font-size: .88rem; }
.warning-note { padding: 13px; border-radius: 10px; background: rgba(185, 231, 105, .11); color: #cfdbd6; font-size: .76rem; }

.occurrence-row, .message-item { padding: 18px; border: 1px solid #e2e5dd; border-radius: 13px; background: #fff; }
.occurrence-main, .occurrence-row footer, .message-item > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.occurrence-main { justify-content: flex-start; }
.occurrence-main strong, .occurrence-main small { display: block; }
.occurrence-main small, .occurrence-row footer, .message-item small, .message-item time { color: var(--muted); font-size: .72rem; }
.occurrence-row p, .message-item p { margin: 14px 0; color: #46544f; font-size: .87rem; }
.occurrence-row footer { flex-wrap: wrap; }
.occurrence-row footer form { margin-left: auto; }
.message-item time { font-weight: 400; }
.message-item > a { font-size: .78rem; font-weight: 750; }
.message-item.unread { border-left: 4px solid var(--accent-dark); background: #fbfff4; }
.communication-grid { display: grid; grid-template-columns: minmax(285px, .72fr) minmax(0, 1.7fr); align-items: start; gap: 22px; }
.compose-card { position: sticky; top: 25px; }
.nav-underline { gap: 20px; }
.nav-underline .nav-link { color: var(--muted); font-weight: 750; }
.nav-underline .nav-link.active { color: var(--ink); border-color: var(--accent-dark); }
.nav-underline .nav-link span { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 3px; border-radius: 7px; background: #e8ebe4; font-size: .65rem; }

.admin-grid { display: grid; grid-template-columns: minmax(250px, .55fr) minmax(0, 1.7fr); align-items: start; gap: 22px; }
.admin-grid.wide-form { grid-template-columns: minmax(290px, .68fr) minmax(0, 1.7fr); }
.sticky-form { position: sticky; top: 25px; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.row-actions form { display: inline-flex; }

.report-toolbar .filter-bar { flex: 0 1 auto; }
.report-toolbar .filter-bar > div { min-width: 160px; }
.bar-chart { display: grid; gap: 9px; max-height: 370px; overflow-y: auto; }
.bar-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 34px; align-items: center; gap: 10px; }
.bar-row time { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .68rem; }
.bar-track { height: 13px; overflow: hidden; border-radius: 999px; background: #ebede7; }
.bar-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-dark), var(--accent)); }
.bar-row strong { font-size: .75rem; }
.wait-time { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; font-weight: 750; }
.wait-time.late { display: inline-block; padding: 4px 7px; border-radius: 6px; background: #f5ddda; color: var(--danger); }
.report-tabs .nav { overflow-x: auto; flex-wrap: nowrap; }
.report-tabs .nav-link { white-space: nowrap; }
.audit-table code { color: #344f48; font-size: .7rem; }
.audit-action { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .68rem; font-weight: 800; }
.json-data { display: block; max-width: 260px; margin-top: 7px; white-space: pre-wrap; word-break: break-word; }
.pagination-wrap { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; color: var(--muted); font-size: .8rem; }

.mobile-header { position: sticky; top: 0; z-index: 1025; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line); background: rgba(255, 254, 249, .94); backdrop-filter: blur(12px); }
.mobile-header .brand { color: var(--ink); }
.mobile-header .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 1rem; }
.mobile-user-name { min-width: 0; margin-left: auto; overflow: hidden; color: var(--muted); font-size: .72rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.mobile-header .btn { flex: 0 0 auto; }
.mobile-menu { display: flex; flex-direction: column; }
.mobile-menu > a { padding: 13px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 750; text-decoration: none; }
.mobile-bottom-nav { position: fixed; inset: auto 10px 10px; z-index: 1020; display: flex; align-items: center; justify-content: space-around; min-height: 62px; padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 18px; background: rgba(20, 34, 31, .96); box-shadow: 0 12px 35px rgba(0, 0, 0, .25); }
.mobile-bottom-nav a { position: relative; display: inline-flex; align-items: center; gap: 4px; color: #aebbb6; font-size: .66rem; font-weight: 750; text-decoration: none; }
.mobile-bottom-nav a.active { color: var(--accent); }
.mobile-bottom-nav .quick-add { display: grid; place-items: center; width: 45px; height: 45px; margin-top: -25px; border: 4px solid var(--paper); border-radius: 50%; background: var(--accent); color: var(--ink); font-size: 1.6rem; }
.mobile-unread-badge { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border: 2px solid var(--ink); border-radius: 999px; background: #dc3545; color: #fff; font-size: .58rem; font-weight: 850; line-height: 1; }

.app-alert-modal .modal-dialog { max-width: 460px; }
.app-alert-modal .modal-content { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 26px 80px rgba(12, 27, 23, .25); }
.app-alert-modal .modal-header { align-items: center; gap: 14px; padding: 26px 28px 12px; border: 0; }
.app-alert-modal .modal-title { color: var(--ink); font-size: 1.3rem; font-weight: 850; letter-spacing: -.025em; }
.app-alert-modal .modal-body { padding: 4px 28px 12px; }
.app-alert-modal .modal-body p { margin: 0; color: var(--muted); line-height: 1.55; white-space: pre-line; }
.app-alert-modal .modal-footer { padding: 12px 28px 26px; border: 0; }
.app-alert-symbol { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; background: #dcecf2; color: #1c5870; font-size: 1.15rem; font-weight: 900; }
.app-alert-modal[data-alert-tone="success"] .app-alert-symbol { background: #dcefe6; color: #17604e; }
.app-alert-modal[data-alert-tone="warning"] .app-alert-symbol { background: #f7e7bf; color: #7d500d; }
.app-alert-modal[data-alert-tone="danger"] .app-alert-symbol { background: #f5ddda; color: #8a2925; }
.processing-modal .modal-dialog { max-width: 520px; }
.processing-modal .modal-content { overflow: hidden; border: 0; border-radius: 22px; background: var(--surface); box-shadow: 0 28px 90px rgba(12, 27, 23, .3); }
.processing-modal .modal-body { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 20px; padding: 31px; }
.processing-indicator { display: grid; width: 64px; height: 64px; border-radius: 19px 19px 19px 7px; background: var(--ink); color: var(--accent); place-items: center; }
.processing-indicator .spinner-border { width: 31px; height: 31px; border-width: 3px; }
.processing-copy h2 { margin: 3px 0 6px; color: var(--ink); font-size: 1.25rem; font-weight: 850; letter-spacing: -.025em; }
.processing-copy p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.processing-copy small { display: block; margin-top: 9px; color: #87918d; font-size: .68rem; font-weight: 700; }

.login-body { display: grid; place-items: center; padding: 24px; background: var(--ink); }
.login-shell { display: grid; grid-template-columns: minmax(360px, .9fr) minmax(440px, 1.1fr); width: min(1040px, 100%); min-height: 640px; overflow: hidden; border-radius: 26px; background: var(--surface); box-shadow: 0 35px 90px rgba(0, 0, 0, .3); }
.login-card { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 7vw, 74px); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 65px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand small { color: var(--muted); font-size: .72rem; }
.login-copy { margin-bottom: 28px; }
.login-copy h1 { margin: 7px 0; font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 850; letter-spacing: -.055em; }
.login-copy p { color: var(--muted); }
.pwa-install-button { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; margin-top: 14px; }
.pwa-install-symbol { display: inline-grid; width: 22px; height: 22px; border-radius: 7px; place-items: center; background: var(--ink); color: #fff; font-size: 1rem; line-height: 1; }
.pwa-install-button + .login-footnote { margin-top: 20px; }
.login-footnote { margin: 32px 0 0; color: var(--muted); font-size: .72rem; text-align: center; }
.login-panel { position: relative; flex-direction: column; justify-content: space-between; padding: 60px; overflow: hidden; background: var(--accent); }
.login-panel::before { content: ""; position: absolute; top: -170px; right: -170px; width: 450px; height: 450px; border: 72px solid rgba(20, 34, 31, .08); border-radius: 50%; }
.login-panel > div { position: relative; z-index: 1; }
.login-panel h2 { max-width: 410px; margin: 14px 0; font-size: clamp(2.2rem, 5vw, 4.2rem); font-weight: 900; line-height: .97; letter-spacing: -.07em; }
.login-panel p { max-width: 360px; color: #40564f; }
.panel-number { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 800; }
.panel-status { font-size: .75rem; font-weight: 750; }
.panel-status span { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 5px rgba(20, 34, 31, .12); }

@media (min-width: 992px) {
    .page-heading { position: sticky; top: 0; z-index: 1020; margin-inline: -14px; padding: 18px 14px 16px; border-bottom: 1px solid rgba(220, 222, 213, .88); background: rgba(243, 241, 233, .94); backdrop-filter: blur(14px); }
}

@media (max-width: 1199.98px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-layout,
    .form-layout.compact-sidebar,
    .detail-grid { grid-template-columns: 1fr; }
    .resident-detail .detail-main,
    .resident-detail .detail-sidebar { display: contents; }
    .resident-detail .evidence-card { order: -3; }
    .resident-detail .withdrawal-access-card { order: -2; }
    .resident-detail .identification-card { order: -1; }
    .tip-card, .sticky-form { position: static; }
    .form-layout.compact-sidebar .side-card { max-width: none; }
}

@media (max-width: 991.98px) {
    body.qr-camera-open { overflow: hidden; }
    .camera-reader.is-camera-active { position: fixed; inset: 0; z-index: 1080; display: grid; margin: 0; border-radius: 0; place-items: center; background: #000; }
    .camera-reader.is-camera-active video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
    .camera-reader.is-camera-active button { top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); z-index: 1; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); }
    .content-shell { margin-left: 0; }
    .main-content { padding: 25px 20px 105px; }
    .communication-grid,
    .admin-grid,
    .admin-grid.wide-form { grid-template-columns: 1fr; }
    .dashboard-charts { grid-template-columns: 1fr; }
    .page-user-summary { display: none; }
    .compose-card { position: static; }
    .login-shell { display: block; width: min(520px, 100%); min-height: auto; }
    .login-card { min-height: 620px; }
}

@media (max-width: 767.98px) {
    .main-content { padding-inline: 14px; }
    .page-heading { margin-bottom: 20px; }
    .page-heading time { display: none; }
    .quick-actions,
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
    .quick-action { min-height: 88px; padding: 14px; }
    .action-symbol { width: 40px; height: 40px; flex-basis: 40px; }
    .metric-card { min-height: 128px; padding: 17px; }
    .metric-card strong { font-size: 2.1rem; }
    .resident-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 7px; }
    .resident-metrics .metric-card { min-height: 104px; padding: 12px 5px; border-radius: 14px; }
    .resident-metrics .metric-card::after { right: -28px; bottom: -38px; width: 72px; height: 72px; border-width: 12px; }
    .resident-metrics .metric-card > span { font-size: .58rem; letter-spacing: .035em; }
    .resident-metrics .metric-card strong { margin: 7px 0 0; font-size: 1.9rem; }
    .resident-metrics .metric-card small { display: none; }
    .weekly-column { grid-template-rows: 160px auto; }
    .weekly-bars { height: 160px; }
    .toolbar, .filter-bar { align-items: stretch; flex-direction: column; }
    .toolbar > *, .filter-bar > *, .filter-bar > .form-control, .filter-bar > .form-select { width: 100%; max-width: none; }
    .section-heading { align-items: flex-start; }
    .detail-header { align-items: stretch; flex-direction: column; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list > div:nth-child(odd) { padding-right: 0; }
    .evidence-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pin-reveal { align-items: center; flex-direction: column; text-align: center; }
    .proof-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-actions { align-items: stretch; flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .row-actions { justify-content: flex-start; }
    .report-toolbar .filter-bar > div { min-width: 0; }
    .login-body { padding: 0; background: var(--surface); }
    .login-shell { width: 100%; min-height: 100vh; border-radius: 0; box-shadow: none; }
    .login-card { min-height: 100vh; padding: 34px 24px; }
    .login-brand { margin-bottom: 45px; }
}

@media (max-width: 420px) {
    .quick-action { align-items: flex-start; flex-direction: column; gap: 9px; padding: 13px; }
    .metric-card { min-height: 116px; }
    .chart-period { display: none; }
    .chart-legend { justify-content: flex-start; }
    .weekly-chart { gap: 3px; }
    .weekly-bar b { font-size: .55rem; }
    .status-chart-wrap { grid-template-columns: 1fr; gap: 16px; }
    .status-donut { margin-inline: auto; }
    .evidence-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
