/* ═══════════════════════════════════════════════════════════════════
   MURDOCK — School Services CRM
   Bert Murdock Music
   Mobile-first. Built for a rep standing in a band room.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --navy-900: #0f1b2d;
    --navy-800: #16273f;
    --navy-700: #1e3453;
    --navy-600: #2a4468;
    --brass-500: #c8952b;
    --brass-400: #dcae4a;
    --brass-100: #fbf1dd;

    --blue-600: #1d4ed8;
    --blue-500: #2563eb;
    --blue-50:  #eff6ff;

    --green-600: #15803d;
    --green-50:  #ecfdf5;
    --amber-600: #b45309;
    --amber-50:  #fffbeb;
    --red-600:   #b91c1c;
    --red-50:    #fef2f2;

    --gray-900: #111827;
    --gray-800: #1f2937;
    --gray-700: #374151;
    --gray-600: #4b5563;
    --gray-500: #6b7280;
    --gray-400: #9ca3af;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50:  #f9fafb;
    --white:    #ffffff;

    --text:      var(--gray-900);
    --text-muted:var(--gray-500);
    --border:    var(--gray-200);
    --bg:        #f4f6f9;
    --surface:   var(--white);

    --radius:    10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06);
    --shadow:    0 2px 8px rgba(15, 27, 45, .08);
    --shadow-lg: 0 12px 32px rgba(15, 27, 45, .16);

    --sidebar-w: 248px;
    --header-h:  56px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

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

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

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

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .75rem; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── App shell ───────────────────────────────────────────────────── */

.app { min-height: 100vh; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 .875rem;
    background: var(--navy-900);
    color: #fff;
    box-shadow: var(--shadow);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: .01em;
}
.topbar-brand:hover { text-decoration: none; color: #fff; }
.topbar-brand i { color: var(--brass-400); }
.topbar-brand small {
    display: block;
    font-size: .625rem;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.6);
}

.topbar-spacer { flex: 1; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    font-size: 1.05rem;
    cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brass-500);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    flex: 0 0 auto;
}
.avatar-sm { width: 26px; height: 26px; font-size: .65rem; }

/* ── Sidebar ─────────────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--navy-800);
    color: rgba(255,255,255,.85);
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 60;
    overflow-y: auto;
    padding-bottom: 2rem;
}
.sidebar.open { transform: translateX(0); }

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 .875rem;
    background: var(--navy-900);
}

.sidebar-group { padding: .75rem 0 .25rem; }
.sidebar-label {
    display: block;
    padding: 0 1rem .375rem;
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: rgba(255,255,255,.4);
    font-weight: 600;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem 1rem;
    color: rgba(255,255,255,.82);
    font-size: .9rem;
    border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.sidebar-link.active {
    background: rgba(200,149,43,.15);
    border-left-color: var(--brass-400);
    color: #fff;
    font-weight: 600;
}
.sidebar-link i { width: 18px; text-align: center; color: rgba(255,255,255,.55); }
.sidebar-link.active i { color: var(--brass-400); }

.sidebar-badge {
    margin-left: auto;
    background: var(--brass-500);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: .05rem .4rem;
    border-radius: 999px;
}

.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,27,45,.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    z-index: 50;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

/* ── Main ────────────────────────────────────────────────────────── */

.main { padding: 1rem .875rem 5rem; }

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1rem;
}
.page-head .page-title { flex: 1 1 240px; min-width: 0; }
.page-head h1 { margin-bottom: .15rem; }
.page-sub { color: var(--text-muted); font-size: .875rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.breadcrumb {
    font-size: .8125rem;
    color: var(--text-muted);
    margin-bottom: .4rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--blue-600); }

