:root {
  --page-bg: #fff3d3;
  --panel-bg: #fff9e8;
  --line: #ddcfaa;
  --line-strong: #243a34;
  --green: #237a4f;
  --green-dark: #15593a;
  --green-soft: #e9f6ed;
  --gold: #f8e5a8;
  --cyan-row: #bdf0f2;
  --cyan-row-alt: #d7f8f8;
  --text: #1b1f1d;
  --muted: #5d665f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  line-height: 1.35;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: none;
  place-items: center;
  background: rgba(255,243,211,.72);
  backdrop-filter: blur(2px);
}

.loading-overlay.show {
  display: grid;
}

.loading-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 170px;
  justify-content: center;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--green-dark);
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(70,50,8,.16);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #d7eadc;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.topbar {
  min-height: 54px;
  background: linear-gradient(180deg, #102119 0%, #08130f 100%);
  padding: 8px clamp(10px, 1.4vw, 18px);
  overflow-x: visible;
  border-bottom: 2px solid #d9c38a;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

.nav-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.nav-grid,
.nav-side,
.header-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.nav-grid {
  flex: 1 1 auto;
}

.header-tools {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.nav-side {
  justify-content: flex-end;
}

.nav-btn,
.action-btn {
  min-height: 36px;
  border: 1px solid rgba(248,229,168,.72);
  background: var(--green);
  color: #fff7cf;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(0,0,0,.2);
  transition: background-color .14s ease, border-color .14s ease, box-shadow .14s ease, transform .06s ease;
}

.nav-btn {
  min-width: 0;
  padding: 0 13px;
  white-space: nowrap;
}

.topbar .nav-btn {
  min-height: 34px;
  border-radius: 7px;
  font-size: 15px;
  padding: 0 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 1px 2px rgba(0,0,0,.18);
}

.nav-btn.active {
  background: #35a166;
  border-color: #ffe9a8;
  color: #fffbe0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 0 0 2px rgba(255,233,168,.18);
}

.nav-btn:hover,
.action-btn:hover {
  background: #2f925f;
  border-color: #ffe2a1;
  transform: translateY(-1px);
}

.nav-btn:active,
.action-btn:active {
  transform: translateY(0);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.22);
}

.nav-btn:focus-visible,
.action-btn:focus-visible,
.mini-btn:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid #0b73d9;
  outline-offset: 2px;
}

.exit-btn {
  grid-row: auto;
  background: #2b8c5a;
}

.server-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid rgba(248,229,168,.36);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: #f9edbf;
  font-size: 12px;
  white-space: nowrap;
}

.server-status strong {
  color: #ffffff;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #50d27b;
  box-shadow: 0 0 0 3px rgba(80,210,123,.15);
}

.status-dot.offline {
  background: #e85e5e;
  box-shadow: 0 0 0 3px rgba(232,94,94,.15);
}

.status-divider {
  width: 1px;
  height: 16px;
  background: rgba(248,229,168,.26);
}

.page {
  min-height: calc(100vh - 54px);
  padding: clamp(16px, 3.4vh, 44px) 14px 34px;
}

.panel-page {
  width: min(1120px, 100%);
  margin-left: clamp(0px, 4vw, 76px);
}

.center-page {
  width: min(1000px, 100%);
  margin: 0 auto;
}

h1 {
  margin: 18px 0 18px;
  color: var(--green);
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0;
}

.box {
  border: 1px solid var(--line);
  background: var(--panel-bg);
  padding: 12px 14px;
  margin: 10px auto;
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(67,48,8,.08);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(220px, 350px) minmax(100px, 140px) minmax(220px, 350px);
  gap: 6px 10px;
  align-items: start;
}

.form-grid.compact {
  grid-template-columns: minmax(130px, 180px) minmax(220px, 350px);
  width: min(594px, 100%);
}

.label {
  text-align: right;
  padding-top: 5px;
  white-space: nowrap;
}

input,
textarea,
select {
  height: 36px;
  border: 1px solid #c8c8c8;
  background: #fff;
  font: inherit;
  padding: 4px 8px;
  width: 100%;
  min-width: 0;
  border-radius: 4px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}

textarea {
  height: 72px;
  resize: none;
}

select {
  background-color: var(--green);
  color: #fff0b8;
  border-color: #bfae78;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: min(860px, 100%);
  padding: 14px;
}

