/* Government-project register — shared visual language with document and JOB registers. */
@media screen {
  .government-project-register {
    --gov-register-green:#155b4b;
    --gov-register-green-dark:#0b3337;
    --gov-register-line:#d3e1dc;
    --gov-register-soft:#eff7f4;
    padding:0 !important;
    overflow:hidden;
    border:0 !important;
    border-radius:10px !important;
    background:transparent !important;
    box-shadow:none !important;
  }

  .government-project-register > .panel-head {
    margin:0 !important;
    padding:8px 2px 7px !important;
    border:0 !important;
    background:transparent !important;
  }
  .government-project-register > .panel-head h3 {
    margin:0 !important;
    color:#173b34 !important;
    font-size:16px !important;
  }
  .government-project-register > .panel-head p {
    margin:1px 0 0 !important;
    color:#687b75 !important;
    font-size:10px !important;
  }

  .government-project-register .government-register-search {
    display:grid !important;
    grid-template-columns:minmax(320px,2.4fr) minmax(150px,1fr) minmax(160px,1fr) auto !important;
    gap:7px 9px !important;
    align-items:end !important;
    margin:0 0 8px !important;
    padding:9px 11px !important;
    border:0 !important;
    border-radius:9px !important;
    background:var(--gov-register-green-dark) !important;
    box-shadow:0 4px 12px rgba(8,38,43,.12) !important;
  }
  .government-project-register .government-register-search label {
    min-width:0 !important;
    color:#c8d9d4 !important;
  }
  .government-project-register .government-register-search label > span {
    margin:0 0 2px !important;
    color:#c8d9d4 !important;
    font-size:10px !important;
    font-weight:600 !important;
  }
  .government-project-register .government-register-search :is(input,select,button) {
    min-height:32px !important;
    border-radius:6px !important;
    font-size:11px !important;
  }
  .government-project-register .government-register-search input {
    background:#fff !important;
    color:#173b34 !important;
  }
  .government-project-register .government-register-search .ghost {
    border-color:#ffffff55 !important;
    color:#fff !important;
    background:#ffffff12 !important;
  }

  .government-project-register .government-project-list {
    display:block !important;
    overflow:hidden;
    border:1px solid var(--gov-register-line) !important;
    border-radius:10px !important;
    background:#fff !important;
    box-shadow:0 4px 14px rgba(16,59,48,.05) !important;
  }
  .government-project-register .government-project-list::before {
    content:'ทะเบียนโครงการภาครัฐ  ·  คลิกแถวเพื่อเปิดรายละเอียด';
    display:block;
    padding:8px 12px;
    border-bottom:1px solid var(--gov-register-line);
    color:#155b4b;
    background:linear-gradient(110deg,#eff8f4,#fff);
    font-size:11px;
    font-weight:800;
  }
  .government-project-register .government-project-list > article {
    margin:0 !important;
    padding:0 !important;
    border:0 !important;
    border-bottom:1px solid #e3ebe7 !important;
    border-radius:0 !important;
    background:#fff !important;
  }
  .government-project-register .government-project-list > article:nth-of-type(even) {
    background:#f8faf9 !important;
  }
  .government-project-register .government-project-list > article:last-child {
    border-bottom:0 !important;
  }

  .government-project-register .government-project-summary {
    display:grid !important;
    grid-template-columns:32px 180px minmax(250px,1.35fr) minmax(360px,1.65fr) 132px !important;
    gap:8px !important;
    align-items:center !important;
    width:100% !important;
    min-height:54px !important;
    margin:0 !important;
    padding:7px 10px !important;
    border:0 !important;
    border-radius:0 !important;
    color:#1b2f37 !important;
    background:transparent !important;
    text-align:left !important;
  }
  .government-project-register .government-project-sequence {
    position:static !important;
    grid-column:1 !important;
    grid-row:1 !important;
    width:28px !important;
    height:28px !important;
    font-size:11px !important;
  }
  .government-project-register .government-project-summary:hover {
    background:#eef7f3 !important;
    box-shadow:inset 3px 0 0 var(--gov-register-green) !important;
  }
  .government-project-register .government-project-summary[aria-expanded='true'] {
    background:#e7f3ee !important;
    box-shadow:inset 4px 0 0 var(--gov-register-green) !important;
  }
  .government-project-register .government-project-head {
    display:contents !important;
  }
  .government-project-register .government-project-head > div:first-child {
    grid-column:2 !important;
    grid-row:1 !important;
    min-width:0;
  }
  .government-project-register .government-project-head > div:first-child b,
  .government-project-register .government-project-head > div:first-child small {
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .government-project-register .government-project-head > div:first-child b {
    color:#172c33 !important;
    font-size:11px !important;
  }
  .government-project-register .government-project-head > div:first-child small {
    margin-top:1px !important;
    color:#64766f !important;
    font-size:9px !important;
  }
  .government-project-register .government-project-title {
    grid-column:3 !important;
    grid-row:1 !important;
    margin:0 !important;
    min-width:0;
    overflow:hidden;
    color:#1b2f37 !important;
    font-size:11px !important;
    font-weight:700 !important;
    line-height:1.35 !important;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .government-project-register .government-project-brief {
    grid-column:4 !important;
    grid-row:1 !important;
    display:grid !important;
    grid-template-columns:minmax(0,1.3fr) minmax(0,1fr) minmax(0,.9fr) minmax(0,.8fr) minmax(0,.65fr) !important;
    gap:6px !important;
    min-width:0;
    overflow:hidden;
  }
  .government-project-register .government-project-brief b {
    display:block;
    min-width:0;
    max-width:100%;
    overflow:hidden;
    color:#657872 !important;
    font-size:9px !important;
    font-weight:500 !important;
    line-height:1.25 !important;
    text-overflow:ellipsis;
    white-space:nowrap !important;
  }
  .government-project-register .government-status-stack {
    grid-column:5 !important;
    grid-row:1 !important;
    display:flex !important;
    flex-wrap:wrap;
    justify-content:flex-end;
    gap:3px !important;
  }
  .government-project-register .government-status-stack strong {
    padding:4px 7px !important;
    border-radius:999px !important;
    font-size:9px !important;
    line-height:1.1 !important;
    white-space:nowrap;
  }
  .government-project-register .government-expand-label {
    display:none !important;
  }

  .government-project-register .government-project-details {
    margin:0 !important;
    padding:12px 14px 15px !important;
    border:0 !important;
    border-top:1px solid #cdded8 !important;
    border-radius:0 !important;
    background:#f7fbf9 !important;
  }

  /* The project detail already shows its linked JOB. Keep the relationship
     data, but remove the duplicate summary block below the register. */
  .government-entry-grid > .job-project-relations {
    display:none !important;
  }

  /* Approved desktop dimensions for the government-project creation form.
     Fixed-size controls keep their approved width and wrap instead of being
     squeezed by the legacy four-column grid. */
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form {
    display:flex !important;
    flex-wrap:wrap !important;
    column-gap:7px !important;
    row-gap:8px !important;
    align-items:flex-end !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label {
    flex:0 0 auto !important;
    min-width:0 !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(.auto-number) { width:160px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(select[name='decisionStatus']) { width:182px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='governmentProjectNo']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='governmentContractNo']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(select[name='customerId']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='agency']) { width:301px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(select[name='procurementMethod']) { width:250px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='name']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(textarea[name='scopeSummary']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='sourceReference']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .government-data-rule,
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .form-actions {
    width:100% !important;
    flex-basis:100% !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='agencyAddress']) { width:609px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='agencyHeadPosition']) { width:400px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .government-agency-address-summary {
    width:609px !important;
    min-height:34px;
    box-sizing:border-box;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    padding:4px 6px 4px 10px;
    border:1px solid #c5d7d1;
    border-radius:6px;
    background:#f4f8f6;
    color:#36574e;
    font-size:12px;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .government-agency-address-summary .ghost {
    min-height:26px !important;
    padding:3px 9px !important;
    white-space:nowrap;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .government-project-area-heading {
    width:100% !important;
    flex-basis:100% !important;
    display:flex;
    align-items:baseline;
    gap:8px;
    padding:2px 0 0;
    color:#174f40;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .government-project-area-heading[hidden] {
    display:none !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .government-project-area-heading b {
    font-size:13px;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .government-project-area-heading span {
    color:#667872;
    font-size:11px;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(select[name='province']) { width:149px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(select[name='district']) { width:145px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(select[name='subdistrict']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='announcementDate']) { width:150px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='projectPostcode']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='estimatedValue']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='referencePrice']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='bidPrice']),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='winningPrice']) { width:100px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label:has(input[name='submissionDeadline']) { width:150px !important; }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form :is(input,select,.pst-thai-date-button) {
    box-sizing:border-box !important;
    max-width:100% !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form .auto-number {
    width:160px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form select[name='decisionStatus'] {
    width:182px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form input[name='governmentProjectNo'],
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form input[name='governmentContractNo'],
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form select[name='customerId'],
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form input[name='agency'] {
    width:301px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form select[name='procurementMethod'] {
    width:250px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form input[name='name'] {
    width:1225px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form input[name='agencyAddress'] {
    width:609px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form input[name='agencyHeadPosition'] {
    width:400px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form select[name='province'] {
    width:149px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form select[name='district'] {
    width:145px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form select[name='subdistrict'] {
    width:150px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form input[name='projectPostcode'] {
    width:100px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form :is(
    input[name='estimatedValue'],
    input[name='referencePrice'],
    input[name='bidPrice'],
    input[name='winningPrice']
  ) {
    width:100px !important;
    height:34px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form label:has(input[name='announcementDate']) .pst-thai-date-button {
    width:150px !important;
    height:38px !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form input[name='submissionDeadline'] {
    width:150px !important;
    height:36px !important;
  }
}

@media screen and (max-width:1100px) {
  .government-project-register .government-project-summary {
    grid-template-columns:32px 165px minmax(220px,1fr) 120px !important;
  }
  .government-project-register .government-project-brief { display:none !important; }
  .government-project-register .government-status-stack { grid-column:4; }
}

@media screen and (max-width:760px) {
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > .government-agency-address-summary {
    width:100% !important;
    flex-basis:100% !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form > label {
    width:100% !important;
    flex-basis:100% !important;
  }
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form :is(
    .auto-number,
    input[name='governmentProjectNo'],
    input[name='governmentContractNo'],
    input[name='name'],
    select[name='decisionStatus'],
    select[name='customerId'],
    input[name='agency'],
    input[name='agencyAddress'],
    input[name='agencyHeadPosition'],
    select[name='procurementMethod'],
    select[name='province'],
    select[name='district'],
    select[name='subdistrict'],
    input[name='projectPostcode'],
    input[name='estimatedValue'],
    input[name='referencePrice'],
    input[name='bidPrice'],
    input[name='winningPrice'],
    input[name='submissionDeadline']
  ),
  .government-entry-grid > .panel.form-panel:first-child > form.inline-form label:has(input[name='announcementDate']) .pst-thai-date-button {
    width:100% !important;
  }
  .government-project-register .government-register-search {
    grid-template-columns:1fr 1fr !important;
  }
  .government-project-register .government-register-search label:first-child {
    grid-column:1 / -1;
  }
  .government-project-register .government-register-search .ghost {
    grid-column:1 / -1;
  }
  .government-project-register .government-project-list::before {
    font-size:10px;
  }
  .government-project-register .government-project-summary {
    grid-template-columns:30px minmax(0,1fr) auto !important;
    gap:6px !important;
    min-height:62px !important;
    padding:7px 8px !important;
  }
  .government-project-register .government-project-head > div:first-child { grid-column:2 !important;grid-row:1 !important; }
  .government-project-register .government-project-title {
    grid-column:2 !important;
    grid-row:2 !important;
    white-space:normal;
  }
  .government-project-register .government-status-stack {
    grid-column:3 !important;
    grid-row:1 / span 2 !important;
    max-width:92px;
  }
}

/* Keep the collapsed register as a clean project-name picker. Full metadata
   remains available in the existing detail panel after the row is opened. */
@media screen {
  .government-project-register .government-project-summary {
    grid-template-columns:minmax(0,1fr) !important;
    gap:0 !important;
    min-height:40px !important;
    padding:9px 12px !important;
  }
  .government-project-register .government-project-sequence,
  .government-project-register .government-project-head,
  .government-project-register .government-project-brief,
  .government-project-register .government-status-stack,
  .government-project-register .government-expand-label {
    display:none !important;
  }
  .government-project-register .government-project-title {
    grid-column:1 !important;
    grid-row:1 !important;
    width:100%;
    font-size:12px !important;
    white-space:nowrap !important;
  }
}
/* One government contract and JOB can contain multiple operational sites. */
.government-site-builder {
  flex:1 0 100%;
  width:100%;
  box-sizing:border-box;
  margin:2px 0 4px;
  padding:10px;
  border:1px solid #bfd5cd;
  border-radius:8px;
  background:#f5faf8;
}
.government-site-builder-head,
.government-site-card > header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.government-site-builder-head small { display:block; color:#64766f; }
.government-site-primary { margin-top:8px; }
.government-site-extra { display:grid; gap:8px; margin-top:8px; }
.government-site-card { padding:8px; border:1px solid #d5e4df; border-radius:7px; background:#fff; }
.government-site-fields,
.government-site-fields.pst-auto-fit-row { display:grid !important; grid-template-columns:repeat(12,minmax(0,1fr)); gap:6px !important; align-items:end !important; margin-top:7px; }
.government-site-fields label { min-width:0; }
.government-site-fields.pst-auto-fit-row > .pst-auto-fit-field { width:auto !important; }
.government-site-fields label:has([data-field='name']) { grid-column:span 2; }
.government-site-fields label:has([data-field='address']) { grid-column:span 3; }
.government-site-fields label:has([data-field='province']),
.government-site-fields label:has([data-field='district']),
.government-site-fields label:has([data-field='subdistrict']) { grid-column:span 2; }
.government-site-fields label:has([data-field='postcode']) { grid-column:span 1; }
.government-site-fields label:has([data-field='latitude']),
.government-site-fields label:has([data-field='longitude']),
.government-site-fields label:has([data-field='plannedBudget']),
.government-site-fields label:has([data-field='startDate']),
.government-site-fields label:has([data-field='endDate']),
.government-site-fields label:has([data-field='status']) { grid-column:span 2; }
.government-site-fields span { display:block; margin-bottom:2px; font-size:11px; }
.government-site-fields input,
.government-site-fields select { width:100%; min-width:0; height:32px; box-sizing:border-box; }
.government-site-fields select.pst-auto-fit-select { width:100% !important; }
.government-site-fields .pst-thai-date-button { width:100% !important; height:32px !important; }
.government-site-fields .government-site-scope { grid-column:1 / -1; width:100%; }
.government-procurement-group {
  flex:1 0 100%;
  width:100%;
  box-sizing:border-box;
  padding:9px 10px 10px;
  border:1px solid #c7d9d3;
  border-radius:8px;
  background:#f7faf9;
}
.government-procurement-heading {
  display:flex;
  align-items:baseline;
  gap:8px;
  margin-bottom:7px;
  color:#164f42;
}
.government-procurement-heading span {
  color:#64766f;
  font-size:11px;
}
.government-procurement-fields {
  display:grid;
  grid-template-columns:250px repeat(4,100px) 150px 150px;
  gap:7px;
  align-items:end;
}
.government-procurement-fields > label { min-width:0 !important; width:auto !important; }
.government-procurement-fields select[name='procurementMethod'] { width:100% !important; height:34px !important; }
.government-procurement-fields input[name='estimatedValue'],
.government-procurement-fields input[name='referencePrice'],
.government-procurement-fields input[name='bidPrice'],
.government-procurement-fields input[name='winningPrice'] { width:100% !important; height:34px !important; }
.government-procurement-fields label:has(input[name='announcementDate']) .pst-thai-date-button { width:100% !important; height:38px !important; }
.government-procurement-fields input[name='submissionDeadline'] { width:100% !important; height:36px !important; }

@media screen and (max-width:1100px) {
  .government-site-fields { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .government-site-fields > label:not(.government-site-scope) { grid-column:auto !important; }
  .government-site-fields > .government-site-scope { grid-column:1 / -1 !important; }
  .government-procurement-fields { grid-template-columns:2fr repeat(4,1fr); }
  .government-procurement-fields > label:nth-child(n+6) { grid-column:span 2; }
}
@media screen and (max-width:760px) {
  .government-site-fields { grid-template-columns:1fr 1fr; }
  .government-site-fields > label:not(.government-site-scope) { grid-column:auto !important; }
  .government-site-fields > .government-site-scope { grid-column:1 / -1 !important; }
  .government-procurement-heading { display:block; }
  .government-procurement-heading span { display:block; margin-top:2px; }
  .government-procurement-fields { grid-template-columns:1fr 1fr; }
  .government-procurement-fields > label:first-child { grid-column:1/-1; }
  .government-procurement-fields > label:nth-child(n+6) { grid-column:auto; }
}
