:root {
    --navy-950: #0b1f33;
    --navy-900: #102a43;
    --navy-800: #173f5f;
    --navy-700: #24577a;
    --blue-600: #1877b7;
    --teal-600: #00897b;
    --teal-100: #dff6f1;
    --amber-500: #e8a317;
    --amber-100: #fff3d5;
    --red-600: #c23b3b;
    --red-100: #fde9e7;
    --slate-900: #17212b;
    --slate-700: #475569;
    --slate-500: #7a8898;
    --slate-300: #cfd8e3;
    --slate-200: #e3e9ef;
    --slate-100: #f1f5f8;
    --slate-50: #f7f9fb;
    --white: #fff;
    --shadow-sm: 0 1px 3px rgba(15, 35, 55, .08);
    --shadow-md: 0 12px 32px rgba(15, 35, 55, .09);
    --radius: 14px;
    --sidebar: 248px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--slate-900); background: var(--slate-50); font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif; font-size: 14px; line-height: 1.55; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(26px, 3vw, 38px); line-height: 1.18; letter-spacing: -.02em; }
h2 { margin-bottom: 5px; font-size: 21px; }
h3 { margin-bottom: 7px; }
.muted { color: var(--slate-500); }
.eyebrow { margin-bottom: 7px; color: var(--teal-600); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; flex-direction: column; width: var(--sidebar); color: #d7e3ed; background: var(--navy-950); }
.brand { display: flex; align-items: center; gap: 12px; padding: 24px 22px; }
.brand-mark { display: inline-grid; flex: 0 0 40px; width: 40px; height: 40px; place-items: center; color: var(--navy-950); background: #63d4c1; border-radius: 11px; font-size: 18px; font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand strong { color: white; font-size: 17px; letter-spacing: .03em; }
.brand small { margin-top: 1px; color: #8fa9bd; font-size: 11px; }
.side-nav { flex: 1; padding: 9px 12px; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: 12px; margin: 3px 0; padding: 10px 12px; color: #bad0df; border-radius: 9px; font-weight: 600; transition: .16s ease; }
.side-nav a:hover, .side-nav a.active { color: white; background: rgba(92, 198, 181, .13); }
.side-nav a.active { box-shadow: inset 3px 0 #62cfbd; }
.side-nav a span { width: 20px; color: #72c8bb; font-size: 18px; text-align: center; }
.side-nav a b { min-width: 20px; margin-left: auto; padding: 1px 6px; color: var(--navy-950); background: #f5c45b; border-radius: 20px; font-size: 11px; text-align: center; }
.nav-label { padding: 20px 12px 7px; color: #648198; font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin: 12px; padding: 12px; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.07); border-radius: 12px; }
.sidebar-user .avatar { display: grid; flex: 0 0 34px; height: 34px; place-items: center; color: white; background: var(--navy-700); border-radius: 10px; font-weight: 800; }
.sidebar-user > span:nth-child(2) { min-width: 0; flex: 1; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { color: white; font-size: 12px; }
.sidebar-user small { color: #7895aa; font-size: 10px; }
.icon-button { color: #9ab0c1; background: transparent; border: 0; font-size: 18px; }

.main-content { min-height: 100vh; margin-left: var(--sidebar); }
.content-wrap { width: min(1480px, 100%); margin: 0 auto; padding: 38px 42px 70px; }
.mobile-header, .mobile-nav { display: none; }
.page-heading { margin-bottom: 27px; }
.page-heading > div > p:last-child, .page-heading > p:last-child { max-width: 680px; margin-bottom: 0; color: var(--slate-500); }
.heading-with-actions { display: flex; align-items: flex-end; justify-content: space-between; gap: 25px; }
.button-group { display: flex; align-items: center; gap: 9px; }
.button-group form { margin: 0; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 9px 16px; color: var(--slate-700); background: white; border: 1px solid var(--slate-300); border-radius: 9px; font-weight: 700; line-height: 1; transition: .15s ease; white-space: nowrap; }
.button:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.button.primary { color: white; background: var(--teal-600); border-color: var(--teal-600); }
.button.secondary { background: white; }
.button.danger { color: white; background: var(--red-600); border-color: var(--red-600); }
.button.dashed { color: var(--navy-700); background: transparent; border-style: dashed; }
.button.wide { width: 100%; }
.button.large { min-height: 51px; font-size: 15px; }
.button.small { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.text-link { color: var(--blue-600); font-weight: 700; white-space: nowrap; }
.strong-link { color: var(--navy-800); font-weight: 800; }
.text-button { padding: 0; background: transparent; border: 0; font-weight: 700; }
.danger-text { color: var(--red-600); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 34px; }
.stat-card { position: relative; min-height: 144px; padding: 23px; overflow: hidden; background: white; border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat-card::after { position: absolute; right: -25px; bottom: -40px; width: 105px; height: 105px; background: var(--slate-100); border-radius: 50%; content: ""; }
.stat-card.accent::after { background: var(--teal-100); }
.stat-card.warning::after { background: var(--amber-100); }
.stat-card .stat-label, .stat-card strong, .stat-card small { position: relative; z-index: 1; display: block; }
.stat-card .stat-label { color: var(--slate-500); font-size: 12px; font-weight: 700; }
.stat-card strong { margin: 7px 0 1px; color: var(--navy-900); font-size: 38px; line-height: 1.1; }
.stat-card small { color: var(--slate-500); }
.stat-card small a { color: #a26700; font-weight: 700; }

.section-block { margin-top: 34px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.section-heading p, .section-heading h2 { margin-bottom: 0; }
.warehouse-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.warehouse-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; min-height: 105px; padding: 18px; background: white; border: 1px solid var(--slate-200); border-radius: var(--radius); transition: .15s ease; }
.warehouse-card:hover { border-color: #a9c9d6; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.warehouse-icon { display: grid; width: 48px; height: 48px; place-items: center; color: var(--navy-800); background: #e7f2f6; border-radius: 12px; font-size: 19px; font-weight: 900; }
.warehouse-card h3, .warehouse-card p { margin: 0; }
.warehouse-card p { color: var(--slate-500); font-size: 12px; }
.warehouse-card p strong { color: var(--navy-900); font-size: 17px; }
.badge, .status { display: inline-flex; align-items: center; padding: 4px 9px; color: var(--slate-700); background: var(--slate-100); border-radius: 99px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.success, .status.posted { color: #087264; background: var(--teal-100); }
.badge.danger, .status.cancelled { color: #a62e2e; background: var(--red-100); }
.status.draft { color: #946100; background: var(--amber-100); }

.table-card { background: white; border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--slate-200); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--slate-500); background: #fafbfd; font-size: 11px; font-weight: 800; letter-spacing: .035em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfe; }
td.number, th.number { text-align: right; }
.cell-subtitle { display: block; color: var(--slate-500); font-size: 11px; }
.warehouse-pill { color: var(--navy-700); font-weight: 700; }
.empty-row, .empty-state { padding: 28px; color: var(--slate-500); text-align: center; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; padding: 12px; background: white; border: 1px solid var(--slate-200); border-radius: 12px; }
.filter-bar .grow { flex: 1; }
.form-control { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--slate-900); background: white; border: 1px solid var(--slate-300); border-radius: 8px; outline: none; transition: border .15s, box-shadow .15s; }
.form-control:focus { border-color: #38a997; box-shadow: 0 0 0 3px rgba(0, 137, 123, .1); }
.form-control.large { min-height: 50px; padding: 12px 13px; }
textarea.form-control { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.field { min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field label { display: block; margin-bottom: 6px; color: var(--slate-700); font-size: 12px; font-weight: 800; }
.field label sup { color: var(--red-600); }
.field label em { color: var(--teal-600); font-style: normal; }
.field small { display: block; margin-top: 5px; color: var(--slate-500); font-size: 11px; }
.field .errorlist, .errorlist { margin: 4px 0 0; padding: 0; color: var(--red-600); font-size: 11px; list-style: none; }
.check-input { margin: 10px 6px 0 0; }
.form-error { margin-bottom: 14px; padding: 11px 13px; color: #9f2828; background: var(--red-100); border-radius: 8px; }
.form-card { margin-bottom: 17px; padding: 23px; background: white; border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.form-card-heading { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--slate-200); }
.form-card-heading > span { display: grid; width: 34px; height: 34px; place-items: center; color: var(--teal-600); background: var(--teal-100); border-radius: 9px; font-size: 11px; font-weight: 900; }
.form-card-heading h2, .form-card-heading p { margin: 0; }
.form-card-heading p { color: var(--slate-500); font-size: 12px; }
.narrow-form { max-width: 820px; }
.form-actions { display: flex; gap: 9px; margin-top: 23px; }

.line-card { position: relative; margin-bottom: 13px; padding: 18px; background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: 11px; }
.line-index { margin-bottom: 12px; color: var(--navy-700); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.line-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.2fr 1fr; gap: 12px; align-items: start; }
.line-grid .line-note { grid-column: span 2; }
.line-footer { display: flex; justify-content: flex-end; margin-top: 11px; }
.delete-check, .hidden-fields { display: none; }
.sticky-actions { position: sticky; z-index: 10; bottom: 18px; display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; padding: 13px; background: rgba(255,255,255,.9); border: 1px solid var(--slate-200); border-radius: 12px; box-shadow: var(--shadow-md); backdrop-filter: blur(10px); }
.upload-zone { display: flex; min-height: 145px; flex-direction: column; align-items: center; justify-content: center; padding: 20px; color: var(--slate-700); background: var(--slate-50); border: 1.5px dashed #9ab4c4; border-radius: 11px; cursor: pointer; text-align: center; }
.upload-zone:hover { background: #f0f8f7; border-color: var(--teal-600); }
.upload-icon { display: grid; width: 36px; height: 36px; margin-bottom: 7px; place-items: center; color: white; background: var(--teal-600); border-radius: 50%; font-size: 22px; }
.upload-zone small { color: var(--slate-500); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.file-preview, .existing-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-chip, .existing-files a { padding: 6px 10px; color: var(--navy-700); background: #edf4f7; border-radius: 7px; font-size: 11px; }

.document-hero { display: grid; grid-template-columns: 240px 1fr; gap: 25px; padding: 24px; color: white; background: linear-gradient(125deg, var(--navy-950), var(--navy-800)); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.document-hero h2 { margin-top: 12px; font-size: 28px; }
.document-hero dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 0; }
.document-hero dl div { min-width: 0; }
.document-hero dt { color: #9eb9cb; font-size: 10px; font-weight: 800; letter-spacing: .05em; }
.document-hero dd { margin: 3px 0 0; overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; }
.attachment-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.attachment-grid a { padding: 16px; background: white; border: 1px solid var(--slate-200); border-radius: 10px; }
.attachment-grid span, .attachment-grid strong { display: block; }
.attachment-grid span { color: var(--teal-600); font-size: 11px; font-weight: 800; }
.attachment-grid strong { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 35px; padding: 18px; background: var(--red-100); border: 1px solid #f6cbc7; border-radius: 12px; }
.danger-zone h3, .danger-zone p { margin: 0; }
.danger-zone p { color: #98514d; font-size: 12px; }
.cancel-form { display: flex; gap: 8px; }
.cancel-form input { min-width: 260px; }
.muted-zone { background: var(--slate-100); border-color: var(--slate-200); }

.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.info-card { padding: 20px; background: white; border: 1px solid var(--slate-200); border-radius: var(--radius); }
.info-card .card-top { display: flex; justify-content: space-between; }
.info-card h3 { margin-top: 16px; }
.info-card p { min-height: 23px; color: var(--slate-500); }
.status-dot { width: 8px; height: 8px; background: var(--teal-600); border-radius: 50%; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings-list { border-top: 1px solid var(--slate-200); }
.settings-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--slate-200); }
.settings-list a:last-child { border-bottom: 0; }
.settings-list strong, .settings-list small { display: block; }
.settings-list small, .settings-list > a > span:last-child { color: var(--slate-500); font-size: 11px; }

.message-stack { position: fixed; z-index: 100; top: 18px; right: 22px; width: min(410px, calc(100vw - 30px)); }
.message { margin-bottom: 8px; padding: 12px 14px; color: #6a4a00; background: var(--amber-100); border: 1px solid #f2dfaa; border-radius: 9px; box-shadow: var(--shadow-md); }
.message.success { color: #075c52; background: var(--teal-100); border-color: #afe2d9; }
.message.error { color: #922b2b; background: var(--red-100); border-color: #f0c4c1; }

.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(400px, .9fr) 1.1fr; background: white; }
.login-copy { display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; padding: 54px 62px; color: white; background: radial-gradient(circle at 85% 80%, rgba(43,141,128,.28), transparent 35%), linear-gradient(145deg, #071b2c, #153e5c); }
.login-copy .brand { padding: 0; }
.login-copy h1 { margin: 15px 0 20px; font-size: clamp(38px, 5vw, 64px); }
.login-copy > div > p:last-child { max-width: 500px; color: #a9c0d0; font-size: 16px; }
.login-copy > small { color: #7693a8; }
.login-panel { display: grid; place-items: center; padding: 35px; }
.login-card { width: min(430px, 100%); }
.login-card h2 { margin-bottom: 4px; font-size: 32px; }
.login-card > label { display: block; margin: 20px 0 7px; font-weight: 800; }
.login-card .button { margin-top: 25px; }
.security-note { display: block; margin-top: 20px; color: var(--slate-500); text-align: center; }
.mobile-login-brand { display: none; }

@media (max-width: 1100px) {
    .content-wrap { padding: 32px 27px 70px; }
    .warehouse-grid, .card-grid, .settings-grid { grid-template-columns: repeat(2, 1fr); }
    .line-grid { grid-template-columns: repeat(3, 1fr); }
    .login-copy { padding: 45px; }
}

@media (max-width: 760px) {
    body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .mobile-header { position: sticky; z-index: 25; top: 0; display: flex; height: 62px; align-items: center; justify-content: space-between; padding: 8px 16px; background: rgba(11,31,51,.96); backdrop-filter: blur(10px); }
    .mobile-header .brand { padding: 0; }
    .mobile-header .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 15px; }
    .mobile-header .brand strong { font-size: 15px; }
    .quick-plus { display: grid; width: 36px; height: 36px; place-items: center; color: white; background: var(--teal-600); border-radius: 10px; font-size: 22px; }
    .mobile-nav { position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; display: grid; height: calc(63px + env(safe-area-inset-bottom)); grid-template-columns: repeat(5, 1fr); padding: 5px 5px env(safe-area-inset-bottom); background: white; border-top: 1px solid var(--slate-200); box-shadow: 0 -8px 30px rgba(20,40,60,.08); }
    .mobile-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--slate-500); font-size: 10px; font-weight: 700; }
    .mobile-nav a span { font-size: 19px; }
    .mobile-nav a.active { color: var(--teal-600); }
    .mobile-nav .mobile-action span { display: grid; width: 36px; height: 36px; margin-top: -20px; place-items: center; color: white; background: var(--navy-900); border: 4px solid white; border-radius: 50%; font-size: 23px; }
    .content-wrap { padding: 22px 14px 24px; }
    .page-heading { margin-bottom: 20px; }
    .heading-with-actions { display: block; }
    .heading-with-actions > .button-group, .heading-with-actions > .button { margin-top: 14px; }
    .heading-with-actions > .button-group { display: grid; grid-template-columns: 1fr 1fr; }
    .desktop-only { display: none !important; }
    h1 { font-size: 28px; }
    .stat-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
    .stat-card { min-height: 112px; padding: 15px 12px; }
    .stat-card strong { font-size: 29px; }
    .stat-card small { font-size: 10px; }
    .warehouse-grid, .card-grid, .settings-grid { grid-template-columns: 1fr; }
    .warehouse-card { min-height: 90px; padding: 14px; }
    .warehouse-card .badge { display: none; }
    .section-heading { align-items: center; }
    .filter-bar { display: grid; grid-template-columns: 1fr 100px; }
    .filter-bar .grow { grid-column: 1 / -1; grid-row: 1; }
    .form-card { padding: 17px 14px; }
    .form-grid { grid-template-columns: 1fr; }
    .field.span-2 { grid-column: auto; }
    .line-card { padding: 14px; }
    .line-grid { grid-template-columns: 1fr 1fr; }
    .line-grid .material-field, .line-grid .line-note { grid-column: 1 / -1; }
    .sticky-actions { bottom: 72px; display: grid; grid-template-columns: 1fr 1fr; padding: 9px; }
    .sticky-actions .button.primary { grid-column: 1 / -1; grid-row: 1; }
    .document-hero { grid-template-columns: 1fr; padding: 19px; }
    .document-hero dl { grid-template-columns: repeat(2, 1fr); }
    .attachment-grid { grid-template-columns: 1fr; }
    .danger-zone, .cancel-form { align-items: stretch; flex-direction: column; }
    .cancel-form input { min-width: 0; }
    .message-stack { top: 70px; right: 12px; }
    .login-shell { display: block; background: linear-gradient(160deg, #0b2439 0 32%, var(--slate-50) 32%); }
    .login-copy { display: none; }
    .login-panel { min-height: 100vh; padding: 25px 17px; }
    .login-card { padding: 26px 21px; background: white; border-radius: 16px; box-shadow: var(--shadow-md); }
    .mobile-login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; color: var(--navy-900); }
    .mobile-login-brand .brand-mark { width: 36px; height: 36px; flex-basis: 36px; }
}

