/* ---------------------------------------------------------------
   Tokens
--------------------------------------------------------------- */
:root {
    --ink: #16221E;
    --ink-2: #1E2C27;
    --ink-line: rgba(255, 255, 255, 0.09);
    --ink-text: #F4F2EC;
    --ink-text-muted: rgba(244, 242, 236, 0.56);
    --ink-text-faint: rgba(244, 242, 236, 0.38);

    --paper: #FAF9F5;
    --surface: #FFFFFF;
    --line: #E7E3D8;
    --line-strong: #D9D4C5;

    --text: #1E241F;
    --text-muted: #6E756E;
    --text-faint: #98988C;

    --brass: #A47A2E;
    --brass-strong: #8A6524;
    --brass-tint: #F1E4C8;
    --brass-tint-line: #E3D0A0;

    --brick: #A0432C;
    --brick-strong: #7A2E1C;
    --brick-tint: #F7E4DE;
    --brick-tint-line: #E7C3B6;

    --sage: #4C7A5D;
    --sage-strong: #2F5B40;
    --sage-tint: #E1EEE3;
    --sage-tint-line: #C3DFC9;

    --dusk: #3F5673;
    --dusk-tint: #E7EDF4;

    --shadow-sm: 0 1px 2px rgba(20, 25, 20, 0.06);
    --shadow-md: 0 8px 24px rgba(20, 25, 20, 0.08);
    --shadow-lg: 0 24px 56px rgba(15, 20, 15, 0.22);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------------------------------------------------------------
   Base
--------------------------------------------------------------- */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

[hidden] {
    display: none !important;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}

p {
    margin: 0 0 12px;
    color: var(--text-muted);
}

:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

.text-muted {
    color: var(--text-muted);
    font-size: 13px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.nowrap {
    white-space: nowrap;
}

.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
   Login / standalone screens
--------------------------------------------------------------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(900px 560px at 50% -8%, #24352E 0%, transparent 60%),
        var(--ink);
}

.login-card {
    background: var(--surface);
    padding: 40px 38px 36px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 380px;
}

.login-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(155deg, var(--brass), var(--brass-strong));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 600;
    font-size: 19px;
    color: var(--ink);
    margin-bottom: 18px;
}

.login-eyebrow {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--brass-strong);
    margin-bottom: 10px;
}

.login-card h1 {
    font-style: italic;
    font-size: 27px;
    margin-bottom: 6px;
}

.login-card p.subtitle {
    color: var(--text-muted);
    font-size: 13.5px;
    margin-bottom: 28px;
}

/* ---------------------------------------------------------------
   Form fields
--------------------------------------------------------------- */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
.field input[type="date"],
.field input[type="number"],
.field input[type="url"],
.field input[type="file"],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--text);
}

.field textarea {
    resize: vertical;
    line-height: 1.5;
}

.field .hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(164, 122, 46, 0.15);
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    font-size: 14px;
}

.checkbox-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brass);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--ink);
    color: var(--paper);
    border: 1px solid var(--ink);
    padding: 10px 18px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    text-align: center;
    transition: background .15s ease;
}

.btn:hover {
    background: var(--ink-2);
}

.btn-auto {
    width: auto;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line-strong);
}

.btn-secondary:hover {
    background: var(--paper);
}

.btn-danger {
    background: var(--brick);
    border-color: var(--brick);
}

.btn-danger:hover {
    background: var(--brick-strong);
}

