/* ===================== DoomDash theme ===================== */
:root {
    --red: #E11900;
    --red-bright: #FF1A1A;
    --red-dark: #B11200;

    /* Light theme (default) */
    --t-bg: #E9EBEE;
    --t-card: #FFFFFF;
    --t-inset: #F4F5F7;
    --t-text: #16181D;
    --t-muted: #6B7280;
    --t-line: #E7E9EC;
    --t-shadow: 0 12px 44px rgba(0,0,0,.18);
    --t-grip: #D8DADE;
    --t-toggle-bg: #FFFFFF;
}
[data-theme="dark"] {
    --t-bg: #0A0A0C;
    --t-card: #1A1B20;
    --t-inset: #232429;
    --t-text: #F1F2F4;
    --t-muted: #9BA0A8;
    --t-line: #2B2D33;
    --t-shadow: 0 12px 44px rgba(0,0,0,.6);
    --t-grip: #3A3C42;
    --t-toggle-bg: #1F2126;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink, #16181D);
    background: var(--bg, #f5f5f5);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--t-muted); }
.hidden { display: none !important; }

/* ===================== Landing ===================== */
.landing { background: radial-gradient(120% 80% at 50% 0%, #2a0d0a 0%, #120606 55%, #0b0405 100%); min-height: 100vh; }
.landing-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; padding: 20px; }
.landing-card { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(8px);
    border-radius: 24px; padding: 40px 32px; width: 100%; max-width: 420px; text-align: center; color: #fff; }
.landing-logo { width: 96px; height: 96px; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(255,26,26,.45)); }
.landing-word { width: 220px; max-width: 80%; display: block; margin: 8px auto 0; object-fit: contain; }
.landing-card h2 { margin: 14px 0 6px; font-weight: 800; }
.landing-tag { color: #c9c9c9; margin: 6px 0 22px; font-size: 15px; }
.code-form { display: flex; gap: 8px; }
.code-form input { flex: 1; padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,.15);
    background: rgba(0,0,0,.3); color: #fff; font-size: 16px; outline: none; }
.code-form input::placeholder { color: #8a8a8a; }
.code-form button { padding: 14px 22px; border: none; border-radius: 12px; background: var(--red); color: #fff;
    font-weight: 800; font-size: 16px; cursor: pointer; transition: background .15s; }
.code-form button:hover { background: var(--red-bright); }
.demo-link { display: inline-block; margin-top: 18px; color: #ff8a80; font-weight: 600; font-size: 14px; }
.landing-help { margin-top: 16px; color: #8a8a8a; font-size: 13px; }
.admin-corner { position: absolute; top: 18px; right: 22px; color: #888; font-size: 13px; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; text-align: left; }
.flash.error { background: #3a0f0f; color: #ffb4ac; border: 1px solid #6b1f1f; }
.flash.ok { background: #0f2a16; color: #b6f0c4; border: 1px solid #1f6b3a; }

/* ===================== Tracking ===================== */
body.track { background: var(--t-bg); color: var(--t-text); }
.app { position: relative; max-width: 540px; margin: 0 auto; min-height: 100vh; background: var(--t-bg); }
.map { height: 46vh; min-height: 320px; width: 100%; z-index: 1; background: var(--t-inset); }

/* Floating controls over the map */
.brand-logo { position: absolute; top: 16px; left: 16px; z-index: 600; background: var(--t-toggle-bg);
    border-radius: 50%; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; box-shadow: var(--t-shadow); }
.brand-logo img { width: 30px; height: 30px; object-fit: contain; }
.theme-toggle { position: fixed; top: 16px; right: 16px; z-index: 600; width: 46px; height: 46px; border-radius: 50%;
    border: none; cursor: pointer; background: var(--t-toggle-bg); box-shadow: var(--t-shadow); font-size: 20px; line-height: 1;
    display: flex; align-items: center; justify-content: center; }
[data-theme="light"] .theme-toggle .ic-moon { display: inline; }
[data-theme="light"] .theme-toggle .ic-sun { display: none; }
[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
[data-theme="dark"] .theme-toggle .ic-sun { display: inline; }

/* Panel (mobile bottom-sheet) */
.panel { position: relative; margin-top: -20px; background: var(--t-card); color: var(--t-text);
    border-radius: 22px 22px 0 0; padding: 6px 18px 40px; z-index: 400; box-shadow: 0 -8px 24px rgba(0,0,0,.14); }
.panel-head { display: none; }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--t-grip); margin: 8px auto 14px; }

/* Delivered photo */
.delivered-photo { margin: 4px 0 18px; border-radius: 16px; overflow: hidden; position: relative; border: 1px solid var(--t-line); }
.delivered-photo img { width: 100%; display: block; max-height: 260px; object-fit: cover; background: var(--t-inset); }
.delivered-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px;
    background: linear-gradient(transparent, rgba(0,0,0,.78)); color: #fff; font-weight: 800; font-size: 15px; }
.delivered-cap .check { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
    background: #2ecc71; color: #fff; font-size: 13px; margin-right: 6px; vertical-align: middle; }

.eta-block { text-align: center; padding: 8px 0 2px; }
.eta-label { font-size: 13px; color: var(--t-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.eta-time { font-size: 40px; font-weight: 900; line-height: 1.1; letter-spacing: -1px; color: var(--t-text); }
.eta-time.range { font-size: 26px; letter-spacing: 0; }
.eta-mins { font-size: 15px; color: var(--red); font-weight: 700; }

.progress { margin: 16px 0 6px; }
.progress-bar { height: 7px; background: var(--t-line); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; width: 6%; background: linear-gradient(90deg, var(--red), var(--red-bright));
    border-radius: 5px; transition: width .8s cubic-bezier(.4,0,.2,1); }
.stages { display: flex; justify-content: space-between; margin-top: 10px; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1; }
.stage .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--t-line); transition: all .3s; }
.stage .stage-label { font-size: 11px; color: var(--t-muted); font-weight: 600; }
.stage.done .dot, .stage.active .dot { background: var(--red); }
.stage.active .dot { box-shadow: 0 0 0 4px rgba(225,25,0,.18); }
.stage.done .stage-label, .stage.active .stage-label { color: var(--t-text); }

.status-title { font-size: 21px; font-weight: 800; margin: 16px 0 4px; line-height: 1.25; color: var(--t-text); }
.status-sub { font-size: 14.5px; color: var(--t-muted); margin: 0 0 14px; }

.dasher-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--t-line);
    border-radius: 16px; margin-bottom: 16px; background: var(--t-card); }
.dasher-avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff; font-weight: 800; font-size: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dasher-info { flex: 1; min-width: 0; }
.dasher-name { font-weight: 800; font-size: 16px; color: var(--t-text); }
.dasher-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12.5px; color: var(--t-muted); margin-top: 2px; }
.badge-top { background: rgba(225,25,0,.12); color: var(--red); font-weight: 700; padding: 2px 8px; border-radius: 20px; }
[data-theme="dark"] .badge-top { background: rgba(255,26,26,.16); color: #ff8a80; }
.rating { color: var(--t-text); font-weight: 700; }
.dasher-actions { display: flex; gap: 8px; }
.round-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--t-inset); display: flex; align-items: center;
    justify-content: center; font-size: 17px; border: 1px solid var(--t-line); }
.round-btn:active { transform: scale(.94); }

.card { border: 1px solid var(--t-line); border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; background: var(--t-card); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.rest-img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--t-inset); }
.rest-name { font-weight: 800; font-size: 16px; color: var(--t-text); }
.card-title { font-weight: 800; font-size: 15px; margin-bottom: 10px; color: var(--t-text); }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; gap: 10px; padding: 6px 0; font-size: 14.5px; align-items: baseline; color: var(--t-text); }
.items .qty { color: var(--red); font-weight: 800; min-width: 26px; }
.items .iname { flex: 1; }
.items .iprice { color: var(--t-muted); font-weight: 600; }
.totals { border-top: 1px dashed var(--t-line); margin-top: 8px; padding-top: 10px; }
.totals > div { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; color: var(--t-muted); }
.totals .grand { color: var(--t-text); font-weight: 800; font-size: 16px; border-top: 1px solid var(--t-line); margin-top: 6px; padding-top: 8px; }

.addr { display: flex; gap: 10px; align-items: flex-start; color: var(--t-text); }
.addr-icon { font-size: 18px; }
.instructions { margin-top: 10px; padding: 10px 12px; background: var(--t-inset); border-radius: 10px; font-size: 13.5px; color: var(--t-muted); font-style: italic; }
.footer-note { text-align: center; color: var(--t-muted); font-size: 13px; margin-top: 18px; font-weight: 600; }

/* Leaflet marker pins */
.pin { display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 18px;
    box-shadow: 0 3px 8px rgba(0,0,0,.35); border: 2px solid #fff; }
.pin-store { width: 38px; height: 38px; background: #111; }
.pin-dest { width: 38px; height: 38px; background: var(--red); }
.pin-dasher { width: 42px; height: 42px; background: #fff; border: 3px solid var(--red); }
.leaflet-container { background: var(--t-inset); }

/* ===================== Desktop "web view" ===================== */
@media (min-width: 900px) {
    .app { max-width: none; height: 100vh; min-height: 0; overflow: hidden; }
    .map { position: fixed; inset: 0; height: 100%; min-height: 0; }
    .brand-logo { display: none; }

    .panel {
        position: fixed; top: 22px; left: 22px; bottom: 22px; width: 430px; margin: 0;
        border-radius: 20px; padding: 24px 24px 28px; overflow-y: auto;
        box-shadow: var(--t-shadow); border: 1px solid var(--t-line);
    }
    .sheet-grip { display: none; }
    .panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--t-line); }
    .panel-head-logo { width: 38px; height: 38px; object-fit: contain; }
    .panel-head-word { height: 22px; object-fit: contain; }
    [data-theme="dark"] .panel-head-word { filter: none; }
    .eta-time { font-size: 44px; }
    .panel::-webkit-scrollbar { width: 8px; }
    .panel::-webkit-scrollbar-thumb { background: var(--t-line); border-radius: 8px; }
}

/* ===================== Pickup ===================== */
body.pickup { background: var(--t-bg); color: var(--t-text); }
.pk-page { display: flex; justify-content: center; min-height: 100vh; }
.pk-card { width: 100%; max-width: 460px; background: var(--t-card); min-height: 100vh; position: relative; }

.pk-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-bottom: 1px solid var(--t-line); }
.pk-brand { display: flex; align-items: center; gap: 8px; }
.pk-logo { width: 30px; height: 30px; object-fit: contain; }
.pk-word { height: 18px; object-fit: contain; }
.pk-toggle { position: static; top: auto; right: auto; box-shadow: none; border: 1px solid var(--t-line); width: 40px; height: 40px; }

.pk-map-wrap { position: relative; height: 240px; background: var(--t-inset); }
.pk-map { width: 100%; height: 100%; }
.pk-back { position: absolute; top: 12px; left: 12px; z-index: 500; width: 38px; height: 38px; border-radius: 50%;
    background: var(--t-card); display: flex; align-items: center; justify-content: center; box-shadow: var(--t-shadow);
    color: var(--t-text); font-size: 26px; font-weight: 700; line-height: 1; text-decoration: none; padding-bottom: 3px; }
.pk-help { position: absolute; top: 12px; right: 12px; z-index: 500; padding: 8px 16px; border-radius: 24px;
    background: var(--t-card); box-shadow: var(--t-shadow); font-size: 14px; font-weight: 600; color: var(--t-text); }
.pk-pin { width: 38px; height: 38px; background: var(--red); border: 2px solid #fff; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg); box-shadow: 0 3px 10px rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; }
.pk-pin span { transform: rotate(45deg); font-size: 17px; line-height: 1; }

.pk-body { padding: 18px 18px 30px; }
.pk-title { font-size: 24px; font-weight: 800; line-height: 1.2; margin-bottom: 6px; color: var(--t-text); }
.pk-pickup-time { font-size: 15px; color: var(--t-muted); margin-bottom: 18px; }
.pk-pickup-time strong { color: var(--t-text); font-weight: 800; }
.pk-mins { color: var(--red); font-weight: 700; }

.timeline { position: relative; margin: 4px 0 16px; }
.tl-track { position: absolute; top: 19px; left: 19px; right: 19px; height: 3px; background: var(--t-line); border-radius: 2px; z-index: 0; }
.tl-fill { height: 100%; width: 0; background: var(--red); border-radius: 2px; transition: width .6s cubic-bezier(.4,0,.2,1); }
.tl-steps { display: flex; justify-content: space-between; list-style: none; margin: 0; padding: 0; position: relative; z-index: 1; }
.tl-step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.tl-dot { width: 38px; height: 38px; border-radius: 50%; background: var(--t-inset); border: 2px solid var(--t-line);
    display: flex; align-items: center; justify-content: center; font-size: 17px; transition: all .3s; filter: grayscale(0.5) opacity(0.55); }
.tl-label { font-size: 11px; color: var(--t-muted); font-weight: 600; }
.tl-step.done .tl-dot, .tl-step.active .tl-dot { background: rgba(225,25,0,.12); border-color: var(--red); filter: none; }
[data-theme="dark"] .tl-step.done .tl-dot, [data-theme="dark"] .tl-step.active .tl-dot { background: rgba(255,26,26,.18); }
.tl-step.active .tl-dot { box-shadow: 0 0 0 4px rgba(225,25,0,.15); }
.tl-step.done .tl-label, .tl-step.active .tl-label { color: var(--t-text); }

.pk-sub { font-size: 14.5px; color: var(--t-muted); margin: 0 0 16px; line-height: 1.5; }
.pk-instr { font-size: 14px; color: var(--t-muted); line-height: 1.6; margin: 0; }
.pk-merchant { display: flex; align-items: center; gap: 12px; }
.pk-merchant-info { flex: 1; min-width: 0; }
.pk-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pk-addr { display: flex; gap: 12px; align-items: flex-start; }
.pk-addr-title { font-size: 15px; font-weight: 800; color: var(--t-text); margin-bottom: 2px; }

@media (min-width: 600px) {
    .pk-page { padding: 28px 16px; align-items: flex-start; }
    .pk-card { min-height: 0; border-radius: 20px; overflow: hidden; box-shadow: var(--t-shadow); border: 1px solid var(--t-line); }
}

/* ===================== Admin ===================== */
body.admin { background: #0e0f13; color: #e8e8ea; }
.admin-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px;
    background: #15161c; border-bottom: 1px solid #24262f; position: sticky; top: 0; z-index: 10; }
.admin-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; }
.admin-brand img { width: 34px; height: 34px; object-fit: contain; }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 26px 24px 60px; }
.admin-main.narrow { max-width: 640px; }

.btn { display: inline-block; padding: 10px 16px; border-radius: 10px; background: var(--red); color: #fff;
    border: none; font-weight: 700; font-size: 14px; cursor: pointer; transition: background .15s, transform .05s; }
.btn:hover { background: var(--red-bright); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border: 1px solid #34363f; color: #d6d6d8; }
.btn.ghost:hover { background: #1d1f27; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.big { padding: 14px 20px; font-size: 16px; width: 100%; }
.btn.danger { background: #2a1212; color: #ff8a80; border: 1px solid #5a2020; }
.btn.danger:hover { background: #3a1818; }

body.admin .flash.error { background: #2a1212; color: #ffb4ac; border: 1px solid #5a2020; }
body.admin .flash.ok { background: #122a18; color: #b6f0c4; border: 1px solid #1f6b3a; }

.orders-table { width: 100%; border-collapse: collapse; background: #15161c; border-radius: 12px; overflow: hidden; }
.orders-table th, .orders-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #22242d; font-size: 14px; }
.orders-table th { color: #9a9ca6; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.orders-table code { background: #0c0d11; padding: 2px 7px; border-radius: 6px; color: #ff8a80; }
.row-actions { display: flex; gap: 8px; }
.pill { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; background: #22242d; color: #c7c9d1; }
.pill.stage-0 { background: #2a2410; color: #f0d97a; }
.pill.stage-1 { background: #102a2a; color: #7af0e8; }
.pill.stage-2 { background: #2a1810; color: #f0b67a; }
.pill.stage-3 { background: #122a18; color: #8af0a0; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 0 0 rgba(46,204,113,.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(46,204,113,.6)} 70%{box-shadow:0 0 0 8px rgba(46,204,113,0)} 100%{box-shadow:0 0 0 0 rgba(46,204,113,0)} }

.form-grid fieldset { border: 1px solid #24262f; border-radius: 12px; margin: 0 0 18px; padding: 16px 18px; background: #15161c; }
.form-grid legend { padding: 0 8px; font-weight: 700; color: #fff; }
.form-grid legend small { color: #8a8c96; font-weight: 400; }
.form-grid label { display: block; margin-bottom: 12px; font-size: 13px; color: #b6b8c0; }
.form-grid label.check { display: flex; align-items: center; gap: 8px; }
.form-grid input, .form-grid textarea, .control input, .control select {
    width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 9px; border: 1px solid #2c2e38;
    background: #0d0e12; color: #fff; font-size: 14px; font-family: inherit; outline: none; }
.form-grid input:focus, .form-grid textarea:focus { border-color: var(--red); }
.form-grid .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label.check input { width: auto; margin: 0; }

.control-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.panel.adminpanel, section.panel { background: #15161c; border: 1px solid #24262f; border-radius: 14px; padding: 18px 20px;
    position: static; box-shadow: none; width: auto; overflow: visible; color: #e8e8ea; }
section.panel h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
section.panel hr { border: none; border-top: 1px solid #24262f; margin: 16px 0; }
.big-status { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.kv { display: grid; gap: 6px; margin: 12px 0; }
.kv > div { display: flex; justify-content: space-between; font-size: 13.5px; border-bottom: 1px solid #1d1f27; padding-bottom: 5px; }
.kv span:first-child { color: #8a8c96; }
.kv code { color: #ff8a80; }
.track-link { margin-top: 10px; font-size: 13px; color: #8a8c96; }
.track-link code { color: #ffb4ac; background: #0c0d11; padding: 2px 7px; border-radius: 6px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.row label { font-size: 13px; color: #b6b8c0; }
.status-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.status-btn { background: #1d1f27; border: 1px solid #2c2e38; color: #c7c9d1; font-size: 12px; }
.status-btn:hover { background: #262833; }
.status-btn.current { background: var(--red); color: #fff; border-color: var(--red); }
.control label { display: block; margin-bottom: 8px; font-size: 13px; color: #b6b8c0; }
.control input[type=range] { accent-color: var(--red); }
output { font-weight: 700; color: var(--red-bright); }

@media (max-width: 540px) {
    .form-grid .two { grid-template-columns: 1fr; }
    .admin-header { padding: 12px 16px; }
    .admin-main { padding: 18px 14px 50px; }
}