/* ── Cards ───────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    overflow: hidden;
}
.card-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
}
.card-head h2, .card-head h3 { margin: 0; font-size: .95rem; }
.card-head .spacer { flex: 1; }
.card-body { padding: 1rem; }
.card-body.tight { padding: .5rem 1rem; }
.card-foot {
    padding: .625rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
    font-size: .8125rem;
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ── Stat tiles ──────────────────────────────────────────────────── */

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .875rem;
    box-shadow: var(--shadow-sm);
    display: block;
    color: inherit;
}
.stat:hover { text-decoration: none; box-shadow: var(--shadow); }
.stat-label {
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .35rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; margin-top: .25rem; }
.stat-note { font-size: .75rem; color: var(--text-muted); }
.stat.accent-amber .stat-value { color: var(--amber-600); }
.stat.accent-red .stat-value { color: var(--red-600); }
.stat.accent-green .stat-value { color: var(--green-600); }
.stat.accent-blue .stat-value { color: var(--blue-600); }

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem .85rem;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 38px;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-brass   { background: var(--brass-500); color: #fff; }
.btn-outline { background: var(--white); border-color: var(--gray-300); color: var(--gray-700); }
.btn-danger  { background: var(--red-600); color: #fff; }
.btn-ghost   { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: .3rem .55rem; font-size: .78rem; min-height: 30px; }
.btn-lg { padding: .7rem 1.1rem; font-size: 1rem; min-height: 46px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Floating quick-log button (thumb reach on mobile) */
.fab {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 45;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brass-500);
    color: #fff;
    border: 0;
    font-size: 1.25rem;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
}
.fab:hover { background: var(--brass-400); }

/* ── Badges & pills ──────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 650;
    letter-spacing: .01em;
    background: var(--gray-100);
    color: var(--gray-700);
    white-space: nowrap;
}
.badge-blue   { background: var(--blue-50);  color: var(--blue-600); }
.badge-green  { background: var(--green-50); color: var(--green-600); }
.badge-amber  { background: var(--amber-50); color: var(--amber-600); }
.badge-red    { background: var(--red-50);   color: var(--red-600); }
.badge-brass  { background: var(--brass-100);color: #8a6516; }
.badge-navy   { background: #e8eef6; color: var(--navy-700); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .6rem;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    font-size: .8rem;
    background: var(--white);
    color: var(--gray-700);
}
.chip.active { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.chip:hover { text-decoration: none; }

.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .875rem; }

/* ── Tables ──────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
table.data th {
    text-align: left;
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 700;
    padding: .55rem .75rem;
    border-bottom: 1px solid var(--border);
    background: var(--gray-50);
    white-space: nowrap;
}
table.data td {
    padding: .625rem .75rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
}
table.data tbody tr:hover { background: var(--gray-50); }
table.data td.num, table.data th.num { text-align: right; }
table.data .nowrap { white-space: nowrap; }

.empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}
.empty i { font-size: 1.75rem; color: var(--gray-300); display: block; margin-bottom: .5rem; }

/* ── Lists (mobile-friendly rows) ────────────────────────────────── */

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    color: inherit;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--gray-50); text-decoration: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: .8125rem; color: var(--text-muted); }
.list-item .li-meta { text-align: right; font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

.li-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: .8rem;
    flex: 0 0 auto;
}

/* ── Timeline ────────────────────────────────────────────────────── */

.timeline { list-style: none; margin: 0; padding: .5rem 0; }
.timeline-item {
    position: relative;
    padding: .75rem 1rem .75rem 3.25rem;
    border-bottom: 1px solid var(--gray-100);
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: 2rem;
    top: 3rem;
    bottom: -.25rem;
    width: 2px;
    background: var(--gray-200);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    position: absolute;
    left: 1rem;
    top: .8rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--blue-50);
    color: var(--blue-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    border: 2px solid var(--white);
    z-index: 1;
}
.timeline-dot.t-visit    { background: var(--brass-100); color: #8a6516; }
.timeline-dot.t-call     { background: var(--green-50);  color: var(--green-600); }
.timeline-dot.t-delivery { background: #eef2ff; color: #4338ca; }
.timeline-dot.t-issue    { background: var(--red-50); color: var(--red-600); }
.timeline-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; }
.timeline-head .t-subject { font-weight: 650; }
.timeline-meta { font-size: .75rem; color: var(--text-muted); }
.timeline-body { font-size: .875rem; color: var(--gray-700); white-space: pre-line; margin-top: .25rem; }

/* ── Forms ───────────────────────────────────────────────────────── */

.form-grid { display: grid; gap: .875rem; grid-template-columns: 1fr; }

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label,
.field .label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--gray-700);
}
.field .hint { font-size: .75rem; color: var(--text-muted); }
.field.span-2 { grid-column: 1 / -1; }