.error {
    background: var(--brick-tint);
    color: var(--brick-strong);
    border: 1px solid var(--brick-tint-line);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.success {
    background: var(--sage-tint);
    color: var(--sage-strong);
    border: 1px solid var(--sage-tint-line);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-actions .btn {
    width: auto;
}

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

.sidebar {
    width: 258px;
    flex-shrink: 0;
    background: var(--ink);
    color: var(--ink-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 26px 22px 22px;
}

.sidebar-brand .mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(155deg, var(--brass), var(--brass-strong));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 600;
    color: var(--ink);
    font-size: 17px;
    flex-shrink: 0;
}

.sidebar-brand .mark-logo {
    background: var(--surface);
    object-fit: cover;
}

.sidebar-brand .word {
    font-family: var(--font-display);
    font-size: 16.5px;
    font-weight: 600;
    color: var(--ink-text);
    line-height: 1.25;
}

.sidebar-brand .word small {
    display: block;
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-text-faint);
    margin-top: 2px;
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-text-muted);
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.sidebar-link:hover {
    background: var(--ink-2);
    color: var(--ink-text);
}

.sidebar-link.active {
    background: rgba(164, 122, 46, 0.18);
    color: #EFD9A8;
}

.sidebar-footer {
    border-top: 1px solid var(--ink-line);
    padding: 12px;
    position: relative;
}

.avatar-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ink-text);
    text-align: left;
}

.avatar-btn:hover {
    background: var(--ink-2);
}

.avatar-btn img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--ink-line);
    flex-shrink: 0;
}

.avatar-btn .who {
    min-width: 0;
    flex: 1;
}

.avatar-btn .who .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.avatar-btn .who .email {
    font-size: 10.5px;
    color: var(--ink-text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
    margin-top: 1px;
}

.avatar-dropdown {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% + 8px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: none;
    z-index: 30;
}

.avatar-dropdown.open {
    display: block;
}

.avatar-dropdown a {
    display: block;
    padding: 11px 15px;
    font-size: 13.5px;
    text-decoration: none;
    color: var(--text);
}

.avatar-dropdown a:hover {
    background: var(--paper);
}

.avatar-dropdown a.logout {
    color: var(--brick);
    border-top: 1px solid var(--line);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 40px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    flex-wrap: wrap;
}

.page-header .eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.page-header h1 {
    font-size: 21px;
}

.content {
    padding: 32px 40px 56px;
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.content.wide {
    max-width: none;
    margin: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.card h2 {
    font-size: 16.5px;
    margin-bottom: 6px;
}

.directory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.directory-header h2 {
    margin-bottom: 0;
}

/* ---------------------------------------------------------------
   KPI ledger
--------------------------------------------------------------- */
.kpi-row {
    display: flex;
    flex-wrap: wrap;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    gap: 1px;
    margin-bottom: 22px;
}

.kpi-card {
    flex: 1;
    min-width: 180px;
    background: var(--surface);
    padding: 22px 24px 24px;
}

.kpi-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 11px;
    margin-bottom: 12px;
    border-bottom: 1.5px solid var(--brass);
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 600;
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.kpi-sublist {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ---------------------------------------------------------------
   Tags
--------------------------------------------------------------- */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 5px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.tag-elder {
    background: var(--brass-tint);
    color: var(--brass-strong);
}

.tag-deacon {
    background: var(--sage-tint);
    color: var(--sage-strong);
}

.tag-staff {
    background: var(--dusk-tint);
    color: var(--dusk);
}

.tag-member {
    background: var(--dusk-tint);
    color: var(--dusk);
}

.tag-head {
    background: var(--paper);
    color: var(--text-muted);
    border: 1px solid var(--line-strong);
}

.tag-pdf {
    background: var(--brick-tint);
    color: var(--brick-strong);
}

.tag-epub {
    background: var(--sage-tint);
    color: var(--sage-strong);
}

/* ---------------------------------------------------------------
   Data table
--------------------------------------------------------------- */
.table-scroll {
    overflow-x: auto;
    position: relative;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data-table th {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1.5px solid var(--line-strong);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

table.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--text);
}

table.data-table tbody tr:hover {
    background: var(--paper);
}

table.data-table tr:last-child td {
    border-bottom: none;
}

.edit-link {
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brass-strong);
    border: 1px solid var(--brass-tint-line);
    border-radius: 6px;
    text-decoration: none;
    background: var(--brass-tint);
}

.edit-link:hover {
    background: var(--brass);
    color: #fff;
    border-color: var(--brass);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: 6px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    vertical-align: middle;
    color: var(--text-muted);
}

.icon-btn:hover {
    background: var(--brick-tint);
    border-color: var(--brick-tint-line);
    color: var(--brick);
}

.icon-btn svg {
    width: 15px;
    height: 15px;
}

/* ---------------------------------------------------------------
   List controls / pagination
--------------------------------------------------------------- */
.list-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 9px 13px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--text);
}

.search-input:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(164, 122, 46, 0.15);
}