.action-btn {
  min-width: 126px;
  width: auto;
  min-height: 36px;
  height: auto;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  padding: 6px 18px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.search-panel {
  width: min(640px, 100%);
  margin: 0 auto;
}

.search-panel form {
  display: grid;
  gap: 10px;
}

.search-panel .box {
  width: 100%;
}

.search-actions {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
  padding: 12px;
}

.search-actions .action-btn {
  width: 100%;
  min-width: 0;
}

.mini-btn {
  min-height: 28px;
  border: 1px solid #8fb2b2;
  background: #fff;
  color: #111;
  font: inherit;
  font-size: clamp(10px, .72vw, 12px);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  width: 100%;
  cursor: pointer;
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 1px rgba(0,0,0,.1);
}

.cell-tooltip {
  position: fixed;
  z-index: 10000;
  display: none;
  max-width: min(520px, calc(100vw - 24px));
  padding: 7px 10px;
  border: 1px solid #173a2a;
  border-radius: 5px;
  background: #10261c;
  color: #fff9dc;
  font-size: 14px;
  line-height: 1.25;
  box-shadow: 0 8px 22px rgba(0,0,0,.24);
  pointer-events: none;
  white-space: normal;
  word-break: break-word;
}

.cell-tooltip.show {
  display: block;
}

.mini-btn:hover {
  background: var(--green-soft);
  border-color: var(--green);
}

.mini-btn.danger {
  color: #9b1111;
}

.action-btn.dark {
  background: #080808;
  border-color: #080808;
}

.search-box {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 460px);
  align-items: center;
  width: min(774px, 100%);
  gap: 8px;
  padding: 14px;
}

.table-wrap {
  max-height: 394px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 12px;
  border: 1px solid var(--line-strong);
  border-right: 8px solid #e9e9e9;
  max-width: 100%;
  background: var(--cyan-row);
  border-radius: 5px;
}

