:root,
[data-theme="light"] {
    color-scheme: light;
    --body-bg: #f4f7fb;
    --body-glow: rgba(37, 99, 235, .07);
    --sidebar-bg: rgba(255, 255, 255, .96);
    --topbar-bg: rgba(244, 247, 251, .88);
    --card-bg: #ffffff;
    --card-secondary: #f7f9fc;
    --card-hover: #f9fbff;
    --border: #e2e8f0;
    --border-strong: #d5deea;
    --text: #111827;
    --muted: #6b7280;
    --input: #ffffff;
    --primary: #0969ed;
    --primary-hover: #075dcc;
    --primary-soft: #eaf2ff;
    --success: #15803d;
    --success-soft: #e5f8eb;
    --warning: #b45309;
    --warning-soft: #fff3d8;
    --danger: #dc2626;
    --danger-soft: #feecec;
    --purple: #7c3aed;
    --shadow: 0 8px 24px rgba(15, 23, 42, .055);
    --shadow-raised: 0 18px 50px rgba(15, 23, 42, .12);
}

[data-theme="dark"] {
    color-scheme: dark;
    --body-bg: #06111f;
    --body-glow: rgba(30, 111, 255, .13);
    --sidebar-bg: rgba(8, 21, 36, .97);
    --topbar-bg: rgba(6, 17, 31, .88);
    --card-bg: #0b1828;
    --card-secondary: #101f31;
    --card-hover: #0e1d2e;
    --border: rgba(148, 163, 184, .15);
    --border-strong: rgba(148, 163, 184, .24);
    --text: #f3f7fc;
    --muted: #8fa0b7;
    --input: #081524;
    --primary: #2d7ff9;
    --primary-hover: #4b92fc;
    --primary-soft: rgba(45, 127, 249, .14);
    --success: #39ce72;
    --success-soft: rgba(34, 197, 94, .14);
    --warning: #f6ad38;
    --warning-soft: rgba(245, 158, 11, .14);
    --danger: #ff6868;
    --danger-soft: rgba(239, 68, 68, .15);
    --purple: #b69af8;
    --shadow: 0 12px 32px rgba(0, 0, 0, .19);
    --shadow-raised: 0 24px 70px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background-color: var(--body-bg);
    background-image: radial-gradient(circle at 72% -15%, var(--body-glow), transparent 34%);
    background-attachment: fixed;
    color: var(--text);
    font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    transition: background-color .2s ease, color .2s ease;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
.text-muted { color: var(--muted) !important; }
.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 232px;
    padding: 20px 14px 16px;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(18px);
}
.brand {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    color: var(--text);
}
.brand:hover { color: var(--text); }
.brand-logo { display: block; width: 148px; height: auto; filter: invert(1); }
[data-theme="dark"] .brand-logo { filter: none; }
.sidebar-close {
    position: absolute;
    top: 14px;
    right: 12px;
    z-index: 2;
    width: 34px;
    height: 34px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-secondary);
    color: var(--text);
}
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(2, 8, 18, .56);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}

.sidebar-nav { margin-top: 16px; overflow-y: auto; overflow-x: hidden; }
.nav-section {
    padding: 20px 11px 7px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}
.sidebar .nav-link {
    min-height: 39px;
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 3px 0;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 620;
    transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.sidebar .nav-link i { width: 17px; color: inherit; font-size: 15px; text-align: center; }
.sidebar .nav-link:hover { color: var(--text); background: var(--card-secondary); }
.sidebar .nav-link.active { color: var(--primary); background: var(--primary-soft); border-color: rgba(45, 127, 249, .09); }
.sidebar-user {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    padding: 16px 7px 0;
    border-top: 1px solid var(--border);
}
.avatar {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(45, 127, 249, .2);
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 10px;
    font-weight: 850;
}
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sidebar-user strong { font-size: 11px; }
.sidebar-user small { color: var(--muted); font-size: 9px; }
.user-actions { display: flex; gap: 10px; margin-top: 4px; font-size: 9px; }
.user-actions form { display: inline; }
.user-actions button { padding: 0; border: 0; background: none; color: var(--danger); }

.sidebar-theme { margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--border); }
.sidebar-theme .theme-toggle { width: 100%; display: flex; align-items: center; justify-content: flex-start; gap: 9px; color: var(--muted); }
.sidebar-theme .theme-toggle:hover { color: var(--text); }
.mobile-topbar {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
    z-index: 1030;
    border-bottom: 1px solid var(--border);
    background: var(--topbar-bg);
    backdrop-filter: blur(16px);
}
.mobile-topbar .btn-icon { position: absolute; left: 16px; top: 11px; width: 36px; padding: 0; }
.mobile-brand-logo { display: block; width: 112px; height: auto; filter: invert(1); }
[data-theme="dark"] .mobile-brand-logo { filter: none; }
.app-main { min-height: 100vh; padding-left: 232px; }
.app-main > .container-fluid { width: 100%; max-width: 1680px; padding: 30px 30px 42px !important; }

