:root {
  --ink: #17211c;
  --muted: #5d6b63;
  --line: #d9d2c5;
  --paper: #f4efe6;
  --surface: #fffdf8;
  --pine: #1b4332;
  --pine-2: #245c44;
  --gold: #9a7b2f;
  --gold-soft: #efe3c4;
  --danger: #8f2d2d;
  --ok: #1f6b45;
  --warn: #8a6a1a;
  --info: #2c5d73;
  --shadow: 0 12px 32px rgba(23, 33, 28, 0.08);
  --radius: 18px;
  --sidebar: 280px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--pine);
  color: #fff;
  cursor: pointer;
  min-height: 42px;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--pine-2); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #efe8da; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #7f6423; }
.btn-danger { background: var(--danger); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span, .label { color: var(--muted); font-size: 13px; }
.field input, .field select, .field textarea, .input {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
}
.field input:focus, .field select:focus, .input:focus {
  outline: 2px solid #c8e2d2;
  border-color: var(--pine);
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 12% 20%, rgba(154, 123, 47, .16), transparent 28%),
    radial-gradient(circle at 90% 80%, rgba(27, 67, 50, .16), transparent 30%),
    var(--paper);
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 8px 0 6px; font-size: 28px; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.login-mark {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--pine); color: #fff; font-size: 26px; font-weight: 700;
}
.login-card form { display: grid; gap: 14px; }
.error-banner {
  background: #f8e6e6; color: var(--danger);
  border-radius: 12px; padding: 10px 12px; font-size: 14px;
  margin-bottom: 10px; overflow-wrap: anywhere;
}
.success-banner {
  background: #e5f4eb; color: var(--ok);
  border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px;
}

