:root {
    --page-bg: #F6F7F9;
    --card-bg: #FFFFFF;
    --text-main: #1F2937;
    --text-regular: #374151;
    --text-sub: #6B7280;
    --text-muted: #9CA3AF;
    --border-light: #EEF0F3;
    --border: #E5E7EB;
    --brand: #2563EB;
    --brand-strong: #1D4ED8;
    --brand-soft: #EFF6FF;
    --brand-border: #BFDBFE;
    --warning: #B45309;
    --warning-soft: #FFF7ED;
    --warning-border: #FED7AA;
    --success: #10B981;
    --success-soft: #ECFDF5;
    --danger: #EF4444;
    --danger-soft: #FEF2F2;
    --info: #3B82F6;
    --info-soft: #EFF6FF;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.04);
    --shadow-float: 0 16px 40px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--page-bg);
    color: var(--text-main);
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
}

.navbar {
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--border-light);
    backdrop-filter: blur(14px);
    min-height: 64px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.container {
    width: min(1200px, calc(100% - 48px));
    margin: 32px auto 72px;
    padding: 0;
}

.surface,
.card,
.stat-card,
.chart-box,
.table-wrap,
.data-table-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.section-header,
.header-actions {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.section-title,
h1 {
    margin: 0;
    color: var(--text-main);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0;
}

.subtitle,
.section-subtitle {
    margin-top: 6px;
    color: var(--text-sub);
    font-size: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    font-weight: 700;
}

.brand-mark,
.logo-box,
.logo-icon {
    background: #F8FAFC;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
}

.brand-title {
    font-size: 18px;
    white-space: nowrap;
}

.store-pill {
    background: var(--brand-soft);
    color: var(--brand-strong);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.main-nav a {
    min-height: 36px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-sm);
    color: var(--text-sub);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.main-nav a:hover,
.main-nav a.active {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.store-id-chip {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.btn,
.btn-mini,
.btn-outline,
.btn-primary,
.btn-danger,
.btn-logout,
.action-btn {
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.btn {
    min-height: 40px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
}

.btn-sm {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-primary,
.action-primary {
    background: var(--brand);
    color: #FFFFFF;
}

.btn-primary:hover,
.action-primary:hover {
    background: var(--brand-strong);
}

.btn-outline,
.action-secondary {
    background: #FFFFFF;
    color: var(--text-regular);
    border: 1px solid var(--border);
}

.btn-outline:hover,
.action-secondary:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
}

.btn-danger,
.action-danger {
    background: var(--danger);
    color: #FFFFFF;
}

.btn-danger:hover,
.action-danger:hover {
    background: #DC2626;
}

.btn-logout {
    color: var(--text-sub);
    background: transparent;
}

.btn-logout:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 22px;
}

.stat-label {
    margin-bottom: 8px;
    color: var(--text-sub);
    font-size: 13px;
    font-weight: 600;
}

.stat-value {
    color: var(--text-main);
    font-size: 30px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0;
}

.stat-unit {
    margin-left: 4px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.charts-section,
.layout-split {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 0.9fr);
    gap: 20px;
    margin-bottom: 24px;
}

.chart-box {
    padding: 22px;
}

.box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.box-title {
    margin: 0 0 18px;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 700;
}

.box-header .box-title {
    margin-bottom: 0;
}

.info-list {
    display: grid;
    gap: 2px;
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-sub);
    font-size: 14px;
}

.info-row:last-child {
    border-bottom: 0;
}

.info-val {
    color: var(--text-main);
    font-weight: 600;
    text-align: right;
    word-break: break-all;
}

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-dot::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}

.status-ok { color: var(--success); }
.status-warn { color: var(--warning); }
.status-danger { color: var(--danger); }

.action-stack {
    display: grid;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.action-btn {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 700;
}

.tabs {
    width: fit-content;
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    padding: 5px;
    background: #FFFFFF;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.tab-item {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    color: var(--text-sub);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.tab-item.active {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    padding: 14px 20px;
    text-align: left;
    background: #F9FAFB;
    color: var(--text-sub);
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    font-weight: 700;
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: 0;
}

tr:hover {
    background: #FAFAFA;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.tag-green { background: var(--success-soft); color: #047857; }
.tag-red { background: var(--danger-soft); color: #B91C1C; }
.tag-orange { background: var(--warning-soft); color: var(--warning); }
.tag-blue { background: var(--info-soft); color: #1D4ED8; }
.tag-gray { background: #F3F4F6; color: var(--text-sub); }

.page-grid {
    display: grid;
    gap: 20px;
}

.quick-grid,
.preview-grid,
.filter-grid,
.summary-grid {
    display: grid;
    gap: 16px;
}

.quick-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 24px;
}

.preview-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(280px, 0.85fr);
}

.filter-grid {
    grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(150px, 0.45fr));
    align-items: end;
}

.summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 22px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-title {
    margin: 0;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 800;
}

.panel-link {
    color: var(--brand-strong);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.quick-card {
    display: block;
    min-height: 116px;
    padding: 18px;
    background: #FFFFFF;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    color: inherit;
    text-decoration: none;
}

.quick-card:hover {
    border-color: var(--brand-border);
}

.quick-icon {
    width: 38px;
    height: 38px;
    margin-bottom: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 900;
}

.quick-icon.warn { background: var(--warning-soft); color: var(--warning); }
.quick-icon.green { background: var(--success-soft); color: #047857; }
.quick-icon.gray { background: #F3F4F6; color: var(--text-sub); }

.quick-title {
    color: var(--text-main);
    font-size: 15px;
    font-weight: 800;
}

.quick-desc {
    margin-top: 5px;
    color: var(--text-sub);
    font-size: 12px;
    line-height: 1.5;
}

.task-list {
    display: grid;
    gap: 12px;
}

.task-item {
    padding: 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: #F9FAFB;
}

.task-label {
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 700;
}

.task-value {
    margin-top: 6px;
    color: var(--text-main);
    font-size: 18px;
    font-weight: 800;
}

.mini-list {
    display: grid;
    gap: 10px;
}

.mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.mini-row:last-child {
    border-bottom: 0;
}

.mini-main {
    min-width: 0;
}

.mini-title {
    color: var(--text-main);
    font-size: 14px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-sub {
    margin-top: 4px;
    color: var(--text-sub);
    font-size: 12px;
}

.empty-line {
    padding: 28px 0;
    color: var(--text-muted);
    text-align: center;
    font-size: 14px;
}

.form-control {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    color: var(--text-main);
    outline: none;
}

.form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 800;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    min-height: 34px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #FFFFFF;
    color: var(--text-sub);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.chip.active {
    border-color: var(--brand-border);
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.product-thumb {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #F8FAFC;
    color: var(--text-muted);
    font-weight: 800;
    object-fit: cover;
}

.product-thumb-img {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #F8FAFC;
    object-fit: cover;
    display: block;
}

.product-hero-img {
    width: 100%;
    aspect-ratio: 4 / 3;
    margin-bottom: 18px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: #F8FAFC;
    object-fit: cover;
    display: block;
}

.drawer-mask {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    justify-content: flex-end;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(4px);
}

.drawer {
    width: min(520px, 100%);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #FFFFFF;
    border-left: 1px solid var(--border-light);
    box-shadow: var(--shadow-float);
}

.drawer-header {
    padding: 20px 22px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.drawer-title {
    font-size: 18px;
    font-weight: 800;
}

.drawer-body {
    padding: 22px;
    overflow-y: auto;
}

.danger-zone {
    border-color: #FECACA;
    background: #FFFBFB;
}

.list-hint {
    display: none;
    margin: 0 0 12px;
    padding: 10px 14px;
    border: 1px solid var(--brand-border);
    border-radius: var(--radius-md);
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 13px;
}

.list-hint.show {
    display: block;
}

.modal-mask,
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(4px);
}

.modal-card,
.modal {
    width: min(520px, 100%);
    max-height: 84vh;
    overflow: hidden;
    background: #FFFFFF;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
}

.m-header {
    padding: 18px 22px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
}

.m-body {
    padding: 22px;
    overflow-y: auto;
}

.m-close {
    color: var(--text-muted);
    cursor: pointer;
    font-size: 22px;
}

.m-info-bar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: #F9FAFB;
    color: var(--text-regular);
    font-size: 13px;
}

.order-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.order-item:last-child {
    border-bottom: 0;
}

.oi-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.oi-img {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #F3F4F6;
    object-fit: cover;
}

.oi-info {
    min-width: 0;
}

.oi-info div:first-child {
    color: var(--text-main);
    font-size: 14px;
    font-weight: 700;
}

.oi-info div:last-child {
    margin-top: 3px;
    color: var(--text-sub);
    font-size: 12px;
}

.oi-right {
    color: var(--brand-strong);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 800;
    white-space: nowrap;
}

.loading-mask,
#loader {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.88);
    color: var(--brand-strong);
    font-weight: 700;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 900px) {
    .container {
        width: min(100% - 28px, 1200px);
        margin-top: 20px;
    }

    .navbar {
        padding-left: 16px !important;
        padding-right: 16px !important;
        align-items: flex-start;
        flex-direction: column;
        padding-top: 12px !important;
        padding-bottom: 12px !important;
    }

    .main-nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }

    .section-header,
    .header-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .grid-cards,
    .charts-section,
    .layout-split,
    .quick-grid,
    .preview-grid,
    .filter-grid,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        width: 100%;
        overflow-x: auto;
    }

    .tab-item {
        flex: 1;
        text-align: center;
        white-space: nowrap;
    }

    .table-wrap,
    .data-table-wrap,
    .card {
        overflow-x: auto;
    }

    table {
        min-width: 760px;
    }
}
