/* Parking Tracker
   Palette:
   --ink      #14213D  deep navy  - headers, text
   --paper    #F6F7F5  soft white - background
   --card     #FFFFFF  card surface
   --line     #E3E6E1  hairline borders
   --go       #1E7D45  available green (AA contrast on white)
   --go-bg    #E7F5EC
   --stop     #B3241C  full red
   --stop-bg  #FCEAE8
   --amber    #C97A1F  admin / edit accent
   Type: system UI stack for speed + native mobile feel; numerals get
   tabular-nums so stall counts don't jitter.
*/

:root {
    --ink: #14213D;
    --ink-soft: #4B5670;
    --paper: #F6F7F5;
    --card: #FFFFFF;
    --line: #E3E6E1;
    --go: #1E7D45;
    --go-bg: #E7F5EC;
    --stop: #B3241C;
    --stop-bg: #FCEAE8;
    --amber: #C97A1F;
    --amber-bg: #FBF0E1;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20,33,61,0.06), 0 4px 14px rgba(20,33,61,0.06);
    font-size: 17px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    padding-bottom: 2.5rem;
}

a { color: inherit; }

.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.topbar {
    background: var(--ink);
    color: #fff;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.topbar-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(155deg, #2B62C4, #1E7D45 130%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.topbar h1 {
    font-size: 1.05rem;
    margin: 0;
    font-weight: 700;
    line-height: 1.15;
}
.topbar .sub {
    font-size: 0.72rem;
    color: #B9C2DE;
    margin: 0;
    letter-spacing: 0.02em;
}
.topbar-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.topbar-actions a {
    text-decoration: none;
    font-size: 0.82rem;
    color: #DCE2F2;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
}
.topbar-actions a:active { background: rgba(255,255,255,0.12); }

main.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem 1rem 0;
}

/* ---------- Login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.25rem;
}
.login-card {
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 2rem 1.6rem;
    width: 100%;
    max-width: 380px;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}
.login-brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(155deg, #2B62C4, #1E7D45 130%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.login-brand h1 { font-size: 1.1rem; margin: 0; }
.login-sub { margin: 0.1rem 0 0; font-size: 0.78rem; color: var(--ink-soft); }
.login-area {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    margin: 0 0 1rem;
}
.login-error {
    background: var(--stop-bg);
    color: var(--stop);
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}
.login-card form { display: flex; flex-direction: column; gap: 0.6rem; }
.login-card label { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }
.login-card input[type="password"] {
    font-size: 1.05rem;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    border: 1.5px solid var(--line);
    background: var(--paper);
}
.login-card input[type="password"]:focus {
    outline: 3px solid #2B62C4;
    outline-offset: 1px;
    border-color: #2B62C4;
}
.login-card button {
    margin-top: 0.4rem;
    background: var(--ink);
    color: #fff;
    border: none;
    padding: 0.8rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}
.login-card button:active { opacity: 0.85; }

/* ---------- Sort bar ---------- */
.sortbar {
    display: flex;
    gap: 0.5rem;
    margin: 0.9rem 0 1rem;
    overflow-x: auto;
    padding-bottom: 2px;
}
.sortbar a {
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--line);
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    white-space: nowrap;
}
.sortbar a.active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

.summary-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.9rem;
}
.summary-chip {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.7rem 0.8rem;
    text-align: center;
}
.summary-chip .num { font-size: 1.35rem; font-weight: 800; display: block; }
.summary-chip .lbl { font-size: 0.72rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.summary-chip.go .num { color: var(--go); }
.summary-chip.stop .num { color: var(--stop); }

/* ---------- Lot cards (dashboard) ---------- */
.lot-list { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1.5rem; }

.lot-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    border-left: 5px solid var(--line);
}
.lot-card.is-available { border-left-color: var(--go); }
.lot-card.is-full { border-left-color: var(--stop); }

.indicator {
    flex-shrink: 0;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-weight: 800;
    line-height: 1;
}
.indicator.go { background: var(--go-bg); color: var(--go); }
.indicator.stop { background: var(--stop-bg); color: var(--stop); }
.indicator .count { font-size: 1.3rem; }
.indicator .count-lbl { font-size: 0.55rem; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 1px; }
.indicator .glyph { font-size: 1.4rem; }

