:root {
  --ink: #13352e;
  --muted: #70827c;
  --line: #dbe4df;
  --bg: #f4f7f5;
  --card: #ffffff;
  --nav: #082f29;
  --nav-soft: #15463d;
  --lime: #c9ef62;
  --green: #237a60;
  --green-bg: #e8f5ef;
  --red: #c84943;
  --red-bg: #fcebea;
  --orange: #ae681b;
  --orange-bg: #fff1dc;
  --blue: #396f93;
  --blue-bg: #eaf2f7;
  --shadow: 0 22px 50px rgba(8, 47, 41, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif; }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { color: #71857f; font-size: 11px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: #fff; }
.login-brand { padding: 9vw; display: flex; flex-direction: column; justify-content: center; background: var(--nav); color: #fff; position: relative; overflow: hidden; }
.login-brand::after { content: ""; width: 520px; height: 520px; border: 110px solid rgba(201, 239, 98, .08); border-radius: 50%; position: absolute; right: -260px; bottom: -230px; }
.brand-mark { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 17px; background: var(--lime); color: var(--nav); font-size: 20px; font-weight: 950; letter-spacing: -.05em; }
.login-brand p { color: #9db6ae; margin: 24px 0 8px; font-weight: 800; }
.login-brand h1 { font-size: clamp(34px, 4.5vw, 66px); line-height: 1.08; letter-spacing: -.05em; max-width: 680px; margin: 0 0 24px; }
.login-brand > span { color: #aec4bd; font-size: 17px; line-height: 1.8; max-width: 530px; }
.login-card { width: min(420px, calc(100% - 44px)); margin: auto; padding: 38px; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.login-card h2 { font-size: 32px; margin: 10px 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 28px; }
label { color: #4a625b; font-size: 13px; font-weight: 800; }
label input { display: block; width: 100%; margin: 8px 0 18px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; outline: none; background: #fff; }
label input:focus, .toolbar input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(35, 122, 96, .1); }
.form-message { min-height: 20px; color: var(--red); font-size: 13px; margin-top: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px 18px; color: #c2d5cf; background: var(--nav); display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 25px; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 11px; font-size: 15px; flex: 0 0 auto; }
.brand strong { color: #fff; display: block; font-size: 19px; }
.brand small { color: #8ca9a0; display: block; margin-top: 2px; }
nav button, .side-action { width: 100%; border: 0; border-radius: 9px; background: transparent; color: #b9cec7; display: flex; align-items: center; gap: 11px; padding: 11px 12px; margin: 2px 0; cursor: pointer; text-align: left; font-weight: 750; }
nav button span { width: 24px; height: 24px; display: grid; place-items: center; background: rgba(255,255,255,.06); border-radius: 7px; color: #89a99e; font-size: 10px; font-weight: 900; }
nav button:hover, nav button.active { color: #fff; background: var(--nav-soft); }
nav button.active span { color: var(--nav); background: var(--lime); }
.nav-label { color: #6f9589; font-size: 10px; font-weight: 900; letter-spacing: .15em; padding: 21px 13px 6px; }
.sidebar-bottom { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.11); }
.side-action { padding: 9px 12px; font-size: 13px; }

.main { min-width: 0; padding: 28px 34px 56px; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 6px 0 0; font-size: 29px; font-weight: 650; letter-spacing: -.03em; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.data-state { display: flex; align-items: center; gap: 9px; padding-right: 8px; max-width: 250px; }
.data-state small { color: var(--muted); display: block; font-size: 10px; }
.data-state strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa9a4; box-shadow: 0 0 0 4px rgba(112,130,124,.12); }
.state-dot.live { background: #35a77c; box-shadow: 0 0 0 4px rgba(53,167,124,.13); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #dcebe5; color: var(--nav); display: grid; place-items: center; font-weight: 900; }
.primary, .secondary { border-radius: 10px; padding: 11px 15px; border: 1px solid transparent; cursor: pointer; font-weight: 850; transition: .15s ease; }
.primary { background: var(--nav); color: #fff; }
.primary:hover { background: #12493e; transform: translateY(-1px); }
.primary:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.secondary { background: #fff; border-color: var(--line); }
.secondary:hover { border-color: #9db8ae; background: #f8fbf9; }
.wide { width: 100%; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; margin: 20px 0; }
.kpi { min-height: 142px; border: 1px solid var(--line); border-radius: 15px; background: #fff; text-align: left; padding: 18px; cursor: pointer; transition: .18s ease; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(8,47,41,.08); }
.kpi small { display: block; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .06em; }
.kpi strong { display: block; margin: 15px 0 7px; font-size: 38px; line-height: 1; }
.kpi strong i { font-size: 13px; font-style: normal; margin-left: 2px; }
.kpi > span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.kpi.dark { background: var(--nav); border-color: var(--nav); color: #fff; }
.kpi.dark small, .kpi.dark > span { color: #adc5bd; }
.kpi.danger strong { color: var(--red); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.panel-head { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.panel-head h2 { font-size: 19px; margin: 4px 0 0; }
.panel-head p { color: var(--muted); font-size: 12px; margin: 0; }
.panel-body { padding: 8px 20px 15px; }
.focus-panel { margin: 0 0 18px; }
.focus-grid { display: grid; grid-template-columns: repeat(6, 1fr); padding: 15px; gap: 9px; }
.focus-card { border: 1px solid var(--line); background: #f8faf9; border-radius: 11px; padding: 13px; text-align: left; cursor: pointer; }
.focus-card:hover { border-color: #a8c3b9; background: var(--green-bg); }
.focus-card strong { display: block; font-size: 25px; margin-bottom: 3px; }
.focus-card span { font-size: 12px; color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.wide-panel { grid-column: 1 / -1; }
.attention-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid #edf1ef; }
.attention-row:last-child { border-bottom: 0; }
.attention-row strong { display: block; font-size: 13px; }
.attention-row p { color: var(--muted); margin: 4px 0 0; font-size: 11px; }
.compact-list { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 30px; }
.empty-inline { padding: 30px 5px; color: var(--muted); text-align: center; font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 9px; margin: 20px 0 10px; }
.search-wrap { flex: 1 1 290px; }
.toolbar input, .toolbar select { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; outline: none; background: #fff; color: var(--ink); }
.toolbar select { width: auto; min-width: 130px; }
.result-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin: 10px 2px; }
.order-card { background: #fff; border: 1px solid var(--line); border-radius: 13px; margin: 9px 0; overflow: hidden; }
.order-summary { display: grid; grid-template-columns: 42px 1.3fr 1fr .8fr 1.1fr 22px; gap: 13px; align-items: center; padding: 15px; cursor: pointer; }
.po-badge { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: #ecf3ef; font-size: 11px; font-weight: 950; }
.order-summary h3 { margin: 5px 0 3px; font-size: 14px; }
.sub { color: var(--muted); font-size: 11px; line-height: 1.5; }
.summary-cell strong { display: block; font-size: 12px; margin-bottom: 3px; }
.delivery-risk { color: var(--red); font-weight: 800; font-size: 12px; }
.delivery-normal { color: var(--green); font-weight: 800; font-size: 12px; }
.chevron { transition: .18s ease; }
.order-card.open .chevron { transform: rotate(180deg); }
.order-detail { display: none; border-top: 1px solid var(--line); padding: 16px; background: #f7faf8; }
.order-card.open .order-detail { display: block; }
.remark { margin-bottom: 12px; padding: 10px 12px; border: 1px solid #efd8b7; background: #fff8eb; border-radius: 9px; color: #8b5a20; font-size: 12px; }
.node-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.node-card { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 13px; }
.node-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.node-card h4 { margin: 0; font-size: 14px; }
.node-owner { color: var(--muted); font-size: 10px; }
.node-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; }
.node-field small { color: var(--muted); display: block; font-size: 9px; }
.node-field span { display: block; margin-top: 2px; font-size: 11px; overflow-wrap: anywhere; }
.attention { margin: 10px 0 0; padding: 8px 9px; border-radius: 8px; background: var(--orange-bg); color: #80501c; font-size: 10px; line-height: 1.55; }
.attention div + div { margin-top: 4px; }
.status { display: inline-flex; align-items: center; border-radius: 20px; padding: 4px 8px; font-size: 10px; font-weight: 900; }
.status.done { color: var(--green); background: var(--green-bg); }
.status.overdue, .status.high { color: var(--red); background: var(--red-bg); }
.status.due_today, .status.medium, .status.attention { color: var(--orange); background: var(--orange-bg); }
.status.blocked { color: #617079; background: #eef1f2; }
.status.upcoming, .status.normal { color: var(--blue); background: var(--blue-bg); }

.empty-start { margin-top: 50px; padding: 70px 24px; background: #fff; border: 1px dashed #b8cac3; border-radius: 18px; text-align: center; }
.empty-start h2 { margin: 16px 0 7px; }
.empty-start p { color: var(--muted); max-width: 560px; margin: 0 auto 22px; }
.empty-icon, .upload-mark { width: 58px; height: 58px; border-radius: 15px; display: grid; place-items: center; margin: auto; background: var(--green-bg); color: var(--green); font-weight: 950; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(2, 26, 22, .56); backdrop-filter: blur(5px); }
.modal-card { width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 28px; position: relative; }
.modal-card.large { width: min(760px, 100%); }
.modal-card h2 { margin: 7px 0 6px; font-size: 27px; }
.modal-close { position: absolute; right: 18px; top: 15px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #eff3f1; cursor: pointer; font-size: 21px; }
.drop-zone { display: grid; text-align: center; gap: 7px; margin: 22px 0 14px; padding: 38px 20px; border: 2px dashed #afc3bb; border-radius: 14px; background: #f7faf8; cursor: pointer; }
.drop-zone.dragging { border-color: var(--green); background: var(--green-bg); }
.drop-zone small { color: var(--muted); font-weight: 500; }
.import-result { margin-top: 15px; padding: 14px; border-radius: 10px; background: #f5f8f6; font-size: 12px; line-height: 1.6; }
.import-result.success { border: 1px solid #b9dacb; background: var(--green-bg); }
.mapping-list { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 5px; }
.mapping-list span { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 9px; }
.history-item, .user-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.history-item strong, .user-item strong { display: block; font-size: 13px; }
.history-item p, .user-item p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.active-label { color: var(--green); font-size: 11px; font-weight: 900; }
.user-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 9px; align-items: end; margin-top: 18px; }
.user-form label input { margin: 6px 0 0; }
.user-form button { margin-bottom: 0; }
.section-title { margin: 20px 0 5px; font-size: 15px; }
.toast { position: fixed; right: 25px; bottom: 25px; z-index: 80; max-width: 420px; padding: 13px 16px; border-radius: 10px; background: var(--nav); color: #fff; box-shadow: var(--shadow); font-size: 13px; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .focus-grid { grid-template-columns: repeat(3, 1fr); }
  .node-grid { grid-template-columns: repeat(2, 1fr); }
  .order-summary { grid-template-columns: 42px 1.4fr 1fr 1fr 22px; }
  .order-summary .hide-mid { display: none; }
}

@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px; }
  .brand { padding-bottom: 10px; }
  .sidebar nav { display: flex; overflow-x: auto; gap: 4px; }
  .sidebar nav button { white-space: nowrap; width: auto; }
  .nav-label, .sidebar-bottom { display: none; }
  .main { padding: 18px 16px 42px; }
  .topbar { align-items: flex-start; }
  .data-state, #showImports { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .wide-panel { grid-column: auto; }
  .compact-list { grid-template-columns: 1fr; }
  .order-summary { grid-template-columns: 38px 1fr 100px 20px; }
  .order-summary .summary-cell, .order-summary .hide-mid { display: none; }
  .node-grid { grid-template-columns: 1fr; }
  .user-form { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar h1 { font-size: 23px; }
  .top-actions .secondary { display: none; }
  .kpi-grid, .focus-grid { grid-template-columns: 1fr 1fr; }
  .kpi { min-height: 126px; }
  .toolbar select { flex: 1; }
  .result-meta span:last-child { display: none; }
}