.per-page-select {
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--font-mono);
    background: var(--surface);
    color: var(--text);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.result-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-info {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.page-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
}

.page-btn:hover {
    border-color: var(--brass);
    color: var(--brass-strong);
}

.page-btn.disabled {
    color: var(--text-faint);
    pointer-events: none;
    background: var(--paper);
}

/* ---------------------------------------------------------------
   Dashboard
--------------------------------------------------------------- */
.verse-card {
    background: var(--ink);
    border-color: var(--ink);
    text-align: center;
    padding: 30px 32px;
}

.verse-text {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 18px;
    line-height: 1.5;
    color: var(--ink-text);
    max-width: 640px;
    margin: 0 auto 10px;
}

.verse-ref {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brass-tint);
    margin: 0;
}

.kpi-link {
    text-decoration: none;
    color: inherit;
    transition: background .15s ease;
}

.kpi-link:hover {
    background: var(--paper);
}

.dash-list {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
}

.dash-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.dash-list-item:first-child {
    border-top: none;
    padding-top: 0;
}

.dash-list-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-list-title:hover {
    color: var(--brass-strong);
    text-decoration: underline;
}

.dash-book-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 16px;
    margin-top: 14px;
}

.dash-book {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text);
}

.dash-book-cover {
    width: 100%;
    height: 150px;
    margin-bottom: 8px;
}

.dash-book-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.dash-book:hover .dash-book-title {
    color: var(--brass-strong);
}

.dash-book-authors {
    font-size: 11.5px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

/* ---------------------------------------------------------------
   Households
--------------------------------------------------------------- */
.household-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.household-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    background: var(--surface);
}

.household-head-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2px;
}

.household-monogram {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--brass-tint);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
}

.household-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
}

.household-count {
    display: block;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 2px;
}

.household-members {
    list-style: none;
    margin: 14px 0 0;
    padding: 12px 0 0;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.household-members li {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    flex-wrap: wrap;
}

.household-members a {
    text-decoration: none;
    color: var(--text);
}

.household-members a:hover {
    color: var(--brass-strong);
}

/* ---------------------------------------------------------------
   Students & teachers
--------------------------------------------------------------- */
.person-photo {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--line);
    background: var(--paper);
}

.person-name {
    font-weight: 600;
    min-width: 160px;
}

.person-email {
    font-size: 12.5px;
    color: var(--text-muted);
}

.icon-btn-placeholder {
    display: inline-block;
    width: 28px;
    margin-left: 6px;
    vertical-align: middle;
}

.form-section-title {
    font-size: 15px;
    margin: 26px 0 14px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.photo-field {
    flex: 1;
    min-width: 220px;
    margin-bottom: 0;
}

.field label .optional {
    font-weight: 400;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------
   Books
--------------------------------------------------------------- */
.empty-state {
    margin: 8px 0 0;
    padding: 28px 0 12px;
    text-align: center;
}

.empty-state a {
    color: var(--brass-strong);
}

table.data-table td.cover-cell {
    width: 1%;
    padding-right: 0;
}

.book-cover,
.book-cover-blank {
    display: block;
    width: 36px;
    height: 54px;
    border-radius: 3px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: var(--paper);
}

.book-title {
    font-weight: 600;
    min-width: 180px;
}

.book-subtitle {
    font-size: 12.5px;
    color: var(--text-muted);
}

.row-actions {
    white-space: nowrap;
    text-align: right;
}

.row-actions .edit-link + .edit-link {
    margin-left: 4px;
}

.current-file {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text);
    font-size: 13.5px;
    margin-bottom: 18px;
}

.current-file-name {
    overflow-wrap: anywhere;
}

.current-file .mono {
    font-size: 12px;
    color: var(--text-muted);
}

.current-file a {
    color: var(--brass-strong);
}

.lookup-controls {
    margin-bottom: 10px;
}

.lookup-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
}

