:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --ink: #172033;
    --muted: #667085;
    --line: #dfe5ec;
    --line-strong: #cbd5e1;
    --brand: #1753a6;
    --brand-dark: #103c7b;
    --brand-soft: #eaf2ff;
    --nav: #101828;
    --nav-soft: #1d2939;
    --good: #087a55;
    --good-soft: #ecfdf3;
    --warn: #9a6700;
    --warn-soft: #fffaeb;
    --bad: #b42318;
    --bad-soft: #fef3f2;
    --shadow: 0 8px 30px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 24px 70px rgba(16, 24, 40, 0.18);
    --radius: 14px;
    --sidebar-width: 278px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font: 15px/1.5 Inter, Aptos, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    height: 100vh;
    flex-direction: column;
    overflow-y: auto;
    color: #fff;
    background:
        radial-gradient(circle at top left, rgba(49, 111, 216, 0.2), transparent 42%),
        var(--nav);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 80px;
    padding: 18px 20px;
}

.app-brand,
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
}

.app-brand:hover { text-decoration: none; }

.app-brand strong,
.auth-brand strong {
    display: block;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.app-brand small,
.auth-brand span {
    display: block;
    margin-top: 1px;
    color: #98a2b3;
    font-size: 12px;
}

.brand-mark {
    display: inline-grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(145deg, #2f72d6, #17468b);
    box-shadow: 0 8px 22px rgba(20, 81, 171, 0.35);
    font-weight: 800;
}

.admin-mode {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 16px 12px;
    padding: 10px 12px;
    color: #fedf89;
    background: rgba(181, 120, 14, 0.16);
    border: 1px solid rgba(254, 200, 75, 0.22);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: #fdb022;
    box-shadow: 0 0 0 4px rgba(253, 176, 34, 0.13);
}

.nav {
    display: grid;
    gap: 4px;
    padding: 8px 14px 20px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    color: #d0d5dd;
    border-radius: 10px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
    text-decoration: none;
}

.nav a.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(47, 114, 214, 0.32), rgba(47, 114, 214, 0.12));
    box-shadow: inset 3px 0 #64a0ff;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.signed-in-as {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.signed-in-as > span:last-child {
    min-width: 0;
}

.signed-in-as small {
    display: block;
    color: #98a2b3;
}

.signed-in-as strong {
    display: block;
    overflow: hidden;
    color: #f2f4f7;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 50%;
    color: #dbeafe;
    background: #344054;
    font-weight: 800;
}

