/* ESL Uniforms — Internal Tool Styles */

:root {
    --navy: #1b2a4a;
    --navy-light: #2c3e6b;
    --navy-dark: #0f1a30;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --white: #ffffff;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.5;
}

/* Navigation */
nav {
    background: var(--navy);
    color: var(--white);
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: var(--shadow-md);
}

nav .brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--white);
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.nav-logo {
    height: 28px;
    width: 28px;
    max-height: 28px;
    max-width: 28px;
    object-fit: contain;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

nav a {
    color: var(--gray-200);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.15s;
}

nav a:hover {
    color: var(--white);
}

nav a.nav-active {
    color: var(--white);
    font-weight: 600;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.15rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex: 1;
    border-left: 1px solid var(--navy-light);
    padding-left: 1.25rem;
}

.nav-settings {
    margin-left: auto;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.nav-settings:hover {
    color: var(--white);
    opacity: 1;
}

/* Container */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Headings */
h1 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--navy);
}

h2 {
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
    color: var(--navy);
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--navy-light);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card h2 {
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: var(--white);
}

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

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #15803d;
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-warning:hover {
    background: #b45309;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-unprinted {
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge-printed {
    background: #dbeafe;
    color: #1e40af;
}

.badge-pressing {
    background: #fef3c7;
    color: #92400e;
}

.badge-pressed {
    background: #d1fae5;
    color: #065f46;
}

.badge-shipped, .badge-mailed {
    background: #cffafe;
    color: #155e75;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-partially-pressed {
    background: #fef9c3;
    color: #854d0e;
}

.badge-partially-mailed {
    background: #e0e7ff;
    color: #3730a3;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: var(--gray-100);
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    color: var(--gray-700);
}

td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

tr:hover {
    background: var(--gray-50);
}

/* Forms */
input[type="text"],
input[type="number"],
select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
}

/* Flash Messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: 500;
    border-left: 4px solid var(--success);
    background: #f0fdf4;
    color: #166534;
}

.flash-error {
    border-left-color: var(--danger);
    background: #fef2f2;
    color: #991b1b;
}

/* Scanner overlay */
.scanner-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--navy);
    color: var(--white);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 1000;
}

.scanner-fab:hover {
    background: var(--navy-light);
}

.scanner-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.scanner-modal.active {
    display: flex;
}

.scanner-modal-content {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    width: 90%;
    max-width: 400px;
    position: relative;
}

.scanner-modal-content h3 {
    margin-bottom: 0.75rem;
}

.scanner-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
}

#qr-reader {
    width: 100%;
}

/* Rate options */
.rate-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.rate-option:hover {
    border-color: var(--accent);
    background: #f0f7ff;
}

.rate-option input[type="radio"] {
    cursor: pointer;
}

.rate-option .rate-details {
    flex: 1;
}

.rate-option .rate-carrier {
    font-weight: 600;
}

