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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f0f4f8;
    min-height: 100vh;
    color: #1a1a2e;
}

.container { max-width: 820px; margin: 0 auto; padding: 12px 14px 40px; }

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 16px;
}

h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; margin-bottom: 10px; }

/* Logo in header */
.header-logo { height: 34px; width: auto; display: block; max-width: 160px; }

/* Full-screen PIN layout (index.html) */
.pin-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f4f8;
    padding: 24px;
}
.pin-screen-inner {
    text-align: center;
    width: 100%;
    max-width: 300px;
}
.pin-screen-logo {
    max-width: 220px;
    height: auto;
    margin: 0 auto 36px;
    display: block;
}

.back-btn {
    background: none;
    border: none;
    color: #1a73e8;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px 4px 0;
}

/* Language toggle */
.lang-toggle { display: flex; gap: 6px; }
.lang-toggle button {
    padding: 5px 13px;
    border: 2px solid #1a73e8;
    background: white;
    color: #1a73e8;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
}
.lang-toggle button.active { background: #1a73e8; color: white; }

/* Role grid */
.role-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 20px;
}
@media (min-width: 520px) { .role-grid { grid-template-columns: repeat(3, 1fr); } }

.role-btn {
    padding: 28px 20px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,.1);
    transition: transform .1s;
    width: 100%;
    text-align: left;
}
.role-btn:active { transform: scale(.97); }
.role-icon { font-size: 2rem; }
.admin-btn   { background: #e3f2fd; color: #1565c0; }
.yard-btn    { background: #fff3e0; color: #bf360c; }
.forklift-btn{ background: #e8f5e9; color: #1b5e20; }

/* Card */
.card {
    background: white;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge-arriving     { background: #bbdefb; color: #0d47a1; }
.badge-yard_checked { background: #b2dfdb; color: #00695c; }
.badge-loading      { background: #c8e6c9; color: #1b5e20; animation: blink 2s infinite; }
.badge-finished     { background: #ffe0b2; color: #e65100; }
.badge-parked       { background: #e1bee7; color: #7b1fa2; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ADR — green = has ADR (confirmed), red = no ADR */
.adr-yes { color: #1b8a3e; font-weight: 700; }
.adr-no  { color: #c62828; font-weight: 700; }

/* Forms */
.form-group { margin-bottom: 12px; }
label { display: block; font-weight: 600; font-size: .85rem; color: #555; margin-bottom: 4px; }
input, select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: #fafafa;
}
input:focus, select:focus { outline: none; border-color: #1a73e8; background: white; }

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .15s;
    margin-top: 8px;
}
.btn:active { opacity: .8; }
.btn-primary { background: #1a73e8; color: white; }
.btn-success { background: #1b8a3e; color: white; }
.btn-danger  { background: #c62828; color: white; }
.btn-warning { background: #f9a825; color: #333; }
.btn-gray    { background: #9e9e9e; color: white; }
.btn-outline { background: white; border: 2px solid #1a73e8; color: #1a73e8; }

.btn-sm { display: inline-block; width: auto; padding: 7px 14px; font-size: .85rem; margin-top: 0; }

.btn-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.btn-2col .btn { margin-top: 0; }

/* Truck info grid */
.truck-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 6px 0 4px;
    font-size: .88rem;
    color: #555;
}
.truck-meta strong { color: #1a1a2e; }

/* Loading time */
.loading-time { font-size: .82rem; color: #555; margin-top: 5px; }

/* Section header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 18px 0 8px;
}

/* Empty state */
.empty-state { text-align: center; padding: 36px 20px; color: #9e9e9e; }
.empty-icon  { font-size: 3rem; margin-bottom: 8px; }

/* Notification banner */
.notif-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff8e1;
    border: 1px solid #f9a825;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: .9rem;
}

/* Gate grid */
.gate-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-top: 10px;
}
@media (min-width: 480px) { .gate-grid { grid-template-columns: repeat(10, 1fr); } }

.gate-cell {
    padding: 10px 4px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: .85rem;
    border: 2px solid #ccc;
    background: #eee;
    color: #444;
    user-select: none;
    transition: all .15s;
}
.gate-cell.active {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #1b5e20;
}
.gate-cell:active { transform: scale(.93); }

/* Priority border + tint */
.priority-blue   { border-left: 4px solid #1a73e8; background: #e8f0fd; }
.priority-red    { border-left: 4px solid #c62828; background: #ffebee; }
.priority-green  { border-left: 4px solid #1b8a3e; background: #e8f5e9; }
.priority-orange { border-left: 4px solid #f9a825; background: #fff8e1; }
.priority-gray   { border-left: 4px solid #9e9e9e; background: #f5f5f5; opacity: .85; }
.priority-teal   { border-left: 4px solid #00897b; background: #e0f2f1; }
.priority-purple { border-left: 4px solid #7b1fa2; background: #f3e5f5; }

/* Phase section header */
.phase-header {
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .09em;
    padding: 3px 10px;
    margin: 14px 0 4px;
    border-left: 3px solid currentColor;
}

/* Range chip button (yard marshal header) */
.range-chip-btn {
    background: #f0f0f0;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: .8rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    line-height: 1.4;
}
.range-chip-btn.active {
    background: #e8f5e9;
    border-color: #1b8a3e;
    color: #1b8a3e;
}

/* History table */
.history-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.history-table th { text-align: left; padding: 6px 8px; color: #555; font-weight: 600; border-bottom: 2px solid #eee; }
.history-table td { padding: 7px 8px; border-bottom: 1px solid #f0f0f0; }

/* Check form */
.check-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid #eee; }
.check-form .tn-input { font-size: 1.6rem; text-align: center; letter-spacing: .2em; font-weight: 700; }

/* ── Gate map (admin) ─────────────────────────────────────────────────────── */
.gate-map {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
@media (min-width: 420px) { .gate-map { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 580px) { .gate-map { grid-template-columns: repeat(5, 1fr); } }

.gm-cell {
    border-radius: 12px;
    padding: 12px 6px 10px;
    cursor: pointer;
    color: white;
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    transition: transform .1s, box-shadow .1s;
    user-select: none;
}
.gm-cell:active { transform: scale(.94); }
.gm-cell.gm-selected {
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px #1a73e8 !important;
    transform: scale(1.04);
}
.gm-num  { font-size: 1.25rem; font-weight: 900; line-height: 1; }
.gm-dest { font-size: .65rem; opacity: .9; white-space: nowrap; overflow: hidden; max-width: 72px; text-overflow: ellipsis; }
.gm-tn   { font-size: .65rem; opacity: .8; }
.gm-plus { font-size: 1.6rem; opacity: .6; line-height: 1; }

/* ── PIN modal ────────────────────────────────────────────────────────────── */
.pin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.pin-overlay.open { display: flex; }

.pin-box {
    background: white;
    border-radius: 20px;
    padding: 28px 24px 24px;
    width: 310px;
    max-width: 92vw;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.pin-role { text-align: center; font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.pin-hint { text-align: center; color: #777; font-size: .85rem; margin-bottom: 18px; }
.pin-display {
    font-size: 2rem;
    letter-spacing: .4em;
    text-align: center;
    margin-bottom: 20px;
    font-weight: 700;
    transition: color .2s;
    padding-left: .4em; /* compensate letter-spacing on last char */
}
.pin-display.error { color: #c62828; }

.pin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}
.pin-grid button {
    padding: 18px 0;
    font-size: 1.4rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    background: #f0f4f8;
    color: #1a1a2e;
    cursor: pointer;
    transition: background .1s;
}
.pin-grid button:active { background: #d0d8e4; }
.pin-cancel {
    display: block; width: 100%; padding: 10px;
    border: none; background: none;
    color: #9e9e9e; cursor: pointer; font-size: .9rem;
}

@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%,60% { transform: translateX(-8px); }
    40%,80% { transform: translateX(8px); }
}

.section-toggle {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; margin: 8px 0 4px;
    background: #eeeeee; border-radius: 8px;
    font-size: .85rem; font-weight: 700; color: #555;
    cursor: pointer; user-select: none;
}
.section-toggle:active { opacity: .75; }

.gate-range-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    background: white; border-radius: 10px; padding: 10px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07); margin-bottom: 12px;
}
.gate-range-bar label { font-size: .8rem; font-weight: 700; color: #555; white-space: nowrap; }
.gate-range-bar input[type=number] {
    width: 58px; padding: 8px 4px; border: 2px solid #ddd; border-radius: 8px;
    font-size: 1.1rem; font-weight: 700; text-align: center; background: #fafafa;
}
.gate-range-bar input:focus { border-color: #1a73e8; outline: none; background: white; }
.notif-row {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 8px 0 2px; border-top: 1px solid #eee; margin-top: 6px; width: 100%;
}
