:root {
  color-scheme: light;
  --ink: #163454;
  --muted: #58758b;
  --line: #c7e1ec;
  --surface: #ffffff;
  --page: #f2f9fc;
  --accent: #176da3;
  --accent-dark: #173b70;
  --cyan: #25afcb;
  --soft-blue: #eaf7fc;
  --warn: #9a3412;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--page);
  color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(23, 59, 112, 0.08);
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--accent-dark); white-space: nowrap; }
.brand img { width: 44px; height: 34px; object-fit: contain; }
.nav { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: 14px; }
.logout-form { display: flex; align-items: center; gap: 10px; margin: 0; }
.user-chip { color: var(--muted); font-size: 13px; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 48px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 18px; margin-top: 0; }
p { color: var(--muted); line-height: 1.55; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
}
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--accent-dark); font-size: 13px; font-weight: 700; background: var(--soft-blue); }
.item-price-list {
  display: grid;
  gap: 7px;
  min-width: 360px;
  max-width: 560px;
}
.item-price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  line-height: 1.35;
  color: var(--ink);
}
.item-price-material {
  font-weight: 800;
  color: var(--accent-dark);
}
.item-price-brand {
  color: var(--ink);
}
.item-price-separator {
  color: var(--muted);
}
.item-price-value {
  color: var(--accent-dark);
  white-space: nowrap;
}
.item-price-list small {
  color: var(--muted);
  font-weight: 700;
}
.procurement-records-table th:nth-child(4),
.procurement-records-table td:nth-child(4) {
  width: 38%;
}
.procurement-records-table th:nth-child(8),
.procurement-records-table td:nth-child(8) {
  white-space: nowrap;
}
.compact-total-list {
  display: grid;
  grid-template-columns: max-content max-content;
  gap: 3px 8px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.compact-total-list dt,
.compact-total-list dd {
  margin: 0;
}
.compact-total-list dt {
  color: var(--muted);
  font-weight: 700;
}
.compact-total-list dd {
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
}
.compact-total-list dt:last-of-type,
.compact-total-list dd:last-of-type {
  color: var(--accent-dark);
  font-weight: 800;
}
button, .button, .button-link {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.button:hover { text-decoration: none; }
.button.primary, .button:not(.secondary):not(.danger) { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.secondary { background: var(--surface); color: var(--accent-dark); }
.button.danger, button.danger { background: #a7352d; border-color: #a7352d; color: #fff; }
.button.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); text-decoration: none; }
.messages { display: grid; gap: 8px; margin-bottom: 18px; }
.message { padding: 10px 12px; border-radius: 6px; background: var(--soft-blue); border: 1px solid var(--line); }
.message.error { border-color: #f0b7a8; color: var(--warn); background: #fff4f0; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.metric span, .detail-grid span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 26px; margin-top: 8px; }
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.form-grid {
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}
.wide-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-grid label { display: grid; gap: 6px; font-weight: 700; }
.form-grid label span { color: var(--muted); font-size: 13px; }
.form-grid label.is-disabled { opacity: 0.68; }
.form-control, .form-select, input, textarea, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}
.kpcc-native-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.kpcc-combo {
  position: relative;
  width: 100%;
}
.kpcc-combo-control {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.kpcc-combo.is-open .kpcc-combo-control {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(27, 115, 201, 0.12);
}
.kpcc-combo-value {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 8px 32px 8px 10px;
  line-height: 22px;
  color: var(--ink);
}
.kpcc-combo-value.is-placeholder {
  color: var(--muted);
}
.kpcc-combo-search {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 6px 6px 0 0;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
}
.kpcc-combo-search:focus {
  outline: 0;
}
.kpcc-combo-arrow {
  position: absolute;
  right: 11px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  pointer-events: none;
}
.kpcc-combo-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 290px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 47, 87, 0.16);
}
.kpcc-combo-option {
  display: block;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 0;
  padding: 9px 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font: inherit;
}
.kpcc-combo-option:hover,
.kpcc-combo-option.is-selected {
  background: var(--soft-blue);
}
.kpcc-combo-option.is-add-new {
  color: var(--accent);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.kpcc-combo-empty {
  padding: 10px 12px;
  color: var(--muted);
}
.kpcc-combo.is-disabled .kpcc-combo-control {
  background: #f4f7fb;
}
.kp-add-new-overlay[hidden] {
  display: none;
}
.kp-add-new-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.kp-add-new-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 52, 84, 0.46);
}
.kp-add-new-overlay__surface {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1080px, calc(100vw - 24px));
  height: min(820px, calc(100vh - 24px));
  margin: 12px auto;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(15, 47, 87, 0.28);
  overflow: hidden;
}
.kp-add-new-overlay__head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.kp-add-new-overlay__body {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 18px;
  background: var(--page);
}
.kp-add-new-title {
  margin-bottom: 12px;
}
.kp-add-new-overlay-open {
  overflow: hidden;
}
textarea { min-height: 96px; }
.actions { display: flex; gap: 10px; align-items: center; grid-column: 1 / -1; }
.actions form { margin: 0; }
.page-header, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.form-card { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, dt { color: var(--accent-dark); font-size: 13px; font-weight: 700; }
.field small { color: var(--muted); }
.line-form { margin-bottom: 12px; border-left: 4px solid var(--cyan); }
.line-form .form-grid { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); border-radius: 0 6px 6px 0; }
.procurement-line-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 14px;
}
.procurement-line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 0 6px 0 0;
}
.procurement-line-head strong {
  color: var(--accent-dark);
}
.procurement-line-head .delete-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-weight: 700;
}
.procurement-line .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.procurement-line .form-grid input[readonly] {
  background: #f8fbff;
  color: var(--muted);
}
.line-calculated {
  align-content: end;
}
.line-calculated strong {
  display: block;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #f8fbff;
  color: var(--accent-dark);
}
.procurement-line-notes {
  grid-column: 1 / -1;
}
.delete-field { align-content: end; }
.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}
.detail-grid dt, .detail-grid dd { margin: 0; }
.detail-grid dd { margin-top: 7px; }
.auth-panel { max-width: 420px; margin: 60px auto; text-align: center; }
.auth-panel form { text-align: left; }
.login-logo { width: 150px; height: 108px; object-fit: contain; margin-bottom: 18px; }
.status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.detail-grid div, .text-block, .workflow {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.long-value-card {
  display: grid;
  gap: 7px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.long-value-card span {
  color: var(--muted);
  font-size: 13px;
}
.long-value-card strong {
  color: var(--accent-dark);
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}
.workflow { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.app-download-panel {
  display: grid;
  gap: 14px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}
.muted { color: var(--muted); }
.mobile-menu-button { display: none; }
.inline-form { display: grid; gap: 8px; max-width: 420px; }
.filter-bar { display: flex; gap: 12px; align-items: end; margin-bottom: 18px; }
.filter-bar label { display: grid; gap: 6px; min-width: 280px; font-weight: 700; }
.filter-bar label span { color: var(--muted); font-size: 13px; }
.compact-head { margin-top: 20px; margin-bottom: 10px; }
.compact-head h2 { margin-bottom: 0; }
.comparison-block, .report-section { margin-bottom: 26px; }
.lowest-offer { background: #edf9f4; }
.line-table-wrap { overflow-x: auto; }
.related-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
  margin-top: 20px;
}
.related-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
}
.related-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.related-card-head h2 {
  margin: 0;
  font-size: 16px;
}
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--accent-dark);
  font-size: 12px;
}
.related-table-wrap {
  overflow-x: auto;
}
.related-table th,
.related-table td {
  padding: 8px 10px;
  font-size: 13px;
}
.related-limit-note {
  margin: 10px 0 0;
  font-size: 12px;
}
.quotation-lines { min-width: 1900px; }
.quotation-lines th, .quotation-lines td { min-width: 125px; padding: 8px; }
.quotation-lines th:first-child, .quotation-lines td:first-child { min-width: 210px; }
.quotation-lines textarea { min-height: 72px; }
.report-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.report-links a { display: grid; gap: 6px; min-height: 112px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.report-links a:hover { border-color: var(--accent); text-decoration: none; }
.report-links span { color: var(--muted); font-size: 14px; line-height: 1.4; }
.report-filter { flex-wrap: wrap; }
.report-filter label { min-width: 150px; flex: 1 1 150px; }
.unread-row { background: #f0f8f5; }
.muted-text { color: var(--muted); }
.inline-delete { display: inline; margin-left: 6px; }
.inline-delete button { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.payment-filter { flex-wrap: wrap; }
.payment-filter label { min-width: 160px; flex: 1 1 160px; }
.petty-filter { flex-wrap: wrap; }
.petty-filter label { min-width: 150px; flex: 1 1 150px; }
.decision-form { margin-top: 24px; }
.permission-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin: 12px 0 16px;
}
.permission-legend span {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fcfe;
  color: var(--muted);
}
.permission-legend strong {
  color: var(--accent-dark);
}
.access-edit-form {
  display: grid;
  gap: 18px;
  padding-bottom: 72px;
}
.permission-module-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  align-items: start;
  gap: 14px;
}
.permission-module-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(8, 47, 73, 0.05);
}
.permission-module-card h3 {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 16px;
  line-height: 1.25;
}
.permission-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 8px;
}
.permission-action-card {
  display: grid;
  grid-template-columns: minmax(82px, 1fr) 132px;
  gap: 5px 10px;
  align-items: center;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #d9eaf1;
  border-radius: 7px;
  background: #f8fcfe;
}
.permission-action-label {
  min-width: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}
