:root {
  --ink: #17211c;
  --muted: #67736c;
  --paper: #f4f5f1;
  --surface: #ffffff;
  --line: #dde2dc;
  --forest: #183f32;
  --forest-2: #245946;
  --lime: #c9e66b;
  --sand: #e9e4d8;
  --danger: #a43d36;
  --shadow: 0 18px 50px rgba(19, 44, 34, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--forest-2); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.login-layout { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.brand-panel { padding: clamp(48px, 8vw, 120px); display: flex; flex-direction: column; justify-content: center; color: white; background: var(--forest); position: relative; overflow: hidden; }
.brand-panel::after { content: ""; position: absolute; width: 520px; height: 520px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; right: -180px; bottom: -220px; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.02); }
.brand-panel .eyebrow { color: var(--lime); }
.brand-mark, .logo span { width: 54px; height: 54px; display: grid; place-items: center; background: var(--lime); color: var(--forest); font-weight: 900; letter-spacing: -.05em; border-radius: 4px 16px 4px 4px; }
.brand-panel h1 { font-family: Georgia, serif; font-size: clamp(48px, 7vw, 86px); font-weight: 400; line-height: .95; max-width: 650px; margin: 32px 0 24px; }
.lead { max-width: 570px; color: #d7e1db; font-size: 19px; line-height: 1.6; margin-bottom: 52px; }
.feature-row { display: flex; gap: 18px; align-items: center; padding: 15px 0; border-top: 1px solid rgba(255,255,255,.13); max-width: 520px; }
.feature-row span { color: var(--lime); font: italic 18px Georgia, serif; }
.feature-row p { margin: 0; color: #eef2ef; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(430px, 100%); background: var(--surface); padding: 48px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card h2, .dialog-form h2 { margin: 0 0 34px; font: 400 36px Georgia, serif; }
label { display: grid; gap: 8px; color: #425049; font-size: 13px; font-weight: 700; margin-bottom: 18px; }
input, select, textarea { width: 100%; border: 1px solid #ccd4cd; border-radius: 4px; background: white; color: var(--ink); padding: 12px 13px; outline: none; transition: border .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(36, 89, 70, .12); }
.button { border: 0; border-radius: 8px; padding: 12px 18px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .18s, box-shadow .18s, background .18s, border-color .18s; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible { outline: 3px solid rgba(36, 89, 70, .2); outline-offset: 2px; }
.button.primary { color: white; background: var(--forest-2); box-shadow: 0 7px 18px rgba(24, 63, 50, .16); }
.button.primary:hover { background: var(--forest); box-shadow: 0 9px 22px rgba(24, 63, 50, .24); }
.button.secondary { color: var(--forest); background: #edf0eb; border: 1px solid #d8ded8; }
.button.secondary:hover { background: #e4e9e3; border-color: #c7d0c8; }
.button.danger { color: white; background: var(--danger); }
.button.danger:hover { background: #812f2a; }
.login-card .button { width: 100%; margin-top: 8px; }
.form-error { color: var(--danger); min-height: 20px; font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; display: flex; flex-direction: column; background: var(--forest); color: white; }
.logo { color: white; text-decoration: none; display: flex; align-items: center; gap: 13px; line-height: 1.05; letter-spacing: .02em; }
.logo span { width: 42px; height: 42px; }
.sidebar nav { margin-top: 54px; display: grid; gap: 8px; }
.nav-item { border: 0; padding: 12px 14px; border-radius: 5px; background: transparent; color: #c9d5cf; text-align: left; font-weight: 700; }
.nav-item span { margin-right: 12px; color: var(--lime); }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.1); color: white; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.13); padding-top: 20px; }
.sidebar select { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.12); color: white; margin-bottom: 18px; }
.sidebar select option { color: var(--ink); }
.user-chip { display: flex; align-items: center; gap: 11px; }
.user-chip small { color: #aebdb6; display: block; margin-top: 2px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--lime); color: var(--forest); font-weight: 900; }
.text-button { border: 0; background: none; color: #b9c6c0; padding: 15px 0 0; }
.content { min-width: 0; padding: 44px clamp(24px, 4vw, 64px) 70px; }
.page { max-width: 1500px; margin: auto; }
.page-header, .project-header, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.page-header h1, .project-header h1 { font: 400 clamp(38px, 5vw, 58px) Georgia, serif; margin: 0; letter-spacing: -.03em; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 34px 0 24px; }
.metric { background: white; border: 1px solid var(--line); padding: 24px; min-height: 145px; }
.metric.accent { background: var(--sand); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; font: 400 46px Georgia, serif; margin: 9px 0; }
.panel { background: white; border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(29, 54, 43, .035); margin-top: 24px; }
.panel-head { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font: 400 23px Georgia, serif; }
.panel-head p { margin: 5px 0 0; font-size: 13px; }
.search { width: 260px; }
.project-row { display: grid; grid-template-columns: 100px 1.4fr 1fr 150px 32px; gap: 16px; align-items: center; padding: 18px 24px; border-bottom: 1px solid #edf0ed; cursor: pointer; }
.project-row:last-child { border: 0; }
.project-row:hover { background: #fafbf8; }
.project-row strong { display: block; }
.project-row small { color: var(--muted); }
.status { display: inline-block; width: fit-content; padding: 5px 9px; border-radius: 99px; background: #edf1ec; color: var(--forest-2); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.project-header { margin-top: 22px; }
.calculation-settings { display: inline-block; margin: 12px 0 0; padding: 7px 10px; color: var(--forest); background: var(--sand); font-size: 13px; font-weight: 800; }
.header-actions { display: flex; justify-content: flex-end; align-items: stretch; gap: 10px; flex-wrap: wrap; }
.file-button { cursor: pointer; }
.file-button input { display: none; }
.action-button { min-height: 58px; padding: 9px 14px 9px 10px; justify-content: flex-start; text-align: left; }
.action-button .action-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 7px; font-size: 18px; font-weight: 900; }
.button-copy { display: grid; gap: 2px; line-height: 1.1; }
.button-copy strong { font-size: 13px; white-space: nowrap; }
.button-copy small { font-size: 10px; font-weight: 700; opacity: .72; white-space: nowrap; }
.tender-button { color: var(--forest); background: #eef4e7; border: 1px solid #d8e4c7; }
.tender-button:hover { background: #e5efd8; border-color: #c5d8a9; }
.tender-button .action-icon { color: var(--forest); background: var(--lime); }
.supplier-button { color: #604817; background: #fbf5e5; border: 1px solid #eadcb6; }
.supplier-button:hover { background: #f7edcf; border-color: #ddc888; }
.supplier-button .action-icon { color: #65480d; background: #f0d884; }
.export-button .action-icon { color: var(--forest); background: var(--lime); }
.icon-only { width: 58px; min-width: 58px; padding: 0; font-size: 22px; }
.file-button.uploading { opacity: .65; pointer-events: none; }
.file-button.uploading .action-icon { animation: button-pulse .8s ease-in-out infinite alternate; }
@keyframes button-pulse { to { transform: scale(.82); opacity: .55; } }
.back-button { border: 0; background: none; color: var(--forest-2); padding: 0; font-weight: 800; }
.table-scroll { max-height: calc(100vh - 280px); overflow: auto; scrollbar-gutter: stable; }
.boq-table { width: 100%; border-collapse: collapse; min-width: 1050px; }
.boq-table th { position: sticky; top: 0; z-index: 4; color: var(--muted); background: #fafbf9; padding: 11px 10px; border-bottom: 1px solid var(--line); box-shadow: 0 2px 5px rgba(23, 33, 28, .06); font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .06em; }
.boq-table td { border-top: 1px solid #edf0ed; padding: 10px; vertical-align: top; font-size: 13px; }
.boq-table input { min-width: 84px; padding: 8px; text-align: right; }
.editable-cell { min-width: 118px; }
.editable-cell:focus-within { background: #f2f7ef; box-shadow: inset 0 0 0 2px rgba(36, 89, 70, .2); }
.calculation-input { transition: border .2s, box-shadow .2s, background-color .35s; }
.calculation-input.saving { border-color: #d4b75d; background: #fff9e8; }
.calculation-input.saved-flash { animation: saved-field 1.5s ease-out; }
.revision-hint { display: block; margin-top: 5px; color: #68806f; font-size: 10px; font-weight: 700; white-space: nowrap; }
@keyframes saved-field {
  0%, 55% { color: #174b2e; border-color: #78b98c; background: #dff5e5; box-shadow: 0 0 0 3px rgba(71, 155, 97, .16); }
  100% { background: white; }
}
.boq-table .description { min-width: 280px; }
.boq-table .description small { display: block; margin-top: 4px; color: var(--muted); max-width: 500px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.boq-table tr.section td { background: #edf1ec; font-weight: 800; color: var(--forest); padding: 12px 10px; }
.boq-table tr.has-similar-match > td { background-color: #f4f8fb; }
.boq-table tr.has-exact-match > td { background-color: #f2f8e8; }
.boq-table tr.has-similar-match > td:first-child { box-shadow: inset 4px 0 #7ca7c2; }
.boq-table tr.has-exact-match > td:first-child { box-shadow: inset 4px 0 #8cb14a; }
.save-item, .suggest-item { border: 0; background: none; color: var(--forest-2); font-weight: 900; padding: 6px; }
.suggest-item.has-matches { min-width: 42px; padding: 6px 8px; border-radius: 99px; color: #173f31; background: var(--lime); box-shadow: 0 3px 9px rgba(52, 84, 62, .16); }
.empty-state { text-align: center; padding: 70px 30px; color: var(--muted); }
.empty-state strong { color: var(--ink); font: 400 25px Georgia, serif; }
.user-row { display: grid; grid-template-columns: 46px 1fr 1fr 140px; align-items: center; gap: 14px; padding: 17px 24px; border-bottom: 1px solid #edf0ed; }
.user-row:last-child { border: 0; }

dialog { border: 0; padding: 0; width: min(620px, calc(100vw - 32px)); box-shadow: 0 30px 100px rgba(10, 30, 22, .22); }
dialog::backdrop { background: rgba(17, 36, 29, .62); backdrop-filter: blur(3px); }
.dialog-form { padding: 30px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.icon-button { border: 0; background: #eef1ed; width: 34px; height: 34px; font-size: 22px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }
.dialog-actions.split-actions { display: grid; grid-template-columns: auto 1fr auto auto; }
.suggestion { border: 1px solid var(--line); padding: 16px; margin: 10px 0; }
.suggestion strong { display: block; margin: 11px 0; }
.suggestion-choice { width: 100%; color: var(--ink); background: white; text-align: left; transition: border-color .18s, box-shadow .18s, transform .18s; }
.suggestion-choice:hover { border-color: #91ad9d; box-shadow: 0 9px 24px rgba(22, 56, 42, .1); transform: translateY(-1px); }
.suggestion-choice.exact { border-left: 5px solid #8cb14a; }
.suggestion-head, .suggestion-values { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.suggestion-head small { color: var(--muted); }
.match-badge { width: fit-content; padding: 4px 8px; border-radius: 99px; color: var(--forest); background: #edf3e2; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.suggestion-values { justify-content: flex-start; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.suggestion-values span { padding-right: 13px; border-right: 1px solid var(--line); }
.suggestion-values span:last-child { border: 0; }
.suggestion-values b { color: var(--ink); }
.apply-hint { display: block; margin-top: 13px; color: var(--forest-2); font-size: 12px; font-weight: 900; }
.toast { position: fixed; z-index: 2147483647; right: 24px; top: 24px; max-width: min(420px, calc(100vw - 48px)); padding: 14px 18px; color: white; background: var(--forest); box-shadow: 0 18px 50px rgba(8, 25, 18, .3); transform: translateY(-100px); opacity: 0; transition: .25s; filter: none; backdrop-filter: none; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .login-layout { grid-template-columns: 1fr; }
  .brand-panel { display: none; }
  .app-shell { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 22px 12px; }
  .logo strong, .nav-item:not(.active), .nav-item { font-size: 0; }
  .nav-item span { font-size: 20px; margin: 0; }
  .sidebar-bottom select, .user-chip div:not(.avatar), .text-button { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .project-row { grid-template-columns: 80px 1fr 100px; }
  .project-row > :nth-child(3), .project-row > :last-child { display: none; }
}

@media (max-width: 620px) {
  .content { padding: 26px 15px 50px; }
  .page-header, .project-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions > * { flex: 1 1 145px; }
  .header-actions .icon-only { flex: 0 0 58px; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .search { width: 150px; }
}
