

:root {
    
    --brand:       #4b3621;   
    --brand-light: #8a6244;   
    --ink:         #111827;
    --muted:       #6b7280;
    --line:        #e5e7eb;
    --bg:          #f7f9fb;
    --card:        #ffffff;
    --warn:        #b45309;
    --warn-bg:     #fff7ed;
    --bad:         #b91c1c;
    --good:        #15803d;

    
    --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: rgba(0,0,0,.08); }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    
    -webkit-text-size-adjust: 100%;
}


.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.is-on { display: flex; }

.pad { padding: 16px; }


.scroller { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
            padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.centered { display: flex; flex-direction: column; align-items: center; justify-content: center;
            flex: 1; text-align: center; gap: 12px; padding: 24px 16px; }


.bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--brand); color: #fff;
    padding: max(8px, env(safe-area-inset-top)) 8px 8px 8px;
    position: sticky; top: 0; z-index: 10;
}
.bar h2 { font-size: 18px; margin: 0; flex: 1; text-align: center;
          overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-btn {
    min-width: var(--tap); min-height: var(--tap);
    background: transparent; border: 0; color: #fff; font-size: 24px;
    border-radius: 10px; cursor: pointer;
}
.bar-btn-text { font-size: 16px; padding: 0 10px; min-width: auto; }
.bar-btn:active { background: rgba(255,255,255,.18); }

.bar-btn.on { background: rgba(255,255,255,.26); box-shadow: inset 0 0 0 2px rgba(255,255,255,.65); }

.bar-btn.armed {
    background: var(--bad); font-weight: 700;
    white-space: normal; line-height: 1.15; text-align: left;
    max-width: 62%; min-width: auto;
}


.view-switch {
    display: flex; margin: 0 0 14px;
    border: 1px solid var(--brand-light); border-radius: 12px; overflow: hidden;
}
.view-switch[hidden] { display: none; }
.vs-btn {
    flex: 1 1 0; min-height: var(--tap); padding: 10px 8px;
    background: var(--card); color: var(--brand-light);
    border: none; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
.vs-btn + .vs-btn { border-left: 1px solid var(--brand-light); }
.vs-btn.on { background: var(--brand); color: #fff; }


.jc-qr { margin: 10px 0; display: flex; justify-content: center; }
.jc-qr svg { background: #fff; padding: 8px; border-radius: 10px; }
.jc-link { font-size: 12px; color: var(--muted); word-break: break-all; margin: 4px 0 10px; }
.jc-actions { gap: 8px; flex-wrap: wrap; }
.jc-actions .btn { flex: 1 1 auto; }


.foot {
    
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom) + var(--pwa-bar-h, 0px)) 16px;
    background: var(--card); border-top: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 8px;
}


.btn {
    display: block; width: 100%;
    min-height: var(--tap);
    padding: 12px 16px;
    font-size: 17px; font-weight: 600;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--card); color: var(--ink);
    cursor: pointer;
    
    text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn + .btn { margin-top: 8px; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-quiet   { background: transparent; border-color: transparent; color: var(--brand-light); }
.btn-big     { min-height: 56px; font-size: 18px; }
.btn[disabled] { opacity: .5; }


label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password],
select, textarea {
    width: 100%; min-height: var(--tap);
    padding: 11px 12px;
    font-size: 17px;                 
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--card); color: var(--ink);
}
.hint { color: var(--muted); font-size: 14px; margin-top: 4px; }
.hint.warn { color: var(--warn); font-weight: 600; }
.hint.ok   { color: var(--good); }


.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
        padding: 14px; margin-bottom: 16px; }
.row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.row .grow { flex: 1 1 140px; min-width: 0; }

.row .qty-cell { flex: 0 0 96px; min-width: 0; }

.muted { color: var(--muted); }
.fineprint { color: var(--muted); font-size: 13px; }
.steps { line-height: 1.9; }



.stop-row {
    display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 14px; margin-bottom: 10px;
}
.stop-row .qty {
    flex: 0 0 44px; height: 44px; border-radius: 12px;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 17px;
}

.stop-row .grow { flex: 1 1 160px; min-width: 0; }