.lookup-results:not(:empty) {
    margin-top: 14px;
}

.lookup-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-family: var(--font-body);
    text-align: left;
    cursor: pointer;
    color: var(--text);
}

.lookup-result:hover {
    border-color: var(--brass-tint-line);
    background: var(--paper);
}

.lookup-result.selected {
    border-color: var(--brass);
    background: var(--brass-tint);
}

.lookup-result img,
.lookup-result .book-cover-blank {
    width: 32px;
    height: 48px;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.lookup-result-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.lookup-result-text strong {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
}

.lookup-result-text span {
    font-size: 12px;
    color: var(--text-muted);
}

.book-details {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 24px;
    margin-top: 16px;
}

.book-details-cover img,
.book-details-cover .book-cover-blank {
    width: 150px;
    height: 225px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    object-fit: cover;
    box-shadow: var(--shadow-md);
}

.book-details-cover .book-cover-blank {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-faint);
    box-shadow: none;
}

.book-details-fields {
    min-width: 0;
}

/* ---------------------------------------------------------------
   Assignments
--------------------------------------------------------------- */
.tag-today {
    background: var(--brass-tint);
    color: var(--brass-strong);
}

.tag-soon {
    background: var(--sage-tint);
    color: var(--sage-strong);
}

.tag-later,
.tag-link {
    background: var(--dusk-tint);
    color: var(--dusk);
}

.tag-past {
    background: var(--paper);
    color: var(--text-muted);
    border: 1px solid var(--line-strong);
}

.tag-book {
    background: var(--brass-tint);
    color: var(--brass-strong);
}

td .tag {
    margin-left: 6px;
}

.row-title-link {
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
}

.row-title-link:hover {
    color: var(--brass-strong);
    text-decoration: underline;
}

.row-subtext {
    font-size: 12.5px;
    color: var(--text-muted);
    max-width: 420px;
    min-width: 200px;
}

.assignment-description {
    color: var(--text);
    white-space: pre-line;
    overflow-wrap: anywhere;
    margin: 10px 0 0;
}

.eyebrow-link {
    text-decoration: none;
}

.eyebrow-link:hover {
    color: var(--brass-strong);
}

.page-header .form-actions .btn {
    width: auto;
}

.kpi-date {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
}

.avatar-stack {
    display: inline-flex;
    align-items: center;
    padding-left: 8px;
}

.avatar-stack img,
.avatar-more {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--surface);
    margin-left: -8px;
    object-fit: cover;
    background: var(--paper);
}

.avatar-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    background: var(--line);
}

.student-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    padding: 2px;
}

.picker-item,
.student-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    min-width: 0;
}

.picker-item {
    cursor: pointer;
}

.picker-item:hover {
    background: var(--paper);
}

.picker-item:has(input:checked) {
    border-color: var(--brass);
    background: var(--brass-tint);
}

.picker-item input {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--brass);
}

.picker-item .person-photo,
.student-chip .person-photo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.picker-text,
.resource-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.picker-text strong,
.resource-text strong {
    font-size: 13.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-text span,
.resource-text span {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-empty {
    grid-column: 1 / -1;
    margin: 8px 0;
}

.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.resource-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.resource-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--paper);
}

.resource-row .tag {
    width: 46px;
    justify-content: center;
    flex-shrink: 0;
}

.resource-row .icon-btn {
    margin-left: 0;
    flex-shrink: 0;
}

.resource-input {
    flex: 1;
    min-width: 0;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--text);
}

