:root {
  --ink: #17211b;
  --muted: #66736c;
  --line: #dce3de;
  --panel: #ffffff;
  --bg: #f4f7f5;
  --soft: #edf4ef;
  --gold: #d79b21;
  --accent: #176b59;
  --accent-strong: #0f5143;
  --warn: #b42318;
  --focus: #f4b63d;
  --shadow: 0 18px 45px rgba(23, 33, 27, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef5f0 0, #f7f8f6 380px, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-strong);
}

button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(244, 182, 61, 0.45);
  outline-offset: 2px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 48px);
  position: sticky;
  top: 0;
  z-index: 5;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.05;
}

h2 {
  font-size: clamp(22px, 2vw, 30px);
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tabs {
  background: #eef3ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  padding: 4px;
}

.tab {
  background: transparent;
  color: var(--muted);
  min-height: 38px;
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), #215d88);
  color: #fff;
}

main {
  margin: 0 auto;
  max-width: 1480px;
  padding: 28px clamp(16px, 4vw, 48px) 56px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-head > div:first-child {
  min-width: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 100%;
}

.ghost {
  background: #e8efeb;
  color: var(--accent-strong);
}

.ghost:hover {
  background: #dce8e2;
}

.staff-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 22px;
}

.staff-form::before {
  background: linear-gradient(90deg, var(--accent), #2f79a7, var(--gold));
  border-radius: 8px 8px 0 0;
  content: "";
  grid-column: 1 / -1;
  height: 4px;
  margin: -22px -22px 2px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.wide {
  grid-column: span 2;
}

.field.full {
  grid-column: 1 / -1;
}

.field label,
.toolbar span {
  color: #34433b;
  font-size: 13px;
  font-weight: 800;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

input,
select,
textarea {
  background: #fbfcfb;
  border: 1px solid #cfd9d3;
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

input:invalid:not(:placeholder-shown) {
  border-color: #d35349;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.message {
  color: var(--muted);
  margin-right: auto;
}

.toolbar {
  align-items: end;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 1fr) minmax(145px, 180px) minmax(145px, 180px) 82px;
  margin-bottom: 14px;
  padding: 16px;
}

.toolbar label {
  display: grid;
  gap: 7px;
}

.icon-button {
  min-width: 82px;
}

.table-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: auto;
  width: 100%;
}

table {
  border-collapse: collapse;
  min-width: 1040px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef3ef;
  color: #314139;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  color: #26342d;
  font-size: 14px;
  max-width: 320px;
  overflow-wrap: anywhere;
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 130px;
}

.small {
  font-size: 13px;
  min-height: 34px;
  padding: 0 10px;
}

.danger {
  background: #f8e7e5;
  color: var(--warn);
}

.danger:hover {
  background: #f3d0cc;
}

.auth-dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(18, 31, 25, 0.28);
  max-width: min(520px, calc(100vw - 28px));
  padding: 0;
  width: 520px;
}

.auth-dialog::backdrop {
  background: rgba(15, 24, 20, 0.48);
}

.auth-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.dialog-copy {
  color: var(--muted);
  line-height: 1.5;
}

.password-field {
  display: grid;
  gap: 7px;
}

.password-field span {
  font-size: 13px;
  font-weight: 800;
}

.checkline {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  line-height: 1.4;
}

.checkline input {
  flex: 0 0 auto;
  margin-top: 2px;
  min-height: auto;
  width: auto;
}

.auth-error {
  color: var(--warn);
  font-weight: 700;
  min-height: 20px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@media (max-width: 1000px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs,
  .actions {
    justify-content: stretch;
  }

  .tabs button,
  .actions button {
    flex: 1;
    min-width: 0;
  }

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

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  main {
    padding-inline: 12px;
  }

  .staff-form,
  .toolbar {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .staff-form::before {
    margin: -14px -14px 2px;
  }

  .field.wide,
  .field.full {
    grid-column: 1;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .message {
    margin-right: 0;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .table-wrap {
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  thead {
    height: 1px;
    overflow: hidden;
    position: absolute;
    width: 1px;
  }

  tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(23, 33, 27, 0.08);
    margin-bottom: 12px;
    overflow: hidden;
  }

  td {
    align-items: start;
    border-bottom: 1px solid #edf1ee;
    display: grid;
    gap: 10px;
    grid-template-columns: 96px minmax(0, 1fr);
    max-width: none;
    padding: 10px 12px;
  }

  td::before {
    color: var(--accent-strong);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  td:last-child {
    border-bottom: 0;
  }

  .row-actions {
    min-width: 0;
  }

  .row-actions button {
    flex: 1;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media print {
  .topbar,
  .section-head .actions,
  .toolbar,
  .row-actions,
  #entryPage {
    display: none !important;
  }

  body {
    background: #fff;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .page {
    display: block;
  }

  .table-wrap {
    border: 0;
    box-shadow: none;
    overflow: visible;
  }
}
