@import url("https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&family=Noto+Serif:wght@600;700&display=swap");

:root {
  --bg: #fff1a8;
  --panel: #ffffff;
  --panel-2: #fff7cf;
  --ink: #3b2413;
  --muted: #7b6546;
  --line: #d7aa51;
  --green: #8c3f1f;
  --green-dark: #5e2714;
  --coral: #d95f4c;
  --amber: #d89a26;
  --cyan: #2f8ea8;
  --shadow: 0 14px 32px rgba(86, 50, 15, 0.16);
  --family-bg: url("images/nen-gia-pha-nguyen-huu.png");
}

.personal-call-chip {
  border: 1px solid rgba(147, 55, 28, 0.25);
  background: #ffe6aa;
  color: #7b2516;
}

.grave-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #dfbd72;
}

.grave-section h3,
.form-subhead h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: #702617;
}

.grave-section h3 .icon { width: 20px; height: 20px; }

.grave-photo {
  width: 150px;
  height: 112px;
  margin-bottom: 14px;
}

.grave-photo img { width: 100%; height: 100%; object-fit: cover; }

.text-link { color: #8f2c19; font-weight: 700; }

.form-subhead {
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid #dfbd72;
}

.form-subhead p { margin: -6px 0 0; color: #756044; }

.permission-note {
  margin: 12px 0 0;
  padding: 12px;
  border-left: 3px solid #c17822;
  background: #fff3cf;
  color: #66492d;
  line-height: 1.45;
}

.change-requests-box { padding: 18px; border-top: 1px solid #dfbd72; }

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

.change-requests-head h3 { margin: 0; }

.change-requests-head span {
  color: #7b5939;
  font-size: 14px;
  font-weight: 700;
}

.change-request-list { display: grid; gap: 9px; }

.change-request {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid #ddbf82;
  border-left: 4px solid #be7b21;
  border-radius: 6px;
  background: #fffaf0;
}

.change-request.approved { border-left-color: #168261; }
.change-request.rejected { border-left-color: #b63b2d; }
.change-request > div:first-child { display: grid; gap: 3px; }

.change-request span,
.change-request p {
  margin: 0;
  color: #725c41;
  font-size: 13px;
  line-height: 1.4;
}

.change-preview {
  display: grid;
  grid-template-columns: minmax(86px, auto) minmax(0, 1fr);
  gap: 4px 10px;
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}

.change-preview dt { color: #806849; font-weight: 700; }
.change-preview dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #412719; }

.request-actions { display: flex; gap: 8px; }
.request-actions button { min-height: 38px; padding: 8px 14px; }

.viewer-account-form,
.viewer-account-row { grid-template-columns: minmax(130px, 1fr); }

.viewer-account-form select[name="personId"],
.viewer-account-row select[name="personId"] { min-width: 0; }

@media (max-width: 720px) {
  .grave-photo { width: 120px; height: 90px; }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(255, 244, 181, 0.82), rgba(255, 244, 181, 0.82)),
    var(--family-bg) center top / cover fixed,
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  background: rgba(255, 246, 201, 0.9);
  border-bottom: 1px solid #b47a29;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #9f3f1e, #d79b27);
  color: #fff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn,
.ghost-btn,
.danger-btn,
.text-btn {
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 123, 99, 0.22);
}

.btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.text-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger-btn {
  background: #fff2f0;
  color: #9b2f22;
  border: 1px solid #f0bbb3;
}

.text-btn {
  background: transparent;
  color: var(--green-dark);
}

.workspace {
  position: relative;
  padding: 18px 22px 24px;
  background:
    linear-gradient(rgba(255, 244, 181, 0.42), rgba(255, 244, 181, 0.42)),
    var(--family-bg) center top / min(100%, 1120px) auto no-repeat;
}

.floating-tools {
  position: fixed;
  right: 18px;
  top: 86px;
  z-index: 30;
}

.menu-toggle {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 233, 0.96);
  color: var(--green-dark);
  box-shadow: var(--shadow);
}

.menu-panel {
  position: absolute;
  right: 0;
  top: 54px;
  width: min(340px, calc(100vw - 28px));
  display: none;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  box-shadow: 0 18px 42px rgba(86, 50, 15, 0.22);
}

.floating-tools.open .menu-panel {
  display: block;
}

.menu-section {
  padding: 10px 0;
  border-bottom: 1px solid rgba(215, 170, 81, 0.55);
}

.menu-section:first-child {
  padding-top: 0;
}

.menu-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.menu-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.compact-search {
  min-width: 0;
  width: 100%;
  box-shadow: none;
}

.stats-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stats-menu h3,
.menu-help {
  grid-column: 1 / -1;
}

.stats-menu div:not(:first-child) {
  padding: 8px;
  border: 1px solid rgba(215, 170, 81, 0.55);
  border-radius: 8px;
  background: #fff7cf;
}

.stats-menu strong {
  display: block;
  font-size: 18px;
}

.stats-menu span,
.menu-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.searchbar {
  flex: 1 1 260px;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(255, 252, 233, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(24, 35, 31, 0.06);
}

.search-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.searchbar input {
  width: 100%;
  min-width: 120px;
  border: 0;
  outline: 0;
  background: transparent;
}

.admin-suggestions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.admin-suggestion {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid rgba(198, 146, 57, 0.38);
  border-radius: 8px;
  background: rgba(255, 253, 242, 0.9);
  color: var(--ink);
  text-align: left;
}

.admin-suggestion:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.admin-suggestion strong {
  font-size: 13px;
}

.admin-suggestion span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.admin-search-empty,
.empty-admin-search {
  margin: 8px 0 0;
  font-size: 12px;
}

.viewer-suggestions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.viewer-suggestion {
  display: grid;
  gap: 2px;
  padding: 8px 9px;
  border: 1px solid rgba(198, 146, 57, 0.38);
  border-radius: 8px;
  background: rgba(255, 253, 242, 0.92);
  color: var(--ink);
  text-align: left;
}

.viewer-suggestion:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.viewer-suggestion strong {
  font-size: 13px;
}

.viewer-suggestion span,
.search-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 8px;
}

.tool-action {
  width: 100%;
  min-height: 48px;
}

.kinship-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 35;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255, 225, 153, 0.9);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 248, 205, 0.95), transparent 32%),
    linear-gradient(145deg, #bd4b1f, #7d2416);
  color: #fff8dd;
  box-shadow: 0 16px 34px rgba(75, 33, 14, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.kinship-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(75, 33, 14, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.kinship-fab .icon {
  width: 30px;
  height: 30px;
  stroke-width: 2.3;
}

.kinship-fab span {
  position: absolute;
  right: 74px;
  bottom: 13px;
  width: max-content;
  max-width: 210px;
  padding: 9px 11px;
  border: 1px solid rgba(198, 146, 57, 0.55);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(53, 30, 13, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.kinship-fab:hover span,
.kinship-fab:focus-visible span {
  opacity: 1;
  transform: translateX(0);
}

.kinship-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
}

.kinship-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(43, 25, 12, 0.34);
}

.kinship-panel {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  box-shadow: 0 28px 80px rgba(53, 30, 13, 0.34);
}

.kinship-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(215, 170, 81, 0.55);
}

.kinship-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  color: var(--ink);
}

.kinship-head p,
.kinship-answer span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kinship-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.kinship-result {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(198, 146, 57, 0.38);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff9df, #fff0bd);
}

.kinship-answer {
  display: grid;
  gap: 8px;
}

.kinship-answer p {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.kinship-answer b {
  color: #8a321b;
}

.toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-self: center;
  gap: 8px;
  align-items: center;
}

.segmented,
.zoom-controls {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(255, 252, 233, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button,
.zoom-controls button {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active,
.zoom-controls button.active {
  background: var(--green);
  color: #fff;
}

.icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  padding: 14px;
  background: rgba(255, 252, 233, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat strong {
  display: block;
  font-size: 22px;
}

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

.tree-viewport {
  position: relative;
  height: calc(100vh - 124px);
  min-height: 620px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 246, 188, 0.72), rgba(255, 246, 188, 0.72)),
    var(--family-bg) center center / cover no-repeat,
    #fff2a6;
  border: 3px double #9b6425;
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
  box-shadow: var(--shadow), inset 0 0 0 10px rgba(255, 232, 130, 0.28);
}

.tree-viewport.dragging {
  cursor: grabbing;
}

.tree-canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.tree-lines {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.pan-pad {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 8;
  display: none;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(155, 100, 37, 0.55);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.86);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px rgba(86, 50, 15, 0.18);
}

.pan-pad button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #fff8dc;
  color: var(--green-dark);
  border: 1px solid var(--line);
}

.pan-pad [data-pan="up"] {
  grid-column: 2;
}

.pan-pad [data-pan="left"] {
  grid-column: 1;
  grid-row: 2;
}

.pan-pad [data-pan="right"] {
  grid-column: 3;
  grid-row: 2;
}

.pan-pad [data-pan="down"] {
  grid-column: 2;
  grid-row: 3;
}

.mobile-help {
  display: none;
  margin: -4px 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.9);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.edge,
.edge-halo {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edge-halo {
  stroke: rgba(255, 248, 211, 0.92);
  stroke-width: 7;
}

.edge {
  stroke: #6d8179;
  stroke-width: 2;
}

.spouse-line {
  stroke: var(--coral);
  stroke-width: 3;
  stroke-linecap: round;
}

.person-card {
  position: absolute;
  width: var(--card-w, 218px);
  height: var(--card-h, 128px);
  display: grid;
  grid-template-columns: var(--photo-w, 58px) 1fr;
  gap: 11px;
  align-items: center;
  padding: 10px;
  background: rgba(255, 252, 235, 0.96);
  border: 1px solid #c59542;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  box-shadow: 0 9px 18px rgba(86, 50, 15, 0.14);
  text-align: left;
}

.person-card.female {
  border-left-color: var(--coral);
}

.person-card.other {
  border-left-color: var(--cyan);
}

.person-card.highlight {
  outline: 3px solid rgba(230, 169, 59, 0.55);
}

.person-photo,
.avatar-fallback {
  width: var(--photo-w, 58px);
  height: var(--photo-h, 72px);
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-2);
}

.photo-button {
  width: fit-content;
  height: fit-content;
  display: block;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

.photo-button:hover {
  outline: 3px solid rgba(216, 154, 38, 0.5);
}

.photo-button img {
  display: block;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--green-dark);
  font-size: 22px;
  font-weight: 900;
}

.person-main {
  min-width: 0;
}

.person-name {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gender-symbol {
  display: inline-grid;
  place-items: center;
}

.gender-symbol .icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.gender-symbol.female {
  color: var(--coral);
}

.gender-symbol.male {
  color: var(--green);
}

.gender-symbol.other {
  color: var(--cyan);
}

.person-meta {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  color: #17724f;
  font-size: 12px;
  font-weight: 800;
}

.status-line.deceased,
.mini-badge.deceased,
.chip.deceased {
  color: #8b3529;
}

.status-line.alive,
.mini-badge.alive,
.chip.alive {
  color: #17724f;
}

.status-line .icon {
  width: 14px;
  height: 14px;
}

.achievement-pill {
  display: inline-block;
  max-width: 100%;
  margin-top: 5px;
  padding: 3px 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #fff5d8;
  color: #7b5510;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-panel,
.admin-panel,
.login-panel {
  background: rgba(255, 252, 235, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.viewer-login-screen {
  min-height: calc(100vh - 78px);
}

.viewer-login-panel {
  width: min(440px, calc(100vw - 28px));
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 224px);
}

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

button:disabled {
  cursor: wait;
  opacity: 0.66;
  transform: none !important;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff4bf;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:hover td {
  background: #fff8d8;
}

.table-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 245, 216, 0.9);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.mini-badge .icon {
  width: 14px;
  height: 14px;
}

.detail-drawer {
  position: fixed;
  right: 18px;
  top: 82px;
  bottom: 18px;
  z-index: 50;
  width: min(420px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  background: rgba(255, 252, 235, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(24, 35, 31, 0.22);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-size: 22px;
}

.drawer-body {
  overflow: auto;
  padding: 16px;
}

.profile-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.profile-hero img,
.profile-hero .avatar-fallback {
  width: 92px;
  height: 112px;
}

.profile-hero .photo-button .person-photo {
  width: 92px;
  height: 112px;
}

.info-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 9px 12px;
}

.info-grid dt {
  color: var(--muted);
  font-weight: 700;
}

.info-grid dd {
  margin: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.icon-chip .icon {
  width: 14px;
  height: 14px;
}

.gallery-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.gallery-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}

.gallery-photo {
  aspect-ratio: 1;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8dc;
}

.gallery-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.gallery-photo:hover {
  outline: 3px solid rgba(216, 154, 38, 0.5);
}

.empty-state {
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
}

.admin-panel {
  min-height: calc(100vh - 128px);
  overflow: hidden;
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
}

.panel-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.person-list {
  flex: 0 0 auto;
  height: 330px;
  min-height: 280px;
  overflow: auto;
  padding: 8px;
  scrollbar-gutter: stable;
  border-bottom: 1px solid var(--line);
}

.searchable-person-select {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.select-search {
  position: relative;
  display: block;
  min-width: 0;
}

.select-search .icon {
  position: absolute;
  top: 50%;
  left: 10px;
  z-index: 1;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.select-search .person-select-filter {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px 7px 34px;
  border: 1px solid rgba(151, 91, 34, 0.42);
  border-radius: 8px;
  outline: 0;
  background: rgba(255, 253, 243, 0.95);
  color: var(--ink);
}

.select-search .person-select-filter:focus {
  border-color: #9c4a23;
  box-shadow: 0 0 0 3px rgba(156, 74, 35, 0.12);
}

.searchable-person-select > select {
  width: 100%;
  min-width: 0;
}

.viewer-account-box {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 248, 220, 0.74);
}

.viewer-account-box h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
}

.storage-box {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(198, 146, 57, 0.5);
  border-radius: 8px;
  background: rgba(255, 253, 242, 0.82);
}

.storage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
}

.storage-head span {
  color: var(--muted);
  font-weight: 800;
}

.storage-bar {
  height: 8px;
  margin: 8px 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(198, 146, 57, 0.22);
}

.storage-bar span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #b7791f);
}

.storage-lines {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.storage-lines strong {
  color: var(--ink);
}

.storage-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.viewer-account-form {
  display: grid;
  gap: 8px;
}

.viewer-account-form input,
.viewer-account-form select {
  width: 100%;
  min-height: 36px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf2;
}

.viewer-account-form .btn {
  width: 100%;
}

.viewer-account-list {
  max-height: 170px;
  margin-top: 10px;
  overflow: auto;
}

.viewer-account-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 9px 0;
  border-top: 1px solid rgba(198, 146, 57, 0.38);
}

.viewer-account-row input,
.viewer-account-row select {
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf2;
  font-size: 13px;
}

.account-main {
  display: grid;
  gap: 2px;
}

.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.account-lock {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.viewer-account-row small {
  color: var(--muted);
}

.admin-person-row {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
  padding: 8px;
  background: transparent;
  border-radius: 8px;
  text-align: left;
}

.admin-person-row.active,
.admin-person-row:hover {
  background: var(--panel-2);
}

.mini-avatar {
  width: 40px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel-2);
}

.form-wrap {
  overflow: auto;
  max-height: calc(100vh - 128px);
  padding: 16px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.role-hidden {
  display: none !important;
}

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

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #fffdf2;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.readonly-box {
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8dc;
  color: var(--ink);
  line-height: 1.55;
}

.field select[multiple] {
  min-height: 132px;
}

.form-actions,
.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.login-screen {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 22px;
}

.login-panel h2 {
  margin: 0 0 8px;
}

.notice {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 80;
  max-width: min(480px, calc(100vw - 30px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
}

.photo-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(33, 22, 11, 0.72);
}

.photo-viewer-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff8dc;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.photo-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.photo-viewer-panel img {
  max-width: 100%;
  max-height: calc(92vh - 62px);
  object-fit: contain;
  background: #1f160c;
}

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

  .floating-tools {
    top: 76px;
    right: 10px;
  }

  .toolbar-actions {
    align-self: flex-start;
    flex-wrap: wrap;
  }

  .nav-actions {
    justify-content: flex-start;
  }

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

  .mobile-help {
    display: block;
  }

  .pan-pad {
    display: grid;
  }

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

  .admin-panel {
    min-height: auto;
  }

  .person-list {
    height: 320px;
    min-height: 320px;
  }

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

@media (max-width: 560px) {
  .workspace {
    padding: 10px;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 10px;
  }

  .stat strong {
    font-size: 18px;
  }

  .stat span {
    font-size: 11px;
  }

  .tree-viewport {
    height: calc(100dvh - 118px);
    min-height: 500px;
  }

  .floating-tools {
    top: 66px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .topbar {
    padding: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }
}

/* Visual refresh */
:root {
  --bg: #f8e6a3;
  --panel: #fffaf0;
  --panel-2: #fff1bf;
  --ink: #2b1a10;
  --muted: #765d3e;
  --line: #c69239;
  --green: #0f6f55;
  --green-dark: #5a1f12;
  --coral: #c64035;
  --amber: #c88724;
  --cyan: #287f95;
  --shadow: 0 18px 38px rgba(80, 44, 13, 0.18);
}

body {
  background:
    linear-gradient(180deg, rgba(255, 248, 211, 0.76), rgba(249, 224, 139, 0.74)),
    var(--family-bg) center top / cover fixed,
    #f3d676;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(127, 55, 19, 0.08), transparent 16%, transparent 84%, rgba(127, 55, 19, 0.08)),
    repeating-linear-gradient(0deg, rgba(92, 52, 18, 0.035) 0 1px, transparent 1px 7px);
}

.topbar {
  padding: 12px 22px;
  background: rgba(255, 248, 221, 0.92);
  border-bottom: 2px solid rgba(135, 63, 27, 0.42);
  box-shadow: 0 10px 32px rgba(75, 38, 12, 0.12);
}

.brand-mark {
  border: 1px solid rgba(255, 229, 153, 0.82);
  background:
    linear-gradient(145deg, #7b2416, #b64a20 54%, #d79b27);
  box-shadow:
    inset 0 0 0 2px rgba(255, 238, 183, 0.25),
    0 8px 18px rgba(90, 31, 18, 0.18);
  letter-spacing: 0;
}

.brand h1 {
  color: #321509;
  font-size: 21px;
  font-weight: 900;
}

.brand p {
  color: #7a4820;
  font-weight: 700;
}

.workspace {
  min-height: calc(100vh - 72px);
  padding: 16px 18px 18px;
  background:
    linear-gradient(rgba(255, 239, 166, 0.48), rgba(255, 239, 166, 0.48)),
    var(--family-bg) center 12px / min(100%, 1180px) auto no-repeat;
}

.btn,
.ghost-btn,
.danger-btn,
.text-btn {
  border-radius: 7px;
}

.btn {
  background: linear-gradient(180deg, #9b351b, #762212);
  box-shadow: 0 10px 24px rgba(118, 34, 18, 0.24);
}

.ghost-btn {
  background: rgba(255, 250, 235, 0.92);
  color: #5a1f12;
}

.floating-tools {
  top: 88px;
  right: 18px;
}

.menu-toggle {
  border-color: rgba(122, 58, 22, 0.48);
  background: linear-gradient(180deg, #fff9de, #ffe9a4);
  color: #6b2415;
}

.menu-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(80, 44, 13, 0.24);
}

.menu-panel {
  width: min(360px, calc(100vw - 28px));
  max-height: calc(100vh - 152px);
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(143, 83, 29, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 252, 238, 0.98), rgba(255, 244, 204, 0.98));
  box-shadow: 0 22px 58px rgba(72, 37, 13, 0.26);
}

.menu-section h3 {
  color: #7a3f1d;
  font-size: 11px;
  font-weight: 900;
}

.searchbar,
.field input,
.field select,
.field textarea,
.readonly-box {
  border-color: rgba(151, 91, 34, 0.48);
  background: rgba(255, 253, 243, 0.95);
}

.segmented,
.zoom-controls {
  background: rgba(255, 247, 220, 0.95);
  border-color: rgba(151, 91, 34, 0.45);
}

.segmented button.active,
.zoom-controls button.active {
  background: linear-gradient(180deg, #8a321b, #642012);
}

.stats-menu div:not(:first-child) {
  border-color: rgba(151, 91, 34, 0.4);
  background: linear-gradient(180deg, #fff8d8, #ffefb9);
}

.stats-menu strong {
  color: #6d2413;
  font-weight: 900;
}

.tree-viewport {
  height: calc(100vh - 116px);
  min-height: 640px;
  border: 2px solid rgba(117, 63, 22, 0.72);
  background:
    linear-gradient(rgba(255, 246, 195, 0.68), rgba(255, 241, 169, 0.7)),
    var(--family-bg) center center / cover no-repeat,
    #ffefa0;
  box-shadow:
    0 20px 44px rgba(80, 44, 13, 0.18),
    inset 0 0 0 8px rgba(255, 232, 130, 0.26),
    inset 0 0 0 1px rgba(255, 255, 255, 0.44);
}

.edge {
  stroke: #4f746c;
  stroke-width: 2.2;
}

.spouse-line {
  stroke: #bf4a34;
  stroke-width: 3.2;
}

.person-card {
  background:
    linear-gradient(180deg, rgba(255, 253, 239, 0.98), rgba(255, 244, 205, 0.98));
  border-color: rgba(143, 83, 29, 0.56);
  border-left-width: 6px;
  box-shadow:
    0 12px 22px rgba(74, 42, 13, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.person-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 30px rgba(74, 42, 13, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.person-card.male {
  border-left-color: #12684f;
}

.person-card.female {
  border-left-color: #c64035;
}

.person-card.other {
  border-left-color: #287f95;
}

.person-photo,
.avatar-fallback {
  border: 1px solid rgba(156, 96, 34, 0.26);
  background: linear-gradient(145deg, #fff6d5, #ffe7a4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.avatar-fallback {
  color: #6d2413;
}

.person-name {
  color: #2b1208;
  font-size: 13px;
  font-weight: 900;
}

.person-meta {
  color: #795637;
}

.status-line {
  color: #0f6f55;
}

.status-line.deceased,
.mini-badge.deceased,
.chip.deceased {
  color: #9a2f22;
}

.achievement-pill,
.chip,
.mini-badge {
  background: linear-gradient(180deg, #fff7d9, #ffedb1);
}

.detail-drawer,
.list-panel,
.admin-panel,
.login-panel {
  background:
    linear-gradient(180deg, rgba(255, 253, 243, 0.98), rgba(255, 246, 215, 0.98));
  border-color: rgba(143, 83, 29, 0.5);
  box-shadow: 0 24px 58px rgba(70, 38, 13, 0.24);
}

.detail-drawer {
  width: min(460px, calc(100vw - 32px));
}

.drawer-head {
  background: linear-gradient(180deg, rgba(255, 244, 204, 0.86), rgba(255, 250, 232, 0.72));
}

.drawer-head h2 {
  color: #321509;
  font-size: 24px;
  font-weight: 900;
}

.info-grid {
  grid-template-columns: 132px 1fr;
  gap: 11px 14px;
}

.info-grid dt {
  color: #80603e;
}

.info-grid dd {
  color: #3a1b0d;
  font-weight: 600;
}

.gallery-photo {
  border-color: rgba(151, 91, 34, 0.45);
  box-shadow: 0 8px 16px rgba(80, 44, 13, 0.14);
}

.admin-person-row.active,
.admin-person-row:hover,
tr:hover td {
  background: rgba(255, 238, 177, 0.72);
}

.login-screen {
  background:
    linear-gradient(rgba(255, 239, 172, 0.38), rgba(255, 239, 172, 0.38)),
    var(--family-bg) center center / min(100%, 1180px) auto no-repeat;
}

.login-panel {
  border-width: 2px;
}

.login-panel h2 {
  color: #4d1a0d;
  font-size: 26px;
  font-weight: 900;
}

.toast {
  background: #35180c;
}

@media (max-width: 920px) {
  .floating-tools {
    top: 74px;
  }

  .detail-drawer {
    top: 74px;
    right: 10px;
    bottom: 10px;
    width: min(460px, calc(100vw - 20px));
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .topbar {
    min-height: 52px;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 6px 8px;
  }

  .brand {
    flex: 1 1 auto;
    gap: 7px;
    min-width: 0;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 6px;
    font-size: 14px;
  }

  .brand h1 {
    display: -webkit-box;
    overflow: hidden;
    max-width: 42vw;
    font-size: 15px;
    line-height: 1.12;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .nav-actions {
    flex: 0 0 auto;
    gap: 5px;
    justify-content: flex-end;
  }

  .nav-actions .btn,
  .nav-actions .ghost-btn {
    min-height: 30px;
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1;
  }

  .workspace {
    padding: 8px;
  }

  .tree-viewport {
    height: calc(100dvh - 72px);
    min-height: 520px;
  }

  .pan-pad {
    display: none;
  }

  .floating-tools {
    top: 62px;
    right: 8px;
  }

  .detail-drawer {
    top: 62px;
  }

  .menu-panel {
    max-height: calc(100dvh - 118px);
  }

  .brand p {
    display: none;
  }
}

/* Typography polish */
:root {
  --font-ui: "Be Vietnam Pro", Arial, Helvetica, sans-serif;
  --font-title: "Noto Serif", "Be Vietnam Pro", Georgia, serif;
}

* {
  letter-spacing: 0;
}

body {
  font-family: var(--font-ui);
  font-weight: 400;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: var(--font-ui);
}

.brand h1,
.login-panel h2,
.drawer-head h2,
.form-wrap h2,
.panel-head h2 {
  font-family: var(--font-title);
  font-weight: 700;
  line-height: 1.22;
}

.brand h1 {
  font-size: 22px;
}

.brand p,
.notice,
.person-meta,
.info-grid dt,
.field label,
.menu-section h3,
th {
  font-weight: 600;
}

.brand-mark,
.person-name,
.admin-person-row strong,
.table-name,
.status-line,
.mini-badge,
.chip {
  font-family: var(--font-ui);
}

.person-name {
  font-size: 13px;
  font-weight: 700;
}

.person-meta {
  font-size: 11.5px;
  line-height: 1.45;
}

.btn,
.ghost-btn,
.danger-btn,
.text-btn {
  font-weight: 700;
}

.info-grid dd {
  font-weight: 500;
  line-height: 1.55;
}

.drawer-head h2 {
  font-size: 25px;
}

.login-panel h2 {
  font-size: 27px;
}

@media (max-width: 560px) {
  .brand h1 {
    font-size: 15px;
    line-height: 1.18;
  }

  .login-panel h2 {
    font-size: 22px;
  }
}

@media (max-width: 560px) {
  .kinship-fields {
    grid-template-columns: 1fr;
  }

  .kinship-head {
    align-items: stretch;
    flex-direction: column;
  }

  .kinship-fab {
    right: 14px;
    bottom: 14px;
    width: 54px;
    height: 54px;
  }

  .kinship-fab span {
    display: none;
  }
}

/* Bảng vàng vinh danh */
.view-switch-fab,
.kinship-fab {
  background: linear-gradient(145deg, #b7461f, #6f2015);
}

.view-switch-fab {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 35;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 225, 153, 0.9);
  border-radius: 50%;
  background: linear-gradient(145deg, #17705a, #15493f);
  color: #fff8dd;
  box-shadow: 0 15px 32px rgba(36, 56, 36, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.view-switch-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 19px 38px rgba(36, 56, 36, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.view-switch-fab .icon {
  width: 27px;
  height: 27px;
  stroke-width: 2.2;
}

.view-switch-fab span {
  position: absolute;
  right: 68px;
  bottom: 10px;
  width: max-content;
  max-width: 220px;
  padding: 9px 11px;
  border: 1px solid rgba(198, 146, 57, 0.55);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(53, 30, 13, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.view-switch-fab:hover span,
.view-switch-fab:focus-visible span {
  opacity: 1;
  transform: translateX(0);
}

.honor-board {
  min-height: calc(100vh - 112px);
  margin: -16px -18px -18px;
  padding: 34px clamp(16px, 4vw, 64px) 72px;
  background:
    linear-gradient(90deg, rgba(54, 16, 12, 0.93), rgba(113, 35, 23, 0.84) 32%, rgba(116, 55, 22, 0.8) 68%, rgba(38, 65, 48, 0.9)),
    linear-gradient(rgba(75, 23, 16, 0.52), rgba(48, 42, 22, 0.72)),
    var(--family-bg) center top / cover fixed,
    #5c2117;
  color: #fff9e8;
}

.honor-banner {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 0 28px;
  border-bottom: 1px solid rgba(255, 215, 125, 0.55);
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 18px 22px;
  align-items: center;
}

.honor-banner::before,
.honor-banner::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 229, 155, 0.3);
}

.honor-banner::before {
  top: 0;
}

.honor-banner::after {
  bottom: 4px;
}

.honor-emblem {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 224, 138, 0.75);
  border-radius: 50%;
  color: #ffe09a;
  background: rgba(86, 29, 17, 0.72);
  box-shadow: inset 0 0 0 5px rgba(255, 221, 126, 0.08), 0 14px 30px rgba(23, 9, 6, 0.24);
}

.honor-emblem .icon {
  width: 38px;
  height: 38px;
}

.honor-heading p {
  margin: 0 0 6px;
  color: #f2d49b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.honor-heading h2 {
  margin: 0;
  color: #fff1bd;
  font-family: var(--font-title);
  font-size: clamp(27px, 4vw, 46px);
  line-height: 1.15;
  text-shadow: 0 3px 18px rgba(30, 9, 5, 0.42);
}

.honor-heading > span {
  display: block;
  max-width: 820px;
  margin-top: 8px;
  color: rgba(255, 249, 229, 0.85);
  font-size: 14px;
}

.honor-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid rgba(255, 218, 128, 0.26);
  border-bottom: 1px solid rgba(255, 218, 128, 0.26);
}

.honor-stats div {
  min-width: 0;
  padding: 13px 16px;
  border-right: 1px solid rgba(255, 218, 128, 0.24);
}

.honor-stats div:last-child {
  border-right: 0;
}

.honor-stats strong,
.honor-stats span {
  display: block;
}

.honor-stats strong {
  color: #ffe39d;
  font-family: var(--font-title);
  font-size: 25px;
}

.honor-stats span {
  color: rgba(255, 249, 229, 0.75);
  font-size: 11px;
  font-weight: 700;
}

.honor-toolbar {
  max-width: 1240px;
  margin: 22px auto 18px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(210px, 280px);
  gap: 12px;
  align-items: end;
}

.honor-search {
  width: 100%;
  min-width: 0;
  background: rgba(255, 251, 232, 0.96);
}

.honor-filter-label {
  display: grid;
  gap: 6px;
}

.honor-filter-label span {
  color: #f4dca8;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.honor-filter-label select {
  min-height: 46px;
  width: 100%;
  padding: 9px 34px 9px 11px;
  border: 1px solid rgba(229, 189, 100, 0.72);
  border-radius: 8px;
  background: rgba(255, 251, 232, 0.96);
  color: #432116;
  font-weight: 700;
}

.honor-grid {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.honor-card {
  position: relative;
  min-width: 0;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(219, 173, 74, 0.78);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 239, 0.98), rgba(255, 241, 195, 0.97));
  color: #321b10;
  box-shadow: 0 18px 34px rgba(25, 9, 6, 0.28), inset 0 3px 0 rgba(146, 43, 24, 0.76);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.honor-card:hover,
.honor-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 24px 42px rgba(25, 9, 6, 0.36), inset 0 3px 0 #176b55;
  outline: none;
}

.honor-card-top {
  display: grid;
  grid-template-columns: 34px 76px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
}

.honor-rank {
  align-self: start;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #c88a28;
  border-radius: 50%;
  background: #7d2919;
  color: #ffe9aa;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
}

.honor-card .photo-button {
  width: 76px;
  height: 92px;
  padding: 0;
}

.honor-photo,
.honor-card-top > .avatar-fallback {
  width: 76px;
  height: 92px;
  border-radius: 6px;
  object-fit: cover;
}

.honor-identity {
  min-width: 0;
}

.honor-level {
  display: inline-block;
  margin-bottom: 5px;
  color: #8b321e;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.honor-identity h3 {
  margin: 0;
  overflow-wrap: anywhere;
  color: #2f160c;
  font-family: var(--font-title);
  font-size: 18px;
  line-height: 1.25;
}

.honor-identity p {
  margin: 6px 0 0;
  color: #7a6044;
  font-size: 12px;
}

.honor-details {
  margin: 14px 0 0;
  padding-top: 11px;
  border-top: 1px solid rgba(174, 119, 42, 0.28);
  display: grid;
  gap: 6px;
}

.honor-details div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px;
}

.honor-details dt {
  color: #806443;
  font-size: 11px;
  font-weight: 700;
}

.honor-details dd {
  margin: 0;
  color: #432116;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.honor-achievements {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(174, 119, 42, 0.28);
  display: grid;
  gap: 5px;
}

.honor-achievements strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #7f2b1b;
  font-size: 11px;
  text-transform: uppercase;
}

.honor-achievements .icon {
  width: 14px;
  height: 14px;
}

.honor-achievements span,
.honor-achievements small {
  color: #59422c;
  font-size: 12px;
  line-height: 1.45;
}

.honor-achievements span::before {
  content: "•";
  margin-right: 7px;
  color: #b54a22;
}

.honor-note {
  margin: 11px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(174, 119, 42, 0.28);
  color: #6c5438;
  font-size: 12px;
  line-height: 1.5;
}

.honor-empty {
  grid-column: 1 / -1;
  padding: 56px 20px;
  border-top: 1px solid rgba(255, 221, 139, 0.36);
  border-bottom: 1px solid rgba(255, 221, 139, 0.36);
  text-align: center;
  color: rgba(255, 249, 229, 0.82);
}

.honor-empty .icon {
  width: 42px;
  height: 42px;
  color: #ffe09a;
}

.honor-empty h3 {
  margin: 10px 0 4px;
  font-family: var(--font-title);
  color: #fff0bb;
}

.honor-empty p {
  margin: 0;
}

.login-warning {
  padding: 9px 10px;
  border-left: 3px solid #b54828;
  background: rgba(255, 235, 201, 0.8);
}

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

@media (max-width: 640px) {
  .honor-board {
    min-height: calc(100dvh - 62px);
    margin: -8px;
    padding: 22px 12px 90px;
    background-attachment: scroll;
  }

  .honor-banner {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 12px;
    padding-bottom: 20px;
  }

  .honor-emblem {
    width: 54px;
    height: 54px;
  }

  .honor-emblem .icon {
    width: 29px;
    height: 29px;
  }

  .honor-heading h2 {
    font-size: 25px;
  }

  .honor-heading > span {
    grid-column: 1 / -1;
    font-size: 12px;
  }

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

  .honor-stats div:nth-child(2) {
    border-right: 0;
  }

  .honor-stats div:nth-child(-n + 2) {
    border-bottom: 1px solid rgba(255, 218, 128, 0.24);
  }

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

  .honor-card {
    padding: 13px;
  }

  .honor-card-top {
    grid-template-columns: 30px 66px minmax(0, 1fr);
    gap: 9px;
  }

  .honor-card .photo-button,
  .honor-photo,
  .honor-card-top > .avatar-fallback {
    width: 66px;
    height: 82px;
  }

  .honor-identity h3 {
    font-size: 16px;
  }

  .view-switch-fab {
    right: 14px;
    bottom: 78px;
    width: 52px;
    height: 52px;
  }

  .view-switch-fab span {
    display: none;
  }
}

/* Integrated person picker and compact mobile layout */
.searchable-person-select {
  position: relative;
  display: block;
  min-width: 0;
}

.searchable-person-select > select {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

.person-combobox {
  position: relative;
  min-width: 0;
}

.person-combobox > .icon {
  position: absolute;
  top: 12px;
  left: 11px;
  z-index: 2;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.person-combobox input.person-select-input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px 9px 42px;
  border: 1px solid rgba(151, 91, 34, 0.48);
  border-radius: 8px;
  outline: 0;
  background: rgba(255, 253, 243, 0.98);
  color: var(--ink);
}

.person-combobox input.person-select-input:focus {
  border-color: #9c4a23;
  box-shadow: 0 0 0 3px rgba(156, 74, 35, 0.12);
}

.person-combobox input.person-select-input:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.person-select-results {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  z-index: 80;
  max-height: 230px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid rgba(151, 91, 34, 0.5);
  border-radius: 8px;
  background: #fffdf3;
  box-shadow: 0 14px 30px rgba(70, 38, 13, 0.22);
}

.person-select-results[hidden] {
  display: none;
}

.person-select-results button {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.person-select-results button:hover,
.person-select-results button.active,
.person-select-results button.keyboard-active {
  background: #ffedb4;
}

.person-select-results p {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.compact-personal-kinship {
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid #d9a441;
  border-left: 3px solid #9f2f1b;
  border-radius: 6px;
  background: #fff4c9;
  color: #5e2818;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
    font-size: 13px;
  }

  .topbar {
    min-height: 54px;
    gap: 6px;
    padding: 6px 8px;
  }

  .brand {
    min-width: 0;
    gap: 7px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    font-size: 13px;
  }

  .brand h1 {
    max-width: 46vw;
    overflow: hidden;
    font-size: 16px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand p {
    max-width: 46vw;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-actions {
    flex: 0 0 auto;
    gap: 5px;
  }

  .nav-actions a[href="/"],
  .nav-actions a[href="./"] {
    display: none;
  }

  .nav-actions .btn,
  .nav-actions .ghost-btn {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  .workspace {
    padding: 6px;
  }

  .detail-drawer {
    top: 56px;
    right: 0;
    bottom: 0;
    width: 100vw;
    border-radius: 0;
  }

  .drawer-head {
    gap: 8px;
    padding: 10px 12px;
  }

  .drawer-head h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
  }

  .drawer-head .notice {
    margin-top: 4px;
    font-size: 12px;
  }

  .drawer-head .ghost-btn {
    min-height: 38px;
    padding: 7px 10px;
  }

  .drawer-body {
    padding: 10px 12px 24px;
  }

  .compact-personal-kinship {
    margin-bottom: 10px;
    padding: 7px 9px;
    font-size: 12px;
  }

  .profile-hero {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
  }

  .profile-hero > button:first-child,
  .profile-hero > .profile-photo {
    width: 82px;
    height: 106px;
  }

  .chips {
    gap: 5px;
    margin-top: 3px;
  }

  .chip {
    padding: 5px 7px;
    font-size: 11px;
  }

  .info-grid {
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 7px 10px;
    margin-top: 14px;
  }

  .info-grid dt,
  .info-grid dd {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .admin-layout {
    gap: 8px;
  }

  .panel-head,
  .form-wrap,
  .viewer-account-box,
  .change-requests-box {
    padding: 11px;
  }

  .person-list {
    height: 280px;
    min-height: 280px;
  }

  .form-wrap {
    max-height: none;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 11px;
  }

  .field.full {
    grid-column: auto;
  }

  .field input,
  .field select,
  .field textarea,
  .person-select-input {
    min-height: 40px;
  }

  .person-select-results {
    max-height: 220px;
  }

  .kinship-panel {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 12px;
  }

  .kinship-head {
    gap: 8px;
  }

  .kinship-head h2 {
    font-size: 20px;
  }

  .kinship-head p {
    font-size: 11px;
  }

  .kinship-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
}
