:root {
  --bg: #0c1118;
  --bg-raised: #151b24;
  --bg-hover: #1c2430;
  --line: #2a3340;
  --text: #e8edf4;
  --muted: #93a0b3;
  --gold: #d4af37;
  --gold-dim: #8a7020;
  --ok: #3dd68c;
  --bad: #f07178;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --chrome: #080c11;
  --chrome-line: #2a2416;
  --gold-wash: #2a230e;
  --row-even: #121820;
  --row-odd: #0e141c;
  --row-selected: #2a2416;
  --head: #10161e;
  --accent-bg: #1a1608;
  --ok-bg: #10261c;
  --ok-line: #1f5c40;
  --bad-bg: #2a1416;
  --bad-line: #6b2a30;
  --name: #f4f7fb;
  --login-spot: #2a230e;
  --login-base: #0c1118;
  font-family: "Segoe UI", "Be Vietnam Pro", "Noto Sans", sans-serif;
}

html[data-theme="light"] {
  --bg: #f3efe6;
  --bg-raised: #fffdf8;
  --bg-hover: #efe6d4;
  --line: #d8d0c2;
  --text: #1c1914;
  --muted: #6b6356;
  --gold: #9a7b1e;
  --gold-dim: #b8922c;
  --ok: #1a7f4b;
  --bad: #b4232c;
  --shadow: 0 12px 32px rgba(40, 30, 10, 0.12);
  --chrome: #f6f1e6;
  --chrome-line: #e6d9b4;
  --gold-wash: #f4e6bc;
  --row-even: #fffdf8;
  --row-odd: #f6f0e4;
  --row-selected: #efe3c0;
  --head: #efe8d6;
  --accent-bg: #f3e8c8;
  --ok-bg: #e5f4ea;
  --ok-line: #7cbc90;
  --bad-bg: #f8e6e6;
  --bad-line: #d48a8e;
  --name: #1c1914;
  --login-spot: #f0e2b8;
  --login-base: #f3efe6;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100%;
}

.app-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 0;
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-line);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  color: var(--gold);
  font-weight: 650;
  font-size: 14px;
}

.app-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--gold-wash);
  border: 1px solid var(--gold-dim);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.login-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  place-items: center;
  background:
    radial-gradient(circle at top, var(--login-spot) 0%, transparent 42%),
    var(--login-base);
}

.login-gate.is-open {
  display: grid;
}

#license-gate {
  z-index: 45;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  padding: 28px 26px;
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
}

.login-hint {
  font-size: 12px;
}

.login-error {
  margin: 0;
  color: var(--bad);
  font-size: 13px;
}

.login-error:empty {
  display: none;
}

.license-card {
  width: min(520px, calc(100vw - 32px));
}

.license-mid-row {
  display: flex;
  gap: 8px;
}

.license-mid-row input {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0.04em;
}

.license-card textarea {
  resize: vertical;
  min-height: 88px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.license-meta {
  color: var(--gold);
  font-size: 12px;
  white-space: nowrap;
}

.login-card label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.login-card input[type="text"],
.login-card input[type="password"],
.login-card textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus,
.login-card textarea:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.login-card .login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.login-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.login-remember-hint {
  font-size: 11px;
  line-height: 1.4;
}

.whoami {
  color: var(--muted);
  font-size: 12px;
}

.pill-btn,
.linkish,
.age-btn {
  font: inherit;
  cursor: pointer;
}

.linkish {
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  text-decoration: underline;
}

.age-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  padding: 16px;
}

.age-btn {
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.age-btn:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.app-mod {
  padding: 7px 14px 9px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.app-mod.is-active {
  background: var(--row-even);
  border-color: var(--chrome-line);
  color: var(--gold);
}

.app-bar .status {
  margin-left: 8px;
}

.app-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.notify-wrap {
  position: relative;
}

.notify-bell {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
}

.notify-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.notify-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: min(380px, calc(100vw - 24px));
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}

.notify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg-raised);
}

.notify-list {
  display: grid;
}

.notify-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.notify-item:hover {
  background: var(--bg-hover);
}

.notify-item.is-unread {
  background: var(--gold-wash);
}

.notify-item small {
  color: var(--muted);
}

.invite-html {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  max-height: 360px;
  overflow: auto;
}

.pay-qr {
  max-width: 220px;
  max-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 13px;
}

.ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 8px 12px 6px;
  background: var(--row-even);
  border-bottom: 1px solid var(--gold-dim);
}

.ribbon-group {
  display: flex;
  flex-direction: column;
  padding: 0 14px 4px;
  border-right: 1px solid var(--line);
}

.ribbon-items {
  display: flex;
  gap: 4px;
}

.ribbon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 76px;
  padding: 8px 10px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ribbon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.ribbon-btn.is-active {
  background: var(--accent-bg);
  border-color: var(--gold-dim);
  color: var(--gold);
}

.ribbon-ico {
  font-size: 18px;
  line-height: 1;
}

.ribbon-label {
  margin-top: 4px;
  color: var(--gold-dim);
  font-size: 11px;
  text-align: center;
}

.ribbon-side {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-left: auto;
  padding: 4px 0 2px;
}

.ribbon-url {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}

.ribbon-url input {
  width: 220px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.work-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 0;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}

.work-tab {
  padding: 7px 14px 8px;
  border: 1px solid var(--gold-dim);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--gold-wash);
  color: var(--gold);
  font-size: 13px;
}

button,
input {
  font: inherit;
}

.btn {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
}

.btn:hover {
  border-color: var(--gold-dim);
}

.btn-primary {
  background: var(--gold-wash);
  border-color: var(--gold-dim);
  color: var(--gold);
}

