/* Desktop ops console. Gated by width so the first paint is already the PC layout
   (no wait for JS). Phones below 960px keep the original mobile skin. */

@media (min-width: 960px) {
    html,
    html body {
        height: 100%;
        overflow: hidden;
    }

    html .pc-only { display: block !important; }
    html .pc-only.theme-toggle,
    html button.pc-only { display: inline-flex !important; align-items: center; }
    html .stat.pc-only { display: flex !important; }
    html .pc-only[hidden],
    html .hero-stage[hidden],
    html .last-parcel-bar[hidden] { display: none !important; }
    html .phone-only { display: none !important; }

    html:root {
        --rail: #12151c;
        --rail-text: #e8eaee;
        --rail-muted: #8b93a7;
        --rail-line: rgba(255, 255, 255, 0.08);
        --bg: #eef0f4;
        --bg-2: #f7f8fb;
        --surface: #ffffff;
        --line: #e2e5ec;
        --text: #12151c;
        --text-2: #5c6478;
        --text-3: #8a91a3;
        --accent: #c45c14;
        --accent-2: #a3470e;
        --ok: #0f7a4d;
        --warn: #b45309;
        --bad: #c03636;
        --shadow: 0 1px 0 rgba(16, 18, 28, 0.04), 0 10px 28px rgba(16, 18, 28, 0.06);
        --radius: 12px;
        background: var(--bg);
        color: var(--text);
    }
    html body {
        background: var(--bg);
        color: var(--text);
        display: grid;
        grid-template-columns: 220px minmax(0, 1fr);
        grid-template-rows: 100%;
        min-height: 100vh;
        height: 100vh;
    }

    html:root[data-theme="dark"],
    html[data-theme="dark"] {
        --rail: #0c0e12;
        --bg: #101318;
        --bg-2: #161a22;
        --surface: #1a1f28;
        --line: rgba(255, 255, 255, 0.08);
        --text: #eef1f6;
        --text-2: #9aa3b5;
        --text-3: #6d7688;
        --accent: #e08a3c;
        --accent-2: #c96e22;
        --ok: #3ecf8e;
        --warn: #e0b04a;
        --bad: #ef6b6b;
        --shadow: none;
    }

    /* Sidebar */
    html .nav {
        position: static;
        grid-column: 1;
        grid-row: 1;
        width: auto;
        height: 100vh;
        margin: 0;
        padding: 20px 14px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        background: var(--rail);
        border: 0;
        border-right: 1px solid var(--rail-line);
        z-index: 40;
    }
    html .nav-brand {
        display: flex !important;
        align-items: center;
        gap: 10px;
        padding: 4px 8px 18px;
        color: var(--rail-text);
    }
    html .nav-brand img {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }
    html .nav-brand-name {
        font-size: 14px;
        font-weight: 800;
        letter-spacing: -0.03em;
    }
    html .nav-brand-sub {
        margin-top: 2px;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--rail-muted);
        max-width: 140px;
        line-height: 1.3;
    }
    html .nav-btns {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    html .nav button {
        width: 100%;
        height: 42px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: var(--rail-muted);
        font-size: 14px;
        font-weight: 700;
        text-align: left;
        padding: 0 12px;
        justify-content: flex-start;
    }
    html .nav button:hover {
        background: rgba(255, 255, 255, 0.05);
        color: var(--rail-text);
    }
    html .nav button.active {
        background: var(--accent);
        color: #fff;
    }

    /* Workspace */
    html .wrap {
        grid-column: 2;
        grid-row: 1;
        width: auto;
        max-width: none;
        height: 100vh;
        margin: 0;
        padding: 12px 16px 14px;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto minmax(0, 1fr);
        column-gap: 12px;
        row-gap: 10px;
        min-width: 0;
        overflow: hidden;
    }
    html .top {
        grid-column: 2;
        grid-row: 1;
        flex-shrink: 0;
        margin: 0;
        align-items: center;
        align-self: center;
    }
    html .stats {
        grid-column: 1;
        grid-row: 1;
        flex-shrink: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin: 0;
        align-self: center;
    }
    html .stats-note { grid-column: 1 / -1; }
    html .panel {
        grid-column: 1 / -1;
        grid-row: 2;
        min-height: 0;
    }
    html .top .brand { display: none; }
    html .top-actions {
        display: flex;
        margin-left: auto;
        gap: 8px;
    }
    html .theme-toggle,
    html .logout {
        height: 34px;
        padding: 0 12px;
        border-radius: 8px;
        border: 1px solid var(--line);
        background: var(--surface);
        color: var(--text-2);
        font-size: 12px;
        font-weight: 700;
        cursor: pointer;
    }
    html .theme-toggle:hover,
    html .logout:hover {
        color: var(--text);
        border-color: var(--accent);
    }

    html .stats {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        grid-template-columns: none;
    }
    html .stat {
        flex: 1 1 140px;
        display: flex;
        align-items: baseline;
        gap: 8px;
        margin: 0;
        padding: 8px 12px;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 10px;
        box-shadow: none;
        text-align: left;
    }
    html .stat b {
        display: inline;
        font-size: 18px;
        letter-spacing: -0.04em;
        line-height: 1;
    }
    html .stat span {
        display: inline;
        margin: 0;
        font-size: 11px;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        color: var(--text-3);
    }
    html .stat-hint,
    html .stats-note {
        display: none !important;
    }

    html .panel[data-panel="accept"].active {
        display: grid;
        grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
        grid-template-rows: minmax(0, 1fr);
        gap: 12px;
        height: 100%;
        min-height: 0;
    }
    html .panel[data-panel="issue"].active,
    html .panel[data-panel="search"].active {
        display: block;
        overflow: auto;
    }

    html .scan-box,
    html .card,
    html .scan-log {
        background: var(--surface);
        border: 1px solid var(--line);
        box-shadow: none;
        border-radius: var(--radius);
    }
    html .scan-box {
        padding: 14px 16px;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: auto;
    }
    html .panel[data-panel="accept"] .scan-box {
        overflow: hidden;
    }
    html .label {
        margin-bottom: 6px;
        font-size: 11px;
    }
    html .field { gap: 8px; }
    html .field input {
        height: 44px;
        font-size: 16px;
        background: var(--bg-2);
        color: var(--text);
        border-radius: 10px;
    }
    html .btn {
        height: 44px;
        border-radius: 10px;
        padding: 0 14px;
        font-size: 13px;
    }
    html .btn-accent { min-width: 88px; }
    html .btn-block { margin-top: 8px; }
    html .status-line {
        margin-top: 6px;
        min-height: 16px;
        font-size: 12px;
    }

    html .hero-stage {
        margin-top: 12px;
        padding: 14px 18px 16px;
        border-radius: 14px;
        display: grid !important;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        column-gap: 20px;
        row-gap: 4px;
        align-items: center;
        background: var(--bg-2);
        border: 1px solid var(--line);
    }
    html .hero-kicker {
        grid-column: 1 / -1;
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--accent);
    }
    html .hero-num {
        margin: 0;
        font-family: var(--mono);
        font-size: 64px;
        line-height: 0.92;
        font-weight: 700;
        letter-spacing: -0.05em;
    }
    html .hero-stage.hero-archive .hero-num {
        font-size: 40px;
        color: var(--accent);
    }
    html .hero-name {
        margin: 0;
        font-size: 24px;
        font-weight: 800;
        letter-spacing: -0.03em;
        line-height: 1.15;
    }
    html .hero-track {
        margin: 2px 0 0;
        font-size: 14px;
        color: var(--text-3);
    }

    html .last-parcel-bar {
        margin-top: 10px;
        padding: 8px 10px 8px 12px;
        border-radius: 10px;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        background: #fff7ed;
        border: 1px solid #f3d2a6;
        flex-shrink: 0;
    }
    html[data-theme="dark"] .last-parcel-bar {
        background: rgba(224, 176, 74, 0.12);
        border-color: rgba(224, 176, 74, 0.28);
    }
    html .last-parcel-bar[hidden] { display: none !important; }
    html .last-parcel-title { font-weight: 800; font-size: 13px; }
    html .last-parcel-sub {
        margin-top: 2px;
        font-size: 12px;
        color: var(--text-2);
        max-width: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    html .last-parcel-bar .btn {
        height: 34px;
        font-size: 12px;
    }

    html .pending-hint { display: none; }
    html .result { margin-top: 8px; }
    html .result .card {
        margin: 0;
        padding: 10px 12px;
        box-shadow: none;
    }
    html .meta { gap: 4px; margin-bottom: 8px; }
    html .meta-row { font-size: 13px; }
    html .track-actions { margin-top: 8px; gap: 6px; }

    html .scan-log {
        margin: 0;
        padding: 12px 12px 8px;
        min-height: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    html .scan-log-head { margin-bottom: 8px; }
    html .scan-log-note {
        display: block !important;
        margin-top: 3px;
        font-size: 11px;
        color: var(--text-3);
        line-height: 1.3;
        max-width: none;
        text-transform: none;
        letter-spacing: 0;
        font-weight: 500;
    }
    html .scan-log-list {
        flex: 1;
        max-height: none;
        overflow: auto;
        gap: 6px;
    }
    html .scan-log-item {
        background: var(--bg-2);
        border-color: var(--line);
        border-radius: 10px;
        padding: 8px 10px;
    }
    html .scan-log-undo {
        height: 28px;
        margin-top: 6px;
        background: transparent;
        border: 1px solid var(--line);
        color: var(--text-2);
        cursor: pointer;
        font-size: 11px;
    }
    html .scan-log-undo:hover {
        border-color: var(--bad);
        color: var(--bad);
    }

    html .panel[data-panel="issue"] .scan-box,
    html .panel[data-panel="search"] .scan-box {
        max-width: 720px;
    }
    html .issue-safe-note {
        display: block !important;
        margin: 0 0 10px;
        padding: 8px 10px;
        border-radius: 8px;
        background: #eefaf3;
        color: var(--text-2);
        font-size: 12px;
        line-height: 1.35;
    }
    html[data-theme="dark"] .issue-safe-note {
        background: rgba(62, 207, 142, 0.1);
    }

    html .field input:focus {
        border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
    }

    html .cam-overlay {
        position: fixed;
    }

    html.pvz-login,
    html:has(.login-wrap) {
        height: auto;
        overflow: auto;
    }
    html.pvz-login body,
    html:has(.login-wrap) body {
        display: block;
        height: auto;
        min-height: 100vh;
        overflow: auto;
        background: var(--bg);
    }
    html .login-card {
        background: var(--surface);
        border: 1px solid var(--line);
        box-shadow: var(--shadow);
        color: var(--text);
    }
    html .login-card h1 { color: var(--text); }
    html .login-card p,
    html .hint { color: var(--text-2); }

    @media (max-width: 1180px) {
        html body {
            grid-template-columns: 188px minmax(0, 1fr);
        }
        html .panel[data-panel="accept"].active {
            grid-template-columns: 1fr 280px;
        }
    }

    @media (max-height: 760px) {
        html .hero-num { font-size: 48px; }
        html .hero-name { font-size: 20px; }
        html .last-parcel-sub { display: none; }
    }
}
