* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; background: #eef1f5; color: #1f2937;
  font-family: "Microsoft YaHei", "Segoe UI", system-ui, sans-serif; font-size: 13px;
}
.sidebar { width: 272px; flex: none; background: #fff; border-right: 1px solid #dfe3e8; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 12px; border-bottom: 1px solid #eef0f3; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: #1d4ed8; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.brand-name { font-weight: 600; font-size: 12px; line-height: 1.35; white-space: nowrap; }
.brand-sub { color: #8a94a6; font-size: 11px; margin-top: 2px; }
nav { padding: 8px 8px; overflow: auto; flex: 1; }
.nav-group { color: #8a94a6; font-size: 11px; padding: 12px 10px 4px; letter-spacing: .5px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; color: #374151; cursor: pointer; user-select: none; }
.nav-item:hover { background: #f3f6fb; }
.nav-item.active { background: #e8f0ff; color: #1d4ed8; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; color: #6b7280; }
.nav-item.active .ico { color: #1d4ed8; }
.side-foot { padding: 10px 16px; border-top: 1px solid #eef0f3; color: #9aa3b2; font-size: 11px; line-height: 1.6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 48px; flex: none; background: #fff; border-bottom: 1px solid #dfe3e8; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; }
.crumbs { font-weight: 600; color: #111827; }
.pill { background: #eef2ff; color: #1d4ed8; border-radius: 20px; padding: 3px 10px; font-size: 12px; }
.page { padding: 16px 18px 30px; overflow: auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 12px; }
.page-title { font-size: 20px; font-weight: 600; margin: 0; }
.page-sub { color: #8a94a6; font-size: 12px; margin-top: 3px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.btn { border: 1px solid #d5dae1; background: #fff; color: #374151; border-radius: 6px; padding: 6px 11px; font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.btn:hover { border-color: #b9c2cf; background: #fafbfc; }
.btn.primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: #b91c1c; }
.warehouse { display: flex; align-items: center; gap: 6px; color: #4b5563; }
.warehouse select { height: 31px; border: 1px solid #d5dae1; border-radius: 6px; padding: 0 8px; background: #fff; font-size: 12.5px; }
.search { display: flex; align-items: center; gap: 6px; border: 1px solid #d5dae1; border-radius: 6px; background: #fff; padding: 0 8px; height: 31px; width: 230px; }
.search input { border: 0; outline: 0; flex: 1; font-size: 12.5px; background: transparent; }
.formula-bar { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #dfe3e8; border-radius: 8px 8px 0 0; padding: 6px 10px; border-bottom: 0; color: #6b7280; font-size: 12px; }
.formula-bar .cell-ref { min-width: 54px; color: #1d4ed8; font-weight: 600; }
.formula-bar .fx { color: #9aa3b2; font-style: italic; }
.formula-bar input { flex: 1; border: 0; outline: 0; font-size: 12.5px; color: #374151; background: transparent; }

.sheet { background: #fff; border: 1px solid #dfe3e8; border-radius: 0 0 8px 8px; overflow: auto; max-height: calc(100vh - 250px); }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 12.5px; }
table.grid th, table.grid td { border-right: 1px solid #e3e7ec; border-bottom: 1px solid #e9edf2; padding: 0 8px; height: 32px; white-space: nowrap; }
table.grid th { background: #f2f4f7; color: #4b5563; font-weight: 600; position: sticky; top: 0; z-index: 3; text-align: left; }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid td { background: #fff; outline: 0; overflow: hidden; text-overflow: ellipsis; }
table.grid td.num { font-variant-numeric: tabular-nums; }
table.grid td[contenteditable="true"]:focus { background: #eff6ff; box-shadow: inset 0 0 0 2px #3b82f6; }
table.grid tr:hover td { background: #fbfcfe; }
table.grid td.rowno, table.grid th.rowno { background: #f7f8fa; color: #9aa3b2; text-align: center; width: 46px; min-width: 46px; }
table.grid td.rowno { cursor: default; }
table.grid td.locked { background: #f9fafb; color: #9aa3b2; }
table.grid th.sticky-l, table.grid td.sticky-l { position: sticky; left: 0; z-index: 2; }
table.grid th.sticky-l { z-index: 4; }
table.grid td .cell-txt { display: block; min-height: 30px; line-height: 30px; }

.badge { display: inline-block; font-size: 11.5px; border-radius: 4px; padding: 1px 6px; }
.badge.ok { background: #ecfdf5; color: #047857; }
.badge.warn { background: #fff7ed; color: #c2410c; }
.badge.err { background: #fef2f2; color: #b91c1c; }
.badge.gray { background: #f3f4f6; color: #6b7280; }
.toast { position: fixed; right: 22px; top: 22px; background: #111827; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 12.5px; opacity: 0; transition: .2s; pointer-events: none; z-index: 99; }
.toast.show { opacity: 1; }
.footer-note { color: #8a94a6; font-size: 12px; margin-top: 8px; }

.role-sel{height:30px;border:1px solid #d5dae1;border-radius:6px;background:#fff;font-size:12px;color:#374151;padding:0 6px}

/* 物料选择器 */
.picker-mask{position:fixed;inset:0;background:rgba(15,23,42,.18);z-index:120;display:flex;align-items:flex-start;justify-content:center;padding-top:12vh}
.picker{width:620px;max-width:92vw;background:#fff;border:1px solid #d5dae1;border-radius:10px;box-shadow:0 18px 50px rgba(15,23,42,.22);overflow:hidden}
.picker-head{display:flex;align-items:center;justify-content:space-between;padding:11px 14px;border-bottom:1px solid #eef0f3;font-weight:600}
.picker-head .x{cursor:pointer;color:#9aa3b2;font-size:16px;padding:0 4px}
.picker-search{padding:10px 14px;border-bottom:1px solid #eef0f3}
.picker-search input{width:100%;height:34px;border:1px solid #d5dae1;border-radius:7px;padding:0 10px;font-size:13px;outline:0}
.picker-search input:focus{border-color:#3b82f6;box-shadow:0 0 0 3px #dbeafe}
.picker-list{max-height:320px;overflow:auto}
.picker-item{display:flex;gap:10px;align-items:center;padding:8px 14px;border-bottom:1px solid #f4f6f8;cursor:pointer}
.picker-item:hover,.picker-item.active{background:#eff6ff}
.picker-item .code{width:120px;color:#1d4ed8;font-family:Consolas,monospace;font-size:12px}
.picker-item .name{flex:1;font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.picker-item .unit{width:46px;color:#6b7280;font-size:12px;text-align:right}
.picker-foot{padding:8px 14px;color:#9aa3b2;font-size:11.5px;background:#fafbfc;border-top:1px solid #eef0f3}

/* 单元格下拉选项 */
.cell-picker{position:fixed;z-index:130;background:#fff;border:1px solid #d5dae1;border-radius:8px;box-shadow:0 10px 28px rgba(15,23,42,.18);padding:4px;min-width:120px}
.cell-picker .opt{padding:6px 10px;border-radius:5px;font-size:12.5px;cursor:pointer;white-space:nowrap}
.cell-picker .opt:hover,.cell-picker .opt.active{background:#eff6ff;color:#1d4ed8}

/* 单据预览 */
.doc-mask{position:fixed;inset:0;background:rgba(15,23,42,.45);z-index:150;display:flex;align-items:center;justify-content:center;padding:20px}
.doc-modal{width:min(1180px,96vw);height:92vh;background:#fff;border-radius:10px;box-shadow:0 22px 60px rgba(15,23,42,.3);display:flex;flex-direction:column;overflow:hidden}
.doc-head{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;border-bottom:1px solid #e5e7eb;background:#fff}
.doc-title{font-weight:600;font-size:14px;color:#111827;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.doc-actions{display:flex;gap:8px;flex:none}
.doc-body{flex:1;overflow:auto;background:#eef1f5;padding:18px}
.doc-paper{background:#fff;margin:0 auto;padding:18px;width:max-content;min-width:820px;box-shadow:0 6px 18px rgba(15,23,42,.12)}
.doc-paper table{border-collapse:collapse;table-layout:auto}
.doc-paper td,.doc-paper th{border:1px solid #333;padding:2px 4px;font-size:12px;vertical-align:middle}
.doc-paper tr:first-child td{font-weight:600}

tr.doc-generated td{background:#f0fdf4}
tr.doc-generated td.rowno{color:#15803d;font-weight:600}

/* 登录 */
.logged-out .sidebar,.logged-out .main{display:none}
.login-screen{position:fixed;inset:0;z-index:400;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#e8f0ff 0%,#f7f9fc 55%,#eef7f1 100%)}
.login-card{width:380px;background:#fff;border:1px solid #dfe5ec;border-radius:14px;box-shadow:0 24px 60px rgba(15,23,42,.12);padding:30px 32px 24px;text-align:center}
.login-logo{width:46px;height:46px;border-radius:12px;background:#1d4ed8;color:#fff;font-weight:700;font-size:22px;display:flex;align-items:center;justify-content:center;margin:0 auto 10px}
.login-card h1{font-size:20px;margin:0 0 4px}
.login-sub{color:#8a94a6;font-size:12px;margin-bottom:20px}
.login-field{text-align:left;margin-bottom:12px}
.login-field label{display:block;font-size:12px;color:#6b7280;margin-bottom:5px}
.login-field input{width:100%;height:38px;border:1px solid #d5dae1;border-radius:7px;padding:0 10px;font-size:13px;outline:0}
.login-field input:focus{border-color:#3b82f6;box-shadow:0 0 0 3px #dbeafe}
.login-btn{width:100%;height:38px;justify-content:center;margin-top:6px}
.login-hint{margin-top:14px;color:#9aa3b2;font-size:11.5px;line-height:1.7}
.user-label{color:#4b5563;font-size:12.5px;margin-right:8px}
/* 待办 */
.todo-summary{background:#fff;border:1px solid #dfe3e8;border-radius:8px;padding:14px 16px;margin-bottom:14px;color:#374151;font-size:13.5px}
.todo-summary b{color:#1d4ed8;font-size:18px;margin:0 2px}
.todo-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:12px}
.todo-card{display:flex;align-items:center;gap:12px;background:#fff;border:1px solid #dfe3e8;border-radius:10px;padding:16px;cursor:pointer;transition:.15s}
.todo-card:hover{border-color:#93c5fd;box-shadow:0 6px 18px rgba(29,78,216,.08)}
.todo-card.has{border-left:4px solid #1d4ed8}
.todo-ico{width:38px;height:38px;border-radius:9px;background:#eff6ff;color:#1d4ed8;display:flex;align-items:center;justify-content:center;font-weight:700;flex:none}
.todo-main{flex:1}
.todo-title{font-weight:600;font-size:13.5px;color:#111827}
.todo-desc{color:#8a94a6;font-size:11.5px;margin-top:2px}
.todo-count{font-size:26px;font-weight:700;color:#1d4ed8;font-variant-numeric:tabular-nums}
.todo-card:not(.has) .todo-count{color:#c3cad5}

.todo-card.tone-green .todo-count{color:#15803d}
.todo-card.tone-orange .todo-count{color:#c2410c}
.todo-card.tone-blue .todo-count{color:#1d4ed8}

.brand-logo{width:38px;height:38px;object-fit:contain;flex:none}
.brand-name{font-weight:600;font-size:12.5px;line-height:1.35}
.login-logo-img{width:76px;height:76px;object-fit:contain;display:block;margin:0 auto 8px}
.login-card h1{font-size:17px;line-height:1.4;margin:0 0 4px}
.sidebar{width:236px}

.sidebar{width:272px}
.brand-name{font-size:12px;white-space:nowrap}
.toast{top:58px}

tr.conflict td{background:#fef2f2 !important}
tr.conflict td.rowno{color:#b91c1c;font-weight:700}