.btn {
    min-height: 36px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 680;
    box-shadow: none !important;
}
.btn-sm { min-height: 31px; font-size: 11px; }
.btn-primary { border-color: var(--primary); background: var(--primary); }
.btn-primary:hover, .btn-primary:focus { border-color: var(--primary-hover); background: var(--primary-hover); }
.btn-surface, .btn-outline-secondary { border-color: var(--border); background: var(--card-bg); color: var(--text); }
.btn-surface:hover, .btn-outline-secondary:hover { border-color: var(--border-strong); background: var(--card-secondary); color: var(--text); }
.btn-icon { color: var(--text); }
[data-theme="dark"] .dark-icon, [data-theme="light"] .light-icon { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-head h1 { margin: 3px 0 4px; font-size: 24px; font-weight: 760; letter-spacing: -.045em; }
.page-head p { max-width: 720px; margin: 0; color: var(--muted); font-size: 12px; }
.breadcrumb-text { color: var(--primary); font-size: 10px; font-weight: 650; }

.card {
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    color: var(--text);
}
.panel-card > .card-header {
    min-height: 51px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 17px;
    border-color: var(--border);
    background: transparent;
}
.panel-card > .card-header h2 { margin: 0; font-size: 13px; font-weight: 730; }
.card-footer { border-color: var(--border) !important; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
}
.stat-card .stat-icon { flex: 0 0 38px; width: 38px; height: 38px; display: grid; place-items: center; overflow: visible; border-radius: 8px; background: var(--card-secondary); font-size: 17px; line-height: 1; }
.stat-card > div > span { display: block; overflow: hidden; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.stat-card strong { display: block; margin-top: 1px; font-size: 20px; font-weight: 750; letter-spacing: -.035em; }
.text-purple { color: var(--purple) !important; }

.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--border); margin: 0; font-size: 11px; }
.table > :not(caption) > * > * { padding: 11px 12px; vertical-align: middle; }
.table th { color: var(--muted); font-size: 9px; font-weight: 760; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { --bs-table-bg: var(--card-hover); }
.table strong { font-weight: 680; }
.status, .source-badge { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 5px; font-size: 9px; font-weight: 750; white-space: nowrap; }
.status-draft { background: var(--card-secondary); color: var(--muted); }
.status-created, .status-label_created { background: var(--primary-soft); color: var(--primary); }
.status-in_transit { background: var(--warning-soft); color: var(--warning); }
.status-delivered, .status-active { background: var(--success-soft); color: var(--success); }
.status-error, .status-inactive { background: var(--danger-soft); color: var(--danger); }
.status-cancelled { background: var(--card-secondary); color: var(--muted); text-decoration: line-through; }
.source-manual { background: var(--card-secondary); color: var(--text); }
.source-api { background: rgba(124, 58, 237, .13); color: var(--purple); }

.form-control, .form-select {
    min-height: 38px;
    border-color: var(--border);
    border-radius: 7px;
    background-color: var(--input);
    color: var(--text);
    font-size: 12px;
}
.form-control:hover, .form-select:hover { border-color: var(--border-strong); }
.form-control:focus, .form-select:focus { border-color: var(--primary); background-color: var(--input); color: var(--text); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-control::placeholder { color: var(--muted); opacity: .72; }
.form-control:disabled, .form-select:disabled { background: var(--card-secondary); color: var(--muted); }
.form-select option { background: var(--card-bg); color: var(--text); }
.form-label { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 680; }
.form-check-input { background-color: var(--input); border-color: var(--border-strong); }
.form-section { padding: 18px; }
.form-section + .form-section { border-top: 1px solid var(--border); }
.form-section h2 { margin: 0 0 15px; font-size: 13px; font-weight: 730; }
.shipment-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.shipment-card { overflow: hidden; box-shadow: var(--shadow); }
.shipment-data-card, .shipment-details-card { grid-column: 1 / -1; }
.shipment-card > .card-body { padding: 18px; }
.shipment-address-card .row { --bs-gutter-y: 12px; }
.shipment-address-header { gap: 12px; }
.shipment-address-header .address-select { width: min(230px, 58%); min-height: 34px; }
.shipment-details-card > .card-body { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(340px, .9fr); gap: 22px; }
.shipment-details-section + .shipment-details-section { margin: 0; padding: 0 0 0 22px; border-top: 0; border-left: 1px solid var(--border); }
.section-subhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-subhead strong, .section-subhead small { display: block; }
.section-subhead strong { font-size: 11px; }
.section-subhead small { margin-top: 1px; color: var(--muted); font-size: 9px; }
.package-row .col { min-width: 112px; }
.package-row > .col-auto:first-child { display: flex; align-items: flex-end; }
.package-number { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border-radius: 7px; font-size: 11px; line-height: 1; }
.shipment-submit { grid-column: 1 / -1; display: flex; justify-content: flex-end; padding-top: 2px; }
.shipment-submit .btn { min-width: 170px; }
.filter-card { margin-bottom: 14px; padding: 14px; }
.quick-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.quick-tab { padding: 7px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--card-bg); color: var(--muted); font-size: 11px; }
.quick-tab:hover { border-color: var(--border-strong); color: var(--text); }
.quick-tab.active { border-color: rgba(45, 127, 249, .45); background: var(--primary-soft); color: var(--primary); }
.quick-tab b { margin-left: 5px; }
.pagination { margin: 16px 0 0; }
.page-link { border-color: var(--border); background: var(--card-bg); color: var(--text); font-size: 11px; }
.active > .page-link { border-color: var(--primary); background: var(--primary); }

.bar-chart { height: 230px; display: flex; align-items: flex-end; gap: 4px; padding-top: 20px; }
.bar { position: relative; height: 100%; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar i { display: block; width: 70%; min-height: 3px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, #55a0ff, var(--primary)); opacity: .82; }
.bar span { margin-top: 5px; color: var(--muted); font-size: 8px; }
.bar b { position: absolute; top: -18px; display: none; font-size: 9px; }
.bar:hover b { display: block; }
.bar:hover i { opacity: 1; }
.courier-breakdown > div + div { margin-top: 20px; }
.courier-breakdown span { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 11px; }
.progress { height: 5px; background: var(--card-secondary); }
.progress-bar { border-radius: 9px; background: var(--primary); }
.list-group-item { padding: 14px 18px; border-color: var(--border); background: transparent; color: var(--text); }
.list-group-item:hover { background: var(--card-hover); color: var(--text); }
.list-group-item small { display: block; overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.empty-mini, .empty-state { padding: 30px; color: var(--muted); text-align: center; }
.empty-state { max-width: 600px; margin: 8vh auto; }
.empty-state > i { font-size: 45px; }
.toast { background: var(--card-bg); color: var(--text); box-shadow: var(--shadow); }

.login-body { position: relative; display: grid; place-items: center; overflow: hidden; padding: 24px; }
.login-body::before {
    position: fixed;
    width: 560px;
    height: 560px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-soft), transparent 65%);
    content: "";
    opacity: .7;
    transform: translate(36vw, -30vh);
}
.login-theme { position: fixed; right: 22px; top: 22px; z-index: 2; }
.login-card { position: relative; width: min(100%, 430px); padding: 38px; border-radius: 16px; background: var(--card-bg); box-shadow: var(--shadow-raised); }
.login-card .brand { min-height: auto; padding: 0; }
.login-card .brand-logo { width: 210px; }
.login-card h1 { margin: 7px 0 3px; font-size: 24px; font-weight: 760; letter-spacing: -.035em; }
.login-card p { margin: 0 auto; max-width: 310px; font-size: 12px; }
.login-kicker { color: var(--primary); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.demo-hint { display: flex; gap: 11px; align-items: flex-start; margin-top: 24px; padding: 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-secondary); color: var(--muted); font-size: 10px; }
.demo-hint > i { color: var(--primary); font-size: 16px; }
.demo-hint strong, .demo-hint span { display: block; }
.demo-hint strong { margin-bottom: 2px; color: var(--text); font-size: 10px; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.data-list { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; font-size: 11px; }
.data-list dt { color: var(--muted); font-weight: 500; }
.data-list dd { margin: 0; }
.timeline { position: relative; padding-left: 26px; }
.timeline::before { position: absolute; left: 8px; top: 6px; bottom: 6px; width: 1px; background: var(--border); content: ""; }
.timeline-item { position: relative; padding: 0 0 20px; }
.timeline-dot { position: absolute; left: -25px; top: 3px; width: 15px; height: 15px; border: 4px solid var(--card-bg); border-radius: 50%; background: var(--primary); }
.timeline-item small { display: block; color: var(--muted); }
pre.json { max-height: 500px; overflow: auto; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-secondary); color: var(--text); font-size: 11px; }
.http-2 { color: var(--success); }
.http-4 { color: var(--warning); }
.http-5 { color: var(--danger); }
.management-stack { display: grid; gap: 14px; }
.management-card > .card-header > div:first-child small { display: block; margin-top: 2px; font-size: 9px; }
.modal-content, .dropdown-menu { border-color: var(--border); background: var(--card-bg); color: var(--text); }
.modal-content { overflow: hidden; border-radius: 13px; box-shadow: var(--shadow-raised); }
.modal-header { min-height: 66px; padding: 14px 18px; border-color: var(--border); }
.modal-title { margin: 1px 0 0; font-size: 16px; font-weight: 750; letter-spacing: -.025em; }
.modal-kicker { color: var(--primary); font-size: 9px; font-weight: 780; letter-spacing: .09em; text-transform: uppercase; }
.modal-body { padding: 19px 18px; }
.modal-footer { padding: 13px 18px; border-color: var(--border); background: var(--card-secondary); }
.modal-backdrop.show { opacity: .68; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); opacity: .75; }
.alert { border-radius: 9px; font-size: 12px; }
.min-w-0 { min-width: 0; }

@media (max-width: 1199px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .shipment-layout { grid-template-columns: 1fr; }
    .shipment-data-card, .shipment-details-card, .shipment-submit { grid-column: auto; }
    .shipment-details-card > .card-body { grid-template-columns: 1fr; }
    .shipment-details-section + .shipment-details-section { margin-top: 20px; padding: 20px 0 0; border-top: 1px solid var(--border); border-left: 0; }
}
@media (max-width: 991px) {
    .sidebar { transform: translateX(-101%); transition: transform .2s ease; }
    .sidebar.open { transform: none; box-shadow: 14px 0 36px rgba(0, 0, 0, .28); }
    .sidebar.open + .sidebar-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
    .sidebar-close { display: grid; }
    html.sidebar-open, html.sidebar-open body { overflow: hidden; }
    .app-main { padding-top: 58px; padding-left: 0; }
    .app-main > .container-fluid { padding: 24px 18px 36px !important; }
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 575px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-head { align-items: flex-start; flex-direction: column; }
    .page-head .btn { width: 100%; }
    .shipment-address-header { align-items: stretch !important; flex-direction: column; }
    .shipment-address-header .address-select { width: 100%; }
    .section-subhead { align-items: stretch; flex-direction: column; }
    .section-subhead .btn { width: 100%; }
    .shipment-submit .btn { width: 100%; }
    .login-card { padding: 30px 24px; }
    .login-body::before { transform: translate(28vw, -34vh); }
}
