:root {
    --ui-scale: 1.5;
    --bg: #f2f5f9;
    --panel: #ffffff;
    --line: #e6ebf2;
    --line-strong: #d3dae6;
    --text: #1c2430;
    --muted: #7b8796;
    --nav: #182338;
    --nav-active: #2f3f5f;
    --blue: #4f6ef7;
    --blue-dark: #3755db;
    --violet: #7a5af8;
    --orange: #ff9f1a;
    --red: #ff4d4f;
    --green: #14b86e;
    --row: #f8fafc;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font: 12px/1.45 "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
    zoom: var(--ui-scale);
}

[hidden] {
    display: none !important;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button {
    height: 30px;
    min-width: 74px;
    border: 0;
    border-radius: 4px;
    color: #fff;
    background: var(--blue);
    cursor: pointer;
    padding: 0 14px;
    white-space: nowrap;
}

button:hover {
    background: var(--blue-dark);
}

button.secondary {
    color: var(--blue);
    border: 1px solid #cad4e4;
    background: #fff;
}

button.secondary:hover {
    background: #f4f7ff;
}

button.compact-button {
    min-width: 52px;
    height: 26px;
    padding: 0 10px;
}

button.text-button {
    min-width: auto;
    height: auto;
    padding: 0;
    color: var(--blue);
    background: transparent;
}

button.avatar {
    width: auto;
    min-width: 30px;
    max-width: 74px;
    height: 30px;
    padding: 0 8px;
    border-radius: 15px;
    background: var(--blue);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}

.login-panel {
    width: min(360px, 100%);
    display: grid;
    gap: 14px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(24, 35, 56, 0.08);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.login-brand img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.login-brand h1 {
    margin: 0;
    font-size: 18px;
}

.form-error {
    min-height: 18px;
    margin: 0;
    color: var(--red);
}

.form-hint {
    margin: 0;
    color: var(--muted);
}

.primary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    color: #fff;
    background: var(--blue);
    border-radius: 4px;
    text-decoration: none;
}

.primary-link:hover {
    background: var(--blue-dark);
}

.erp-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 86px minmax(0, 1fr);
}

.side-nav {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--nav);
    color: #dbe3f3;
    padding: 8px 6px;
}