.stop-row .name { display: block; font-weight: 600;
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-row .sub  { display: block; color: var(--muted); font-size: 14px;
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-row .sub.note { color: var(--brand-light); }
.stop-row.needs-check { border-color: #f0c48a; background: var(--warn-bg); }

.stop-row.is-done { opacity: 0.72; }
.stop-row .sub.stop-done { color: var(--ok, #1f7a3d); font-weight: 600; }
.stop-warn { color: var(--warn); font-size: 13px; font-weight: 600; margin-top: 4px;
             white-space: normal; }


.stop-notes { margin-top: 6px; }
.stop-note {
    border-left: 3px solid var(--brand-light);
    padding: 4px 0 4px 8px; margin-bottom: 4px;
    
    white-space: normal; font-size: 14px; line-height: 1.35;
}
.stop-note .note-text { display: block; }
.stop-note .note-by   { display: block; color: var(--muted); font-size: 12px; }
.note-compose { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.note-input {
    
    flex: 1 1 100%; min-width: 0; box-sizing: border-box;
    padding: 10px; border: 1px solid var(--line); border-radius: 10px;
    font: inherit; font-size: 16px;   
    resize: vertical;
}

.note-add, .note-save, .note-cancel { min-height: var(--tap); }

.row-del {
    flex: 0 0 auto;
    min-height: var(--tap); padding: 10px 14px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--card); color: var(--bad);
    font: inherit; font-size: 15px; cursor: pointer;
}

.row-del.armed { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 700; }


.geo-results { margin-top: 8px; }
.geo-result {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    width: 100%; text-align: left;
    min-height: var(--tap); padding: 10px 12px;
    
    background: var(--card); color: var(--ink);
    border: 1px solid var(--line); border-radius: 10px;
    margin-bottom: 6px; font: inherit; font-size: 15px; cursor: pointer;
}
.geo-result:active { background: var(--bg); }

.geo-flag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
            border: 1px solid; white-space: nowrap; }
.geo-flag.near  { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.geo-flag.vague { color: var(--bad);  border-color: var(--bad);  background: var(--warn-bg); }

.geo-attrib { color: var(--muted); font-size: 12px; margin: 6px 0 0; }


.inline-msg { white-space: pre-line; margin-top: 12px; padding: 10px 12px; border-radius: 10px;
              background: #fef3c7; color: #78350f; font-size: 15px; }
.inline-msg.bad  { background: #fee2e2; color: #7f1d1d; }
.inline-msg.good { background: #dcfce7; color: #14532d; }



.toast {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(20px + env(safe-area-inset-bottom) + var(--pwa-bar-h, 0px));
    max-width: 92vw; z-index: 9000;
    background: #111827ee; color: #fff;
    padding: 12px 16px; border-radius: 12px; font-size: 15px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
}



.dd-stop {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 14px; margin-bottom: 10px;
    
    transition: transform .3s ease, opacity .3s ease;
}

.dd-stop.dd-top {
    border-color: var(--brand); border-width: 2px;
    padding: 14px 16px 16px; margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(15,47,74,.10);
}
.dd-pos { font-size: 13px; font-weight: 700; color: var(--brand-light);
          text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.dd-main { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.dd-qty {
    flex: 0 0 44px; height: 44px; border-radius: 12px;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 17px;
}
.dd-top .dd-qty { flex-basis: 56px; height: 56px; font-size: 22px; }
.dd-addr { flex: 1 1 140px; min-width: 0; }
.dd-who { font-weight: 700; font-size: 16px; }
.dd-top .dd-who { font-size: 20px; }

.dd-street { font-size: 15px; color: var(--muted); white-space: normal; }
.dd-top .dd-street { font-size: 18px; color: var(--ink); }
.dd-note { margin-top: 6px; font-size: 14px; color: var(--brand-light); white-space: normal; }
.dd-top .dd-note { font-size: 16px; font-weight: 600; }

.dd-dir {
    flex: 0 0 auto; min-height: var(--tap);
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0 16px;
    border: 1px solid var(--brand-light); border-radius: 12px;
    background: var(--card); color: var(--brand-light);
    text-decoration: none; font-weight: 700; font-size: 15px; white-space: nowrap;
}
.dd-top .dd-dir { background: var(--brand); border-color: var(--brand); color: #fff; }
.dd-acts { margin-top: 14px; }
.dd-acts .btn + .btn { margin-top: 8px; }

.dd-acts-closed { margin-top: 14px; }
.dd-closed-note {
    background: var(--warn-bg); border: 1px solid #f0c48a; border-radius: 12px;
    padding: 12px 14px; color: var(--warn); font-weight: 600;
    white-space: normal; line-height: 1.35;
}

.dd-claim {
    display: block; width: 100%; margin-top: 10px;
    min-height: var(--tap);
    border: 1px dashed var(--brand-light); border-radius: 12px;
    background: transparent; color: var(--brand-light);
    font-weight: 700; font-size: 15px; font-family: inherit;
}
.dd-empty { text-align: center; padding: 40px 16px; color: var(--muted); font-size: 17px; }


.dd-queue {
    margin: 0 12px 8px; padding: 10px 14px;
    border-radius: 12px; border: 1px solid var(--brand-light);
    background: var(--card); color: var(--brand-light);
    font-size: 15px; font-weight: 600; line-height: 1.35;
}
.dd-queue.bad { border-color: var(--bad); color: var(--bad); }


.dd-undo {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    background: #111827; color: #fff; padding: 10px 14px; font-size: 15px;
}

.dd-undo[hidden] { display: none; }

.dd-undo button {
    min-height: var(--tap); padding: 8px 18px;
    background: transparent; color: #ffd166; border: 1px solid #ffd166; border-radius: 10px;
    font: inherit; font-weight: 700; cursor: pointer;
}


.dd-done-head {
    width: 100%; text-align: left; margin-top: 18px;
    min-height: var(--tap); padding: 12px 14px;
    background: transparent; border: 1px dashed var(--line); border-radius: 12px;
    font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.dd-done-list { margin-top: 8px; }
.dd-donerow {
    display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.dd-donerow.failed .dd-donewhen { color: var(--bad); font-weight: 600; }
.dd-donewho { font-weight: 600; min-width: 0; }
.dd-donewhen { color: var(--muted); white-space: nowrap; }


.dd-why {
    position: fixed; inset: 0; z-index: 8000;
    background: rgba(0,0,0,.45);
    display: flex; align-items: flex-end;
}
.dd-why[hidden] { display: none; }
.dd-why-inner {
    width: 100%; background: var(--card);
    
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom) + var(--pwa-bar-h, 0px));
    max-height: 80vh; overflow-y: auto;
}
.dd-why-inner h3 { margin: 0 0 12px; }
.dd-why-inner .btn + .btn { margin-top: 8px; }



.cam-wrap { flex: 1; position: relative; background: #000; display: flex; }
#cam-video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.cam-bar {
    
    position: absolute; left: 0; right: 0; bottom: var(--pwa-bar-h, 0px);
    padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0));
    color: #fff; font-size: 14px;
}

.cam-shutter {
    flex: 0 0 72px; width: 72px; height: 72px; border-radius: 50%;
    background: #fff; border: 5px solid rgba(255,255,255,.45);
    cursor: pointer; padding: 0;
}
.cam-shutter:active { transform: scale(.94); }
.cam-hint { flex: 1 1 0; text-align: right; opacity: .85; }
#cam-shots { flex: 1 1 0; }




#dim-curtain {
    position: fixed; inset: 0; z-index: 2147483600;
    background: rgba(0,0,0,.95);
    display: block;
}
#dim-curtain[hidden] { display: none; }


.or-divider {
    display: flex; align-items: center; gap: 10px;
    color: var(--muted); font-size: 13px; margin: 14px 0 2px;
}
.or-divider::before, .or-divider::after {
    content: ""; flex: 1; height: 1px; background: var(--line);
}


.logo-mark {
    width: 72px; height: 72px; border-radius: 20px;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 700; letter-spacing: 1px;
}

h1 { font-size: 24px; margin: 8px 0; }
h3 { font-size: 17px; margin: 18px 0 8px; }


.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}


.bd-route {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 14px; margin-bottom: 10px;
}

.bd-route.has-flags { border-color: #f0c48a; background: var(--warn-bg); }
.bd-head { display: flex; align-items: baseline; gap: 10px; }
.bd-name { font-weight: 700; flex: 1; min-width: 0;
           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-count { flex: 0 0 auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.bd-bar { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 8px 0 6px; }
.bd-bar i { display: block; height: 100%; background: var(--brand-light); }
.bd-sub { color: var(--muted); font-size: 14px; }
.bd-flag { color: var(--warn); font-size: 14px; font-weight: 600; margin-top: 6px; }


.btn.armed { background: var(--warn); border-color: var(--warn); color: #fff; font-weight: 700; }


@media (prefers-color-scheme: dark) {
    :root {
        --ink: #f3f4f6; --muted: #9ca3af; --line: #374151;
        --bg: #0b0f14; --card: #151b23; --warn-bg: #2a1f10;
        
        --warn: #fbbf24; --bad: #f87171; --good: #4ade80;
    }
}


.dd-unordered {
    margin: 0 0 10px; padding: 10px 12px; border-radius: 10px;
    background: rgba(255, 176, 32, 0.14); border: 1px solid rgba(255, 176, 32, 0.45);
    color: var(--warn, #b26a00); font-size: 0.95rem; line-height: 1.35;
}