/* Metro */
.metro-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 60px; }
.metro-top, .workspace-top, .metro-user, .page-head, .filter-bar, .toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.eyebrow { margin: 0; color: var(--gold); font-size: 13px; letter-spacing: .08em; }
.metro-top h1, .workspace-top h1 { margin: 6px 0 0; font-size: 32px; }
.metro-user { align-items: center; }
.metro-user span, .who span { display: block; color: var(--muted); font-size: 13px; }
.metro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}
.tile {
  display: block;
  min-height: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.tile:hover { transform: translateY(-3px); border-color: #c9b27a; }
.tile-icon {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center; background: var(--gold-soft); color: var(--pine);
}
.tile-icon svg { width: 28px; height: 28px; }
.tile h2 { margin: 22px 0 6px; font-size: 28px; }
.tile p { margin: 0; color: var(--muted); }
.tile b { display: block; margin-top: 22px; font-size: 34px; color: var(--pine); }

/* App chrome */
.app-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: #12261c;
  color: #f4efe6;
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 22px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--gold); color: #12261c;
  display: grid; place-items: center; font-weight: 700;
}
.brand small { display: block; color: #c9d4cd; font-size: 12px; }
.side-nav { display: grid; gap: 6px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 12px; color: #e8efe9;
}
.side-nav a svg { width: 20px; height: 20px; }
.side-nav a.active, .side-nav a:hover { background: rgba(255,255,255,.08); }
.side-nav a.active { background: #1b4332; }
.side-foot { margin-top: auto; display: grid; gap: 12px; }
.workspace { min-width: 0; }
.workspace-top { padding: 22px 28px 0; }
.workspace-main { padding: 8px 28px 40px; }
.nav-toggle { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }
.page-head { margin: 8px 0 16px; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  min-width: 110px;
}
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }

.filter-bar, .add-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.add-form { grid-template-columns: 1.1fr 1.1fr 1.3fr auto auto; align-items: end; }
.search-wide { grid-column: span 2; }

.table-wrap { overflow: auto; border-radius: 16px; }
table.data { width: 100%; border-collapse: collapse; min-width: 980px; }
table.data th, table.data td { padding: 12px 10px; text-align: right; border-bottom: 1px solid #eee6d8; }
table.data th { font-size: 13px; color: var(--muted); background: #faf6ee; position: sticky; top: 0; }
table.data tr:hover td { background: #fbf7ef; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--pine);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--gold-soft); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600;
}
.badge svg { width: 14px; height: 14px; }
.badge-ok { background: #e5f4eb; color: var(--ok); }
.badge-warn { background: #fff4d6; color: var(--warn); }
.badge-miss { background: #f8e6e6; color: var(--danger); }

.dropzone {
  border: 1px dashed #c9b27a;
  background: #fbf7ee;
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  cursor: pointer;
}
.dropzone input { display: none; }
.mrz-state { font-size: 12px; }
.mrz-ok { color: var(--ok); }
.mrz-bad { color: var(--danger); }

.toast-root { position: fixed; inset-inline-end: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 40; }
.toast {
  background: #12261c; color: #fff; padding: 12px 14px; border-radius: 12px;
  min-width: 240px; box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); }

.modal-back {
  position: fixed; inset: 0; background: rgba(18, 38, 28, .45);
  display: grid; place-items: center; z-index: 30; padding: 20px;
}
.modal {
  width: min(820px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  max-height: 90vh;
  overflow: auto;
}
.modal img { width: 100%; border-radius: 12px; background: #eee; }
.progress {
  height: 10px; background: #eee6d8; border-radius: 999px; overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--pine); width: 0; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 14px; cursor: pointer;
}
.tab.active { background: var(--pine); color: #fff; border-color: var(--pine); }

.stack { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.muted { color: var(--muted); }
.route { font-weight: 700; color: var(--pine); }
.leg {
  display: grid; grid-template-columns: 40px 1fr; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid #efe8da;
}
.leg-seq {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--pine); font-weight: 700;
}
.trip-card .leg { grid-template-columns: 40px 1fr auto; align-items: center; }
.hidden, [hidden] { display: none !important; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 0; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; direction: ltr; text-align: right; }
.icon-btn[disabled] { opacity: .35; cursor: not-allowed; }
.icon-btn.has-file { border-color: var(--pine); background: #eef5f0; }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn.can-add { border-style: dashed; color: var(--gold); }
.icon-btn.icon-danger { color: var(--danger); }
.icon-btn.icon-danger:hover { background: #f8e6e6; }
.col-check { width: 36px; text-align: center !important; }
.col-check input { width: 16px; height: 16px; accent-color: var(--pine); }
.owner-cell small { display: block; }
.bulk-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px; background: var(--gold-soft); border-color: #d9c48f;
}
tr.row-cancelled td { color: #7a6d6d; }
.upload-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.table-search { max-width: 360px; }
.table-tools { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.table-tools .table-search { flex: 1 1 260px; }
.visa-tag { display: block; font-size: 11px; color: var(--ok); margin-top: 2px; }
.visa-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 14px; }
.visa-info > span:first-child { color: var(--muted); }
.visa-view { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.visa-preview { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f7f4ee; min-height: 120px; display: grid; place-items: center; }
.visa-preview img { max-width: 100%; max-height: 420px; display: block; }
.visa-preview .muted { padding: 30px; }
.visa-frame { width: 100%; height: 420px; border: 0; display: block; background: #fff; }
.visa-qr { margin: 0; display: grid; gap: 8px; justify-items: center; width: 150px; }
.visa-qr img { width: 150px; height: 150px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
@media (max-width: 720px) { .visa-view { grid-template-columns: 1fr; } }
.modal-wide { width: min(760px, 100%); }
.modal-image { width: min(460px, 100%); padding: 16px; }
.modal-image h2 { font-size: 18px; margin: 0 0 10px; }
.img-preview {
  display: grid; place-items: center; min-height: 120px;
  background: #f4efe4; border-radius: 12px; padding: 8px;
}
.modal .img-preview img {
  width: auto; max-width: 100%; max-height: 42vh;
  object-fit: contain; border-radius: 8px; background: transparent;
}
.modal .img-photo img { max-height: 280px; }
.modal-image .upload-box { margin-top: 12px; padding-top: 12px; gap: 10px; }
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-top: 1px solid #eee6d8; font-size: 13px;
}
.pg-info { color: var(--muted); }
.pg-nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pg {
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font: inherit; color: var(--ink, #12261c);
}
.pg:hover:not([disabled]) { background: var(--gold-soft); }
.pg.active { background: var(--pine); color: #fff; border-color: var(--pine); }
.pg[disabled] { opacity: .4; cursor: default; }
.pg-gap { padding: 0 4px; color: var(--muted); }
.pg-size { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.pg-size select { padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; }
.process-panel { padding: 14px 18px; margin-bottom: 16px; display: grid; gap: 10px; }
.process-head, .process-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.progress { height: 8px; border-radius: 99px; background: #eee6d8; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--pine); transition: width .3s; }
.process-panel.paused .progress span { background: var(--warn); }
.log-filters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.log-desc { max-width: 420px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.json-box {
  direction: ltr; text-align: left; background: #12261c; color: #e8efe9; border-radius: 10px;
  padding: 12px; font: 12px/1.5 ui-monospace, Consolas, monospace; max-height: 280px; overflow: auto; white-space: pre-wrap;
}
.badge-ok.sm, .badge-miss.sm { font-size: 11px; padding: 2px 8px; }
.exists-hint { color: var(--danger); font-size: 12px; min-height: 1em; }
.add-owner { grid-column: span 2; }
.split { display: grid; grid-template-columns: minmax(300px, 1fr) 2fr; gap: 16px; align-items: start; }
table.data.compact { min-width: 640px; }
tr.row-active td { background: var(--gold-soft); }
.room-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.setup-list { display: grid; gap: 8px; margin: 14px 0; padding: 0; list-style: none; }
.setup-list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.setup-list .ok { color: var(--ok); font-weight: 600; }
.setup-list .bad { color: var(--danger); font-weight: 600; }
.login-card code { direction: ltr; display: inline-block; }

/* Statistics: top-3 cards on the pilgrims page */
.insights { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 14px; }
.insight { padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: none; }
.insight-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.insight-head strong { font-size: 14px; }
.insight-head .muted, .insight-foot { font-size: 12px; }
.insight-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; }
.insight-item {
  position: relative; width: 100%; display: flex; justify-content: space-between; gap: 8px; align-items: center;
  border: 1px solid #eee6d8; background: #fff; border-radius: 10px; padding: 7px 10px; cursor: pointer; overflow: hidden; text-align: right;
}
.insight-item:disabled { cursor: default; color: var(--muted); }
.insight-item:not(:disabled):hover { border-color: var(--gold); }
.insight-item .lbl { position: relative; z-index: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.insight-item b { position: relative; z-index: 1; font-size: 14px; color: var(--pine); }
.insight-item i { position: absolute; inset: 0 0 0 auto; background: var(--gold-soft); opacity: .65; border-radius: 10px 0 0 10px; }
.insight-empty { font-size: 13px; }
.insight-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.insight-foot a { color: var(--pine-2); font-weight: 600; }
.insight-link { align-items: center; justify-content: center; text-align: center; color: var(--pine); font-weight: 600; background: #f6f1e4; border-style: dashed; }
.insight-link svg { width: 30px; height: 30px; }
.insight-link:hover { border-color: var(--gold); }
.masar-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; }
.masar-mini li { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 10px; background: #e5f4eb; font-size: 13px; }
.masar-mini li b { font-size: 15px; order: 2; }
.masar-mini li.warn { background: #fff4d6; color: var(--warn); }
.masar-mini li:last-child { background: #f3efe6; }
.masar-chip { display: block; margin-top: 4px; font-size: 11px; color: var(--info); white-space: nowrap; }
.masar-chip.is-bad { color: var(--danger); }
.masar-src { margin-inline-start: 6px; }

/* Statistics page */
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stats-card { padding: 18px; scroll-margin-top: 20px; }
.stats-card h2 { margin: 0 0 4px; font-size: 17px; }
.stats-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stats-card .chart-box { position: relative; height: 260px; margin: 12px 0; }
.stats-card.is-wide { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); column-gap: 24px; align-items: center; }
.stats-card.is-wide > h2, .stats-card.is-wide > p { grid-column: 1 / -1; }
@media (max-width: 980px) { .stats-card.is-wide { grid-template-columns: 1fr; } }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table td, .stats-table th { padding: 7px 8px; border-bottom: 1px solid #eee6d8; text-align: right; }
.stats-table th { color: var(--muted); font-weight: 600; background: #faf6ee; }
.stats-table .bar { height: 6px; border-radius: 4px; background: var(--gold-soft); overflow: hidden; min-width: 60px; }
.stats-table .bar span { display: block; height: 100%; background: var(--pine-2); }
.stats-table-wrap { max-height: 320px; overflow: auto; }
.stats-card:target { outline: 2px solid var(--gold); }
.stats-table .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }
.stats-table a { color: var(--pine-2); text-decoration: underline; text-decoration-color: var(--gold-soft); }

/* Masar review */
.masar-import { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 14px 16px; margin-bottom: 14px; }
.masar-import p { margin: 0; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.result-grid .stat { min-width: 0; }
.stat.is-ok b { color: var(--ok); }
.stat.is-bad b { color: var(--danger); }
.stat.is-warn b { color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.chip b { color: var(--pine); margin-inline-start: 4px; }
.text-danger { color: var(--danger); }
label.is-busy { opacity: .6; pointer-events: none; }
.review-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.review-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 13px; }
.review-tabs button.active { background: var(--pine); color: #fff; border-color: var(--pine); }
.review-tabs button b { margin-inline-start: 6px; }
.text-ok { color: var(--ok); }

/* ---------- Accommodation: hotels, building, rooms, beds ---------- */
:root { --male: #2c5d73; --female: #9b3d64; --mixed: #9a7b2f; --glass: #cdd9dd; }
.t-M { color: var(--male); } .t-F { color: var(--female); }

.hotel-strip { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 8px; scroll-snap-type: x proximity; }
.hotel-chip {
  flex: 0 0 236px; display: grid; gap: 8px; text-align: start; cursor: pointer; color: var(--ink);
  border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s, transform .15s; scroll-snap-align: start;
}
.hotel-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.hotel-chip.active { border-color: var(--pine); box-shadow: 0 0 0 3px rgba(27, 67, 50, .12); }
.hc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hc-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-top small, .hc-foot { color: var(--muted); font-size: 12px; }
.hc-bar { height: 6px; background: #ece5d6; border-radius: 99px; overflow: hidden; }
.hc-bar i { display: block; height: 100%; background: linear-gradient(to left, var(--pine), var(--gold)); border-radius: inherit; }
.hc-foot { display: flex; justify-content: space-between; }
.hc-foot b { color: var(--ink); }
.empty-hotels, .floor-empty { display: grid; justify-items: center; text-align: center; gap: 8px; }
.empty-hotels { width: 100%; padding: 44px 20px; }
.empty-hotels p, .floor-empty p { margin: 0; }
.empty-illus svg, .floor-empty > svg { width: 46px; height: 46px; color: var(--gold); }
.floor-empty { padding: 70px 20px; }
.floor-empty.small { grid-column: 1 / -1; padding: 30px; color: var(--muted); }

.housing { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.building-card { padding: 16px; display: grid; gap: 14px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.building-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.building-head h2 { margin: 0; font-size: 19px; }
.building-head p { margin: 3px 0 0; font-size: 13px; }
.h-stats { display: flex; align-items: center; gap: 14px; }
.ring {
  --p: 0; width: 76px; height: 76px; flex: none; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(closest-side, var(--surface) 76%, transparent 77%), conic-gradient(var(--pine) calc(var(--p) * 1%), #e9e2d3 0);
}
.ring b { font-size: 17px; line-height: 1.1; }
.ring span { font-size: 11px; color: var(--muted); }
.h-nums { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 0; }
.h-nums div { display: flex; flex-direction: column; }
.h-nums dt { font-size: 11px; color: var(--muted); }
.h-nums dd { margin: 0; font-weight: 700; }
.h-nums dd.ok { color: var(--ok); }

.locate { position: relative; }
.locate-results {
  position: absolute; inset-inline: 0; top: 100%; margin-top: 4px; z-index: 25; display: grid; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 300px; overflow: auto;
}
.locate-results p { margin: 6px 8px; }
.locate-results button { display: flex; align-items: center; gap: 10px; text-align: start; border: 0; background: none; padding: 6px 8px; border-radius: 10px; cursor: pointer; color: var(--ink); }
.locate-results button:hover, .locate-results button:focus-visible { background: #f1ebde; outline: none; }
.locate-results small { display: block; color: var(--muted); font-size: 12px; }

.building { display: grid; justify-items: center; }
.bld-roof { width: 100%; display: flex; justify-content: center; }
.bld-sign {
  max-width: 86%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--gold); color: #fff; font-weight: 700; font-size: 12px; padding: 5px 16px; border-radius: 9px 9px 0 0;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
}
.bld-add {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 6px; padding: 7px;
  border: 1px dashed #cbbd9f; background: transparent; color: var(--muted); border-radius: 10px; cursor: pointer; font-size: 13px;
}
.bld-add svg { width: 14px; height: 14px; }
.bld-add:hover { border-color: var(--pine); color: var(--pine); background: #f3efe5; }
.bld-body {
  width: 100%; display: grid; gap: 6px; padding: 8px 8px 38px;
  background: linear-gradient(180deg, #ebe2cf, #ddd0b5); border: 1px solid #cbbd9f; border-top: 7px solid #b9a780; border-radius: 6px 6px 0 0;
}
.bld-floor {
  width: 100%; display: grid; grid-template-columns: 38px minmax(0, 1fr) 42px; align-items: center; gap: 8px; padding: 6px;
  background: rgba(255, 253, 248, .5); border: 1px solid transparent; border-radius: 10px; cursor: pointer; color: var(--ink);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.bld-floor:hover { background: #fffdf8; border-color: #cbbd9f; }
.bld-floor.active { background: #fffdf8; border-color: var(--pine); box-shadow: 0 0 0 3px rgba(27, 67, 50, .12); }
.bf-num { font-weight: 700; font-size: 13px; color: var(--pine); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 5px 0; text-align: center; }
.bld-floor.active .bf-num { background: var(--pine); color: #fff; border-color: var(--pine); }
.bf-wins { display: flex; flex-wrap: wrap; gap: 4px; }
.win {
  --f: 0%; --c: transparent; width: 14px; height: 18px; border-radius: 3px 3px 1px 1px;
  background: linear-gradient(to top, var(--c) var(--f), var(--glass) var(--f));
  border: 1px solid rgba(23, 33, 28, .28); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45);
}
.win.t-M { --c: var(--male); } .win.t-F { --c: var(--female); } .win.t-X { --c: var(--mixed); }
.win-none { font-size: 11px; color: var(--muted); }
.bf-stat { text-align: center; line-height: 1.1; }
.bf-stat b { display: block; color: var(--ok); }
.bf-stat small { font-size: 10px; color: var(--muted); }
.bld-empty { width: 100%; display: grid; justify-items: center; gap: 8px; padding: 26px 12px 40px; background: #efe7d6; border: 1px dashed #cbbd9f; border-radius: 8px 8px 0 0; }
.bld-empty p { margin: 0; color: var(--muted); }
.bld-empty .bld-add { width: auto; padding-inline: 16px; }
.bld-ground { width: 106%; height: 14px; display: flex; justify-content: center; background: linear-gradient(#b9a780, #9d8b63); border-radius: 0 0 6px 6px; }
.bld-door { width: 48px; height: 30px; margin-top: -30px; background: linear-gradient(#2a3d33, var(--pine)); border: 2px solid #b9a780; border-bottom: 0; border-radius: 10px 10px 0 0; }
.bld-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; font-size: 12px; color: var(--muted); }
.lg { display: inline-block; width: 10px; height: 13px; margin-inline-end: 5px; vertical-align: -2px; border-radius: 2px; border: 1px solid rgba(0, 0, 0, .2); }
.lg-free { background: var(--glass); } .lg-M { background: var(--male); } .lg-F { background: var(--female); } .lg-X { background: var(--mixed); }

.floor-panel { padding: 18px; min-height: 440px; }
.floor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.floor-head h2 { margin: 0; }
.floor-head p { margin: 4px 0 0; }
.floor-head .btn-sm { min-height: 34px; }
.room-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.room-filters button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 13px; cursor: pointer; font-size: 13px; color: var(--ink); }
.room-filters button.active { background: var(--pine); border-color: var(--pine); color: #fff; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; margin-top: 14px; }
.room-filters + .room-grid { margin-top: 0; }
.room-card {
  display: grid; gap: 12px; padding: 12px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--glass);
  border-radius: 16px; transition: box-shadow .15s;
}
.room-card:hover { box-shadow: var(--shadow); }
.room-card.t-M { border-top-color: var(--male); } .room-card.t-F { border-top-color: var(--female); } .room-card.t-X { border-top-color: var(--mixed); }
.rc-head { display: flex; align-items: center; gap: 8px; }
.rc-title { flex: 1; display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.rc-title b { font-size: 19px; }
.rc-title small { color: var(--muted); font-size: 12px; }
.rc-gender { font-size: 11px; padding: 2px 9px; border-radius: 99px; background: #eef1ef; color: var(--muted); white-space: nowrap; }
.rc-gender.t-M { background: #e2edf1; color: var(--male); }
.rc-gender.t-F { background: #f6e5ed; color: var(--female); }
.rc-gender.t-X { background: var(--gold-soft); color: #6d5620; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn.sm svg { width: 14px; height: 14px; }
.rc-beds { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 10px 8px; justify-items: center; padding: 4px 0; }
.rc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; border-top: 1px solid #f0eadf; padding-top: 10px; }
.rc-count { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.rc-count b { color: var(--ink); }
.rc-count i { --p: 0%; width: 44px; height: 5px; border-radius: 9px; background: linear-gradient(to left, var(--pine) var(--p), #e9e2d3 var(--p)); }

.face {
  --ring: #c9d7dc; width: 46px; height: 46px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: #8a958f; color: #fff; font-weight: 700; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ring); transition: transform .15s, box-shadow .15s;
}
.face img, .modal .face img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; background: none; }
.face.g-M { --ring: var(--male); background: var(--male); }
.face.g-F { --ring: var(--female); background: var(--female); }
.face.g-U { --ring: #8a958f; }
.face-ini { font-size: 15px; letter-spacing: -.02em; }
.face.lg { width: 84px; height: 84px; }
.face.lg .face-ini { font-size: 26px; }
.face.sm { width: 32px; height: 32px; box-shadow: none; }
.face.sm .face-ini { font-size: 12px; }
.face-empty { background: #f6f2ea; color: #ab9f86; box-shadow: none; border: 2px dashed #cfc5b1; }
.face-empty svg { width: 18px; height: 18px; }
.bed-av { position: relative; width: 48px; height: 48px; display: grid; place-items: center; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.bed-av.is-taken { cursor: grab; }
.bed-av.is-taken:hover .face, .bed-av.is-taken:focus-visible .face { transform: scale(1.08); }
.bed-av.is-free:hover .face-empty, .bed-av.is-free:focus-visible .face-empty { border-color: var(--pine); color: var(--pine); background: #eef6f1; transform: scale(1.06); }
.bed-av:focus-visible { outline: 3px solid #c8e2d2; outline-offset: 3px; }
.bed-no {
  position: absolute; bottom: -5px; inset-inline-end: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  display: grid; place-items: center; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 600;
}
.is-dragging .bed-av.drop-ok .face-empty { border-color: var(--ok); color: var(--ok); background: #e5f4eb; }
.is-dragging .bed-av.drop-no { opacity: .3; cursor: not-allowed; }
.bed-av.drop-over .face-empty { transform: scale(1.18); border-style: solid; }
.bed-av.flash .face { animation: bed-flash 1.6s ease; }
@keyframes bed-flash {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ring); }
  25%, 70% { box-shadow: 0 0 0 3px #fff, 0 0 0 9px var(--gold); }
}

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .sw { position: relative; flex: none; width: 34px; height: 20px; border-radius: 20px; background: #d8d0c0; transition: background .15s; }
.switch .sw::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: inset-inline-start .15s;
}
.switch input:checked + .sw { background: var(--gold); }
.switch input:checked + .sw::after { inset-inline-start: 16px; }
.switch input:focus-visible + .sw { outline: 2px solid #c8e2d2; outline-offset: 2px; }

.bed-tip {
  --arrow: 50%; position: absolute; z-index: 80; width: 300px; padding: 12px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 40px rgba(23, 33, 28, .18);
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.bed-tip.show { opacity: 1; transform: none; }
.bed-tip::after {
  content: ""; position: absolute; top: 100%; left: var(--arrow); width: 12px; height: 12px; background: var(--surface);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: translate(-50%, -6px) rotate(45deg);
}
.bed-tip.below::after { top: auto; bottom: 100%; transform: translate(-50%, 6px) rotate(225deg); }
.pc { display: flex; align-items: flex-start; gap: 14px; }
.pc-body { flex: 1; min-width: 0; }
.pc-body > strong { display: block; font-size: 15px; }
.pc dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 13px; }
.pc dt { color: var(--muted); }
.pc dd { margin: 0; }

.assign-head { display: flex; align-items: center; gap: 12px; }
.assign-head h2 { margin: 0; font-size: 19px; }
.assign-head p { margin: 4px 0 0; font-size: 13px; }
.assign-badge { width: 46px; height: 46px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); }
.assign-badge svg { width: 24px; height: 24px; }
.assign-search { margin-top: 16px; }
.assign-search input { font-size: 16px; padding: 13px 14px; }
.as-hint { margin: 12px 0 6px; font-size: 13px; }
.as-wrap { max-height: 430px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.pick-table { min-width: 0; }
.pick-table td { vertical-align: middle; }
.pick-table tbody tr[data-i] { cursor: pointer; }
.pick-table tbody tr.active td { background: #eaf4ee; }
.pick-table tbody tr.is-blocked { opacity: .55; cursor: not-allowed; }
.pick-table tbody.loading { opacity: .5; }
.pk-face { width: 54px; }
.pk-face .face { width: 38px; height: 38px; box-shadow: none; }
.pk-note { display: block; font-size: 12px; color: var(--warn); }
.pk-note.bad { color: var(--danger); }
.pk-note.free { color: var(--muted); }
.pk-note svg { width: 12px; height: 12px; vertical-align: -2px; margin-inline-end: 3px; }
.as-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.as-bar .as-hint { margin: 12px 0 6px; }
.assign-badge svg { width: 22px; height: 22px; }
.confirm-card { display: grid; gap: 14px; margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: #fbf9f4; }
.confirm-title { margin: 0; font-weight: 700; color: var(--pine); }
.confirm-note { margin: 0; font-size: 13px; }
.confirm-actions { justify-content: flex-start; }
.confirm-actions .btn svg, .modal .toolbar .btn svg { width: 16px; height: 16px; vertical-align: -3px; }
.move-path { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 10px; }
.move-path.single { grid-template-columns: 1fr; }
.move-arrow { align-self: center; font-size: 20px; color: var(--gold); font-weight: 700; }
.addr { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.addr small { font-size: 11px; color: var(--muted); }
.addr b { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; font-weight: 600; line-height: 1.5; }
.addr b svg { flex: none; width: 15px; height: 15px; margin-top: 2px; }
.addr.old { background: #f6f2ea; color: #6f6556; }
.addr.old b svg { color: #ab9f86; }
.addr.new { border-color: #b9d8c5; background: #f1f8f3; }
.addr.new b svg { color: var(--pine); }
.swap-side { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.swap-side small { display: block; }
.swap-side .move-path { grid-column: 1 / -1; }
.swap-divider { justify-self: center; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #fff; transform: rotate(90deg); }
.swap-divider svg { width: 18px; height: 18px; }
@media (max-width: 640px) {
  .move-path { grid-template-columns: 1fr; }
  .move-arrow { transform: rotate(-90deg); justify-self: center; }
}
.as-options { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; }
.as-options summary { cursor: pointer; color: var(--muted); }
.as-options details .grid-2 { margin-top: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.modal-occupant { width: min(460px, 100%); }
.modal-occupant .face.lg { width: 96px; height: 96px; }
.fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 0; display: grid; gap: 10px; }
.fieldset legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.fieldset p { margin: 0; font-size: 13px; }
.bed-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 12px; font-size: 12px; cursor: pointer; color: var(--ink); }
.chip-btn:hover { border-color: var(--pine); color: var(--pine); }

@media (max-width: 1100px) {
  .housing { grid-template-columns: 1fr; }
  .building-card { position: static; max-height: none; }
  .building { max-width: 420px; margin: 0 auto; width: 100%; }
}
@media (max-width: 560px) {
  .room-grid { grid-template-columns: 1fr; }
  .bed-tip { width: min(300px, calc(100vw - 16px)); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); z-index: 20; }
  .nav-toggle { display: inline-flex; }
  .metro-grid, .grid-2, .grid-3, .filter-bar, .add-form { grid-template-columns: 1fr 1fr; }
  .add-form, .split, .room-form { grid-template-columns: 1fr; }
  .add-owner { grid-column: auto; }
  .stats-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .metro-grid, .grid-2, .grid-3, .filter-bar { grid-template-columns: 1fr; }
  .workspace-main, .workspace-top { padding-inline: 16px; }
}
