:root {
    --canvas: #f2f5f3;
    --surface: #ffffff;
    --surface-muted: #f7f9f8;
    --border: #d7dfda;
    --border-strong: #b9c5bd;
    --ink: #172019;
    --muted: #68736c;
    --green: #21764a;
    --green-hover: #185d3a;
    --green-soft: #e4f1e9;
    --blue: #2c68b1;
    --blue-soft: #e6eef9;
    --amber: #9a6108;
    --amber-soft: #f8edd8;
    --red: #b13a35;
    --red-soft: #f8e8e6;
    --shadow: 0 8px 24px rgba(26, 46, 34, 0.08);
    --sidebar-width: 224px;
}

* { box-sizing: border-box; }

html { min-height: 100%; font-size: 14px; }

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
    letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 1.9; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 18px 12px 12px;
    color: #ecf4ef;
    background: #1b2b22;
    border-right: 1px solid #0f1a14;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-mark, .login-brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    color: #163021;
    background: #89d3a7;
    border-radius: 6px;
    font-size: 20px;
    font-weight: 800;
}
.brand span:last-child { display: grid; gap: 2px; min-width: 0; }
.brand strong { font-size: 16px; white-space: nowrap; }
.brand small { color: #9fb3a6; font-size: 12px; }

.main-nav { display: grid; gap: 4px; }
.main-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 12px;
    color: #c8d5cd;
    border-radius: 5px;
    transition: background-color .15s ease, color .15s ease;
}
.main-nav a:hover { color: #fff; background: #263b30; }
.main-nav a.active { color: #fff; background: #2d6848; box-shadow: inset 3px 0 #9ed9b4; }

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding: 12px 8px 0;
    border-top: 1px solid #31443a;
}
.user-summary { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    color: #1b2b22;
    background: #dceae1;
    border-radius: 50%;
    font-weight: 700;
}
.user-summary > span:last-child { display: grid; min-width: 0; }
.user-summary strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.user-summary small { color: #9fb3a6; font-size: 11px; }

.workspace { min-width: 0; }
.site-filing { padding: 0 24px 18px; color: var(--muted); font-size: 12px; text-align: center; }
.site-filing a, .public-filing a { color: var(--muted); text-decoration: none; }
.site-filing a:hover, .public-filing a:hover { color: var(--blue); text-decoration: underline; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 74px;
    padding: 14px 26px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 21px; line-height: 1.3; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.environment-badge { padding: 5px 8px; color: var(--blue); background: var(--blue-soft); border-radius: 4px; font-size: 12px; font-weight: 700; }
.page-content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 22px 26px 40px; }

.notice { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 10px 12px; border: 1px solid; border-radius: 5px; }
.notice-success { color: #1e6240; background: var(--green-soft); border-color: #b7d9c5; }
.notice-error { color: #8f2f2a; background: var(--red-soft); border-color: #e5bbb8; }

.panel { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: 15px; }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 14px; }
.panel-footer { display: flex; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); }
.section-stack { display: grid; min-width: 0; gap: 16px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 82px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.metric-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 5px; }
.metric-green .metric-icon { color: var(--green); background: var(--green-soft); }
.metric-blue .metric-icon { color: var(--blue); background: var(--blue-soft); }
.metric-amber .metric-icon { color: var(--amber); background: var(--amber-soft); }
.metric-red .metric-icon { color: var(--red); background: var(--red-soft); }
.metric span:last-child { display: grid; min-width: 0; }
.metric strong { font-size: 24px; line-height: 1.1; }
.metric small { margin-top: 4px; color: var(--muted); }

.split-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 16px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar-spacer { margin-left: auto; }
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; font-weight: 500; white-space: nowrap; }
.checkbox-label input { min-height: 0; }
.threshold-toolbar { background: var(--surface-muted); }
.threshold-toolbar input[type="number"] { width: 90px; }
.read-only-value { min-height: 34px; padding: 7px 9px; color: var(--muted); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 4px; }

.button, .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color .15s ease, border-color .15s ease;
}
.button { padding: 0 12px; white-space: nowrap; }
.icon-button { width: 34px; padding: 0; color: inherit; background: transparent; }
.sidebar .icon-button:hover { background: #31473b; }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover { background: var(--green-hover); border-color: var(--green-hover); }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--border-strong); }
.button-secondary:hover { background: var(--surface-muted); border-color: #99a89f; }
.button-danger { color: var(--red); background: var(--surface); border-color: #dfb3b0; }
.button-danger:hover { background: var(--red-soft); }
.button-quiet { color: var(--blue); background: transparent; }
.button-quiet:hover { background: var(--blue-soft); }
.button-block { width: 100%; }
.button[disabled], .icon-button[disabled] { cursor: not-allowed; opacity: .5; }

input, select, textarea {
    min-height: 34px;
    padding: 6px 9px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(44,104,177,.12); }
label { font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field small { color: var(--muted); }
.field-span-2 { grid-column: span 2; }
.field-actions { display: flex; align-items: end; gap: 8px; }
.form-error { padding: 8px 10px; color: #8f2f2a; background: var(--red-soft); border-radius: 4px; }

.table-wrap { width: 100%; max-width: 100%; overflow: auto; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.data-table th, .data-table td { padding: 10px 11px; text-align: left; border-bottom: 1px solid #e3e8e5; vertical-align: middle; }
.data-table th { position: sticky; top: 0; z-index: 1; color: #536058; background: #f4f7f5; font-size: 12px; white-space: nowrap; }
.data-table tr:hover td { background: #f8faf9; }
.data-table td.numeric, .data-table th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.actions { width: 1%; white-space: nowrap; }
.table-empty { padding: 42px 20px; color: var(--muted); text-align: center; }
.settings-table input { width: 100%; max-width: 220px; }
.role-editor { display: flex; align-items: center; gap: 6px; min-width: 190px; }
.role-editor select { min-width: 140px; }
.movement-history-mobile { display: none; }
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; padding: 8px 12px; color: var(--muted); border-top: 1px solid var(--border); }
.pagination-actions { display: flex; align-items: center; gap: 8px; }

.upload-form { display: flex; align-items: center; gap: 12px; padding: 14px; }
.file-drop { display: flex; align-items: center; gap: 10px; min-width: 320px; flex: 1; padding: 10px 12px; background: var(--surface-muted); border: 1px dashed #9bac9f; border-radius: 5px; cursor: pointer; }
.file-drop:hover { border-color: var(--green); background: #f2f8f4; }
.file-drop.is-dragging { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.file-drop > span { display: grid; gap: 2px; min-width: 0; }
.file-drop strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop small { color: var(--muted); font-weight: 400; }
.file-drop input { position: absolute; width: 1px; height: 1px; padding: 0; opacity: 0; pointer-events: none; }

.alert-list { display: grid; }
.alert-row { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 12px; min-height: 66px; padding: 10px 14px; border-bottom: 1px solid #e3e8e5; }
.alert-row:last-child { border-bottom: 0; }
.alert-row p { margin: 4px 0 0; color: var(--muted); }
.alert-row time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.alert-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 5px; }
.alert-icon.low-stock { color: var(--red); background: var(--red-soft); }
.alert-icon.overdue { color: var(--amber); background: var(--amber-soft); }

.status { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 7px; border-radius: 4px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-ok { color: #1e6240; background: var(--green-soft); }
.status-info { color: #255a97; background: var(--blue-soft); }
.status-warning { color: #805006; background: var(--amber-soft); }
.status-danger { color: #94302b; background: var(--red-soft); }
.text-muted { color: var(--muted); }
.text-danger { color: var(--red); font-weight: 700; }
.nowrap { white-space: nowrap; }

.empty-state { max-width: 620px; margin: 80px auto; padding: 30px; text-align: center; }
.empty-state h1 { margin: 0 0 8px; font-size: 22px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }

dialog { width: min(560px, calc(100vw - 28px)); padding: 0; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20, 29, 23, .38); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: 16px; }
.dialog-body { display: grid; gap: 12px; padding: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; background: var(--surface-muted); border-top: 1px solid var(--border); }

.login-body { display: grid; place-items: center; padding: 24px; background: #e8eeea; }
.login-shell { width: min(420px, 100%); }
.public-filing { margin-top: 14px; color: var(--muted); font-size: 12px; text-align: center; }
.login-panel { display: grid; grid-template-columns: 48px minmax(0,1fr); gap: 14px; padding: 26px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; box-shadow: var(--shadow); }
.login-brand-mark { width: 46px; height: 46px; }
.login-panel h1 { margin: 0; font-size: 22px; }
.login-panel p { margin: 5px 0 0; color: var(--muted); }
.login-form { grid-column: 1 / -1; display: grid; gap: 8px; margin-top: 6px; }
.login-note { grid-column: 1 / -1; color: var(--muted); font-size: 12px; text-align: center; }
.login-policy { grid-column: 1 / -1; font-size: 12px; text-align: center; }
.login-policy a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }

.privacy-body { padding: 28px 16px 48px; background: #edf2ef; }
.privacy-shell { width: min(920px, 100%); margin: 0 auto; }
.privacy-hero, .privacy-contact-card, .privacy-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.privacy-hero { position: relative; padding: 36px 38px 30px; }
.privacy-hero h1 { margin: 14px 0 10px; font-size: 30px; line-height: 1.3; }
.privacy-hero p { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.8; }
.privacy-badge { display: inline-flex; padding: 5px 9px; color: #1e6240; background: var(--green-soft); border-radius: 4px; font-size: 12px; font-weight: 700; }
.privacy-meta { margin-top: 18px; color: var(--muted); font-size: 12px; }
.privacy-back { position: absolute; top: 22px; right: 26px; color: var(--blue); font-weight: 600; }
.privacy-back:hover { text-decoration: underline; }
.privacy-contact-card { margin-top: 16px; padding: 22px 30px; }
.privacy-contact-card h2 { margin: 0 0 14px; font-size: 17px; }
.privacy-contact-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.privacy-contact-card dl > div { padding: 12px 14px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 5px; }
.privacy-contact-card dt { color: var(--muted); font-size: 12px; }
.privacy-contact-card dd { margin: 5px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.privacy-contact-card a { color: var(--blue); }
.privacy-content { margin-top: 16px; padding: 30px 38px; }
.privacy-content section + section { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--border); }
.privacy-content h2 { margin: 0 0 14px; font-size: 19px; }
.privacy-content h3 { margin: 20px 0 8px; font-size: 15px; }
.privacy-content p, .privacy-content li { color: #3f4b43; line-height: 1.85; }
.privacy-content p { margin: 8px 0; }
.privacy-content ul { margin: 8px 0; padding-left: 22px; }
.privacy-content li + li { margin-top: 5px; }

@media (max-width: 1080px) {
    :root { --sidebar-width: 76px; }
    .brand > span:last-child, .main-nav a span, .user-summary > span:last-child { display: none; }
    .brand { justify-content: center; padding-left: 0; padding-right: 0; }
    .main-nav a { justify-content: center; padding: 0; }
    .sidebar-footer { justify-content: center; flex-wrap: wrap; }
    .metric-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
    .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .app-shell { display: block; padding-bottom: 62px; }
    .sidebar { position: fixed; inset: auto 0 0; z-index: 20; width: 100%; height: 58px; padding: 5px 8px; border-top: 1px solid #0f1a14; border-right: 0; }
    .brand, .sidebar-footer { display: none; }
    .main-nav { display: grid; grid-template-columns: repeat(5, 1fr); height: 100%; }
    .main-nav a { display: grid; place-items: center; gap: 0; min-height: 46px; padding: 2px; border-radius: 4px; }
    .main-nav a span { display: block; max-width: 100%; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
    .main-nav a svg { width: 18px; height: 18px; }
    .topbar { min-height: 62px; padding: 10px 14px; }
    .topbar h1 { font-size: 18px; }
    .page-content { padding: 14px 12px 24px; }
    .site-filing { padding: 0 12px 76px; }
    .panel-header { align-items: stretch; flex-direction: column; }
    .panel-header > .button { width: 100%; }
    .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .metric { grid-template-columns: 32px minmax(0,1fr); min-height: 72px; padding: 10px; }
    .metric-icon { width: 30px; height: 30px; }
    .metric strong { font-size: 20px; }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .field-span-2 { grid-column: 1 / -1; }
    .toolbar-spacer { margin-left: 0; }
    .upload-form { align-items: stretch; flex-direction: column; }
    .file-drop { width: 100%; min-width: 0; }
    .upload-form .button { width: 100%; }
    .alert-row { grid-template-columns: 34px minmax(0,1fr); }
    .alert-row time { grid-column: 2; }
    .movement-history-table { display: none; }
    .movement-history-mobile { display: block; }
    .movement-history-row { padding: 14px; border-bottom: 1px solid var(--border); }
    .movement-history-row:last-child { border-bottom: 0; }
    .movement-history-row header, .movement-history-row footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
    .movement-history-row header > div { display: grid; gap: 3px; min-width: 0; }
    .movement-history-row header strong { font-size: 16px; }
    .movement-history-row header div span, .movement-history-row footer, .movement-history-row p { color: var(--muted); font-size: 12px; }
    .movement-history-values { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
    .movement-history-values > div { display: grid; gap: 4px; }
    .movement-history-values span { color: var(--muted); font-size: 11px; }
    .movement-history-values strong { font-size: 15px; font-variant-numeric: tabular-nums; }
    .movement-history-row footer time { white-space: nowrap; }
    .movement-history-row p { margin: 10px 0 0; padding-top: 10px; border-top: 1px dashed var(--border); }
    .pagination-bar { align-items: stretch; flex-direction: column; }
    .pagination-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .pagination-actions .button { width: 100%; }
    .privacy-body { padding: 0 0 28px; }
    .privacy-hero, .privacy-contact-card, .privacy-content { border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
    .privacy-hero { padding: 62px 20px 24px; }
    .privacy-hero h1 { font-size: 24px; }
    .privacy-back { top: 20px; left: 20px; right: auto; }
    .privacy-contact-card { padding: 20px; }
    .privacy-contact-card dl { grid-template-columns: 1fr; }
    .privacy-content { padding: 24px 20px; }
}

@media (max-width: 430px) {
    .metric-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .field-span-2 { grid-column: auto; }
}