.side-brand {
    height: 38px;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

.side-brand-avatar {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: #4f6ef7;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
}

.side-brand-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-tabs {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.nav-tab {
    min-width: 0;
    width: 100%;
    height: 28px;
    padding: 0 6px;
    border-radius: 4px;
    color: #dbe3f3;
    background: transparent;
    text-align: left;
    font-size: 10px;
}

.nav-tab:hover,
.nav-tab.is-active {
    background: var(--nav-active);
    color: #fff;
}

.main-area {
    min-width: 0;
    padding-bottom: 28px;
}

.top-bar {
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.top-bar h1 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.subject-pill {
    max-width: 150px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--blue);
    background: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-actions select {
    width: 178px;
    height: 24px;
    font-size: 10px;
}

.timezone-banner {
    min-height: 28px;
    display: flex;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    color: #566277;
    background: #f8fafc;
    font-size: 10px;
}

.tab-panel {
    display: none;
    padding: 10px 12px 0;
}

.tab-panel.is-active {
    display: block;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.metric-card {
    min-height: 76px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-left: 4px solid transparent;
    border-radius: 5px;
    background: var(--panel);
}

.metric-card span,
.metric-card small {
    display: block;
    color: var(--muted);
}

.metric-card span {
    margin-bottom: 6px;
    font-size: 10px;
}

.metric-card strong {
    display: block;
    font-size: 22px;
    line-height: 1.05;
    letter-spacing: 0;
}

.metric-card small {
    margin-top: 6px;
    font-size: 9px;
}

.accent-blue {
    border-left-color: var(--blue);
}

.accent-violet {
    border-left-color: var(--violet);
}

.accent-orange {
    border-left-color: var(--orange);
}

.accent-red {
    border-left-color: var(--red);
}

.accent-green {
    border-left-color: var(--green);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 10px;
}

.panel,
.filter-panel {
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel);
}

.panel,
.filter-panel {
    padding: 12px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 22px;
    margin-bottom: 10px;
}

.panel-head h2,
.panel > h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
}

.panel-head span {
    color: var(--muted);
    font-size: 10px;
}

.chart-panel,
.donut-panel {
    min-height: 150px;
}

.bar-chart {
    height: 112px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    align-items: end;
    gap: 16px;
    padding: 6px 8px 0;
}

.bar-chart.is-empty {
    display: grid;
    place-items: center;
    grid-template-columns: 1fr;
}

.chart-empty {
    color: var(--muted);
    font-size: 10px;
}

.bar-chart span {
    position: relative;
    height: var(--h);
    min-height: 28px;
    border-radius: 3px 3px 0 0;
    background: var(--blue);
}

.bar-chart b {
    position: absolute;
    left: 50%;
    top: -17px;
    transform: translateX(-50%);
    color: #4a5565;
    font-size: 9px;
    font-weight: 700;
    white-space: nowrap;
}

.bar-chart i {
    position: absolute;
    left: 50%;
    bottom: -18px;
    transform: translateX(-50%);
    color: var(--muted);
    font-style: normal;
    font-size: 9px;
    white-space: nowrap;
}

.donut-wrap {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 10px;
}

.donut {
    width: 112px;
    height: 112px;
    margin: auto;
    border-radius: 50%;
    background:
        radial-gradient(circle at center, #fff 0 47%, transparent 48%),
        var(--donut-bg, conic-gradient(#d8e0ed 0 100%));
    display: grid;
    place-content: center;
    text-align: center;
}

.donut.is-empty {
    --donut-bg: conic-gradient(#d8e0ed 0 100%);
}

.donut b,
.donut em {
    display: block;
}

.donut b {
    font-size: 18px;
}

.donut em {
    color: var(--muted);
    font-size: 9px;
    font-style: normal;
}

.legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 9px;
    color: var(--text);
}

.legend li {
    white-space: nowrap;
}

.legend span {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-radius: 50%;
}

.blue-dot {
    background: var(--blue);
}

.green-dot {
    background: var(--green);
}

.orange-dot {
    background: var(--orange);
}

.violet-dot {
    background: var(--violet);
}

.task-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.task-list li {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    align-items: center;
    color: var(--text);
}

.task-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.task-dot.orange {
    background: var(--orange);
}

.task-dot.red {
    background: var(--red);
}

.task-dot.blue {
    background: var(--blue);
}

.task-dot.green {
    background: var(--green);
}

.filter-panel {
    margin-bottom: 10px;
}

.quick-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr)) auto auto;
    gap: 8px;
    align-items: end;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.action-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

form + form {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

label {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 10px;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid #d9e1ec;
    border-radius: 3px;
    color: var(--text);
    background: #fff;
}

input,
select {
    height: 28px;
    padding: 0 8px;
}

textarea {
    min-height: 72px;
    resize: vertical;
    padding: 7px 8px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    outline: 2px solid rgba(79, 110, 247, 0.12);
}

form > button {
    margin-top: 10px;
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

.table-panel .panel-head {
    margin: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}

.table-wrap {
    width: 100%;
    overflow: auto;
}

.data-table,
.table-wrap table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.data-table.compact {
    min-width: 0;
}

th,
td {
    height: 31px;
    border-bottom: 1px solid var(--line);
    padding: 6px 12px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #4a5565;
    font-size: 10px;
    font-weight: 700;
    background: #f6f8fb;
}

td {
    color: #273143;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

tbody tr:nth-child(even) {
    background: var(--row);
}

.status-green {
    color: var(--green);
    font-weight: 700;
}

.status-orange {
    color: var(--orange);
    font-weight: 700;
}

.status-red {
    color: var(--red);
    font-weight: 700;
}

.status-blue {
    color: var(--blue);
    font-weight: 700;
}

.toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 20;
    min-width: 220px;
    max-width: 360px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-left: 4px solid var(--blue);
    border-radius: 5px;
    color: var(--text);
    background: #fff;
    box-shadow: 0 10px 24px rgba(24, 35, 56, 0.14);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.is-ok {
    border-left-color: var(--green);
}

.toast.is-error {
    border-left-color: var(--red);
}

@media (max-width: 1100px) {
    .erp-shell {
        grid-template-columns: 1fr;
    }

    .side-nav {
        position: static;
        height: auto;
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 8px;
    }

    .nav-tabs {
        margin: 0;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .nav-tab {
        text-align: center;
    }

    .dashboard-grid,
    .action-grid,
    .action-grid.two,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .quick-row {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }
}

@media (max-width: 720px) {
    .top-bar {
        height: auto;
        min-height: 44px;
        display: grid;
        gap: 8px;
        padding: 8px 12px;
    }

    .top-actions {
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .timezone-banner {
        padding: 7px 12px;
    }

    .metric-grid,
    .quick-row,
    .nav-tabs,
    .donut-wrap {
        grid-template-columns: 1fr;
    }

    .toast {
        right: 12px;
        bottom: 12px;
        left: 12px;
        max-width: none;
    }
}