.resource-input:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgba(164, 122, 46, 0.15);
}

.resource-label {
    flex: 0 1 32%;
}

.resource-actions {
    flex-wrap: wrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.resource-items {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.resource-item:first-child {
    border-top: none;
    padding-top: 0;
}

.resource-item .resource-text {
    flex: 1;
}

.resource-link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--dusk-tint);
    color: var(--dusk);
}

.resource-link-icon svg {
    width: 16px;
    height: 16px;
}

.resource-url {
    font-family: var(--font-mono);
    font-size: 11.5px !important;
}

/* ---------------------------------------------------------------
   Settings
--------------------------------------------------------------- */
.settings-avatar-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.settings-avatar-preview img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--line);
}

/* ---------------------------------------------------------------
   Modal
--------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 22, 18, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-size: 17px;
    margin-bottom: 16px;
}

.modal p {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 20px;
}

/* ---------------------------------------------------------------
   Mobile top bar + hamburger menu
--------------------------------------------------------------- */
.mobile-topbar {
    display: none;
}

.mobile-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-topbar-brand .mark {
    width: 30px;
    height: 30px;
    font-size: 15px;
}

.mobile-topbar-brand .word {
    font-family: var(--font-display);
    font-size: 15.5px;
    font-weight: 600;
    color: var(--ink-text);
    max-width: 45vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--ink-text);
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: var(--ink-2);
}

.mobile-menu-btn svg {
    width: 22px;
    height: 22px;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--ink);
    z-index: 200;
    flex-direction: column;
}

.mobile-menu-overlay.open {
    display: flex;
}

.mobile-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 22px 28px;
    overflow-y: auto;
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 22px;
}

.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-link {
    display: block;
    padding: 14px 12px;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 500;
    color: var(--ink-text-muted);
    text-decoration: none;
}

.mobile-menu-link:hover {
    background: var(--ink-2);
    color: var(--ink-text);
}

.mobile-menu-link.active {
    background: rgba(164, 122, 46, 0.18);
    color: #EFD9A8;
}

.mobile-menu-link.logout {
    color: #E3A08F;
}

.mobile-menu-account {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--ink-line);
}

.mobile-menu-who {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 16px;
}

.mobile-menu-who img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--ink-line);
    flex-shrink: 0;
}

.mobile-menu-who .name {
    display: block;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink-text);
}

.mobile-menu-who .email {
    display: block;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--ink-text-faint);
    margin-top: 2px;
}

body.menu-open {
    overflow: hidden;
}

/* ---------------------------------------------------------------
   Responsive
--------------------------------------------------------------- */
@media (max-width: 860px) {
    .shell {
        flex-direction: column;
    }

    .sidebar {
        display: none;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        background: var(--ink);
        padding: 8px 10px 8px 14px;
        position: sticky;
        top: 0;
        z-index: 40;
    }

    .page-header {
        padding: 18px 20px;
    }

    .content {
        padding: 24px 20px 40px;
    }

    .kpi-row {
        flex-direction: column;
    }

    .icon-btn {
        width: 34px;
        height: 34px;
    }

    .page-btn {
        padding: 8px 14px;
    }

    .book-details {
        grid-template-columns: 1fr;
    }

    .book-details-cover img,
    .book-details-cover .book-cover-blank {
        width: 120px;
        height: 180px;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 30px 24px 26px;
    }

    .card {
        padding: 20px 18px;
    }

    .content {
        padding: 18px 14px 32px;
    }

    .page-header {
        padding: 16px 14px;
    }

    .household-grid {
        grid-template-columns: 1fr;
    }

    .settings-avatar-preview {
        flex-wrap: wrap;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .resource-row {
        flex-wrap: wrap;
    }

    .resource-row .resource-input {
        order: 3;
        flex: 1 1 100%;
    }

    .resource-row .icon-btn {
        margin-left: auto;
    }

    .directory-header {
        align-items: flex-start;
    }
}
