* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    background: #f7f7f5;
    color: #1a1a1a;
    line-height: 1.5;
}
h1, h2, h3 { font-weight: 500; }
a { color: #1d4ed8; }

.muted { color: #6b7280; font-size: 0.9rem; }

.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e5e0;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar a { text-decoration: none; }

.container { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }
.container-narrow { max-width: 520px; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-card {
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}

label {
    display: block;
    font-size: 0.85rem;
    color: #374151;
    margin: 1rem 0 0.25rem;
    font-weight: 500;
}
input, select, textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button, .btn-secondary {
    margin-top: 1.25rem;
    padding: 0.65rem 1.25rem;
    background: #1f2937;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
button:hover { background: #374151; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
    background: transparent;
    color: #374151;
    border: 1px solid #d1d5db;
    margin-left: 0.5rem;
}
.link-btn {
    background: none;
    border: none;
    color: #1d4ed8;
    padding: 0;
    margin: 0;
    cursor: pointer;
    font-size: inherit;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-size: 0.9rem;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.pass-row {
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.pass-row.overdue {
    border-color: #fca5a5;
    background: #fef2f2;
}
.pass-student { font-weight: 500; font-size: 1.05rem; }
.pass-meta { font-size: 0.85rem; color: #6b7280; margin-top: 0.25rem; }
.return-btn { margin: 0; padding: 0.5rem 1rem; font-size: 0.9rem; }

.badge-overdue {
    display: inline-block;
    background: #dc2626;
    color: #fff;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.9rem;
}
.history-table th, .history-table td {
    padding: 0.6rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}
.history-table th { background: #f9fafb; font-weight: 500; font-size: 0.85rem; color: #6b7280; }
.history-table tr:last-child td { border-bottom: none; }

/* === Admin pages === */

.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.small { font-size: 0.85rem; }

.topbar nav a.active {
    font-weight: 500;
    border-bottom: 2px solid #1f2937;
    padding-bottom: 2px;
}

.card-section {
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
}
.card-section summary {
    cursor: pointer;
    padding: 0.25rem 0;
}
.card-section[open] summary {
    margin-bottom: 1rem;
}

.inline-form { margin-top: 0.5rem; }
.inline-form label { margin-top: 0.5rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.admin-panels {
    margin-bottom: 1.5rem;
}

.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin: 1.5rem 0 0.5rem;
    background: #fff;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
}
.filter-bar input[type="search"] {
    flex: 1;
    margin: 0;
}
.filter-bar button, .filter-bar a {
    margin: 0;
}
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.9rem;
    white-space: nowrap;
}
.checkbox-inline input {
    width: auto;
    margin: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 0.5rem;
    font-size: 0.92rem;
}
.data-table th, .data-table td {
    padding: 0.7rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table th {
    background: #f9fafb;
    font-weight: 500;
    font-size: 0.82rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.row-inactive { background: #fafaf9; color: #9ca3af; }
.data-table tr.row-inactive td { color: #9ca3af; }

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

.btn-small {
    margin: 0 0.15rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}
.btn-small:hover { background: #e5e7eb; }
.btn-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

.status {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.status-active { background: #dcfce7; color: #15803d; }
.status-inactive { background: #f3f4f6; color: #6b7280; }
.status-locked { background: #fef3c7; color: #92400e; }
.status-pending { background: #e0e7ff; color: #4338ca; }

.role-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    font-size: 0.78rem;
    background: #f3f4f6;
    color: #374151;
}
.role-admin { background: #fce7f3; color: #9d174d; }
.role-teacher { background: #dbeafe; color: #1e40af; }

.badge-you {
    display: inline-block;
    background: #e0e7ff;
    color: #4338ca;
    padding: 0.05rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    margin-left: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.edit-row { background: #fffbeb; }
.inline-edit-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.inline-edit-form input {
    flex: 1;
    min-width: 120px;
    margin: 0;
}
.inline-edit-form button {
    margin: 0;
}

code {
    background: #f3f4f6;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.88em;
}

textarea {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.88rem;
}

/* === History pages === */

.breadcrumb {
    margin: 0 0 1rem;
    font-size: 0.9rem;
}
.breadcrumb a { text-decoration: none; }

.student-header-bar,
.student-profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.filter-panel {
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.filter-grid label {
    margin-top: 0;
    font-size: 0.8rem;
}
.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.filter-actions button,
.filter-actions a { margin: 0; }

.student-link {
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 500;
}
.student-link:hover { text-decoration: underline; }

.row-overdue { background: #fef2f2; }

.status-open {
    background: #dbeafe;
    color: #1e40af;
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    padding: 0.85rem 1rem;
}
.stat-card.stat-warning {
    border-color: #fcd34d;
    background: #fffbeb;
}
.stat-label {
    font-size: 0.78rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.25rem;
    font-weight: 500;
}
.stat-value {
    font-size: 1.6rem;
    font-weight: 500;
    margin: 0;
    line-height: 1.1;
}

.destinations-card {
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}
.destination-bars {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.destination-bar-row {
    display: grid;
    grid-template-columns: 130px 1fr 40px;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
}
.destination-label { font-weight: 500; }
.destination-bar-wrap {
    background: #f3f4f6;
    border-radius: 4px;
    height: 18px;
    overflow: hidden;
}
.destination-bar {
    height: 100%;
    background: #93c5fd;
    border-radius: 4px;
    transition: width 0.3s;
}
.destination-count {
    text-align: right;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
}

.empty-state {
    background: #fff;
    border: 1px solid #e5e5e0;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    color: #6b7280;
}
.empty-state p { margin: 0.25rem 0; }

.badge-overdue-small {
    display: inline-block;
    background: #fef2f2;
    color: #991b1b;
    padding: 0.05rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    margin-left: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* === Frequent flyer indicators === */

.badge-flyer {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    padding: 0.05rem 0.4rem;
    border-radius: 3px;
    font-size: 0.72rem;
    margin-left: 0.4rem;
    font-weight: 500;
    cursor: help;
}

.flyer-banner {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.flyer-banner strong { color: #78350f; }

.flyer-warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 0.65rem 0.85rem;
    border-radius: 6px;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.flyer-stats {
    background: #f9fafb;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    margin: 0.5rem 0;
    font-size: 0.88rem;
}

.pass-row.flyer:not(.overdue) {
    border-color: #fcd34d;
    background: #fffbeb;
}

.row-warning {
    background: #fffbeb;
}
