:root {
    --bg: #071019;
    --panel: rgba(255,255,255,.04);
    --border: rgba(255,255,255,.08);
    --text: #e7eef7;
    --muted: rgba(231,238,247,.72);
    --btn-bg: rgba(0,0,0,.18);
    --btn-bd: rgba(255,255,255,.14);
    --primary-bg: #0b3b2c;
    --danger-bg: rgba(255,65,65,.15);
    --danger-bd: rgba(255,65,65,.35);
    --radius: 18px;
    --radius-sm: 12px;
    --container: 1100px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

    body.page {
        margin: 0;
        font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
        background: radial-gradient(900px 420px at 20% 0%, rgba(0,180,140,.18), transparent 55%), radial-gradient(900px 420px at 80% 0%, rgba(70,130,255,.12), transparent 55%), var(--bg);
        color: var(--text);
        -webkit-text-size-adjust: 100%; /* prevent iOS font inflation */
    }

a {
    color: inherit;
}

/* Layout */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 18px 16px 46px;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(7,16,25,.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar__inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: nowrap; /* stays one row on desktop */
}

/* ── Brand block (left side) ─────────────────────────────────────────────── */
.topbar__brand {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex-shrink: 0;
    min-width: 0;
}

.topbar__company {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #59ff9a;
    line-height: 1;
}

.topbar__title {
    font-size: 18px;
    font-weight: 850;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__meta {
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    white-space: nowrap;
}

.pill {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--btn-bd);
    border-radius: 999px;
    color: rgba(231,238,247,.86);
    font-size: 10px;
    white-space: nowrap;
}

/* ── Nav + right side ────────────────────────────────────────────────────── */
.topbar__right {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
    overflow: hidden;
}

.nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 1;
    min-width: 0;
}

.nav::-webkit-scrollbar { display: none; }

.nav__link {
    display: inline-block;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .12s, color .12s;
    border: 1px solid transparent;
}

.nav__link:hover {
    background: rgba(255,255,255,.07);
    color: var(--text);
}

.nav__link.is-active {
    background: rgba(255,255,255,.10);
    color: #fff;
    border-color: rgba(255,255,255,.16);
}

/* ── Page head (title + actions row) ────────────────────────────────────── */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.page-head__title {
    font-size: 22px;
    font-weight: 900;
}

.page-head__sub {
    margin-top: 2px;
}

/* Cards */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.20);
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.card__title {
    font-size: 16px;
    font-weight: 850;
}

.small {
    font-size: 12px;
}

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

.divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,.10);
    margin: 12px 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: var(--radius-sm);
    border: 1px solid var(--btn-bd);
    padding: 10px 14px;
    background: var(--btn-bg);
    color: var(--text);
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 700;
    touch-action: manipulation; /* faster tap on iOS */
    -webkit-tap-highlight-color: transparent;
}

.btn--sm {
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 13px;
}

.btn--ghost {
    background: rgba(26,42,61,.55);
}

.btn--primary {
    background: var(--primary-bg);
}

.btn--danger {
    background: var(--danger-bg);
    border-color: var(--danger-bd);
    color: #ffd6d6;
}

.inline {
    margin: 0;
    display: inline;
}

/* Flash messages */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-weight: 700;
    font-size: 14px;
}
.flash--success { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.25); color: #34d399; }
.flash--error   { background: rgba(255,65,65,.10);  border: 1px solid rgba(255,65,65,.22);  color: #fca5a5; }

/* Progress */
.progress__pct {
    font-weight: 900;
    color: #59ff9a;
}

.progress {
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,.10);
    margin-bottom: 8px;
}

.progress__fill {
    height: 100%;
    border-radius: 999px;
    background: #28a745;
}

/* Assignments list */
.stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 14px;
    background: rgba(0,0,0,.12);
}

.row__title {
    font-weight: 800;
}

.row__sub {
    margin-top: 2px;
}

/* Forms */
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-field--grow {
    flex: 1;
    min-width: 200px;
}

.form-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--muted);
}

.form-section-label {
    font-size: 13px;
    font-weight: 850;
    color: var(--text);
    margin-top: 4px;
}

.field-hint {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.5;
}

.field-error {
    font-size: 12px;
    color: #fca5a5;
}

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

