:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --ink: #152226;
  --muted: #647176;
  --line: #d9e1e4;
  --primary: #006b7a;
  --primary-dark: #004653;
  --primary-soft: #e4f3f5;
  --danger: #b23b3b;
  --danger-soft: #f8e9e9;
  --shadow: 0 12px 30px rgba(17, 35, 41, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

input,
select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 6px 9px;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(0, 107, 122, .14);
  border-color: var(--primary);
}

select {
  color: var(--primary-dark);
  font-weight: 650;
}

.app {
  min-height: 100vh;
}

.appHeader {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
}

.appHeader h1,
.recordTitle h2,
.searchHero h2,
.sectionHead h3 {
  margin: 0;
}

.appHeader h1 {
  font-size: 20px;
  letter-spacing: .2px;
}

.eyebrow {
  margin: 0 0 3px;
  color: inherit;
  opacity: .76;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.headerActions,
.recordActions,
.recordNav,
.buttonRow,
.searchLine {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghostBtn {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .26);
  color: #fff;
}

.ghostBtn:hover {
  background: #fff;
  color: var(--primary-dark);
}

.primaryBtn {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.primaryBtn:hover {
  background: var(--primary-dark);
  color: #fff;
}

.dangerBtn {
  background: var(--danger-soft);
  border-color: #e4b8b8;
  color: var(--danger);
}

.view {
  width: min(1380px, calc(100% - 32px));
  margin: 18px auto 36px;
}

.hidden {
  display: none;
}

.searchHero,
.recordHeader,
.sectionBlock,
.searchPanel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.searchHero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  margin-bottom: 14px;
}

.searchHero h2 {
  color: var(--primary-dark);
  font-size: 24px;
}

.searchPanel {
  padding: 18px;
}

.searchLine {
  margin-bottom: 10px;
}

.searchLine input {
  max-width: 640px;
  height: 38px;
  font-size: 14px;
}

.meta {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.recordHeader {
  position: sticky;
  top: 76px;
  z-index: 10;
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.recordHeader .ghostBtn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.recordTitle h2 {
  color: var(--primary-dark);
  font-size: 22px;
  line-height: 1.15;
  text-transform: uppercase;
}

.recordTitle .eyebrow {
  color: var(--muted);
}

.codeInput {
  width: 110px;
  text-align: center;
  font-weight: 750;
}

.itemInput {
  width: 52px;
  text-align: center;
}

.iconBtn {
  width: 38px;
  padding: 0;
  font-size: 17px;
}

.sectionBlock {
  padding: 18px;
  margin-bottom: 14px;
}

.sectionHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.sectionHead h3 {
  color: var(--primary-dark);
  font-size: 17px;
}

.sectionHead p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.formGrid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.field input,
.field select {
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
}

.field select {
  color: var(--primary-dark);
  font-weight: 650;
}

.nameInput {
  font-weight: 750;
  text-transform: uppercase;
}

.span1 { grid-column: span 1; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span4 { grid-column: span 4; }
.span5 { grid-column: span 5; }
.span6 { grid-column: span 6; }

.cuilBox {
  display: grid;
  grid-template-columns: 46px 10px minmax(88px, 1fr) 10px 46px auto;
  gap: 5px;
  align-items: center;
}

.cuilBox span {
  color: var(--muted);
  text-align: center;
}

.tableWrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.gridTable {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 12px;
}

.gridTable th,
.gridTable td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  height: 30px;
  padding: 6px 8px;
  white-space: nowrap;
}

.gridTable th {
  background: #edf3f4;
  color: #56666b;
  font-weight: 800;
  text-align: left;
}

.gridTable tr:hover {
  background: #eef9fb;
}

.gridTable th:last-child,
.gridTable td:last-child {
  border-right: none;
}

.gridTable tr:last-child td {
  border-bottom: none;
}

.resultTable tbody tr,
.empTable tbody tr {
  cursor: pointer;
}

.empEditor {
  display: grid;
  grid-template-columns: 86px minmax(220px, 2fr) repeat(3, minmax(90px, 1fr)) minmax(170px, 1.3fr) minmax(150px, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.buttonRow {
  margin-top: 12px;
  flex-wrap: wrap;
}

.buttonRow button {
  min-width: 110px;
}

.obsTable td:nth-child(1) {
  width: 42px;
  color: var(--muted);
  text-align: right;
  font-weight: 750;
}

@media (max-width: 980px) {
  .appHeader,
  .searchHero {
    align-items: stretch;
    flex-direction: column;
  }

  .headerActions,
  .recordActions,
  .recordNav,
  .searchLine {
    flex-wrap: wrap;
  }

  .recordHeader {
    position: static;
    grid-template-columns: 1fr;
  }

  .recordTitle {
    order: -1;
  }

  .formGrid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .span5,
  .span6 {
    grid-column: span 6;
  }

  .span4,
  .span3,
  .span2 {
    grid-column: span 3;
  }

  .span1 {
    grid-column: span 2;
  }

  .empEditor {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  body {
    font-size: 12px;
  }

  .view {
    width: calc(100% - 20px);
    margin-top: 10px;
  }

  .appHeader {
    padding: 12px;
  }

  .appHeader h1,
  .searchHero h2,
  .recordTitle h2 {
    font-size: 18px;
  }

  .sectionBlock,
  .searchPanel,
  .searchHero,
  .recordHeader {
    padding: 12px;
    border-radius: 8px;
  }

  .formGrid,
  .empEditor {
    grid-template-columns: 1fr;
  }

  .span1,
  .span2,
  .span3,
  .span4,
  .span5,
  .span6 {
    grid-column: span 1;
  }

  .cuilBox {
    grid-template-columns: 44px 10px 1fr 10px 44px;
  }

  .cuilBox button {
    grid-column: 1 / -1;
  }

  .searchLine input {
    max-width: none;
  }
}
