:root {
  color-scheme: light;
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  color: #1d1d1d;
  background: #edf3ff;
  --blue: #203a7a;
  --blue-hover: #1f4fa3;
  --blue-light: #e8f0ff;
  --border: #d3def2;
  --muted: #606b65;
}

* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; padding: 24px; background: #edf3ff; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

html.embedded,
html.embedded body { background: #fff; }
html.embedded body { padding: 16px; }
html.embedded .table-view { width: 100%; max-width: none; }
html.embedded .table-card { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }

.primary-button, .secondary-button, .text-button { min-height: 40px; padding: 8px 14px; border-radius: 8px; font-weight: 700; }
.primary-button { border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.primary-button:hover { background: var(--blue-hover); }
.secondary-button { border: 1px solid #b8c9ec; background: #edf3ff; color: var(--blue); }
.secondary-button:hover { background: #e3ecff; }
.text-button { border: 0; background: transparent; color: var(--blue); }
.text-button:hover { text-decoration: underline; }
.access-required { width: min(520px, 100%); margin: 48px auto; padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: #fff; text-align: center; }
.access-required h1 { margin: 0 0 8px; color: var(--blue); font-size: 22px; }
.access-required p { margin: 0; color: var(--muted); }

.table-view { width: min(1600px, 100%); margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.page-header h1 { margin: 0 0 4px; color: var(--blue); font-size: clamp(24px, 4vw, 32px); }
.page-header p { margin: 0; color: var(--muted); }
.table-card { padding: 20px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 4px 12px rgba(32, 58, 122, .08); }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 320px) auto; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar input, .toolbar textarea { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.toolbar input { height: 44px; }
.toolbar textarea { resize: vertical; }
.toolbar textarea { height: 52px; min-height: 52px; }
.toolbar .secondary-button { height: 44px; min-height: 44px; }
.filter-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; }
.filter-controls select { flex: 0 1 190px; width: 190px; min-width: 0; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: inherit; font-size: 12px; }
.top-scroll { height: 17px; margin-bottom: 4px; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--border); border-radius: 8px; background: #f7fbf8; }
.top-scroll > div { height: 1px; }
.top-scroll:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.table-scroll { max-height: 62vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-end-action { display: flex; justify-content: flex-end; margin-top: 8px; }
table { width: max-content; min-width: 2250px; table-layout: auto; border-collapse: collapse; font-size: 11px; }
th, td { padding: 7px 6px; border: 1px solid var(--border); text-align: center; vertical-align: middle; white-space: nowrap; overflow-wrap: normal; word-break: normal; }
th { position: sticky; top: 0; z-index: 1; background: var(--blue-light); }
th:nth-child(1), td:nth-child(1) { width: 48px; }
th:nth-child(2), td:nth-child(2) { width: 36px; }
th:nth-child(3), td:nth-child(3) { width: 180px; min-width: 180px; }
th:nth-child(4), td:nth-child(4),
th:nth-child(5), td:nth-child(5) { width: 180px; }
td:nth-child(4), td:nth-child(5), td:nth-child(6) { white-space: nowrap; }
th:nth-child(6), td:nth-child(6) { width: 210px; }
th:nth-child(7), td:nth-child(7) { width: 140px; }
th:nth-child(8), td:nth-child(8) { width: 75px; }
th:nth-child(9), td:nth-child(9) { width: 105px; }
th:nth-child(10), td:nth-child(10) { width: 145px; }
th:nth-child(11), td:nth-child(11) { width: 150px; }
th:nth-child(12), td:nth-child(12) { width: 120px; }
th:nth-child(13), td:nth-child(13) { width: 160px; }
th:nth-child(14), td:nth-child(14) { width: 125px; }
th:nth-child(15), td:nth-child(15) { width: 85px; }
th:nth-child(16), td:nth-child(16),
th:nth-child(18), td:nth-child(18) { width: 190px; }
th:nth-child(17), td:nth-child(17),
th:nth-child(19), td:nth-child(19) { width: 90px; text-align: center; }
th:nth-child(17), th:nth-child(19) { white-space: normal; }
td:nth-child(16), td:nth-child(18) {
  white-space: pre;
  text-align: left;
  vertical-align: top;
}
th:nth-child(20), td:nth-child(20) { width: 120px; text-align: center; }
th:nth-child(21), td:nth-child(21) { width: 360px; min-width: 360px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
th:nth-child(22), td:nth-child(22) { width: 100px; }
th:nth-child(23), td:nth-child(23) { width: 130px; }
th:nth-child(24), td:nth-child(24) { width: 80px; }
.record-select { width: 17px; height: 17px; accent-color: #d9534f; }
.download-button { min-height: 26px; padding: 4px 7px; border: 1px solid var(--blue); border-radius: 5px; background: var(--blue); color: white; font-size: 10px; font-weight: 700; white-space: nowrap; }
.table-pagination, .table-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.table-pagination { justify-content: center; }
.table-actions { justify-content: flex-start; }
.table-actions input[type="date"] { min-height: 40px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; }
.delete-button { min-height: 40px; padding: 8px 14px; border: 1px solid #f1a4a4; border-radius: 8px; background: #fff4f4; color: #b94141; font-weight: 700; }
.delete-button:disabled { cursor: not-allowed; opacity: .55; }
.table-status { min-height: 20px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }

@media (max-width: 700px) {
  body { padding: 12px; }
  .page-header { align-items: flex-start; }
  .page-header .secondary-button { flex: 0 0 auto; }
  .table-card { padding: 12px; }
  .toolbar { grid-template-columns: 1fr; }
  .toolbar .secondary-button { width: 100%; }
  .filter-controls select { flex-basis: 160px; }
  .table-actions { flex-wrap: wrap; }
  .table-actions label { flex-basis: auto; }
}

@media (max-width: 420px) {
  .filter-controls select { flex-basis: 100%; }
}
