/* =========================================
   BUS 20 — MOBILE FIRST STYLES
========================================= */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --background: #f4f5f7;
    --card: #ffffff;
    --border: #dfe3e8;
    --text: #20242a;
    --muted: #6b7280;

    --primary: #8b1e2d;
    --primary-dark: #681520;
    --gold: #c9a227;

    --yes: #207a45;
    --no: #b42318;
    --na: #667085;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Display",
        "SF Pro Text",
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    min-height: 100vh;
}


/* =========================================
   TOP BAR
========================================= */

.topbar {
    position: sticky;
    top: 0;
    z-index: 500;

    background: var(--primary);
    color: white;

    min-height: 68px;

    padding:
        max(10px, env(safe-area-inset-top))
        14px
        10px
        14px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;

    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.15);
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.1;
    font-weight: 750;
}

.topbar p {
    margin: 3px 0 0;

    font-size: 12px;

    opacity: 0.85;
}


/* =========================================
   LOG BUTTON
========================================= */

.log-button {
    border: none;

    background: var(--gold);
    color: #171717;

    min-height: 44px;

    padding: 0 14px;

    border-radius: 9px;

    font-size: 14px;
    font-weight: 750;

    white-space: nowrap;

    cursor: pointer;

    touch-action: manipulation;
}

.log-button:active {
    transform: scale(0.97);
}


/* =========================================
   MAIN CONTAINER
========================================= */

.container {
    width: 100%;
    max-width: 1200px;

    margin: 0 auto;

    padding: 12px 12px 40px;
}


/* =========================================
   AREA TABS
========================================= */

.area-tabs {
    display: flex;

    gap: 7px;

    overflow-x: auto;
    overflow-y: hidden;

    padding: 2px 2px 12px;

    margin: 0;

    scrollbar-width: none;

    -webkit-overflow-scrolling: touch;
}

.area-tabs::-webkit-scrollbar {
    display: none;
}

.area-tab {
    flex: 0 0 auto;

    min-height: 43px;

    padding: 0 17px;

    border: 1px solid var(--border);

    background: white;
    color: var(--text);

    border-radius: 9px;

    font-size: 14px;
    font-weight: 700;

    white-space: nowrap;

    cursor: pointer;

    touch-action: manipulation;

    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.03);
}

.area-tab:active {
    transform: scale(0.96);
}

.area-tab.active {
    background: var(--primary);
    color: white;

    border-color: var(--primary);

    box-shadow:
        0 2px 5px rgba(139, 30, 45, 0.25);
}


/* =========================================
   AREA HEADER
========================================= */

.area-header {
    background: var(--card);

    border: 1px solid var(--border);

    border-radius: 12px 12px 0 0;

    padding: 15px;

    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;
}