.status {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.status.is-ok {
  border-color: var(--ok-line);
  color: var(--ok);
  background: var(--ok-bg);
}

.status.is-bad {
  border-color: var(--bad-line);
  color: var(--bad);
  background: var(--bad-bg);
}

.main {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 20px;
}

.card {
  max-width: 880px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.tag {
  display: inline-block;
  margin-top: 14px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gold-wash);
  color: var(--gold);
  font-size: 12px;
}

select,
textarea {
  font: inherit;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 16px;
}

.result-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.result-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.result-item strong {
  font-size: 16px;
}

.result-banner {
  padding: 16px 16px 0;
}

.result-banner p {
  margin: 0;
  font-size: 18px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
  border-color: var(--gold-dim);
}

.tab.is-active {
  background: var(--accent-bg);
  border-color: var(--gold-dim);
  color: var(--gold);
}

.md-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.35fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar input,
.toolbar select {
  min-width: 180px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.toolbar input.short,
.toolbar select.short {
  min-width: 120px;
}

.result-item.is-hung,
.han-list li.is-hung,
.result-banner.is-hung {
  border-color: var(--bad-line);
}

.result-item.is-cat,
.han-list li.is-cat,
.result-banner.is-cat {
  border-color: var(--ok-line);
}

.result-item.is-binh {
  border-color: var(--gold-dim);
}

.result-banner.is-hung {
  padding-bottom: 16px;
  background: var(--bad-bg);
}

.result-banner.is-cat {
  padding-bottom: 16px;
  background: var(--ok-bg);
}

.han-list {
  list-style: none;
  margin: 0;
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.han-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.han-list li span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.fengshui-note {
  padding: 0 16px 14px;
  font-size: 13px;
}

.btn-danger {
  border-color: var(--bad-line);
  color: var(--bad);
  background: var(--bad-bg);
}

.btn-ghost {
  background: transparent;
}

.table-wrap {
  overflow: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

table.data td.cell-snip {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.data th {
  color: var(--muted);
  font-weight: 600;
  background: var(--head);
  position: sticky;
  top: 0;
}

table.data tbody tr {
  cursor: pointer;
}

table.data tbody tr:hover {
  background: var(--bg-hover);
}

table.data tbody tr.is-selected {
  background: var(--accent-bg);
  box-shadow: inset 3px 0 0 var(--gold);
}

.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.row-actions .btn {
  padding: 4px 8px;
  font-size: 12px;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.detail-meta {
  padding: 14px 16px 0;
}

.detail-meta p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.detail-meta strong {
  color: var(--text);
}

dialog.modal {
  width: min(520px, calc(100vw - 32px));
}

dialog.modal.modal-wide {
  width: min(860px, calc(100vw - 32px));
}

dialog.modal.modal-float {
  resize: both;
  overflow: auto;
  width: min(920px, 94vw);
  min-width: 420px;
  min-height: 280px;
  max-width: none;
  height: min(820px, 92vh);
}

dialog.modal.modal-float.is-max {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  min-width: 0;
  min-height: 0;
  inset: 0;
  margin: 0;
  border-radius: 0;
  resize: none;
}

dialog.modal.modal-float.is-max .print-layout,
dialog.modal.modal-float.is-max .form {
  min-height: calc(100vh - 72px);
}

dialog.modal.modal-float.is-max .rte-shell {
  min-height: calc(100vh - 420px);
}

.modal-max {
  font-size: 16px;
  line-height: 1;
}

.tra-edit {
  margin-bottom: 12px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 0;
  position: sticky;
  top: 0;
  background: var(--bg-raised);
  z-index: 2;
}

.modal-head h3 {
  margin: 0;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.family-checks {
  max-height: 160px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text);
  font-size: 13px;
}

.word-modal {
  width: min(1080px, 96vw);
}

.print-layout {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  min-height: 360px;
}

.print-picker {
  padding: 10px 12px 16px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.print-picker-title {
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 650;
}

.print-hint {
  margin: 10px 0 0;
  font-size: 12px;
}

.word-stage {
  padding: 12px 16px 20px;
  background: #5c5852;
  min-height: 360px;
}

html[data-theme="light"] .word-stage {
  background: #c8c2b6;
}

.word-paper {
  max-width: 720px;
  min-height: 480px;
  margin: 0 auto;
  padding: 36px 42px 48px;
  background: #fff;
  color: #111;
  font-family: "Times New Roman", Times, serif;
  font-size: 15px;
  line-height: 1.65;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.word-paper h1 {
  text-align: center;
  font-size: 26px;
  margin: 0 0 16px;
}

.word-meta {
  color: #444;
  margin-bottom: 18px;
}

.word-paper img {
  max-width: 100%;
}

.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border: 0;
}

.theme-picker {
  padding: 16px;
}

.theme-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.theme-card {
  width: 200px;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.theme-card.is-active,
.theme-card:hover {
  border-color: var(--gold);
}

.theme-swatch {
  height: 48px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.theme-swatch-dark {
  background: linear-gradient(135deg, #0c1118, #2a2416);
}

.theme-swatch-light {
  background: linear-gradient(135deg, #fffdf8, #efe6d4);
}

fieldset.fs-card {
  margin: 0;
  min-width: 0;
}

fieldset.fs-card legend {
  padding: 0 6px;
  color: var(--gold);
}

dialog.modal {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.form {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.form h3 {
  margin: 0 0 4px;
}

.form label,
.form .field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.form input,
.form select,
.form textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.form textarea {
  min-height: 72px;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: var(--shadow);
}

.toast.is-ok {
  border-color: var(--ok-line);
}

.toast.is-bad {
  border-color: var(--bad-line);
  color: var(--bad);
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill-nam {
  border-color: #2a5a8a;
  color: #8ec8ff;
  background: #102033;
}

.pill-nu {
  border-color: #8a4a2a;
  color: #ffb48e;
  background: #2a1810;
}

.pill-year {
  border-color: #8a5a20;
  color: #ffb84a;
  background: #2a1c0a;
}

.pill-hung {
  border-color: #8a3038;
  color: #ff9aa2;
  background: var(--bad-bg);
}

.pill-cat {
  border-color: var(--ok-line);
  color: #7ee2b0;
  background: var(--ok-bg);
}

.pill-binh {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: var(--accent-bg);
}

.cell-mang {
  color: #9ec9ff;
}

.cell-ky {
  color: var(--muted);
  font-size: 12px;
}

.fs-hero {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.fs-hero.is-hung {
  background: linear-gradient(180deg, #2a1416, transparent);
}

.fs-hero.is-cat {
  background: linear-gradient(180deg, #10261c, transparent);
}

.fs-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fs-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.35;
}

.fs-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 16px;
}

.fs-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.fs-card h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.fs-card.is-ok {
  border-color: var(--ok-line);
}

.fs-card.is-bad {
  border-color: var(--bad-line);
}

.fs-dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.fs-dl div {
  display: grid;
  gap: 2px;
}

.fs-dl dt {
  color: var(--muted);
  font-size: 12px;
}

.fs-dl dd {
  margin: 0;
  line-height: 1.5;
}

.rel-ok {
  color: var(--ok);
}

.rel-bad {
  color: var(--bad);
}

.bang-note {
  padding: 12px 16px 0;
}

.catalog-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 180px);
}

.grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
}

.grid-search {
  flex: 1 1 220px;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.grid-jump {
  width: 110px;
  padding: 8px 10px;
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  background: var(--accent-bg);
  color: var(--gold);
}

.grid-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.grid-selbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.bang-layout {
  display: block;
  min-height: 0;
  flex: 1;
}

.bang-layout.is-open {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.9fr);
}

.detail-head {
  display: flex;
  justify-content: flex-end;
  margin: -2px -2px 8px 0;
}

.detail-x {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.detail-x:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.bang-layout .table-wrap {
  max-height: calc(100vh - 260px);
  border-right: 1px solid var(--line);
}

.grid-table {
  font-size: 13px;
}

.grid-table th,
.grid-table td {
  padding: 8px 8px;
  white-space: nowrap;
}

.grid-table .col-check {
  width: 36px;
  text-align: center;
}

.grid-table .col-actions {
  text-align: right;
}

.grid-table tbody tr:nth-child(even) {
  background: var(--row-even);
}

.grid-table tbody tr:nth-child(odd) {
  background: var(--row-odd);
}

.grid-table tbody tr:hover {
  background: var(--bg-hover);
}

.grid-table tbody tr.is-selected {
  background: var(--row-selected);
  box-shadow: inset 3px 0 0 var(--gold);
}

.grid-name {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

.age-cell {
  min-width: 44px;
  padding: 0;
  text-align: center;
}

.age-pick {
  width: 100%;
  padding: 7px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.age-pick:hover,
.age-pick.is-picked {
  color: var(--gold);
  background: var(--accent-bg);
}

.row-act {
  display: inline-flex;
  gap: 10px;
  justify-content: flex-end;
}

.row-act button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.row-act .act-edit:hover {
  color: var(--text);
}

.row-act .act-copy {
  color: #7ee2b0;
}

.row-act .act-del {
  color: var(--bad);
}

.bang-detail {
  padding: 14px 16px 20px;
  overflow: auto;
  max-height: calc(100vh - 260px);
  background: var(--head);
}

.bang-detail h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.bang-detail .fs-split {
  padding: 0;
  margin-top: 12px;
}

.detail-ages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
}

.detail-ages button {
  min-width: 40px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.detail-ages button.is-picked,
.detail-ages button:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

@media (max-width: 1100px) {
  .bang-layout {
    grid-template-columns: 1fr;
  }

  .bang-layout .table-wrap,
  .bang-detail {
    max-height: none;
    border-right: 0;
  }
}

@media (max-width: 900px) {
  .fs-split {
    grid-template-columns: 1fr;
  }

  .ribbon-side {
    width: 100%;
    margin-left: 0;
    padding-top: 8px;
  }
}

@media (max-width: 900px) {
  .print-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .md-layout {
    grid-template-columns: 1fr;
  }

  .family-split {
    grid-template-columns: 1fr;
  }
}

.family-workspace {
  gap: 12px;
}

.family-master-wrap {
  max-height: min(42vh, 420px);
}

.family-table {
  font-size: 14px;
}

.family-table tbody tr:nth-child(even) {
  background: var(--row-even);
}

.family-table tbody tr:nth-child(odd) {
  background: var(--row-odd);
}

.family-table tbody tr.is-selected {
  background: var(--row-selected);
}

.subtabs {
  display: flex;
  gap: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
}

.subtabs .tab {
  border-radius: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
}

.subtabs .tab.is-active {
  background: var(--bg-hover);
  border-bottom-color: var(--gold);
  color: var(--text);
}

.family-split {
  display: block;
  min-height: 0;
}

.family-split:not(.is-open) .person-detail {
  display: none;
}

.family-split.is-open {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.85fr);
  min-height: 280px;
}

.family-split .table-wrap {
  max-height: min(46vh, 520px);
}

.family-table th,
.family-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.person-detail {
  max-height: min(46vh, 520px);
}

.person-detail .fs-split,
.person-detail .result-grid,
.person-detail .han-list,
.person-detail .fs-hero {
  padding-left: 0;
  padding-right: 0;
}

.name-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--name);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
}

.name-link:hover {
  color: var(--gold);
  text-decoration: underline;
}

.cell-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--name);
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px !important;
}