.permission-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  align-items: center;
}
.permission-override-select {
  width: 128px;
  min-height: 30px;
  padding: 4px 24px 4px 8px;
  border: 1px solid #d4e7ef;
  border-radius: 6px;
  background-color: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.permission-override-select:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(27, 115, 201, 0.12);
}
.permission-override-select:not(.is-allow):not(.is-deny) {
  background: #eef8fc;
  color: var(--accent-dark);
}
.permission-override-select.is-allow {
  background: #ddf4e9;
  border-color: #8ccdac;
  color: #145c3d;
}
.permission-override-select.is-deny {
  background: #ffe5e2;
  border-color: #efaaa5;
  color: #8f231e;
}
.permission-role-default {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.2;
  white-space: nowrap;
}
.permission-final {
  display: inline-flex;
  width: fit-content;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.permission-final.is-allowed {
  background: #d6f3e4;
  border: 1px solid #36a66c;
  color: #0f5b39;
}
.permission-final.is-denied {
  background: #ffe1df;
  border: 1px solid #d94a40;
  color: #8f231e;
}
.access-edit-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 12px 0;
  border-top: 1px solid rgba(182, 213, 225, 0.8);
  background: rgba(246, 251, 253, 0.94);
}
.supplier-logo { display: block; width: 52px; height: 38px; object-fit: contain; }
.supplier-profile { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.supplier-logo-panel { display: grid; min-height: 140px; place-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); text-align: center; }
.supplier-logo-large { display: block; width: 100%; max-height: 150px; object-fit: contain; }
.schedule-late, .status-rejected, .status-danger { background: #fde8e7; color: #9f2d26; }
.schedule-due_today, .schedule-due_tomorrow, .status-warning { background: #fff3d6; color: #8a5a00; }
.schedule-due_soon { background: #e8f5ff; color: #176da3; }
.schedule-on_track, .status-approved, .status-success { background: #e5f6ef; color: #176744; }
.schedule-no_end_date { background: #eef2f5; color: #58758b; }
.schedule-completed { background: #e5f6ef; color: #176744; }
.schedule-on_hold { background: #fff3d6; color: #8a5a00; }
.schedule-planning { background: #eaf1fb; color: #355f91; }
ul.errorlist { color: var(--warn); margin: 4px 0 0; padding-left: 18px; font-weight: 400; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 12px 14px; gap: 10px; }
  .brand { width: 100%; }
  .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-menu-button { display: inline-flex; width: 100%; }
  .nav { display: none; width: 100%; gap: 8px; }
  .nav.is-open { display: grid; grid-template-columns: 1fr; }
  .nav a {
    display: block;
    min-height: 40px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--soft-blue);
  }
  .logout-form { width: 100%; justify-content: space-between; }
  .page { padding: 16px 10px 34px; }
  .wide-form, .two-col, .detail-grid { grid-template-columns: 1fr; }
  .form-grid { padding: 14px; }
  .page-header, .section-heading { align-items: flex-start; flex-direction: column; }
  .actions { align-items: stretch; flex-wrap: wrap; width: 100%; }
  .actions > *, .actions form, .actions button, .actions .button { width: 100%; }
  .supplier-profile { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar label { min-width: 0; width: 100%; }
  .kpcc-combo-menu { max-height: min(60vh, 360px); }
  .kpcc-combo-option, .kpcc-combo-search, input, select, textarea, .form-control, .form-select { font-size: 16px; }
  .permission-module-list { grid-template-columns: 1fr; }
  .permission-action-grid { grid-template-columns: 1fr; }
  .permission-action-card { grid-template-columns: 1fr; }
  .permission-override-select { width: 100%; }
  .access-edit-form { padding-bottom: 0; }
  .access-edit-actions { position: static; }
  input[type="file"] { min-height: 44px; padding: 10px; }
  .app-download-panel { padding: 14px; }
  table { display: block; overflow-x: auto; }
}
