@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Lao:wght@400;500;600;700;800&family=Noto+Sans:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  background: #F4F5F7;
  color: #12141C;
}

input, select, button { font-family: inherit; }
input:focus, select:focus, button:focus { outline: 2px solid #2451D6; outline-offset: 1px; }
a { color: #2451D6; text-decoration: none; }
a:hover { color: #17347F; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.18); border-radius: 6px; }

@media print {
  .print-hide { display: none !important; }
  body { background: #fff !important; }
}

button { border: none; background: none; padding: 0; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 340px; background: #fff; border: 1px solid rgba(15,23,42,0.08);
  border-radius: 16px; padding: 32px 28px; text-align: center;
  box-shadow: 0 4px 24px rgba(15,23,42,0.06);
}
.login-title { font-size: 15.5px; font-weight: 800; line-height: 1.3; }
.login-sub { font-size: 12px; color: #98A2B3; margin-top: 3px; margin-bottom: 22px; }
.login-field { text-align: left; margin-bottom: 14px; }

/* Buttons */
.btn-outline {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: #344054;
  cursor: pointer;
}
.btn-outline:hover { background: #F9FAFB; }

.btn-accent {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #2451D6;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.btn-plain {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #fff;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-approve {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  background: #17803D;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary-lg {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  background: #2451D6;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary-lg:disabled { background: #D0D5DD; color: #fff; cursor: not-allowed; }

.btn-cancel {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid rgba(15,23,42,0.14);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  cursor: pointer;
  color: #2451D6;
  font-size: 13px;
  font-weight: 600;
  width: fit-content;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  border-bottom: 1px solid rgba(15,23,42,0.08);
  padding: 14px 32px;
}
.app-header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #2451D6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.brand-title { font-size: 15px; font-weight: 700; line-height: 1.25; }
.brand-sub { font-size: 11.5px; color: #98A2B3; line-height: 1.2; }

.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.username-input {
  width: 118px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(15,23,42,0.14);
  font-size: 12.5px;
}
.role-chips { display: flex; gap: 6px; background: #F2F4F7; padding: 3px; border-radius: 9px; }
.divider-v { width: 1px; height: 22px; background: rgba(15,23,42,0.12); }

.chip {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #475467;
  white-space: nowrap;
}
.chip.active { font-weight: 700; background: #2451D6; color: #fff; }

.seg-chip {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: #475467;
  border: 1px solid rgba(15,23,42,0.14);
}
.seg-chip.active {
  font-weight: 700;
  color: #2451D6;
  border: 1px solid rgba(15,23,42,0.10);
  box-shadow: 0 1px 2px rgba(15,23,42,0.06);
}

.history-banner {
  background: #FEF6E7;
  border-bottom: 1px solid #F0C36D;
  padding: 10px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  color: #93500B;
  font-weight: 600;
}
.history-banner-btn {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #F0C36D;
  background: #fff;
  color: #93500B;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.page-wrap { max-width: 1440px; margin: 0 auto; padding: 28px 32px 72px; }

.loading-state { display: flex; align-items: center; justify-content: center; padding: 140px 0; color: #98A2B3; font-size: 14px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 120px 0; gap: 14px; }
.empty-state-title { font-size: 16px; font-weight: 700; color: #344054; }
.empty-state-sub { font-size: 13px; color: #98A2B3; }

/* Dashboard */
.dash-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; flex-wrap: wrap; gap: 8px; }
.dash-period { font-size: 22px; font-weight: 800; }
.dash-updated { font-size: 12.5px; color: #667085; margin-top: 2px; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 20px 0 28px; }
.summary-card { background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: 14px; padding: 18px 20px; }
.summary-label { font-size: 12px; color: #667085; font-weight: 600; }
.summary-value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.summary-value-variance { font-size: 19px; font-weight: 800; margin-top: 8px; color: #D92D20; }
.company-progress-row { display: flex; align-items: center; gap: 8px; }
.company-progress-code { font-size: 12px; font-weight: 700; width: 38px; }
.company-progress-track { flex: 1; height: 6px; background: #EEF0F3; border-radius: 4px; overflow: hidden; }
.company-progress-fill { height: 100%; border-radius: 4px; }
.company-progress-pct { font-size: 12px; color: #667085; width: 32px; text-align: right; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.dash-card {
  background: #fff;
  border: 1px solid rgba(15,23,42,0.08);
  border-radius: 14px;
  padding: 18px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dash-card:hover { border-color: rgba(36,81,214,0.5); }
.dash-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dash-card-title-row { display: flex; gap: 10px; align-items: flex-start; }
.dash-card-order {
  width: 25px; height: 25px; border-radius: 7px; background: #F2F4F7; color: #475467;
  font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.dash-card-name-lao { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.dash-card-name-en { font-size: 11px; color: #98A2B3; margin-top: 1px; }
.status-pill { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.dash-card-progress-row { display: flex; align-items: center; gap: 10px; }
.progress-track { flex: 1; height: 7px; background: #EEF0F3; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; }
.dash-card-pct { font-size: 13px; font-weight: 700; width: 38px; text-align: right; }
.dash-card-meta-row { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: #667085; }
.dash-card-percompany { font-size: 11px; color: #98A2B3; }
.dash-card-variance { font-size: 11.5px; font-weight: 600; color: #D92D20; background: #FEF0EE; border-radius: 7px; padding: 5px 9px; width: fit-content; }

/* Detail screen */
.detail-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-title-row { display: flex; gap: 12px; align-items: center; }
.detail-order-badge {
  width: 34px; height: 34px; border-radius: 9px; background: #EEF2FF; color: #2451D6;
  font-size: 14px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.detail-name-lao { font-size: 20px; font-weight: 800; line-height: 1.25; }
.detail-name-en { font-size: 12.5px; color: #98A2B3; }
.detail-actions { display: flex; gap: 8px; align-items: center; }
.detail-hint { font-size: 11.5px; color: #98A2B3; margin: -6px 0 16px; line-height: 1.6; }
.import-notice { font-size: 12.5px; font-weight: 600; color: #344054; background: #F2F4F7; padding: 8px 14px; border-radius: 8px; margin: -6px 0 16px; width: fit-content; }

.detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-toolbar-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-search {
  margin-left: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid rgba(15,23,42,0.14);
  font-size: 12.5px; width: 210px;
}
.detail-toolbar-right { display: flex; align-items: center; gap: 14px; }
.selection-summary { font-size: 12px; color: #667085; }
.progress-label { font-size: 13px; font-weight: 700; color: #344054; }

.awaiting-review-banner {
  background: #EEF2FF; color: #2451D6; padding: 9px 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; margin-bottom: 14px;
}

.grid-panel { background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: 14px; overflow: hidden; }
.hidden-grid-input { position: fixed; top: -999px; left: -999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.formula-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid rgba(15,23,42,0.08); background: #F9FAFB; }
.formula-bar-ref {
  min-width: 52px; padding: 4px 10px; border-radius: 6px; background: #fff; border: 1px solid rgba(15,23,42,0.14);
  font-size: 12px; font-weight: 700; font-family: ui-monospace, Menlo, monospace; text-align: center; color: #344054;
}
.formula-bar-value {
  flex: 1; font-size: 12.5px; color: #344054; font-family: ui-monospace, Menlo, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.grid-scroll { overflow-x: auto; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.grid-table thead tr.colletters { background: #EEF0F3; }
.grid-table thead tr.colletters th { padding: 3px 12px; text-align: center; font-size: 10px; color: #98A2B3; font-weight: 700; border-bottom: 1px solid rgba(15,23,42,0.08); }
.grid-table thead tr.colheads { background: #F9FAFB; border-bottom: 1px solid rgba(15,23,42,0.08); }
.grid-table thead tr.colheads th { text-align: left; padding: 10px 12px; font-weight: 600; color: #667085; }
.grid-table tbody tr { border-bottom: 1px solid rgba(15,23,42,0.06); }
.grid-table tfoot tr { background: #F9FAFB; font-weight: 700; }
.grid-table tfoot td { padding: 10px 12px; text-align: right; font-variant-numeric: tabular-nums; }

.cell-num { padding: 7px 12px; color: #98A2B3; cursor: default; background: #FAFBFC; text-align: center; font-weight: 600; }
.cell-company { padding: 7px 12px; font-weight: 600; cursor: cell; }
.cell-code { padding: 7px 12px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; cursor: cell; }
.cell-name { padding: 7px 12px; cursor: cell; }
.cell-tb { padding: 7px 12px; text-align: right; font-variant-numeric: tabular-nums; cursor: cell; }
.cell-detail { padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; cursor: cell; }
.cell-diff { padding: 7px 12px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; cursor: cell; }
.cell-note { padding: 6px 8px; cursor: cell; }
.cell-done { padding: 7px 12px; text-align: center; }

.cell-selected { background: rgba(36,81,214,0.10); }
.cell-active { box-shadow: inset 0 0 0 2px #2451D6; }

.cell-edit-input {
  width: 100%; padding: 5px 7px; border-radius: 6px; border: 1px solid rgba(15,23,42,0.14);
  font-size: 12.5px;
}
.cell-edit-input.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.cell-edit-input.note { font-size: 12px; }

.empty-rows { padding: 48px 0; text-align: center; color: #98A2B3; font-size: 13px; }

.detail-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; flex-wrap: wrap; gap: 10px; }
.detail-footer-info { font-size: 12px; color: #667085; display: flex; flex-direction: column; gap: 2px; }
.detail-footer-actions { display: flex; gap: 10px; }

/* History */
.history-title { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.history-list { background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: 14px; overflow: hidden; }
.history-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid rgba(15,23,42,0.06); }
.history-row-label { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.history-current-badge { font-size: 10.5px; font-weight: 700; color: #2451D6; background: #EEF2FF; padding: 2px 8px; border-radius: 6px; }
.history-row-date { font-size: 12px; color: #98A2B3; margin-top: 2px; }
.history-row-right { display: flex; align-items: center; gap: 16px; }
.history-row-pct { font-size: 15px; font-weight: 800; }

/* Upload */
.upload-wrap { max-width: 720px; margin: 0 auto; }
.upload-title { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.upload-sub { font-size: 12.5px; color: #667085; margin-bottom: 22px; line-height: 1.6; }
.upload-panel { background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.field-label { font-size: 12.5px; font-weight: 600; color: #344054; margin-bottom: 6px; }
.text-input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(15,23,42,0.14); font-size: 14px; }
.file-input { width: 100%; padding: 10px 0; font-size: 13px; }
.upload-error { background: #FEF0EE; color: #D92D20; padding: 10px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.upload-success { font-size: 12.5px; color: #17803D; font-weight: 600; }
.issues-block { border-top: 1px solid rgba(15,23,42,0.08); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.issues-title { font-size: 12.5px; font-weight: 700; color: #B54708; }
.issue-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: #FEF6E7; padding: 10px 14px; border-radius: 8px; flex-wrap: wrap; }
.issue-text { font-size: 12.5px; }
.issue-select { padding: 6px 10px; border-radius: 6px; border: 1px solid rgba(15,23,42,0.14); font-size: 12px; }
.upload-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
