:root {
  --paper: #f4ede0;
  --paper-deep: #ece1cf;
  --card: #fffaf0;
  --ink: #2f2822;
  --muted: #8b7f70;
  --line: #dfd2be;
  --red: #a83f2d;
  --red-deep: #7d2c22;
  --gold: #ad8749;
  --green: #697b68;
  --shadow: 0 16px 42px rgba(74, 52, 28, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 4%, rgba(255, 255, 255, 0.72), transparent 26%),
    linear-gradient(180deg, #f7f2e8, #f1e8d7);
  font-family: "STSong", "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
}

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

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.brand-seal {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  margin: 0 auto 22px;
  border: 3px double rgba(255, 248, 234, 0.9);
  border-radius: 18px;
  color: #fff8ea;
  background: linear-gradient(145deg, #b84a35, #823026);
  box-shadow: 0 12px 30px rgba(125, 44, 34, 0.22);
  font-size: 42px;
  transform: rotate(-3deg);
}

.brand-seal.small {
  width: 52px;
  height: 52px;
  margin: 0;
  border-radius: 13px;
  font-size: 29px;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(100%, 440px);
  padding: 45px 42px 36px;
  border: 1px solid rgba(173, 135, 73, 0.26);
  border-radius: 28px;
  background: rgba(255, 250, 240, 0.95);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 9px 0 10px;
  font-size: 32px;
  letter-spacing: 0.08em;
  text-align: center;
}

.login-copy {
  margin: 0 0 30px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
  text-align: center;
}

.login-card label,
.form-grid label {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.login-card label > span,
.form-grid label > span {
  color: #716456;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fffdf8;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(168, 63, 45, 0.65);
  box-shadow: 0 0 0 3px rgba(168, 63, 45, 0.08);
}

textarea {
  resize: vertical;
}

.primary-button,
.secondary-button,
.text-button {
  border-radius: 999px;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid transparent;
  color: #fff9ed;
  background: linear-gradient(135deg, #b24a36, #853026);
  box-shadow: 0 10px 24px rgba(125, 44, 34, 0.17);
}

.primary-button.compact,
.secondary-button.compact {
  width: auto;
  min-height: 42px;
  padding: 0 19px;
}

.secondary-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(168, 63, 45, 0.35);
  color: var(--red);
  background: #fffaf1;
}

.text-button {
  padding: 7px 11px;
  border: 0;
  color: #7e6e5c;
  background: transparent;
}

.text-button:hover {
  color: var(--red);
}

.secure-note {
  margin: 18px 0 0;
  color: #9b8d7c;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.form-error {
  min-height: 20px;
  margin: 3px 0 8px;
  color: #b33628;
  font-size: 13px;
}

.site-header {
  border-bottom: 1px solid rgba(173, 135, 73, 0.2);
  background: rgba(255, 250, 240, 0.72);
  backdrop-filter: blur(18px);
}

.header-inner,
.page-main,
.footer-inner {
  width: min(100% - 48px, 1480px);
  margin-right: auto;
  margin-left: auto;
}

.header-inner {
  display: flex;
  min-height: 100px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 17px;
}

.brand-lockup h1 {
  margin: 4px 0 0;
  font-size: 25px;
  letter-spacing: 0.08em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.operator-name {
  color: var(--muted);
  font-size: 13px;
}

.page-main {
  padding: 44px 0 58px;
}

.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-intro h2 {
  margin: 8px 0 10px;
  font-size: clamp(28px, 3vw, 42px);
  letter-spacing: 0.06em;
}

.intro-copy {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.health-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border: 1px solid rgba(105, 123, 104, 0.27);
  border-radius: 999px;
  color: #5e705c;
  background: rgba(105, 123, 104, 0.06);
  font-size: 13px;
  white-space: nowrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #718b6e;
  box-shadow: 0 0 0 4px rgba(113, 139, 110, 0.12);
}

.stats-grid {
  display: grid;
  margin-top: 28px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.stat-card,
.panel {
  border: 1px solid rgba(173, 135, 73, 0.2);
  border-radius: 20px;
  background: rgba(255, 250, 240, 0.9);
  box-shadow: var(--shadow);
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 25px 26px 22px;
}

.stat-card::after {
  position: absolute;
  right: -34px;
  bottom: -54px;
  width: 128px;
  height: 128px;
  border: 1px solid rgba(173, 135, 73, 0.12);
  border-radius: 50%;
  content: "";
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 15px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 3.4vw, 48px);
  line-height: 1;
}

.stat-card small {
  display: block;
  margin-top: 12px;
  color: #9c8f80;
  font-size: 11px;
}

.panel {
  margin-top: 24px;
  padding: 26px 28px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading h2 {
  margin: 6px 0 0;
  font-size: 23px;
  letter-spacing: 0.04em;
}

.import-layout {
  display: grid;
  margin-top: 22px;
  grid-template-columns: minmax(260px, 0.85fr) minmax(300px, 1.15fr);
  gap: 24px;
}

.drop-zone {
  display: grid;
  min-height: 176px;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 24px;
  border: 1px dashed rgba(168, 63, 45, 0.43);
  border-radius: 16px;
  color: #715f4d;
  background: rgba(168, 63, 45, 0.025);
  text-align: center;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: var(--red);
  background: rgba(168, 63, 45, 0.08);
  font-size: 20px;
}

.drop-zone small {
  color: #9a8d7d;
  font-size: 11px;
}

.import-rules {
  align-self: center;
  color: #8a7d6e;
  font-size: 13px;
  line-height: 1.8;
}

.import-rules p {
  margin: 0 0 8px;
}

.records-heading {
  align-items: flex-end;
}

.record-actions {
  display: flex;
  gap: 11px;
}

.filters {
  display: grid;
  margin-top: 22px;
  grid-template-columns: minmax(220px, 1fr) 170px auto;
  gap: 12px;
}

.filters .secondary-button {
  min-height: 44px;
}

.table-wrap {
  margin-top: 20px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(213, 198, 176, 0.52);
  text-align: left;
}

th {
  color: #8c7e6e;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

td {
  color: #51473d;
}

tbody tr:hover {
  background: rgba(173, 135, 73, 0.035);
}

.brick-code {
  color: var(--red);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
}

.status-confirmed {
  color: #536d54;
  background: rgba(93, 122, 91, 0.1);
}

.status-void {
  color: #8d7461;
  background: rgba(128, 106, 82, 0.1);
}

.row-actions {
  display: flex;
  gap: 4px;
}

.row-link {
  border: 0;
  color: var(--red);
  background: transparent;
  font-size: 12px;
}

.row-link.muted-link {
  color: #847767;
}

.records-empty {
  padding: 58px 20px;
  color: #958878;
  font-size: 14px;
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 18px;
  color: #938676;
  font-size: 12px;
}

.pagination-buttons {
  display: flex;
  gap: 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.site-footer {
  margin-top: 0;
  border-top: 1px solid rgba(173, 135, 73, 0.2);
  background: rgba(236, 225, 207, 0.5);
}

.footer-inner {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #8f8273;
  font-size: 12px;
}

.record-dialog {
  width: min(100% - 32px, 760px);
  max-height: 90vh;
  padding: 0;
  overflow-y: auto;
  border: 1px solid rgba(173, 135, 73, 0.3);
  border-radius: 22px;
  color: var(--ink);
  background: #fffaf1;
  box-shadow: 0 28px 90px rgba(42, 30, 19, 0.3);
}

.record-dialog::backdrop {
  background: rgba(38, 29, 20, 0.48);
  backdrop-filter: blur(3px);
}

.record-dialog form {
  padding: 28px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-heading h2 {
  margin: 6px 0 0;
  font-size: 25px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #796d60;
  background: transparent;
  font-family: Arial, sans-serif;
  font-size: 23px;
}

.form-grid {
  display: grid;
  margin-top: 22px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}

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

.checkbox-label {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  align-self: end;
  gap: 9px !important;
  min-height: 44px;
}

.checkbox-label input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--red);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid rgba(213, 198, 176, 0.42);
}

.toast {
  position: fixed;
  z-index: 200;
  right: 24px;
  bottom: 24px;
  padding: 12px 18px;
  border-radius: 10px;
  color: #fff9ef;
  background: #3b3229;
  box-shadow: 0 12px 34px rgba(42, 30, 19, 0.22);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .import-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .header-inner,
  .page-main,
  .footer-inner {
    width: min(100% - 28px, 1480px);
  }

  .operator-name {
    display: none;
  }

  .page-main {
    padding-top: 28px;
  }

  .page-intro,
  .panel-heading,
  .records-heading,
  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .panel {
    padding: 22px 18px;
  }

  .record-actions {
    width: 100%;
  }

  .record-actions button {
    flex: 1;
  }

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

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

  .login-card {
    padding: 34px 25px 28px;
  }
}

