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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
                 "Helvetica Neue", Arial, sans-serif;
    background: #f4f4f6;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.5;
}

input, select, button, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(180deg, #fafafa 0%, #ececf0 100%);
}

.login-box {
    background: white;
    padding: 40px 36px;
    border-radius: 14px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    text-align: center;
}

.login-box h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.login-box .subtitle {
    color: #888;
    margin-bottom: 28px;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.login-box input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s;
}
.login-box input:focus { border-color: #111; }

.login-box button {
    width: 100%;
    padding: 12px;
    background: #111;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.login-box button:hover { opacity: 0.9; }
.login-box button:active { opacity: 0.8; }

.login-box .error {
    color: #d33;
    margin-top: 14px;
    font-size: 13px;
}

/* ---------- Top bar (desktop: single row) ---------- */
.topbar {
    background: #111;
    color: white;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar .brand {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.filters {
    display: flex;
    align-items: stretch;
    height: 100%;
}
.filters a {
    color: #999;
    font-size: 13px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.filters a:hover { color: #ddd; }
.filters a.active {
    color: white;
    border-bottom-color: white;
    font-weight: 600;
}
.filters .count {
    display: inline-block;
    background: #333;
    color: #ccc;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 6px;
    font-weight: 600;
}
.filters a.active .count { background: white; color: #111; }

.search {
    flex: 1;
    max-width: 360px;
    margin-left: auto;
}
.search input {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid #333;
    background: #1f1f1f;
    color: white;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.search input:focus { border-color: #666; background: #2a2a2a; }
.search input::placeholder { color: #777; }

.topbar-actions {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-shrink: 0;
}
.topbar-actions a { color: #aaa; font-size: 13px; }
.topbar-actions a:hover { color: white; }
.topbar-actions .refresh { font-size: 18px; line-height: 1; }

/* ---------- Banners / empty ---------- */
.banner {
    padding: 12px 16px;
    margin: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
}
.banner.error { background: #ffe8e8; color: #c22; border: 1px solid #fcc; }

.empty {
    text-align: center;
    padding: 80px 24px;
    color: #999;
    font-size: 15px;
    line-height: 1.8;
}

/* ---------- Table (desktop default) ---------- */
.table-wrap {
    margin: 16px 20px 60px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.orders-table thead th {
    background: #fafafa;
    border-bottom: 1px solid #e5e5e8;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #666;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    position: sticky;
    top: 52px;
    z-index: 10;
}

.orders-table tbody tr {
    border-bottom: 1px solid #f0f0f3;
    transition: background 0.1s;
}
.orders-table tbody tr:nth-child(even) { background: #fafbfd; }
.orders-table tbody tr:hover { background: #f1f5fb; }
.orders-table tbody tr.fulfilled { opacity: 0.55; background: #fafafa; }
.orders-table tbody tr.fulfilled:hover { opacity: 0.9; background: #f4f4f6; }

.orders-table td {
    padding: 8px 10px;
    vertical-align: top;
}

.col-num { width: 120px; white-space: nowrap; }
.col-customer { width: 150px; }
.col-products { min-width: 150px; }
.col-address { min-width: 220px; max-width: 360px; word-break: break-word; line-height: 1.45; color: #444; }
.col-country { width: 60px; white-space: nowrap; }
.col-date { width: 90px; white-space: nowrap; color: #999; font-size: 12px; }
.col-fulfill { min-width: 380px; }

.order-num {
    font-weight: 600;
    color: #111;
    display: block;
}
.tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 3px;
}
.tag.green { background: #d4f4dd; color: #1a7a2e; }

.sub {
    color: #777;
    font-size: 12px;
    margin-top: 2px;
}
.sub a { color: #0060cc; }
.muted { color: #999; }

/* ---------- Inline form (desktop: single-row) ---------- */
.fulfill-form {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.fulfill-form .tracking-input {
    flex: 1 1 140px;
    min-width: 0;
    text-transform: uppercase;
}
.fulfill-form .carrier-select {
    flex: 1 1 150px;
    min-width: 0;
}
.fulfill-form .tracking-input,
.fulfill-form .carrier-select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
    outline: none;
    background: white;
}
.fulfill-form .tracking-input:focus,
.fulfill-form .carrier-select:focus { border-color: #111; }
.fulfill-form .submit-btn { flex: 0 0 auto; }

.col-fulfill.done {
    color: #666;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.done-pair { display: block; }
.col-fulfill.done .lbl {
    display: inline-block;
    min-width: 36px;
    color: #999;
    font-size: 11px;
    margin-right: 4px;
}

.submit-btn {
    padding: 7px 16px;
    background: #111;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.submit-btn:hover { opacity: 0.9; }
.submit-btn:active { opacity: 0.8; }
.submit-btn:disabled { background: #aaa; cursor: not-allowed; }

.row-status {
    display: block;
    font-size: 11px;
    margin-top: 4px;
    min-height: 14px;
}
.row-status.success { color: #1a7a2e; }
.row-status.error { color: #d33; }

/* ---------- Footer ---------- */
.foot {
    padding: 20px 16px 32px;
    text-align: center;
    color: #aaa;
    font-size: 12px;
}
.foot a { color: #aaa; }

/* ---------- Mobile fallback (<768px): table → cards ---------- */
@media (max-width: 768px) {
    body { font-size: 15px; }

    .topbar {
        height: auto;
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .topbar .brand { flex: 1; }
    .topbar-actions { order: 2; }
    .filters {
        order: 3;
        width: 100%;
        border-top: 1px solid #2a2a2a;
        padding-top: 8px;
        height: auto;
    }
    .filters a { padding: 6px 12px; }
    .search {
        order: 4;
        max-width: none;
        width: 100%;
        margin-left: 0;
    }

    .table-wrap {
        margin: 10px 8px 60px;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }
    .orders-table thead { display: none; }
    .orders-table, .orders-table tbody, .orders-table tr, .orders-table td {
        display: block;
        width: 100%;
    }
    .orders-table tbody tr {
        background: white;
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 12px 14px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
        border-bottom: none;
    }
    .orders-table tbody tr:hover { background: white; }

    .orders-table td {
        padding: 4px 0;
        width: auto !important;
        max-width: none !important;
    }
    .orders-table td.col-num {
        padding-bottom: 8px;
        margin-bottom: 8px;
        border-bottom: 1px solid #f0f0f3;
    }
    .orders-table td[data-label]::before {
        content: attr(data-label);
        display: inline-block;
        width: 50px;
        color: #888;
        font-size: 12px;
        font-weight: 500;
        margin-right: 6px;
        vertical-align: top;
    }
    .col-address details { display: inline-block; vertical-align: top; max-width: calc(100% - 60px); }

    .orders-table td.col-fulfill {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px dashed #e5e5e8;
    }
    .fulfill-form {
        flex-direction: column;
        gap: 8px;
    }
    .fulfill-form .tracking-input,
    .fulfill-form .carrier-select {
        padding: 11px 12px;
        font-size: 15px;
    }
    .fulfill-form .submit-btn {
        width: 100%;
        padding: 11px;
        font-size: 15px;
    }
    .row-status { text-align: right; }
}