input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url],
input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=search],
select, textarea {
    width: 100%;
    padding: .55rem .65rem;
    font-family: inherit;
    font-size: 16px; /* prevents iOS zoom */
    color: var(--text);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    min-height: 42px;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .55rem center; background-size: 14px; padding-right: 1.9rem; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
input[readonly], input[disabled], select[disabled], textarea[disabled] {
    background: var(--gray-100);
    color: var(--gray-500);
}

.check {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    cursor: pointer;
}
.check input[type=checkbox], .check input[type=radio] { width: 18px; height: 18px; margin: 0; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding-top: .5rem;
    border-top: 1px solid var(--border);
    margin-top: .5rem;
}
.form-actions .spacer { flex: 1; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .875rem;
    margin: 0 0 1rem;
}
legend {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 700;
    color: var(--text-muted);
    padding: 0 .35rem;
}

.required::after { content: ' *'; color: var(--red-600); }

/* ── Search / filter bar ─────────────────────────────────────────── */

.filters {
    display: grid;
    gap: .5rem;
    grid-template-columns: 1fr;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem;
}

/* ── Alerts ──────────────────────────────────────────────────────── */

.alert {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .7rem .875rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .875rem;
    border: 1px solid transparent;
}
.alert i { margin-top: .12rem; }
.alert span { flex: 1; }
.alert-success { background: var(--green-50); color: #14532d; border-color: #bbf7d0; }
.alert-error   { background: var(--red-50);   color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--amber-50); color: #78350f; border-color: #fde68a; }
.alert-info    { background: var(--blue-50);  color: #1e3a8a; border-color: #bfdbfe; }
.alert-close { background: none; border: 0; font-size: 1.1rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }

/* ── Definition rows (detail pages) ──────────────────────────────── */

.dl { display: grid; grid-template-columns: 1fr; gap: .55rem; margin: 0; }
.dl > div { display: flex; gap: .6rem; align-items: baseline; }
.dl dt {
    flex: 0 0 42%;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 650;
}
.dl dd { margin: 0; flex: 1; min-width: 0; word-break: break-word; }

.pre-line { white-space: pre-line; }

/* ── Schedule table ──────────────────────────────────────────────── */

.schedule td.period { font-weight: 650; white-space: nowrap; }
.schedule tr.is-prep { background: var(--gray-50); color: var(--text-muted); font-style: italic; }

/* ── Tabs ────────────────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}
.tab {
    padding: .55rem .8rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.tab:hover { text-decoration: none; color: var(--navy-800); }
.tab.active { color: var(--navy-900); border-bottom-color: var(--brass-500); }

/* ── Pagination ──────────────────────────────────────────────────── */

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}
.pagination a, .pagination span {
    padding: .35rem .6rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-size: .8125rem;
    color: var(--gray-700);
}
.pagination .current { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.pagination a:hover { text-decoration: none; background: var(--gray-100); }

/* ── Modal ───────────────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: rgba(15,27,45,.55);
    padding: 0;
}
.modal.show { display: flex; }
.modal-panel {
    background: var(--surface);
    width: 100%;
    max-width: 640px;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
}
.modal-head {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.modal-head h2 { margin: 0; font-size: 1rem; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 1rem; }

/* ── Print (visit sheets) ────────────────────────────────────────── */

@media print {
    .topbar, .sidebar, .backdrop, .fab, .page-actions, .no-print, .tabs { display: none !important; }
    body { background: #fff; font-size: 11pt; }
    .main { padding: 0; }
    .card { break-inside: avoid; box-shadow: none; border-color: #999; }
    a { color: #000; text-decoration: none; }
}

/* ── Utilities ───────────────────────────────────────────────────── */

.muted { color: var(--text-muted); }
.small { font-size: .8125rem; }
.tiny  { font-size: .72rem; }
.bold  { font-weight: 650; }
.right { text-align: right; }
.center{ text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { display: flex; gap: .5rem; align-items: center; justify-content: space-between; }
.gap-1 { gap: .5rem; }
.hide { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack > * + * { margin-top: .5rem; }

.tel-link { font-weight: 600; }

/* ── Login ───────────────────────────────────────────────────────── */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background: linear-gradient(160deg, var(--navy-900), var(--navy-700));
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem 1.5rem;
}
.login-logo { text-align: center; margin-bottom: 1.25rem; }
.login-logo i { font-size: 2rem; color: var(--brass-500); }
.login-logo h1 { margin: .5rem 0 .15rem; font-size: 1.5rem; letter-spacing: .02em; }
.login-logo p { color: var(--text-muted); font-size: .8125rem; margin: 0; }

/* ═══════════════════════════════════════════════════════════════════
   Breakpoints
   ═══════════════════════════════════════════════════════════════════ */

@media (min-width: 640px) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters { grid-template-columns: 2fr 1fr 1fr auto; align-items: end; }
    .main { padding: 1.25rem 1.25rem 5rem; }
    .modal { align-items: center; padding: 1rem; }
    .modal-panel { border-radius: var(--radius-lg); }
    .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.5rem; }
}

@media (min-width: 1024px) {
    .sidebar { transform: translateX(0); }
    .app { padding-left: var(--sidebar-w); }
    .topbar { padding-left: 1.25rem; }
    .topbar .menu-toggle { display: none; }
    .backdrop { display: none; }
    .main { padding: 1.5rem 1.75rem 4rem; max-width: 1400px; }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .fab { display: none; }
}

/* ── Calendar ────────────────────────────────────────────────────── */

.cal-legend { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; padding: .25rem 0; }
.cal-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: .6rem; }
.cal-key.cal-event    { background: var(--brass-500); }
.cal-key.cal-delivery { background: var(--blue-500); }
.cal-key.cal-task     { background: var(--amber-600); }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(96px, 1fr));
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    min-width: 700px;
}
.cal-dow {
    padding: .4rem .5rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--gray-50);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.cal-cell {
    min-height: 108px;
    padding: .3rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.cal-cell.cal-empty { background: var(--gray-50); }
.cal-cell.is-today { background: #fffdf5; box-shadow: inset 0 0 0 2px var(--brass-400); }
.cal-daynum { font-size: .75rem; font-weight: 700; color: var(--gray-600); margin-bottom: .2rem; }

.cal-item {
    display: block;
    font-size: .7rem;
    line-height: 1.25;
    padding: .18rem .3rem;
    margin-bottom: .18rem;
    border-radius: 4px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-item:hover { text-decoration: none; filter: brightness(1.08); }
.cal-item.cal-event    { background: var(--brass-500); }
.cal-item.cal-delivery { background: var(--blue-500); }
.cal-item.cal-task     { background: var(--amber-600); }
.cal-time { font-weight: 700; opacity: .85; }

/* Anchor styled as the floating action button */
a.fab { display: flex; align-items: center; justify-content: center; text-decoration: none; }
a.fab:hover { text-decoration: none; color: #fff; }

/* ── Repair flow strip ───────────────────────────────────────────── */
.repair-flow {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: stretch;
}
.repair-step {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .3rem .55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--gray-50);
    color: var(--gray-500);
    white-space: nowrap;
}
.repair-step i { font-size: .7rem; }
.repair-step.is-done {
    background: var(--green-50);
    border-color: var(--green-600);
    color: var(--green-600);
}
.repair-step.is-now {
    background: var(--navy-800);
    border-color: var(--navy-800);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

/* ── Teacher photos ──────────────────────────────────────────────── */
.photo {
    display: block;
    border-radius: 50%;
    object-fit: cover;
    background: var(--gray-100);
    flex: 0 0 auto;
}
.photo-lg { width: 96px;  height: 96px;  border: 3px solid var(--white); box-shadow: var(--shadow); }
.photo-sm { width: 34px;  height: 34px; }
.photo-xs { width: 26px;  height: 26px; }
.photo-row { display: flex; gap: 1rem; align-items: flex-start; }
.photo-row .photo-body { min-width: 0; flex: 1 1 auto; }

/* ── This-week board ─────────────────────────────────────────────── */
.week-day {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-500);
    padding: .5rem .9rem .25rem;
    border-top: 1px solid var(--border);
    background: var(--gray-50);
}
.week-day:first-child { border-top: 0; }
.week-day.is-today { color: var(--brass-500); }
.digest {
    font-size: .92rem;
    line-height: 1.55;
    padding: .9rem;
    border-left: 3px solid var(--brass-400);
    background: var(--brass-100);
    border-radius: var(--radius-sm);
}

/* ── Collapsible filter block ────────────────────────────────────── */
.filter-fold { margin-bottom: 1rem; }
.filter-fold > summary {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--gray-600);
    padding: .45rem .8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}
.filter-fold > summary::-webkit-details-marker { display: none; }
.filter-fold > summary:hover { color: var(--text); border-color: var(--gray-400); }
.filter-fold[open] > summary { margin-bottom: .6rem; }
.filter-fold .filters { margin-bottom: 0; }