.rate-option .rate-service {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.rate-option .rate-cost {
    font-weight: 700;
    color: var(--navy);
    font-size: 1.1rem;
}

.rate-option .rate-days {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Weighing worksheet: rows still needing a reading stand out */
tr.needs-weight td {
    background: #fffbe6;
}

tr.needs-weight td:first-child {
    box-shadow: inset 3px 0 0 var(--warning);
}

/* Just-in-time weight prompt on the ship panel */
.weigh-dialog {
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 1.25rem;
    max-width: 30rem;
    color: inherit;
    background: #fff;
}

.weigh-dialog h3 {
    margin-top: 0;
}

.weigh-dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
}

.weigh-progress {
    font-weight: 700;
    color: var(--navy);
}

/* Utility */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.text-muted {
    color: var(--gray-500);
    font-size: 0.85rem;
}

.inline-form {
    display: inline;
}

/* Lists */
ul {
    padding-left: 1.25rem;
}

li {
    margin-bottom: 0.4rem;
}

.weight-error {
    padding: 0.75rem;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    color: #92400e;
    font-size: 0.9rem;
}

/* Filter bar */
.filter-bar {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.filter-bar label {
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Multi-select dropdown */
.dropdown-multi {
    position: relative;
    display: inline-block;
}

.dropdown-multi-btn {
    min-width: 120px;
    text-align: left;
}

.dropdown-multi-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 250px;
    overflow-y: auto;
    min-width: 280px;
    z-index: 100;
    padding: 0.25rem 0;
}

.dropdown-multi-menu.open {
    display: block;
}

.dropdown-multi-item {
    display: block;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.dropdown-multi-item:hover {
    background: var(--gray-100);
}

.dropdown-multi-item input[type="checkbox"] {
    width: 0.9rem;
    height: 0.9rem;
    margin-right: 0.4rem;
    vertical-align: middle;
}

/* Active filter tags */
#active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.8rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #dbeafe;
    color: #1e40af;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.filter-tag button {
    background: none;
    border: none;
    cursor: pointer;
    color: #1e40af;
    font-size: 0.85rem;
    padding: 0;
    line-height: 1;
}

/* Session bar */
.session-bar {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.mode-toggle {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
}

/* Scan input */
#scan-input {
    font-size: 1.1rem;
    padding: 0.5rem 0.75rem;
}

/* Press order rows */
.press-order-row:hover {
    background: var(--gray-100);
}

/* QR reader in scan mode */
#press-qr-reader {
    max-width: 350px;
    margin: 0 auto;
}

/* QR reader on the mail station: same constraint, own id so the press
   station's rule stays untouched. */
#mail-qr-reader {
    max-width: 350px;
    margin: 0 auto;
}

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { display: flex; flex-direction: column; gap: 0.5rem; width: 320px; padding: 2rem; border: 1px solid #ddd; border-radius: 8px; }
.login-logo { width: 64px; align-self: center; }
.login-error { color: #b00020; margin: 0; }
.login-card .button { display: block; text-align: center; text-decoration: none; padding: 0.5rem 1rem; border: 1px solid #1a73e8; border-radius: 4px; background: #1a73e8; color: #fff; cursor: pointer; }
.login-card .button:hover { background: #1557b0; border-color: #1557b0; }
.nav-right { display: flex; align-items: center; gap: 0.75rem; }
.nav-user { font-size: 0.9rem; opacity: 0.8; }
.nav-logout { margin: 0; }
.nav-logout button { background: none; border: 1px solid currentColor; border-radius: 4px; padding: 0.2rem 0.6rem; cursor: pointer; font-size: 0.85rem; }

.flash-warning { padding: 0.75rem 1rem; margin-bottom: 1rem; border-left: 4px solid #d97706; background: #fef3c7; color: #78350f; }
.warn-note { display: inline-block; font-size: 0.8rem; color: #92400e; background: #fef3c7; padding: 0.1rem 0.4rem; border-radius: 3px; margin-left: 0.5rem; }

.station-banner { padding: 0.75rem 1rem; margin-bottom: 1rem; border-left: 4px solid #b91c1c; background: #fee2e2; color: #7f1d1d; }

/* A bad-address badge in a table cell: loud enough to stop a label being
   bought blind, quiet enough that it is not mistaken for an error. */
.text-warning { color: #b45309; font-weight: 600; }

/* --- Mail station: queue on the left, one order on the right -------------
 *
 * The queue column is fixed-width and sticky so the scan box stays reachable
 * however long the order on the right becomes. Below 900px the columns stack,
 * queue first, which is the order a phone at the mailing table wants.
 */

/* The mail station needs the width: 960px leaves the work panel so narrow
 * that the operator scrolls for every parcel, which is the whole thing the
 * two columns exist to avoid. */
.container-wide {
    max-width: 1600px;
}

.mail-layout {
    display: grid;
    grid-template-columns: 19rem minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.mail-queue {
    position: sticky;
    top: 1rem;
    /* The column itself no longer scrolls. Scrolling it moved the scan card
     * and the camera preview off screen while the operator was looking
     * through Ready to ship, which is exactly when they need the camera. Each
     * list scrolls inside its own card instead. */
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* The scan card keeps its full height; only the lists give way. */
.mail-queue > .card {
    flex: 0 0 auto;
    margin-bottom: 0;
}

.mail-queue > .card.queue-card {
    /* Shrinks to share what is left, and scrolls inside itself. */
    flex: 1 1 auto;
    min-height: 6rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* The heading and the explanation stay visible; the rows move. */
.queue-card .queue-list {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.mail-work {
    min-width: 0;
}

.queue-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.queue-list li {
    padding: 0.35rem 0;
    border-bottom: 1px solid #eee;
}

.queue-list li:last-child {
    border-bottom: none;
}

.queue-list a {
    text-decoration: none;
}

.queue-list a:hover {
    text-decoration: underline;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.panel-head h2 {
    margin: 0;
}

@media (max-width: 760px) {
    .mail-layout {
        grid-template-columns: 1fr;
    }

    /* Stacked on a narrow screen there is nothing to keep in view, so the
     * page scrolls normally and the lists are shown in full. */
    .mail-queue {
        position: static;
        max-height: none;
        display: block;
    }

    .mail-queue > .card {
        margin-bottom: 1rem;
    }

    .mail-queue > .card.queue-card {
        display: block;
        overflow: visible;
    }

    .queue-card .queue-list {
        overflow-y: visible;
    }
}

/* Shown while a label purchase is in flight. The wait is a carrier round
 * trip, long enough to read as nothing having happened. */
.buy-status {
    font-size: 0.9rem;
    color: #8a5a00;
    align-self: center;
}

/* The number grid, on the admin Numbers page. Cells are fixed width so the
   grid reads as a grid at every team size, and the three states are told
   apart by colour and by the holder name under the number. */
.number-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.number-cell {
    width: 84px;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
}

.number-value { display: block; font-size: 18px; font-weight: bold; }
.number-holder { display: block; color: #555; font-size: 11px; }
.number-free { background: #ffffff; }
.number-reserved { background: #fff6d8; }
.number-committed { background: #e3efe0; }
.number-conflict { background: #fde2e1; border-color: #c0392b; }

/* The change request queue. One row per request, with the order beside it. */
.request-row { border: 1px solid #ddd; border-radius: 6px; padding: 0.75rem; margin-bottom: 0.75rem; }
.request-row-head { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: baseline; }
.request-row-kind { text-transform: uppercase; letter-spacing: 0.03em; }
.request-row-status, .request-row-store, .request-row-family { color: #666; font-size: 0.85rem; }
.request-row-items { margin: 0.4rem 0; padding-left: 1.2rem; }
.request-row-note, .request-row-change, .request-row-item { margin: 0.4rem 0; }
.request-row-warning { color: #a3352b; font-weight: 600; }
.request-row-ok { color: #1f7a3f; }
.request-row-message { background: #eef6ee; padding: 0.5rem; border-radius: 4px; }
.request-row-decision, .request-row-decider { color: #444; font-size: 0.9rem; }
.request-row-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.5rem; }
.request-row-form input[type="text"] { flex: 1 1 18rem; }
.request-money-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.5rem; }
.request-views a { margin-right: 0.75rem; }

/* Inventory: stock, its movements and the queue the sync could not map. */
.stock-table, .movement-list { width: 100%; border-collapse: collapse; }
.stock-table th, .stock-table td,
.movement-list th, .movement-list td {
    border-bottom: 1px solid #e4e4e4; padding: 0.35rem 0.5rem; text-align: left;
}
.stock-table .stock-count, .movement-list .movement-delta {
    text-align: right; font-variant-numeric: tabular-nums;
}
/* A highlight, never a block: a low row is an ordering decision for staff. */
.stock-table tr.low-stock { background: #fff6d8; }
.stock-table tr.low-stock .stock-count { font-weight: 700; color: #a3352b; }
.stock-views a { margin-right: 0.75rem; }
.sync-status { color: #444; }
.nav-badge {
    background: #a3352b; color: #fff; border-radius: 10px;
    padding: 0 0.4rem; font-size: 0.75rem;
}
.review-item { border: 1px solid #ddd; border-radius: 6px; padding: 0.6rem; margin-bottom: 0.6rem; }
.review-item-what { font-weight: 600; }
.review-item-ref { color: #666; font-size: 0.85rem; }
.review-item-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.4rem; }
.adjust-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.adjust-form input[type="text"] { flex: 1 1 12rem; }