.lot-info { flex: 1; min-width: 0; }
.lot-info h3 { margin: 0 0 0.15rem; font-size: 1.02rem; }
.lot-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.7rem;
    font-size: 0.78rem;
    color: var(--ink-soft);
}
.lot-meta span { display: inline-flex; align-items: center; gap: 0.25rem; }
.status-word {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    flex-shrink: 0;
    align-self: flex-start;
}
.status-word.go { background: var(--go-bg); color: var(--go); }
.status-word.stop { background: var(--stop-bg); color: var(--stop); }

.empty-state {
    text-align: center;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 2.2rem 1rem;
    font-size: 0.92rem;
}

/* ---------- Update page: lot picker + form ---------- */
.lot-picker { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.4rem; }
.lot-picker button {
    all: unset;
    cursor: pointer;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border-left: 5px solid var(--line);
}
.lot-picker button.is-available { border-left-color: var(--go); }
.lot-picker button.is-full { border-left-color: var(--stop); }
.lot-picker button:active { background: #F0F1EE; }
.lot-picker .lot-info { flex: 1; }
.lot-picker .lot-info h3 { margin: 0 0 0.1rem; font-size: 1rem; }
.lot-picker .lot-info p { margin: 0; font-size: 0.78rem; color: var(--ink-soft); }
.chevron { color: var(--ink-soft); font-size: 1.2rem; }

.update-form {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    margin-bottom: 1.4rem;
}
.update-form h2 { margin: 0 0 0.2rem; font-size: 1.1rem; }
.update-form .lot-sub { margin: 0 0 1rem; color: var(--ink-soft); font-size: 0.85rem; }

.status-toggle {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.status-toggle label {
    flex: 1;
    text-align: center;
    padding: 0.9rem 0.5rem;
    border-radius: 12px;
    border: 2px solid var(--line);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--ink-soft);
}
.status-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.status-toggle input:checked + span { display: block; }
.status-toggle label.opt-available:has(input:checked) { background: var(--go-bg); border-color: var(--go); color: var(--go); }
.status-toggle label.opt-full:has(input:checked) { background: var(--stop-bg); border-color: var(--stop); color: var(--stop); }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 0.35rem; }
.field input[type=number], .field input[type=text], .field select {
    width: 100%;
    font-size: 1.05rem;
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    border: 1.5px solid var(--line);
    background: var(--paper);
}
.field .hint { font-size: 0.75rem; color: var(--ink-soft); margin-top: 0.3rem; }

.btn-primary {
    width: 100%;
    background: var(--ink);
    color: #fff;
    border: none;
    padding: 0.9rem;
    border-radius: 12px;
    font-size: 1.02rem;
    font-weight: 700;
    cursor: pointer;
}
.btn-primary:active { opacity: 0.85; }
.btn-secondary {
    width: 100%;
    background: transparent;
    color: var(--ink-soft);
    border: 1.5px solid var(--line);
    padding: 0.8rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.6rem;
    text-align: center;
    display: block;
    text-decoration: none;
}

.flash {
    background: var(--go-bg);
    color: var(--go);
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
.flash.error { background: var(--stop-bg); color: var(--stop); }

/* ---------- Admin ---------- */
.admin-section {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    margin-bottom: 1.4rem;
}
.admin-section h2 { margin: 0 0 1rem; font-size: 1.05rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th, .admin-table td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.admin-table th { color: var(--ink-soft); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
.pill {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}
.pill.go { background: var(--go-bg); color: var(--go); }
.pill.stop { background: var(--stop-bg); color: var(--stop); }
.row-actions { display: flex; gap: 0.5rem; }
.row-actions a, .row-actions button {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}
.row-actions .danger { color: var(--stop); border-color: #F0C9C5; }
.admin-add-btn {
    display: inline-block;
    background: var(--amber);
    color: #fff;
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

.table-scroll { overflow-x: auto; }

@media (max-width: 480px) {
    .grid-2 { grid-template-columns: 1fr; }
    .admin-table { font-size: 0.78rem; }
}