.area-heading-group {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.filter-control {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.filter-control select {
    min-height: 38px;
    padding: 0 30px 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.area-header h2 {
    margin: 0;

    font-size: 20px;
    line-height: 1.2;
}

.area-header p {
    margin: 4px 0 0;

    color: var(--muted);

    font-size: 13px;
}

.add-button {
    flex-shrink: 0;

    min-height: 43px;

    padding: 0 14px;

    background: var(--primary);
    color: white;

    border: none;
    border-radius: 9px;

    font-size: 14px;
    font-weight: 700;

    cursor: pointer;

    touch-action: manipulation;
}

.add-button:active {
    transform: scale(0.96);
}


/* =========================================
   TABLE WRAPPER
========================================= */

.table-wrapper {
    background: white;

    border: 1px solid var(--border);
    border-top: none;

    border-radius: 0 0 12px 12px;

    overflow: hidden;
}


/* =========================================
   DESKTOP TABLE
========================================= */

table {
    width: 100%;

    border-collapse: collapse;

    min-width: 900px;
}

th {
    background: #f8f9fa;

    color: #4b5563;

    text-align: left;

    font-size: 13px;
    font-weight: 700;

    padding: 13px 12px;

    border-bottom: 1px solid var(--border);

    white-space: nowrap;
}

td {
    padding: 12px;

    border-bottom: 1px solid var(--border);

    vertical-align: middle;

    font-size: 14px;
}

tbody tr:last-child td {
    border-bottom: none;
}

.check-column {
    width: 62px;

    text-align: center;
}


/* =========================================
   CHECK BUTTONS
========================================= */

.check-button {
    width: 40px;
    height: 40px;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    border: 2px solid var(--border);

    background: white;

    border-radius: 9px;

    font-size: 19px;
    font-weight: 800;

    cursor: pointer;

    touch-action: manipulation;
}

.check-button:active {
    transform: scale(0.90);
}

.check-button.selected.yes {
    background: var(--yes);

    border-color: var(--yes);

    color: white;
}

.check-button.selected.no {
    background: var(--no);

    border-color: var(--no);

    color: white;
}

.check-button.selected.na {
    background: var(--na);

    border-color: var(--na);

    color: white;
}


/* =========================================
   EDIT / DELETE
========================================= */

.edit-button,
.delete-button {
    min-width: 40px;
    min-height: 40px;

    border: none;
    background: transparent;

    font-size: 19px;

    cursor: pointer;

    touch-action: manipulation;
}

.edit-button {
    color: var(--primary);
}

.delete-button {
    color: var(--no);
}

.edit-button:active,
.delete-button:active {
    transform: scale(0.88);
}


/* =========================================
   EMPTY STATE
========================================= */

.empty-message {
    text-align: center;

    color: var(--muted);

    padding: 42px 20px;

    font-size: 14px;

    line-height: 1.7;
}


/* =========================================
   HISTORY
========================================= */

.history-section {
    margin-top: 25px;
}

.section-title {
    background: white;

    border: 1px solid var(--border);

    border-radius: 12px 12px 0 0;

    padding: 16px;
}

.section-title h2 {
    margin: 0;

    font-size: 20px;
}

.section-title p {
    margin: 4px 0 0;

    color: var(--muted);

    font-size: 13px;
}

.history-list {
    background: white;

    border: 1px solid var(--border);
    border-top: none;

    border-radius: 0 0 12px 12px;

    overflow: hidden;
}

.history-item {
    padding: 16px;

    border-bottom: 1px solid var(--border);

    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;
}

.history-item:last-child {
    border-bottom: none;
}

.history-info {
    min-width: 0;
}

.history-info strong {
    display: block;

    margin-bottom: 5px;

    font-size: 15px;
}

.history-info span {
    color: var(--muted);

    font-size: 12px;

    line-height: 1.5;
}

.view-history-button {
    flex-shrink: 0;

    min-height: 40px;

    padding: 0 13px;

    border: 1px solid var(--primary);

    background: white;

    color: var(--primary);

    border-radius: 8px;

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;

    touch-action: manipulation;
}

.view-history-button:active {
    transform: scale(0.95);
}

.no-history {
    padding: 30px 20px;

    text-align: center;

    color: var(--muted);

    font-size: 14px;
}


/* =========================================
   MODAL BACKDROP
========================================= */

.modal {
    position: fixed;

    inset: 0;

    z-index: 1000;

    background: rgba(0, 0, 0, 0.50);

    display: flex;

    align-items: flex-end;
    justify-content: center;

    padding: 0;
}

.modal.hidden {
    display: none;
}


/* =========================================
   MOBILE MODAL
========================================= */

.modal-content {
    width: 100%;

    max-width: 600px;

    max-height: 92vh;

    overflow-y: auto;

    background: white;

    border-radius: 18px 18px 0 0;

    padding:
        20px
        18px
        max(24px, env(safe-area-inset-bottom));

    box-shadow:
        0 -10px 40px rgba(0, 0, 0, 0.25);

    animation: slideUp 0.18s ease-out;
}

@keyframes slideUp {

    from {
        transform: translateY(30px);
        opacity: 0.5;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.small-modal {
    max-width: 500px;
}

.history-modal {
    max-width: 1000px;
    max-height: 94vh;
}


/* =========================================
   MODAL HEADER
========================================= */

.modal-header {
    display: flex;

    justify-content: space-between;
    align-items: flex-start;

    gap: 15px;

    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;

    font-size: 21px;
}

.modal-header p {
    margin: 4px 0 0;

    color: var(--muted);

    font-size: 13px;
}

.close-button {
    flex-shrink: 0;

    width: 42px;
    height: 42px;

    border: none;

    background: #f0f1f3;

    border-radius: 50%;

    color: #555;

    font-size: 28px;

    line-height: 1;

    cursor: pointer;

    touch-action: manipulation;
}


/* =========================================
   FORM
========================================= */

label {
    display: block;

    margin-bottom: 17px;

    font-size: 14px;

    font-weight: 700;
}

label input {
    display: block;

    width: 100%;

    min-height: 50px;

    margin-top: 7px;

    padding: 0 13px;

    border: 1px solid #cfd4da;

    border-radius: 9px;

    background: white;

    color: var(--text);

    font-size: 16px;

    outline: none;

    /*
       16px prevents iPhone Safari
       from automatically zooming.
    */
}

label input:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(139, 30, 45, 0.10);
}


/* =========================================
   MODAL BUTTONS
========================================= */

.modal-actions {
    display: flex;

    gap: 10px;

    margin-top: 22px;
}

.modal-actions button {
    flex: 1;

    min-height: 50px;

    border-radius: 9px;

    font-size: 15px;

    font-weight: 700;

    cursor: pointer;

    touch-action: manipulation;
}

.primary-button {
    background: var(--primary);

    color: white;

    border: none;
}

.secondary-button {
    background: white;

    color: var(--text);

    border: 1px solid var(--border);
}

.modal-actions button:active {
    transform: scale(0.98);
}

.warning-text {
    color: var(--primary);

    font-weight: 700;

    line-height: 1.5;
}


/* =========================================
   HISTORY DETAILS
========================================= */

.history-area {
    margin-bottom: 25px;
}

.history-area h3 {
    margin: 0 0 10px;

    font-size: 17px;
}

.history-area > div {
    overflow-x: auto;

    -webkit-overflow-scrolling: touch;
}

.history-table {
    width: 100%;

    min-width: 750px;

    border-collapse: collapse;
}

.history-table th,
.history-table td {
    border: 1px solid var(--border);
}

.history-check {
    text-align: center;

    font-weight: 800;
}

.actual-checkbox {
    width: 24px;
    height: 24px;

    cursor: pointer;

    accent-color: var(--primary);
}


/* =========================================
   IPHONE-SIZED SCREENS
========================================= */

@media (max-width: 600px) {

    /*
       Convert the current week's
       table into mobile rider cards.
    */

    .table-wrapper {
        background: transparent;

        border: none;

        overflow: visible;
    }

    table {
        min-width: 0;

        display: block;
    }

    thead {
        display: none;
    }

    tbody {
        display: block;
    }

    tbody tr {
        display: block;

        background: white;

        border: 1px solid var(--border);

        border-radius: 12px;

        margin-bottom: 12px;

        padding: 14px;

        box-shadow:
            0 1px 3px rgba(0, 0, 0, 0.04);
    }

    tbody td {
        display: block;

        border: none;

        padding: 2px 0;

        font-size: 14px;
    }

    /*
       Address
    */

    tbody td:nth-child(1) {
        font-size: 17px;

        font-weight: 750;

        margin-bottom: 3px;
    }

    /*
       Rider
    */

    tbody td:nth-child(2) {
        font-size: 15px;

        font-weight: 650;
    }

    /*
       Parent
    */

    tbody td:nth-child(3),
    tbody td:nth-child(4) {
        color: var(--muted);

        font-size: 13px;
    }

    /*
       Yes / No / N/A row
    */

    tbody td:nth-child(5),
    tbody td:nth-child(6),
    tbody td:nth-child(7) {

        display: inline-flex;

        width: 32%;

        margin-top: 13px;

        justify-content: center;

        align-items: center;
    }

    tbody td:nth-child(5)::before {
        content: "YES";

        margin-right: 6px;

        font-size: 11px;

        font-weight: 800;

        color: var(--yes);
    }

    tbody td:nth-child(6)::before {
        content: "NO";

        margin-right: 6px;

        font-size: 11px;

        font-weight: 800;

        color: var(--no);
    }

    tbody td:nth-child(7)::before {
        content: "N/A";

        margin-right: 6px;

        font-size: 11px;

        font-weight: 800;

        color: var(--na);
    }

    /*
       Edit/Delete row
    */

    tbody td:nth-child(8) {
        display: flex;

        justify-content: flex-end;

        gap: 4px;

        border-top: 1px solid var(--border);

        margin-top: 10px;

        padding-top: 8px;
    }

    .check-button {
        width: 42px;
        height: 42px;
    }

    /*
       Make phone number easy to tap
    */

    tbody td:nth-child(4) {
        padding-top: 2px;
    }

    .empty-message {
        background: white;

        border: 1px solid var(--border);

        border-radius: 12px;

        margin-bottom: 12px;
    }

    /*
       History items stack better.
    */

    .history-item {
        align-items: flex-start;
    }

    /*
       Area header
    */

    .area-header {
        padding: 13px;
    }

    /*
       Keep the add button readable.
    */

    .add-button {
        font-size: 13px;

        padding: 0 12px;
    }
}


/* =========================================
   VERY SMALL IPHONES
========================================= */

@media (max-width: 380px) {

    .topbar {
        padding-left: 10px;
        padding-right: 10px;
    }

    .topbar h1 {
        font-size: 20px;
    }

    .topbar p {
        font-size: 11px;
    }

    .log-button {
        padding: 0 10px;

        font-size: 12px;
    }

    .area-tab {
        padding: 0 14px;
    }

    .area-header h2 {
        font-size: 18px;
    }

    .area-header p {
        font-size: 12px;
    }

    .add-button {
        padding: 0 10px;

        font-size: 12px;
    }
}


/* =========================================
   IPHONE LANDSCAPE
========================================= */

@media (max-width: 900px) and (orientation: landscape) {

    .topbar {
        min-height: 58px;
    }

    .modal-content {
        max-height: 96vh;
    }
}


/* =========================================
   REDUCE MOTION
========================================= */

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    .modal-content {
        animation: none;
    }

    * {
        transition: none !important;
    }
}

/* =========================================
   BUS 20 — ALL AREAS / FILTERS / PICKUP
========================================= */

.pickup-button {
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.all-area-name-cell {
    vertical-align: middle;
}

.all-area-name-label {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.1;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 600px) {

    .all-area-row td:nth-child(1) {
        font-size: 17px;
        font-weight: 750;
        margin-bottom: 3px;
    }

    .all-area-row td:nth-child(2) {
        font-size: 15px;
        font-weight: 650;
        margin-bottom: 2px;
    }

    .all-area-row .all-area-name-label {
        font-size: 10px;
        font-weight: 600;
    }

    .all-area-row td:nth-child(3),
    .all-area-row td:nth-child(4) {
        color: var(--muted);
        font-size: 13px;
    }

    .all-area-row td:nth-child(5),
    .all-area-row td:nth-child(6),
    .all-area-row td:nth-child(7) {
        display: inline-flex;
        width: 32%;
        margin-top: 13px;
        justify-content: center;
        align-items: center;
    }

    .all-area-row td:nth-child(5)::before {
        content: "YES";
        margin-right: 6px;
        font-size: 11px;
        font-weight: 800;
        color: var(--yes);
    }

    .all-area-row td:nth-child(6)::before {
        content: "NO";
        margin-right: 6px;
        font-size: 11px;
        font-weight: 800;
        color: var(--no);
    }

    .all-area-row td:nth-child(7)::before {
        content: "NOT HOME";
        margin-right: 6px;
        font-size: 11px;
        font-weight: 800;
        color: var(--na);
    }

    .all-area-row td:nth-child(8) {
        display: flex;
        justify-content: flex-end;
        gap: 4px;
        border-top: 1px solid var(--border);
        margin-top: 10px;
        padding-top: 8px;
    }

    .area-header .pickup-button,
    .area-header .add-button {
        min-height: 38px;
        padding: 0 10px;
        font-size: 12px;
    }
}


/* Street grouping */
.street-group-row td {
    padding: 0;
    background: #f8f1f2;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.street-group-button {
    width: 100%;
    min-height: 48px;

    display: flex;
    align-items: center;

    gap: 9px;

    padding: 0 12px;

    border: none;
    background: transparent;

    color: var(--primary);

    font: inherit;
    font-size: 14px;
    font-weight: 800;

    text-align: left;
    cursor: pointer;

    touch-action: manipulation;
}

.street-group-button:active {
    background: rgba(139, 30, 45, 0.08);
}

.street-chevron {
    width: 18px;
    height: 18px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-size: 24px;
    line-height: 1;

    transform: rotate(90deg);
    transition: transform 0.12s ease;
}

.street-chevron.collapsed {
    transform: rotate(0deg);
}

.street-group-name {
    flex: 1;
}

.street-group-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.street-rider-row td:first-child {
    padding-left: 25px;
}


/* Street selector helper */
.hidden {
  display: none !important;
}

#streetSelect,
#newStreetInput {
  width: 100%;
  box-sizing: border-box;
}


/* BUS MINISTRY APP SHELL */
.app-shell{min-height:100vh;display:flex}.sidebar{width:250px;flex:0 0 250px;background:#fff;border-right:1px solid var(--border);min-height:100vh;position:fixed;left:0;top:0;bottom:0;z-index:900;display:flex;flex-direction:column}.side-brand{height:76px;background:var(--primary);color:#fff;display:flex;align-items:center;gap:11px;padding:12px 16px}.brand-mark{font-size:30px}.side-brand strong{display:block;font-size:17px}.side-brand span{display:block;font-size:11px;opacity:.8;margin-top:2px}.sidebar nav{padding:12px 10px;display:grid;gap:4px}.side-link{display:flex;align-items:center;gap:11px;padding:11px 12px;border-radius:9px;color:var(--text);text-decoration:none;font-weight:700;font-size:14px}.side-link:hover{background:#f6f1f2}.side-link.active{background:var(--primary);color:#fff}.side-icon{width:24px;text-align:center;font-size:17px}.side-user{margin-top:auto;border-top:1px solid var(--border);padding:14px;font-size:13px}.side-user strong,.side-user span{display:block}.side-user span{color:var(--muted);margin:3px 0 8px}.side-user a{color:var(--primary);font-weight:700;text-decoration:none}.page{margin-left:250px;width:calc(100% - 250px);min-width:0}.menu-button{display:none;border:0;background:transparent;color:#fff;font-size:24px;padding:4px}.role-pill{background:rgba(255,255,255,.16);padding:7px 10px;border-radius:999px;font-size:12px;font-weight:700}.top-actions{display:flex;align-items:center;gap:8px}.card{background:#fff;border:1px solid var(--border);border-radius:12px;padding:16px;margin-bottom:14px}.card h2,.card h3{margin:0 0 5px}.muted{color:var(--muted)}.grid-2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.stat-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.stat{background:#fff;border:1px solid var(--border);border-radius:12px;padding:14px}.stat b{font-size:25px;display:block}.primary-btn{border:0;background:var(--primary);color:#fff;padding:11px 15px;border-radius:9px;font-weight:750;cursor:pointer}.secondary-btn{border:1px solid var(--border);background:#fff;color:var(--text);padding:10px 14px;border-radius:9px;font-weight:700;cursor:pointer}.gold-btn{border:0;background:var(--gold);color:#171717;padding:11px 15px;border-radius:9px;font-weight:750;cursor:pointer}.danger-btn{border:0;background:#b42318;color:#fff;padding:10px 14px;border-radius:9px;font-weight:700}.button-row{display:flex;gap:8px;flex-wrap:wrap}.area-tabs .area-tab{cursor:pointer}.street-group{border:1px solid var(--border);border-radius:10px;background:#fff;margin:10px 0;overflow:hidden}.street-head{width:100%;border:0;background:#fff;padding:13px 14px;display:flex;justify-content:space-between;align-items:center;font-weight:800;cursor:pointer}.street-head.closed{background:#f5f5f6;color:#555}.street-body{padding:0 12px 12px}.street-body.hidden{display:none}.check-row{display:flex;align-items:center;justify-content:space-between;border-top:1px solid #eee;padding:11px 2px;gap:8px}.check-row label{display:flex;gap:9px;align-items:center}.check-row input{width:20px;height:20px}.complete{color:#1f6f43}.idea-card img{width:100%;max-height:220px;object-fit:cover;border-radius:9px;margin:8px 0}.idea-meta{font-size:12px;color:var(--muted)}.announcement{border-left:4px solid var(--gold)}.prayer{position:relative}.answer-btn{position:absolute;right:14px;top:14px}.login-wrap{max-width:430px;margin:8vh auto}.login-logo{text-align:center;font-size:44px}.field{display:grid;gap:5px;margin:10px 0}.field label{font-size:13px;font-weight:750}.field input,.field select,.field textarea{width:100%;padding:11px;border:1px solid var(--border);border-radius:8px;font:inherit;background:#fff}.field textarea{min-height:100px;resize:vertical}.file-note{font-size:12px;color:var(--muted)}.notice{padding:11px 13px;border-radius:9px;background:#f8f3e7;border:1px solid #ead9a4}.completion{display:flex;align-items:center;gap:8px;color:#1f6f43;font-weight:800}.sidebar-overlay{display:none}
@media(max-width:800px){.sidebar{transform:translateX(-100%);transition:transform .2s ease;box-shadow:5px 0 20px rgba(0,0,0,.15)}.sidebar.open{transform:translateX(0)}.sidebar-overlay.show{display:block;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:850}.page{margin-left:0;width:100%}.menu-button{display:block}.topbar{justify-content:flex-start}.topbar>div:nth-child(2){flex:1}.top-actions{margin-left:auto}.grid-2,.stat-grid{grid-template-columns:1fr}.container{padding-bottom:28px}.role-pill{display:none}}