table {
  border-collapse: collapse;
  background: var(--cyan-row);
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

th,
td {
  border: 1px solid #263a3a;
  padding: 4px 6px;
  min-height: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(11px, .86vw, 16px);
  vertical-align: middle;
}

th {
  background: #fffaf0;
  font-weight: 600;
  white-space: normal;
  line-height: 1.05;
  text-overflow: clip;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  white-space: nowrap;
}

tbody tr:nth-child(even) td {
  background: var(--cyan-row-alt);
}

tbody tr:hover td {
  background: #ecffff;
}

.radio-panel {
  border: 1px solid var(--line);
  background: var(--panel-bg);
  padding: 10px;
  width: 120px;
  font-size: 14px;
  border-radius: 6px;
}

.radio-panel label {
  display: block;
  margin: 10px 0;
}

.service-layout {
  display: grid;
  grid-template-columns: 140px minmax(320px, 614px);
  gap: 56px;
  align-items: center;
  justify-content: center;
}

.service-form {
  width: min(614px, 100%);
  grid-template-columns: 110px minmax(160px, 184px) 100px minmax(160px, 184px);
}

.wide-table {
  width: min(1258px, calc(100vw - 24px));
  margin-left: 0;
}

.data-table th:first-child,
.data-table td:first-child {
  width: 4%;
  text-align: center;
}

.customer-table th:nth-child(2),
.customer-table td:nth-child(2) {
  width: 15%;
}

.customer-table th:nth-child(3),
.customer-table td:nth-child(3) {
  width: 18%;
}

.customer-table th:nth-child(4),
.customer-table td:nth-child(4),
.customer-table th:nth-child(5),
.customer-table td:nth-child(5),
.customer-table th:nth-child(6),
.customer-table td:nth-child(6) {
  width: 7%;
}

.customer-table th:nth-child(7),
.customer-table td:nth-child(7),
.customer-table th:nth-child(8),
.customer-table td:nth-child(8),
.customer-table th:nth-child(9),
.customer-table td:nth-child(9) {
  width: 6.5%;
}

.customer-table th:nth-child(n+10),
.customer-table td:nth-child(n+10) {
  width: 6%;
}

.customer-table th,
.customer-table td,
.installation-table th,
.installation-table td {
  font-size: clamp(10px, .78vw, 16px);
}

.record-count {
  margin: 4px 0;
  font-size: 15px;
  color: var(--green-dark);
}

.record-bar {
  width: min(1128px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 0;
}

.per-page-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #166b45;
}

.per-page-form select {
  width: 86px;
  height: 30px;
  font-size: 14px;
}

.pager {
  width: min(1128px, 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 14px 0 0;
  font-size: 15px;
}

.pager-link,
.pager-current {
  min-width: 116px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d6c795;
  text-decoration: none;
  border-radius: 6px;
}

.pager-link {
  background: var(--green);
  color: #fff0b8;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(0,0,0,.14);
}

.pager-current {
  background: rgba(255,255,255,.4);
  color: var(--green-dark);
}

.installation-table th:nth-child(2),
.installation-table td:nth-child(2) {
  width: 15%;
}

.installation-table th:nth-child(3),
.installation-table td:nth-child(3) {
  width: 20%;
}

.installation-table th:nth-child(7),
.installation-table td:nth-child(7) {
  width: 8%;
}

.installation-table th:nth-child(n+11),
.installation-table td:nth-child(n+11) {
  width: 6%;
}

.service-table th:first-child,
.service-table td:first-child {
  width: 4%;
}

.service-table th:nth-child(2),
.service-table td:nth-child(2) {
  width: 6%;
}

.service-table th:nth-child(3),
.service-table td:nth-child(3) {
  width: 14%;
}

.service-table th:nth-child(4),
.service-table td:nth-child(4) {
  width: 18%;
}

.service-table th:nth-child(5),
.service-table td:nth-child(5) {
  width: 8%;
}

.service-table th:nth-child(6),
.service-table td:nth-child(6) {
  width: 11%;
}

.service-table th:nth-child(7),
.service-table td:nth-child(7),
.service-table th:nth-child(8),
.service-table td:nth-child(8) {
  width: 8%;
}

.service-table th:nth-child(9),
.service-table td:nth-child(9) {
  width: 12%;
}

.service-table th:nth-child(10),
.service-table td:nth-child(10) {
  width: 5%;
}

.service-table th:nth-child(11),
.service-table td:nth-child(11) {
  width: 6%;
}

.view-service-table th:first-child,
.view-service-table td:first-child {
  width: 4%;
}

.view-service-table th:nth-child(2),
.view-service-table td:nth-child(2) {
  width: 16%;
}

.view-service-table th:nth-child(3),
.view-service-table td:nth-child(3) {
  width: 5%;
}

.view-service-table th:nth-child(4),
.view-service-table td:nth-child(4) {
  width: 22%;
}

.view-service-table th:nth-child(5),
.view-service-table td:nth-child(5) {
  width: 8%;
}

.view-service-table th:nth-child(6),
.view-service-table td:nth-child(6) {
  width: 13%;
}

.view-service-table th:nth-child(7),
.view-service-table td:nth-child(7) {
  width: 9%;
}

.view-service-table th:nth-child(8),
.view-service-table td:nth-child(8) {
  width: 8%;
}

.view-service-table th:nth-child(9),
.view-service-table td:nth-child(9) {
  width: 10%;
}

.view-service-table th:nth-child(10),
.view-service-table td:nth-child(10) {
  width: 5%;
}

.search-table th:first-child,
.search-table td:first-child {
  width: 4%;
}

.search-table th:nth-child(2),
.search-table td:nth-child(2) {
  width: 16%;
}

.search-table th:nth-child(3),
.search-table td:nth-child(3) {
  width: 21%;
}

.search-table th:nth-child(4),
.search-table td:nth-child(4) {
  width: 8%;
}

.search-table th:nth-child(5),
.search-table td:nth-child(5) {
  width: 5%;
}

.search-table th:nth-child(6),
.search-table td:nth-child(6) {
  width: 12%;
}

.search-table th:nth-child(7),
.search-table td:nth-child(7) {
  width: 8%;
}

.search-table th:nth-child(8),
.search-table td:nth-child(8),
.search-table th:nth-child(9),
.search-table td:nth-child(9) {
  width: 8%;
}

.search-table th:nth-child(10),
.search-table td:nth-child(10) {
  width: 8%;
}

.search-table th:nth-child(11),
.search-table td:nth-child(11) {
  width: 4%;
}

.dealer-table th,
.dealer-table td {
  font-size: clamp(10px, .82vw, 17px);
}

.dealer-table th:nth-child(2),
.dealer-table td:nth-child(2) {
  width: 22%;
}

.dealer-table th:nth-child(3),
.dealer-table td:nth-child(3) {
  width: 26%;
}

.dealer-table th:nth-child(4),
.dealer-table td:nth-child(4),
.dealer-table th:nth-child(5),
.dealer-table td:nth-child(5),
.dealer-table th:nth-child(6),
.dealer-table td:nth-child(6) {
  width: 10%;
}

.dealer-table th:nth-child(7),
.dealer-table td:nth-child(7) {
  width: 7%;
}

.dealer-table th:nth-child(n+8),
.dealer-table td:nth-child(n+8) {
  width: 5%;
}

.complaint-table th:first-child,
.complaint-table td:first-child {
  width: 4%;
}

.complaint-table th:nth-child(2),
.complaint-table td:nth-child(2) {
  width: 6%;
}

.complaint-table th:nth-child(3),
.complaint-table td:nth-child(3) {
  width: 15%;
}

.complaint-table th:nth-child(4),
.complaint-table td:nth-child(4) {
  width: 20%;
}

.complaint-table th:nth-child(5),
.complaint-table td:nth-child(5) {
  width: 8%;
}

.complaint-table th:nth-child(6),
.complaint-table td:nth-child(6) {
  width: 12%;
}

.complaint-table th:nth-child(7),
.complaint-table td:nth-child(7),
.complaint-table th:nth-child(8),
.complaint-table td:nth-child(8) {
  width: 8%;
}

.complaint-table th:nth-child(9),
.complaint-table td:nth-child(9) {
  width: 12%;
}

.complaint-table th:nth-child(10),
.complaint-table td:nth-child(10),
.complaint-table th:nth-child(11),
.complaint-table td:nth-child(11) {
  width: 5%;
}

.view-complaint-table th:first-child,
.view-complaint-table td:first-child {
  width: 4%;
}

.view-complaint-table th:nth-child(2),
.view-complaint-table td:nth-child(2) {
  width: 17%;
}

.view-complaint-table th:nth-child(3),
.view-complaint-table td:nth-child(3) {
  width: 6%;
}

.view-complaint-table th:nth-child(4),
.view-complaint-table td:nth-child(4) {
  width: 9%;
}

.view-complaint-table th:nth-child(5),
.view-complaint-table td:nth-child(5) {
  width: 13%;
}

.view-complaint-table th:nth-child(6),
.view-complaint-table td:nth-child(6) {
  width: 9%;
}

.view-complaint-table th:nth-child(7),
.view-complaint-table td:nth-child(7) {
  width: 8%;
}

.view-complaint-table th:nth-child(8),
.view-complaint-table td:nth-child(8) {
  width: 28%;
}

.view-complaint-table th:nth-child(9),
.view-complaint-table td:nth-child(9) {
  width: 6%;
}

.technician-wrap {
  width: min(820px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.model-wrap {
  width: min(900px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.model-table th:nth-child(2),
.model-table td:nth-child(2) {
  width: 32%;
}

.model-table th:nth-child(3),
.model-table td:nth-child(3) {
  width: 20%;
}

.model-table th:nth-child(4),
.model-table td:nth-child(4) {
  width: 12%;
}

.model-table th:nth-child(n+5),
.model-table td:nth-child(n+5) {
  width: 10%;
}

.technician-table th:nth-child(2),
.technician-table td:nth-child(2) {
  width: 34%;
}

.technician-table th:nth-child(n+4),
.technician-table td:nth-child(n+4) {
  width: 12%;
}

.technician-table input,
.technician-table select {
  height: 28px;
  font-size: 15px;
}

.view-service-search {
  width: min(614px, 100%);
}

.service-detail-page {
  width: min(1220px, 100%);
}

.service-detail-grid {
  display: grid;
  grid-template-columns: 120px minmax(320px, 824px);
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.service-kind {
  align-self: center;
}

.detail-box {
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(190px, 224px) minmax(130px, 140px) minmax(220px, 260px);
  gap: 6px;
}

.detail-box input,
.detail-box textarea {
  border: 0;
  background: #fff;
  color: #111;
}

.detail-box textarea {
  height: 86px;
}

.history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 8px;
  margin-top: 8px;
}

.history-panel {
  min-height: 254px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  overflow: hidden;
  background: var(--cyan-row);
}

.service-editor-panel {
  min-height: 120px;
  margin-top: 8px;
  overflow-x: hidden;
}

.service-entry-form {
  width: min(860px, 100%);
  grid-template-columns: minmax(130px, 170px) minmax(170px, .85fr) minmax(120px, 145px) minmax(260px, 1.35fr);
}

.history-table th {
  background: #111914;
  color: #fff;
  font-size: 14px;
  white-space: normal;
}

.history-table td {
  font-size: 14px;
}

.history-table th:first-child,
.history-table td:first-child {
  width: 18%;
}

.history-table th:nth-child(2),
.history-table td:nth-child(2) {
  width: 42%;
}

.service-history-table th:first-child,
.service-history-table td:first-child {
  width: 12%;
}

.service-history-table th:nth-child(2),
.service-history-table td:nth-child(2) {
  width: 12%;
}

.service-history-table th:nth-child(3),
.service-history-table td:nth-child(3) {
  width: 42%;
}

.service-history-table th:nth-child(4),
.service-history-table td:nth-child(4) {
  width: 15%;
}

.service-history-table th:nth-child(5),
.service-history-table td:nth-child(5) {
  width: 9%;
}

.service-history-table th:nth-child(6),
.service-history-table td:nth-child(6),
.service-history-table th:nth-child(7),
.service-history-table td:nth-child(7) {
  width: 5%;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--page-bg);
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  background: var(--panel-bg);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(70,50,8,.12);
}

@media (max-width: 1100px) {
  body {
    font-size: 18px;
  }

  .topbar {
    padding: 9px 8px;
    min-height: 0;
  }

  .nav-shell {
    align-items: flex-start;
    gap: 8px;
  }

  .nav-grid,
  .nav-side {
    width: 100%;
  }

  .nav-grid {
    flex: 1 1 min(680px, 100%);
  }

  .header-tools {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .exit-btn {
    grid-row: auto;
    min-height: 38px;
  }

  .nav-btn {
    font-size: 16px;
    min-width: 0;
    padding-inline: 10px;
  }

  .page {
    padding-top: 32px;
  }

  .panel-page {
    margin: 0 auto;
  }

  .form-grid {
    grid-template-columns: minmax(120px, 180px) minmax(220px, 1fr);
  }

  .form-grid > .label:nth-child(n),
  .form-grid > input:nth-child(n),
  .form-grid > textarea:nth-child(n),
  .form-grid > select:nth-child(n),
  .form-grid > span:nth-child(n) {
    grid-column: auto !important;
  }

  .service-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .service-form {
    grid-template-columns: minmax(120px, 180px) minmax(220px, 1fr);
  }

  .wide-table {
    margin-left: 0;
  }

  .radio-panel {
    width: min(360px, 100%);
    margin: 0 auto;
  }

  .service-detail-grid,
  .history-grid {
    grid-template-columns: 1fr;
  }

  .detail-box {
    grid-template-columns: minmax(120px, 180px) minmax(220px, 1fr);
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  h1 {
    font-size: 22px;
    margin-top: 16px;
  }

  .nav-shell,
  .header-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-grid,
  .nav-side,
  .header-tools {
    gap: 5px;
  }

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

  .nav-btn {
    min-height: 36px;
    font-size: 14px;
    padding-inline: 6px;
    white-space: normal;
  }

  .server-status {
    justify-content: center;
    width: 100%;
  }

  .form-grid,
  .form-grid.compact,
  .search-box {
    grid-template-columns: 1fr;
  }

  .label {
    text-align: left;
  }

  .action-btn {
    min-width: 0;
    width: min(150px, 100%);
    flex: 1 1 130px;
    font-size: 16px;
    padding-inline: 10px;
  }

  input,
  textarea,
  select {
    min-width: 0;
  }

  .table-wrap {
    border-right-width: 6px;
    max-height: 62vh;
  }

  th,
  td {
    padding: 4px;
    font-size: 11px;
  }

  .record-bar,
  .pager {
    flex-direction: column;
    align-items: stretch;
  }

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

  .pager-link,
  .pager-current {
    width: 100%;
  }
}

.login-card h1 {
  margin-top: 0;
}

.login-card button {
  width: 100%;
  margin-top: 14px;
}

.error {
  color: #d00;
  font-size: 16px;
  text-align: center;
}

.setup-card {
  width: min(760px, calc(100vw - 32px));
}

.setup-card pre {
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
  border: 1px solid #d6d6d6;
  padding: 10px;
  font-size: 14px;
}

.setup-copy {
  font-size: 16px;
  line-height: 1.4;
}

.admin-page {
  width: min(1480px, 100%);
}

.admin-table-wrap {
  max-height: 620px;
  overflow-x: auto;
}

.admin-table th,
.admin-table td {
  font-size: clamp(11px, .78vw, 15px);
  vertical-align: top;
}

.admin-table {
  table-layout: auto;
  min-width: 1180px;
}

.admin-table input,
.admin-table select {
  height: 28px;
  font-size: 13px;
}

.permission-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(70px, auto);
  gap: 4px 10px;
  text-align: left;
  min-width: 260px;
}

.permission-grid label {
  white-space: normal;
  line-height: 1.2;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 0 auto 14px;
}

.metric-card {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: 0 1px 3px rgba(67,48,8,.08);
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  color: var(--green-dark);
  font-size: 22px;
}

.analytics-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.analytics-table-wrap {
  max-height: 280px;
}

.analytics-table {
  min-width: 0;
}

.lazy-sentinel {
  min-height: 34px;
  display: grid;
  place-items: center;
  color: var(--green-dark);
  background: rgba(255,249,232,.82);
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .analytics-split {
    grid-template-columns: 1fr;
  }
}