.required { color: #f87171; }

.assign {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
}

.photo-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin: 0 0 12px 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field--grow {
    flex: 1;
    min-width: 220px;
}

.label {
    font-size: 12px;
    color: var(--muted);
}

.input {
    min-width: 0;        /* was 220px — that breaks mobile */
    width: 100%;
    max-width: 100%;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid var(--btn-bd);
    background: rgba(0,0,0,.20);
    color: var(--text);
    outline: none;
    font: inherit;
    font-size: 16px;     /* prevents iOS auto-zoom on focus */
}

.input--sm {
    padding: 8px 10px;
    font-size: 14px;
}

select.input {
    background-color: #0d1d2b;
    color: #e7eef7;
    cursor: pointer;
}

select.input option {
    background-color: #0d1d2b;
    color: #e7eef7;
}

.file {
    max-width: 100%;
}

textarea.input {
    resize: vertical;
    min-height: 60px;
}

/* Toggle */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

/* Data tables - scrollable on mobile */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px; /* forces scroll before squishing columns */
}

.data-table th {
    padding: 12px 14px;
    text-align: left;
    font-size: 11px;
    color: var(--muted);
    font-weight: 800;
    letter-spacing: .3px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

/* Action row in tables */
.action-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

/* Galleries */
.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.thumb {
    width: 160px;
    margin: 0;
}

.thumb__img {
    width: 160px;
    height: 120px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.12);
    display: block;
}

.thumb__cap {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

/* Checklist */
.section-label, .section-title {
    margin-top: 14px;
    font-weight: 950;
    letter-spacing: .5px;
    color: rgba(231,238,247,.88);
}

.task {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.task__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.task__name {
    font-weight: 800;
}

.task__form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.task__photos {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* Mini thumbs */
.mini-gallery {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mini-thumb__img {
    width: 110px;
    height: 80px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.12);
    display: block;
}

/* ══════════════════════════════════════════════════════════════
   MOBILE BREAKPOINTS
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet (≤900px) — topbar stacks ─────────────────────────────────────── */
@media (max-width: 900px) {
    .topbar__inner {
        flex-wrap: wrap;
        padding: 10px 14px;
        gap: 6px;
    }

    /* Brand takes full width so nav drops to its own row */
    .topbar__brand {
        flex: 1 0 100%;
    }

    /* Nav row: full width, scrollable */
    .topbar__right {
        flex: 1 0 100%;
        overflow-x: auto;
        justify-content: flex-start;
    }

    .nav {
        flex: 1;
        max-width: calc(100% - 80px); /* leave room for Logout button */
    }

    .topbar__company {
        font-size: 10px;
    }

    .topbar__title {
        font-size: 16px;
    }

    .container {
        padding: 14px 12px 36px;
    }
}

/* ── Phone (≤520px) — full single-column layout ──────────────────────────── */
@media (max-width: 520px) {
    /* Topbar */
    .topbar__inner {
        padding: 8px 12px;
    }

    .topbar__title {
        font-size: 15px;
    }

    .topbar__meta {
        font-size: 10px;
        gap: 4px;
    }

    .nav {
        max-width: calc(100% - 70px);
    }

    .nav__link {
        padding: 6px 8px;
        font-size: 11px;
    }

    /* Logout button smaller */
    .topbar__right > form .btn,
    .topbar__right > .btn {
        padding: 7px 12px;
        font-size: 12px;
    }

    /* Container */
    .container {
        padding: 10px 10px 30px;
    }

    /* Cards */
    .card {
        border-radius: 14px;
        padding: 12px;
    }

    /* Inputs - 16px prevents iOS zoom */
    .input {
        font-size: 16px;
        padding: 12px 10px;
    }

    /* Photo thumbnails */
    .thumb {
        width: 48%;
    }

    .thumb__img {
        width: 100%;
        height: 120px;
    }

    /* Form rows stack on phone */
    .form-row {
        flex-direction: column;
    }

    .form-field--grow {
        min-width: 0;
    }

    /* Page head stacks title + button */
    .page-head {
        flex-direction: column;
        gap: 10px;
    }

    .page-head > div:last-child {
        width: 100%;
    }

    .page-head > div:last-child .btn {
        width: 100%;
        justify-content: center;
    }

    /* Action buttons in tables - stack vertically */
    .action-row {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Table wrapper enforces scroll */
    .table-wrap {
        margin: 0 -12px;
        border-radius: 0;
    }
}