.main { min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 28px;
    background: rgba(255, 255, 255, 0.93);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-left strong { display: block; }

.topbar-subtitle {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.topbar form { margin: 0; }

.content {
    width: 100%;
    max-width: 1540px;
    margin: 0 auto;
    padding: 28px;
}

.page-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

h1, h2, h3 {
    color: #101828;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 { margin: 0; font-size: clamp(25px, 3vw, 32px); }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 0 0 10px; font-size: 16px; }

.muted { color: var(--muted); }

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

.card {
    min-width: 0;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric {
    margin-top: 8px;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.table-wrap {
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 13px 15px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--muted);
    background: var(--panel-soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

tbody tr:hover { background: #fbfcfe; }
tbody tr:last-child td { border-bottom: 0; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    color: #344054;
    background: #eef2f6;
    font-size: 12px;
    font-weight: 750;
    text-transform: capitalize;
}

.badge.available { color: var(--good); background: var(--good-soft); }
.badge.checked_out { color: #175cd3; background: #eff8ff; }
.badge.in_maintenance { color: var(--warn); background: var(--warn-soft); }

.btn {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    color: #344054;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.btn:hover {
    background: var(--panel-soft);
    text-decoration: none;
    box-shadow: 0 3px 10px rgba(16, 24, 40, .08);
}

.btn:active { transform: translateY(1px); }

.btn.primary {
    color: #fff;
    background: var(--brand);
    border-color: var(--brand);
}

.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); background: var(--bad-soft); border-color: #fecdca; }
.btn-large { min-height: 48px; padding: 12px 18px; }
.btn-full { width: 100%; }

.icon-button {
    display: inline-grid;
    width: 40px;
    height: 40px;
    place-items: center;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
}

.icon-button:hover { background: rgba(127, 127, 127, .1); }

.menu-button {
    display: none;
}

.menu-button span {
    display: block;
    width: 19px;
    height: 2px;
    margin: 3px 0;
    background: currentColor;
    border-radius: 10px;
}

.sidebar-close { display: none; color: #d0d5dd; font-size: 24px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 17px;
}

.stack-form { display: grid; gap: 16px; }

.field label {
    display: block;
    margin-bottom: 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 750;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 43px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    outline: none;
    transition: border .15s ease, box-shadow .15s ease;
}

.field textarea {
    min-height: 110px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: #84adf4;
    box-shadow: 0 0 0 4px rgba(47, 114, 214, .12);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.alert {
    padding: 12px 14px;
    margin: 0 0 18px;
    border-radius: 10px;
    font-weight: 600;
}

.alert.error { color: var(--bad); background: var(--bad-soft); border: 1px solid #fecdca; }
.alert.success { color: var(--good); background: var(--good-soft); border: 1px solid #abefc6; }

.photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.photo {
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.photo img {
    display: block;
    width: 100%;
    height: 155px;
    object-fit: cover;
}

.photo div { padding: 10px; }

.auth-page {
    min-height: 100vh;
    background: #eef3f9;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(360px, 1.1fr) minmax(440px, .9fr);
}

.auth-brand-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(32px, 6vw, 72px);
    color: #fff;
    background:
        radial-gradient(circle at 18% 16%, rgba(65, 135, 239, .38), transparent 28%),
        radial-gradient(circle at 75% 75%, rgba(48, 90, 173, .26), transparent 35%),
        linear-gradient(145deg, #101828, #153d78);
}

.auth-brand { align-self: flex-start; }
.auth-brand > div > span { color: #b8c7dc; }

.auth-message { max-width: 700px; }

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    color: #7aa7ec;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.auth-message h1 {
    margin-bottom: 18px;
    color: #fff;
    font-size: clamp(34px, 5vw, 58px);
}

.auth-message p {
    max-width: 630px;
    color: #cad5e4;
    font-size: 17px;
}

.security-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.security-summary span {
    padding: 7px 11px;
    color: #dce6f3;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.auth-form-panel {
    display: grid;
    place-items: center;
    padding: 28px;
}

.auth-card {
    width: min(460px, 100%);
    padding: clamp(26px, 5vw, 42px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
}

.auth-card h2 {
    margin-bottom: 8px;
    font-size: 27px;
}

.auth-help {
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.status-banner {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 22px;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 750;
}

.status-warning {
    color: var(--warn);
    background: var(--warn-soft);
    border: 1px solid #fedf89;
}

.error-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: linear-gradient(145deg, #eef3f9, #f8fafc);
}

.error-card {
    width: min(560px, 100%);
    padding: 38px;
    text-align: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
}

.error-code {
    color: var(--brand);
    font-size: 13px;
    font-weight: 850;
    letter-spacing: .15em;
}

.error-card h1 { margin: 8px 0 12px; }
.error-card p { color: var(--muted); }

.error-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 22px 0;
}

.error-card small { color: #98a2b3; }

.sidebar-overlay { display: none; }

@media (max-width: 1100px) {
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 880px) {
    .app-shell { display: block; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(var(--sidebar-width), 86vw);
        transform: translateX(-102%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }

    .nav-open .sidebar { transform: translateX(0); }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 35;
        background: rgba(16, 24, 40, .52);
    }

    .nav-open .sidebar-overlay { display: block; }
    .menu-button, .sidebar-close { display: inline-grid; }

    .content { padding: 20px; }
    .topbar { padding: 10px 18px; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand-panel { min-height: 330px; }
}

@media (max-width: 620px) {
    .grid, .form-grid { grid-template-columns: 1fr; }
    .page-title { align-items: stretch; flex-direction: column; }
    .topbar-subtitle, .no-mobile { display: none; }
    .content { padding: 16px; }
    .card { padding: 17px; }
    .auth-brand-panel { display: none; }
    .auth-form-panel { padding: 18px; }
    .auth-card { padding: 25px 20px; }
    .error-actions { flex-direction: column; }
    th, td { padding: 11px 12px; }
}

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .app-shell { display: block; }
    .content { max-width: none; padding: 0; }
    .label-sheet { display: grid; grid-template-columns: repeat(3, 2in); gap: .15in; }
    .asset-label { width: 2in; height: 1in; padding: .08in; border: 1px solid #111; page-break-inside: avoid; }
}
