:root {
  --red: #ed1c24;
  --danger: #b91c1c;
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --panel: #ffffff;
  --bg: #f5f7fb;
  --ok: #166534;
  --warn: #b45309;
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, .button-link { border: 1px solid var(--red); background: var(--red); color: #fff; border-radius: 6px; min-height: 34px; padding: 7px 12px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost, .button-link.ghost { border-color: var(--line); background: #fff; color: var(--ink); }
button.danger { border-color: #fecaca; background: #fff; color: var(--danger); }
input, select, textarea { border: 1px solid #cfd4dc; border-radius: 6px; padding: 7px 8px; color: var(--ink); background: #fff; min-width: 0; }
.multi-select { position: relative; min-width: 170px; }
.multi-select-button { width: 100%; justify-content: space-between; border-color: #cfd4dc; color: var(--ink); background: #fff; }
.multi-select-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 8; width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px rgba(16, 24, 40, .16); padding: 8px; display: grid; gap: 4px; }
.multi-select-menu.hidden { display: none; }
.multi-select-menu label { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; padding: 6px; border-radius: 6px; cursor: pointer; }
.multi-select-menu label:hover { background: #fff7f7; }
.multi-select-menu input { width: auto; min-width: 0; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.checkbox-label { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.checkbox-label input { width: auto; min-width: 0; }
.file-label input { max-width: 220px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--red); }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: var(--bg); }
.login-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 60px rgba(16, 24, 40, .14); padding: 22px; display: grid; gap: 14px; }
.login-card .brand { margin-bottom: 6px; }
.login-card strong { color: var(--ink); font-size: 20px; }
.login-card input, .login-card button { width: 100%; justify-content: center; }
.login-message { margin: 0; min-height: 18px; color: var(--danger); font-size: 13px; font-weight: 700; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.main-nav { background: #fff; border-right: 1px solid var(--line); padding: 18px 14px; display: grid; align-content: start; gap: 22px; }
.nav-brand { align-items: flex-start; }
.nav-brand strong { color: var(--ink); font-size: 15px; }
.nav-user { display: block; margin-top: 4px; color: var(--muted); font-weight: 700; line-height: 1.35; }
.vertical-tabs { display: grid; gap: 8px; }
.main-tab { width: 100%; justify-content: flex-start; text-align: left; background: #fff; border-color: var(--line); color: var(--ink); }
.main-tab.active { background: var(--red); border-color: var(--red); color: #fff; }
.main-content { min-width: 0; padding: 22px; display: grid; }
.main-view { display: none; min-width: 0; align-content: start; gap: 16px; }
.main-view.active { display: grid; }
.list-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0 0 4px; color: var(--red); font-weight: 700; text-transform: uppercase; font-size: 12px; }
h1, h2 { margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-date-filter { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.inline-date-filter input { min-height: 34px; width: 142px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 12px; min-width: 0; }
.list-panel { align-content: start; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); font-size: 13px; font-weight: 700; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stats-grid div { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 6px; }
.stats-grid span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stats-grid strong { font-size: 20px; }
.stats-grid small { color: var(--muted); font-weight: 700; }
.dashboard-kpi-grid strong { font-size: 22px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.dashboard-card { min-height: 220px; }
.dashboard-wide { grid-column: 1 / -1; }
.dashboard-risk-card { grid-column: 1 / -1; width: 100%; }
.dashboard-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dashboard-split h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; }
.donut-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; align-items: center; }
.donut-chart { --value: 0; width: 138px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--red) calc(var(--value) * 1%), #eef2f7 0); position: relative; }
.donut-chart::after { content: ""; position: absolute; inset: 16px; border-radius: 50%; background: #fff; }
.donut-chart span { position: relative; z-index: 1; font-size: 22px; font-weight: 800; color: var(--ink); }
.dashboard-bars { display: grid; gap: 10px; align-content: start; }
.dashboard-bar-row { display: grid; gap: 5px; }
.dashboard-bar-label { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; font-weight: 700; }
.dashboard-bar-label strong { color: var(--ink); font-size: 12px; text-align: right; }
.dashboard-bar-track { height: 9px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.dashboard-bar-track i { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: #64748b; }
.dashboard-bar-track i.ok { background: var(--ok); }
.dashboard-bar-track i.warn { background: var(--warn); }
.dashboard-bar-track i.bad { background: var(--danger); }
.risk-list { display: grid; gap: 8px; margin-top: 12px; }
.risk-summary-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.risk-summary-layout h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; }
.risk-item { width: 100%; display: grid; grid-template-columns: 84px 1fr; gap: 4px 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 9px 10px; cursor: pointer; }
.risk-item:hover { border-color: var(--red); box-shadow: 0 8px 22px rgba(185, 28, 28, .12); }
.risk-item span { font-weight: 800; font-size: 12px; }
.risk-item strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.risk-item small { grid-column: 2; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.risk-trend { min-height: 158px; display: flex; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow-x: auto; }
.risk-trend-bar { min-width: 34px; display: grid; grid-template-rows: 18px 118px 16px; justify-items: center; align-items: end; color: var(--muted); font-size: 10px; font-weight: 700; }
.risk-trend-bar strong { color: var(--ink); font-size: 11px; }
.risk-trend-bar i { width: 22px; display: block; border-radius: 5px 5px 2px 2px; background: var(--red); opacity: .9; }
.risk-trend-bar span { white-space: nowrap; }
.risk-detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.risk-po-list { display: flex; flex-wrap: wrap; gap: 8px; }
#riskDetailNote { min-height: 86px; resize: vertical; }
.action-list { display: grid; gap: 8px; }
.action-item { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 8px 0; font-weight: 700; }
.action-item span { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }
.select-col { min-width: 56px; text-align: center; }
.select-col input { width: auto; min-width: 0; }
.row-action-col { min-width: 58px; text-align: center; }
.approval-cell { min-width: 74px; }
.approval-cell input { width: 16px; height: 16px; vertical-align: middle; }
.approval-cell.is-approved { background: #ecfdf3; }
.approval-cell.is-approved input { accent-color: var(--ok); }
.approval-cell.is-blocked { background: #fff1f2; color: var(--danger); font-weight: 800; }
.approval-cell.is-blocked input { opacity: 1; filter: grayscale(1); cursor: not-allowed; }
.approval-cell span { display: inline-block; margin-left: 5px; font-size: 11px; vertical-align: middle; }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
.list-table-wrap { max-height: calc(100vh - 245px); border: 1px solid var(--line); border-radius: 8px; }
.po-ycmh-cell { min-width: 135px; max-width: 220px; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12px; }
th, td { border: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #fff7f7; color: #991b1b; white-space: nowrap; }
#progressFilterRow th { top: 32px; background: #fff; padding: 4px; }
.progress-filter-input { width: 100%; min-width: 96px; padding: 5px 6px; font-size: 12px; }
tbody tr:hover td { background: #fffafa; }
tbody tr.selected-edit-row td { background: #fff1f2; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; color: var(--ink); }
.muted-cell { text-align: center; color: var(--muted); padding: 28px; }
.status-ok { color: var(--ok); font-weight: 700; }
.status-warn { color: var(--warn); font-weight: 700; }
.status-bad { color: var(--danger); font-weight: 700; }
.change-bad td { background: #fff1f2; }
.change-warn td { background: #fffbeb; }
.po-price-increase td { background: #ffedd5; }
.po-price-increase:hover td { background: #fed7aa; }
.po-price-increase [data-field="unitPrice"] { background: #fff7ed; color: #9a3412; font-weight: 700; }
.cell-input { width: 100%; min-width: 110px; border: 0; border-radius: 4px; padding: 6px; background: #fff; }
.date-control { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 4px; align-items: center; }
.date-control input:not(.native-date-picker) { min-width: 0; }
.date-picker-button { min-width: 34px; height: 34px; padding: 0; border-radius: 6px; background: #fff; color: var(--ink); border: 1px solid var(--line); }
.native-date-picker { position: absolute; right: 0; bottom: 0; width: 1px !important; height: 1px; opacity: 0; pointer-events: none; }
.mini { min-height: 28px; padding: 4px 8px; font-size: 12px; }
.quote-table tbody tr, .clickable-row { cursor: pointer; }
.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .58); padding: 18px; z-index: 20; }
.modal.hidden { display: none; }
.modal-card { width: min(1580px, 98vw); height: min(900px, 96vh); margin: 0 auto; background: var(--bg); border-radius: 10px; box-shadow: 0 24px 80px rgba(0,0,0,.28); display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.modal-card.small-modal { width: min(820px, 96vw); height: auto; max-height: 92vh; }
.modal-header { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 16px; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.modal-body { min-height: 0; display: grid; gap: 12px; padding: 12px; overflow: auto; }
.modal-body.single { grid-template-columns: 1fr; }
.modal .list-table-wrap { max-height: calc(96vh - 190px); }
.supplier-modal-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.supplier-page-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.supplier-page-tab { min-height: 38px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--muted); padding: 8px 14px; white-space: nowrap; }
.supplier-page-tab:hover { color: var(--ink); background: #fffafa; }
.supplier-page-tab.active { color: var(--red); border-bottom-color: var(--red); background: #fff; }
.supplier-page-panel { display: grid; gap: 16px; min-width: 0; }
.supplier-plan-topbar .actions { align-items: end; }
.supplier-plan-topbar input[type="number"] { width: 92px; }
.supplier-plan-note-label { min-width: min(420px, 50vw); }
.supplier-plan-note-label input { width: 100%; }
.supplier-plan-table-wrap { max-height: calc(100vh - 285px); }
.supplier-plan-table th:nth-child(2), .supplier-plan-table td:nth-child(2) { min-width: 190px; position: sticky; left: 0; z-index: 1; background: #fff; }
.supplier-plan-table thead th:nth-child(2) { z-index: 3; background: #fff7f7; }
.supplier-plan-table th:nth-child(n+3):nth-child(-n+14), .supplier-plan-table td:nth-child(n+3):nth-child(-n+14) { width: 42px; min-width: 42px; text-align: center; }
.supplier-plan-table th:nth-child(15), .supplier-plan-table td:nth-child(15) { min-width: 140px; }
.supplier-plan-table th:nth-child(16), .supplier-plan-table td:nth-child(16) { min-width: 125px; }
.supplier-plan-table th:nth-child(17), .supplier-plan-table td:nth-child(17) { min-width: 105px; }
.supplier-plan-table th:nth-child(19), .supplier-plan-table td:nth-child(19) { min-width: 220px; }
.supplier-plan-month input { width: 16px; height: 16px; accent-color: var(--red); }
.supplier-modal-tab { min-height: 36px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--muted); padding: 7px 14px; }
.supplier-modal-tab:hover { color: var(--ink); background: #fffafa; }
.supplier-modal-tab.active { color: var(--red); border-bottom-color: var(--red); background: #fff; }
.supplier-tab-panel { display: grid; gap: 12px; min-width: 0; }
.supplier-evaluation-panel { gap: 14px; }
.supplier-evaluation-visibility-actions { justify-content: flex-end; }
.supplier-evaluation-summary { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 10px; }
.supplier-evaluation-summary div { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 12px; display: grid; gap: 5px; }
.supplier-evaluation-summary span { color: var(--muted); font-size: 12px; font-weight: 700; }
.supplier-evaluation-summary strong { font-size: 18px; }
.supplier-evaluation-meta textarea { width: 100%; resize: vertical; }
.evaluation-scale-note { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 9px 11px; border: 1px solid #fed7aa; background: #fff7ed; color: #7c2d12; border-radius: 6px; font-size: 12px; }
.supplier-evaluation-sections { display: grid; gap: 9px; }
.evaluation-policy { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0 12px 12px; }
.evaluation-policy > summary { min-height: 42px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.evaluation-policy-bands { display: grid; grid-template-columns: repeat(2, minmax(240px, 1fr)); gap: 6px 14px; margin: 10px 0; color: var(--muted); font-size: 12px; }
.supplier-grade { white-space: nowrap; }
.supplier-grade-a { color: #137333; }
.supplier-grade-b { color: #7a5b00; }
.supplier-grade-c { color: #b45309; }
.supplier-grade-d { color: #b91c1c; }
.evaluation-section { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.evaluation-section summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; font-size: 13px; }
.evaluation-section summary:hover { background: #fffafa; }
.evaluation-section summary span { font-weight: 800; }
.evaluation-section summary strong { color: var(--muted); font-size: 12px; }
.evaluation-section[open] summary { border-bottom: 1px solid var(--line); background: #fffafa; }
.evaluation-table th:nth-child(3), .evaluation-table td:nth-child(3) { min-width: 420px; max-width: 620px; }
.evaluation-table th:nth-child(4), .evaluation-table td:nth-child(4) { min-width: 130px; }
.evaluation-table th:nth-child(5), .evaluation-table td:nth-child(5) { width: 92px; min-width: 92px; }
.evaluation-table th:nth-child(6), .evaluation-table td:nth-child(6) { min-width: 280px; }
.evaluation-table th:nth-child(7), .evaluation-table td:nth-child(7) { min-width: 180px; }
.evaluation-question-cell strong { display: block; line-height: 1.4; }
.evaluation-question-cell small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.35; }
.evaluation-table textarea { min-width: 260px; resize: vertical; }
.evaluation-table input[type="number"] { min-width: 76px; }
.evaluation-table input:disabled, .evaluation-table textarea:disabled { background: #f2f4f7; color: #98a2b3; }
.guide-panel { gap: 14px; }
.guide-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 14px; align-items: start; }
.guide-flow { position: sticky; top: 16px; align-content: start; }
.flow-steps { display: grid; gap: 10px; }
.flow-step { position: relative; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px 10px 10px 48px; display: grid; gap: 3px; }
.flow-step::after { content: ""; position: absolute; left: 22px; bottom: -11px; width: 2px; height: 10px; background: var(--line); }
.flow-step:last-child::after { display: none; }
.flow-step strong { position: absolute; left: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 12px; }
.flow-step span { font-weight: 800; }
.flow-step small { color: var(--muted); font-weight: 700; line-height: 1.35; }
.guide-detail { align-content: start; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.guide-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 14px; display: grid; gap: 8px; }
.guide-card.guide-primary { grid-column: 1 / -1; background: #fffafa; border-color: #fecaca; }
.guide-card h2 { font-size: 16px; }
.guide-card p { margin: 0; color: #344054; line-height: 1.45; }
.guide-card ol { margin: 0; padding-left: 22px; color: #344054; line-height: 1.5; }
.guide-card li { margin: 3px 0; }
.guide-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.role-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.role-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; display: grid; gap: 6px; }
.role-card strong { color: var(--ink); }
.role-card small { color: var(--muted); font-weight: 700; line-height: 1.35; }
.toast { position: fixed; right: 18px; bottom: 18px; background: #111827; color: #fff; padding: 12px 14px; border-radius: 8px; max-width: 460px; box-shadow: 0 16px 38px rgba(0,0,0,.18); z-index: 40; }
.hidden { display: none; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .main-nav { border-right: 0; border-bottom: 1px solid var(--line); }
  .vertical-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-topbar { align-items: flex-start; flex-direction: column; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-split { grid-template-columns: 1fr; }
  .dashboard-wide { grid-column: auto; }
  .guide-layout { grid-template-columns: 1fr; }
  .guide-flow { position: static; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .donut-row { grid-template-columns: 1fr; }
  .supplier-evaluation-summary { grid-template-columns: 1fr; }
  .evaluation-policy-bands { grid-template-columns: 1fr; }
}
@media print {
  body { background: #fff; }
  .main-nav, .main-view:not(#view-guide), #view-guide .list-topbar .actions, .toast { display: none !important; }
  .app-shell, .main-content, #view-guide, .guide-grid { display: block; }
  .main-content { padding: 0; }
  .panel, .guide-card { border-color: #999; break-inside: avoid; page-break-inside: avoid; }
  .guide-card { margin-bottom: 10px; }
}
