/* ═══════════════════════════════════════════════
   NHÀ ƠI — STYLESHEET
   Design system: Mintlify-inspired
   Fonts: Inter (UI/body)
═══════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-tint: #fafafa;
  --surface-soft: #f5f5f5;

  /* Text */
  --text: #0d0d0d;
  --text-muted: #666666;
  --text-light: #888888;

  /* Borders (rely on these, not shadows) */
  --border: rgba(0, 0, 0, 0.05);
  --border-strong: rgba(0, 0, 0, 0.08);

  /* Brand */
  --brand: #18E299;
  --brand-deep: #0fa76e;
  --brand-tint: #d4fae8;

  /* Semantic */
  --success: #0fa76e;
  --success-tint: #d4fae8;
  --warning: #c37d0d;
  --warning-tint: #fef3c7;
  --danger: #d45656;
  --danger-tint: #fde2e2;
  --info: #3772cf;
  --info-tint: #e1ecfb;

  /* Stars */
  --amber: #c37d0d;

  /* Elevation */
  --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.06);

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 9999px;

  /* Layout */
  --sidebar-w: 240px;
  --sidebar-w-rail: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-family: 'Inter', system-ui, sans-serif; }

a { color: var(--text); text-decoration: none; transition: color .15s; }
a:hover { color: var(--brand-deep); }

button { font-family: inherit; }

input, select, textarea { font-family: inherit; color: var(--text); }

::selection { background: var(--brand-tint); color: var(--text); }

/* ──────────────────────────────────────────────
   LAYOUT
────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: calc(100vw - var(--sidebar-w));
}

/* Mobile menu button (visible <768px only) */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 101;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-btn);
}
.mobile-menu-btn svg { width: 20px; height: 20px; }

.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
  opacity: 0;
  transition: opacity .2s;
}
.mobile-backdrop.open { opacity: 1; }

/* ──────────────────────────────────────────────
   SIDEBAR
────────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 32px; height: 32px;
  background: var(--brand);
  color: var(--text);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.brand-mark.large {
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  font-size: 1.75rem;
}

.brand-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}
.brand-sub {
  font-family: inherit;
  font-size: 0.625rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .75rem;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all .15s;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover {
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--brand-tint);
  color: var(--brand-deep);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-pill);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.user-avatar.sm { width: 28px; height: 28px; }

.user-avatar-placeholder {
  width: 32px; height: 32px;
  background: var(--brand-tint);
  color: var(--brand-deep);
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem;
  flex-shrink: 0;
}
.user-avatar-placeholder.sm { width: 28px; height: 28px; font-size: .75rem; }

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
  font-family: inherit;
  font-size: 0.625rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.logout-btn {
  color: var(--text-light);
  display: flex; align-items: center;
  transition: color .15s;
  padding: .25rem;
  border-radius: var(--r-sm);
}
.logout-btn:hover { color: var(--text); background: var(--surface-soft); text-decoration: none; }
.logout-btn svg { width: 16px; height: 16px; }

/* ──────────────────────────────────────────────
   PAGE HEADER
────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.8px;
  line-height: 1.1;
  color: var(--text);
}
.page-sub {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.breadcrumb {
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--text-light);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--brand-deep); }

.header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ──────────────────────────────────────────────
   BUTTONS (pill-shaped)
────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--r-pill);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover { opacity: 0.9; color: var(--surface); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--brand-deep); color: var(--brand-deep); }
.btn-secondary.active {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-deep);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); background: var(--surface-soft); }

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}
.btn-danger-ghost:hover { background: var(--danger-tint); }

.btn-xs {
  padding: .25rem .65rem;
  font-size: 0.75rem;
}

.hidden { display: none !important; }

/* ──────────────────────────────────────────────
   BADGES (pill, mono)
────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .15rem .6rem;
  border-radius: var(--r-pill);
  font-family: 'Inter', sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
}
.badge.lg { font-size: 0.75rem; padding: .25rem .75rem; }
.badge.sm { font-size: 0.625rem; padding: .1rem .5rem; }

.badge-reviewing { background: var(--warning-tint); color: var(--warning); }
.badge-liked { background: var(--brand-tint); color: var(--brand-deep); }
.badge-rejected { background: var(--danger-tint); color: var(--danger); }
.badge-link {
  background: var(--surface-soft);
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}
.badge-link:hover { color: var(--brand-deep); text-decoration: none; }

/* ──────────────────────────────────────────────
   FILTERS
────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-tabs { display: flex; gap: .375rem; flex-wrap: wrap; }
.filter-tab {
  padding: .35rem .9rem;
  border-radius: var(--r-pill);
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  transition: all .15s;
  color: var(--text-muted);
}
.filter-tab:hover { color: var(--text); border-color: var(--text); }
.filter-tab.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.filter-sort select {
  padding: .35rem .85rem;
  padding-right: 2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
}

/* ──────────────────────────────────────────────
   APARTMENT CARDS
────────────────────────────────────────────── */
.apt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.apt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  position: relative;
  transition: border-color .15s, transform .15s;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.apt-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.card-check-label {
  position: absolute;
  top: .75rem; right: .75rem;
  z-index: 2;
  cursor: pointer;
}
.card-check { display: none; }
.check-custom {
  display: block;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  transition: all .15s;
}
.card-check:checked + .check-custom {
  background: var(--brand);
  border-color: var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='%230d0d0d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px;
}

.card-thumb {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--surface-tint);
  overflow: hidden;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s;
}
.apt-card:hover .card-thumb img { transform: scale(1.02); }
.card-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  background:
    linear-gradient(135deg, var(--surface-tint), var(--surface-soft));
}
.card-thumb-placeholder svg { width: 36px; height: 36px; opacity: .55; }

.card-badges {
  display: flex; gap: .4rem;
  padding: .75rem 2.5rem 0 1rem;
  flex-wrap: wrap;
}

.card-body {
  display: block;
  padding: .75rem 1rem 1rem;
  color: var(--text);
}
.card-body:hover { color: var(--text); text-decoration: none; }

.card-project {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: .25rem;
  line-height: 1.25;
}
.card-location {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex; align-items: center; gap: .3rem;
  margin-bottom: 1rem;
}

.card-specs {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .875rem;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .65rem .5rem;
}
.spec { text-align: center; flex: 1; min-width: 0; }
.spec-val {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.spec-label {
  display: block;
  font-family: inherit;
  font-size: 0.625rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1px;
}
.spec-divider { width: 1px; height: 22px; background: var(--border); }

.card-price { margin-bottom: .65rem; }
.price-main {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.4px;
  color: var(--text);
}
.price-sqm {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: .5rem;
}
.muted { color: var(--text-muted); }

.card-legal { margin-bottom: .5rem; }
.legal-bar-wrap {
  height: 3px;
  background: var(--surface-soft);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-bottom: .25rem;
}
.legal-bar { height: 100%; background: var(--brand); border-radius: var(--r-pill); transition: width .3s; }
.legal-label {
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-rating { display: flex; gap: .1rem; }
.star { font-size: 0.875rem; color: var(--border-strong); }
.star.filled { color: var(--amber); }

/* ──────────────────────────────────────────────
   FORMS
────────────────────────────────────────────── */
.form-grid { display: flex; flex-direction: column; gap: 1rem; }

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.field { display: flex; flex-direction: column; gap: .35rem; }
.field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}
.req { color: var(--danger); }
.field-hint { font-size: 0.75rem; color: var(--text-light); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.field-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.field-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.field-row:last-child { margin-bottom: 0; }
.field:not(:last-child):not(.field-row *) { margin-bottom: 1rem; }

input[type="text"], input[type="number"], input[type="email"], input[type="url"],
select, textarea {
  width: 100%;
  padding: .55rem .85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-light); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(24, 226, 153, 0.15);
}
textarea { resize: vertical; min-height: 60px; line-height: 1.5; }

.star-input { display: flex; gap: .15rem; cursor: pointer; }
.star-btn {
  font-size: 1.5rem;
  color: var(--border-strong);
  transition: color .1s;
  cursor: pointer;
  user-select: none;
}
.star-btn:hover, .star-btn.filled { color: var(--amber); }

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  flex-wrap: wrap;
  gap: .75rem;
}
.form-actions-right { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Autofill bar */
.autofill-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}
.autofill-label {
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: .6rem;
  display: flex; align-items: center; gap: .4rem;
}
.autofill-input-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.autofill-input-row input { flex: 1; min-width: 200px; }
.autofill-status {
  margin-top: .65rem;
  font-size: 0.8125rem;
  padding: .5rem .75rem;
  border-radius: var(--r-sm);
  background: var(--surface-soft);
  color: var(--text-muted);
}
.autofill-status.success { background: var(--brand-tint); color: var(--brand-deep); }
.autofill-status.error { background: var(--danger-tint); color: var(--danger); }

/* ──────────────────────────────────────────────
   TABS
────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: .65rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  display: flex; align-items: center; gap: .4rem;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 600;
}

.tab-badge {
  background: var(--surface-soft);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.6875rem;
  padding: .1rem .5rem;
  border-radius: var(--r-pill);
  font-weight: 500;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ──────────────────────────────────────────────
   DETAIL VIEW
────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}
.detail-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.detail-rows { display: flex; flex-direction: column; gap: .15rem; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.dr-label { font-size: 0.8125rem; color: var(--text-muted); flex-shrink: 0; }
.dr-val { font-size: 0.875rem; font-weight: 500; text-align: right; color: var(--text); }

.rating-display {
  display: flex; align-items: center; gap: .15rem;
  margin-bottom: 1rem;
}
.star-lg { font-size: 1.5rem; color: var(--border-strong); }
.star-lg.filled { color: var(--amber); }
.rating-num {
  margin-left: .5rem;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.detail-note-box {
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .75rem;
}
.note-label {
  font-family: inherit;
  font-size: 0.625rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: .35rem;
}
.note-text { font-size: 0.875rem; }

/* ──────────────────────────────────────────────
   LEGAL CHECKLIST
────────────────────────────────────────────── */
.legal-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
}

.legal-summary { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }

.legal-progress-circle { position: relative; flex-shrink: 0; }
.legal-progress-circle svg { display: block; }
.legal-progress-circle path { stroke: var(--border); }
.legal-progress-circle #progress-arc { stroke: var(--brand); }
.circle-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.legal-sum-title { font-weight: 600; font-size: 0.9375rem; color: var(--text); }
.legal-sum-sub { font-size: 0.8125rem; color: var(--text-muted); margin-top: .15rem; }

.legal-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: .75rem;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.legal-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .65rem 1.25rem;
  background: var(--surface-tint);
  border-bottom: 1px solid var(--border);
}
.legal-group-name {
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.legal-group-progress {
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--text-light);
}

.legal-item {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.legal-item:last-child { border-bottom: none; }

.legal-item-main { display: flex; align-items: flex-start; gap: .85rem; }

.legal-check-label { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; margin-top: .15rem; }
.legal-check { display: none; }
.legal-check + .check-custom { border-radius: 50%; }
.legal-check:checked + .check-custom {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px;
}

.legal-item-title { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.legal-item-title.done { text-decoration: line-through; color: var(--text-light); }
.legal-code {
  display: inline-block;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.625rem;
  padding: .1rem .4rem;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-right: .35rem;
  vertical-align: middle;
}
.legal-item-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: .3rem;
  line-height: 1.5;
}
.legal-item-notes { margin-top: .55rem; padding-left: 2.4rem; }
.notes-input {
  font-size: 0.8125rem;
  padding: .45rem .65rem;
  min-height: 38px;
  color: var(--text);
  background: var(--surface-tint);
  border-color: var(--border);
}
.notes-input:focus { background: var(--surface); }

/* ──────────────────────────────────────────────
   FINANCE CARDS
────────────────────────────────────────────── */
.finance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
}

.finance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
.finance-card.highlight { border-left: 3px solid var(--brand); }
.finance-card.accent {
  border-color: var(--text);
  background: var(--text);
}
.finance-card.accent .fc-label { color: rgba(255,255,255,0.6); }
.finance-card.accent .fc-val,
.finance-card.accent .fc-unit,
.finance-card.accent .fc-pct { color: rgba(255,255,255,0.95); }

.fc-label {
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: .5rem;
}
.fc-val {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.4px;
  line-height: 1.1;
  color: var(--text);
}
.fc-unit {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: .15rem;
}
.fc-pct {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-left: .35rem;
}
.fc-note {
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--text-light);
  margin-top: .35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.finance-hint {
  background: var(--warning-tint);
  border: 1px solid rgba(195, 125, 13, 0.2);
  border-radius: var(--r-sm);
  padding: .75rem 1rem;
  font-size: 0.8125rem;
  color: var(--warning);
  display: flex; align-items: center; gap: .5rem;
  margin-top: 1rem;
}
.finance-hint a { color: var(--warning); font-weight: 600; }

/* Notes tab */
.notes-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}
.notes-content { font-size: 0.9375rem; line-height: 1.65; white-space: pre-wrap; color: var(--text); }
.notes-empty { color: var(--text-muted); font-size: 0.875rem; }
.notes-meta {
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1rem;
}

/* ──────────────────────────────────────────────
   PHOTOS
────────────────────────────────────────────── */
.photo-upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1rem;
}
.upload-hint {
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: .75rem;
}
.upload-zone {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem;
  background: var(--surface-tint);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}
.upload-status { font-size: 0.8125rem; color: var(--text-muted); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
}
.photo-item {
  position: relative;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  box-shadow: var(--shadow-card);
}
.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s;
}
.photo-item:hover img { transform: scale(1.04); }
.photo-delete {
  position: absolute;
  top: .4rem; right: .4rem;
  width: 28px; height: 28px;
  border-radius: var(--r-pill);
  background: rgba(13, 13, 13, 0.7);
  color: white;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.photo-item:hover .photo-delete { opacity: 1; }
.photo-delete:hover { background: var(--danger); }
.photo-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

/* ──────────────────────────────────────────────
   COMPARE TABLE
────────────────────────────────────────────── */
.compare-filters {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  flex-wrap: wrap;
}
.filter-label {
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.check-filter {
  display: flex; align-items: center; gap: .4rem;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
}
.check-filter input { width: 14px; height: 14px; accent-color: var(--brand-deep); }

.compare-toggles { display: flex; gap: .375rem; }

.compare-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  -webkit-overflow-scrolling: touch;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.8125rem;
}

.compare-table thead th {
  background: var(--text);
  color: var(--surface);
  padding: 1rem 1.25rem;
  text-align: left;
  position: sticky;
  top: 0;
  font-weight: 500;
}
.compare-table thead th.col-label { width: 200px; min-width: 200px; }
.compare-table thead th.col-apt { min-width: 200px; }

.cth-project {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: .2rem;
}
.cth-loc { font-size: 0.75rem; opacity: .7; margin-bottom: .55rem; }
.cth-actions { display: flex; align-items: center; gap: .5rem; }
.cth-actions .btn-xs { background: rgba(255,255,255,0.95); color: var(--text); border: none; }
.cth-actions .btn-xs:hover { background: var(--brand); color: var(--text); }

.group-header td {
  background: var(--surface-tint);
  padding: .55rem 1.25rem;
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.compare-row { transition: background .1s; }
.compare-row:hover td { background: var(--surface-tint); }
.compare-row td {
  padding: .7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.row-label {
  color: var(--text-muted);
  font-size: 0.8125rem;
  background: var(--surface-tint);
  width: 200px;
  min-width: 200px;
  font-weight: 500;
}
.row-val { font-weight: 500; color: var(--text); }
.highlight-row td { background: var(--brand-tint); }
.highlight-row:hover td { background: rgba(24, 226, 153, 0.2); }

.price-cell {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.legal-row .row-label { font-size: 0.75rem; }
.legal-code-sm {
  display: inline-block;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.625rem;
  padding: .1rem .35rem;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-right: .25rem;
}
.legal-check-icon { font-size: 1rem; font-weight: 700; }
.legal-check-icon.ok { color: var(--brand-deep); }
.legal-check-icon.pending { color: var(--text-light); }
.legal-note-sm { font-size: 0.75rem; color: var(--text-muted); margin-top: .2rem; }

.star-sm { font-size: 0.85rem; color: var(--border-strong); }
.star-sm.filled { color: var(--amber); }
.notes-cell { font-size: 0.8125rem; color: var(--text-muted); max-width: 220px; }

.tag-ok {
  display: inline-block;
  background: var(--brand-tint);
  color: var(--brand-deep);
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ──────────────────────────────────────────────
   SETTINGS
────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}
.settings-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: .25rem;
  color: var(--text);
}
.settings-card-sub { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 1.25rem; }

.user-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.5rem; }
.user-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .85rem;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}
.user-row-info { flex: 1; min-width: 120px; }
.user-row-name { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.user-row-email { font-size: 0.75rem; color: var(--text-muted); }
.role-select {
  width: auto;
  padding: .25rem .55rem;
  font-size: 0.75rem;
  border-radius: var(--r-pill);
}

.add-user-form { border-top: 1px solid var(--border); padding-top: 1.25rem; }
.add-user-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: .85rem;
  color: var(--text);
}

/* ──────────────────────────────────────────────
   EMPTY STATE
────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: .5rem;
}
.empty-state p { margin-bottom: 1.5rem; font-size: 0.9375rem; }

/* ──────────────────────────────────────────────
   ALERTS & TOAST
────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.alert-error { background: var(--danger-tint); color: var(--danger); border: 1px solid rgba(212, 86, 86, 0.25); }

.toast {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  padding: .65rem 1.1rem;
  border-radius: var(--r-pill);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  transition: opacity .2s;
  max-width: calc(100vw - 3rem);
}
.toast-success { background: var(--text); color: var(--surface); }
.toast-error { background: var(--danger); color: white; }

/* ──────────────────────────────────────────────
   LOGIN
────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(24, 226, 153, 0.18), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(24, 226, 153, 0.08), transparent 70%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

.login-brand { text-align: center; margin-bottom: 2rem; display: flex; flex-direction: column; align-items: center; }
.login-title {
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.6px;
  margin: 1rem 0 .25rem;
  color: var(--text);
}
.login-subtitle { font-size: 0.875rem; color: var(--text-muted); }

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  width: 100%;
  padding: .75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 1rem;
}
.btn-google:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(24, 226, 153, 0.15);
  color: var(--text);
  text-decoration: none;
}

.login-note {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
  line-height: 1.5;
}

.login-deco {
  display: flex; align-items: center; gap: 1rem;
  color: var(--text-light);
  font-family: inherit;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  width: 100%;
}
.deco-line { flex: 1; height: 1px; background: var(--border-strong); }

/* ──────────────────────────────────────────────
   RESPONSIVE
────────────────────────────────────────────── */
@media (max-width: 1023px) {
  :root { --sidebar-w: var(--sidebar-w-rail); }
  .brand-name, .brand-sub, .nav-item span:not(.nav-icon), .user-info, .logout-btn { display: none; }
  .sidebar-brand { justify-content: center; padding: 1rem .5rem; }
  .nav-item { justify-content: center; padding: .65rem; }
  .sidebar-user { justify-content: center; padding: .75rem .5rem; }
  .main-content { padding: 1.5rem; }
  .settings-grid, .detail-grid { grid-template-columns: 1fr; }
  .field-row.cols-4, .field-row.cols-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 767px) {
  :root { --sidebar-w: 0px; }

  .mobile-menu-btn { display: flex; }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  }
  .sidebar.open { transform: translateX(0); }

  /* Restore full sidebar layout when open on mobile */
  .sidebar .brand-name,
  .sidebar .brand-sub,
  .sidebar .user-info,
  .sidebar .logout-btn { display: block; }
  .sidebar .nav-item { justify-content: flex-start; padding: .65rem .85rem; }
  .sidebar .nav-item span { display: inline; }
  .sidebar .sidebar-brand { justify-content: flex-start; padding: 1.25rem; }
  .sidebar .sidebar-user { justify-content: flex-start; padding: 1rem 1.25rem; }
  .sidebar .logout-btn { display: flex; }

  .mobile-backdrop.open { display: block; }

  .main-content {
    margin-left: 0;
    padding: 4rem 1rem 1.5rem;
    max-width: 100vw;
  }

  .page-header { flex-direction: column; align-items: flex-start; }
  .page-title { font-size: 1.625rem; letter-spacing: -0.6px; }
  .header-actions { width: 100%; }

  .apt-grid { grid-template-columns: 1fr; }
  .finance-grid { grid-template-columns: 1fr; }
  .settings-grid, .detail-grid { grid-template-columns: 1fr; }
  .field-row, .field-row.cols-4, .field-row.cols-3 { grid-template-columns: 1fr; gap: .75rem; }

  .form-section, .detail-card, .legal-header, .legal-group, .settings-card, .photo-upload-card, .notes-view {
    padding: 1.25rem;
  }

  .photo-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }

  .legal-item { padding: .75rem 1rem; }
  .legal-item-notes { padding-left: 0; }

  .compare-table thead th,
  .compare-table tbody td { padding: .6rem .85rem; }
  .row-label, .compare-table thead th.col-label { width: 140px; min-width: 140px; }

  .toast { right: 1rem; left: 1rem; bottom: 1rem; text-align: center; }

  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions-right { justify-content: flex-end; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .form-actions-right .btn { width: auto; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: .25rem; }
  .filter-tabs::-webkit-scrollbar { display: none; }
}

@media (max-width: 380px) {
  .photo-grid { grid-template-columns: 1fr; }
  .card-specs { padding: .5rem .25rem; gap: .25rem; }
  .spec-divider { height: 18px; }
  .spec-val { font-size: 0.8125rem; }
}

/* ──────────────────────────────────────────────
   THEME SEGMENTED CONTROL
────────────────────────────────────────────── */
.theme-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .25rem 0;
  flex-wrap: wrap;
}
.theme-toggle-label { display: flex; flex-direction: column; gap: .15rem; }
.theme-toggle-title { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.theme-toggle-sub { font-size: 0.75rem; color: var(--text-muted); }

.theme-segmented {
  display: inline-flex;
  background: var(--surface-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.theme-segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--r-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background .15s, color .15s, box-shadow .15s;
}
.theme-segmented button:hover { color: var(--text); }
.theme-segmented button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(24, 226, 153, 0.25);
}
.theme-segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.theme-segmented svg { width: 14px; height: 14px; flex-shrink: 0; }
[data-theme="dark"] .theme-segmented button.active {
  background: var(--surface-tint);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ──────────────────────────────────────────────
   DARK MODE
────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0d0d0d;
  --surface: #141414;
  --surface-tint: #1a1a1a;
  --surface-soft: #222222;

  --text: #ededed;
  --text-muted: #a0a0a0;
  --text-light: #6b6b6b;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --brand-tint: rgba(24, 226, 153, 0.16);
  --warning-tint: rgba(195, 125, 13, 0.18);
  --danger-tint: rgba(212, 86, 86, 0.18);
  --success-tint: rgba(24, 226, 153, 0.16);
  --info-tint: rgba(55, 114, 207, 0.18);

  --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.4);

  color-scheme: dark;
}

/* Brand mark text stays dark on bright green in both modes */
[data-theme="dark"] .brand-mark { color: #0d0d0d; }
[data-theme="dark"] .user-avatar-placeholder { color: #0d0d0d; }

/* Inverted surfaces: in dark mode var(--text) becomes light, so foregrounds need to flip too */
[data-theme="dark"] .finance-card.accent .fc-label { color: rgba(13, 13, 13, 0.65); }
[data-theme="dark"] .finance-card.accent .fc-val,
[data-theme="dark"] .finance-card.accent .fc-unit,
[data-theme="dark"] .finance-card.accent .fc-pct { color: rgba(13, 13, 13, 0.95); }

/* Compare table action button on light header */
[data-theme="dark"] .cth-actions .btn-xs { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
[data-theme="dark"] .cth-actions .btn-xs:hover { background: var(--brand); color: #0d0d0d; border-color: var(--brand); }

/* Input autofill workaround: WebKit fills with light yellow on dark */
[data-theme="dark"] input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--text);
}

/* Status pills — boost text vs the dimmer tinted backgrounds */
[data-theme="dark"] .badge-reviewing { color: #e0a64a; }
[data-theme="dark"] .badge-rejected { color: #eb8888; }
[data-theme="dark"] .badge-liked { color: var(--brand); }

/* Mobile menu button surface */
[data-theme="dark"] .mobile-menu-btn { background: var(--surface); }

/* Selection */
[data-theme="dark"] ::selection { background: rgba(24, 226, 153, 0.3); color: var(--text); }


/* ══════════════════════════════════════════════════════════════════════════
   LOAN DASHBOARD
   ══════════════════════════════════════════════════════════════════════════ */

/* Form: hint under a section title, and per-listing prepayment block */
.section-hint {
  font-size: .8125rem; color: var(--text-muted); line-height: 1.55;
  margin: -0.9rem 0 1.25rem;
}
.section-hint a { color: var(--brand-deep); font-weight: 500; }

.prepay-details {
  border: 1px dashed var(--border-strong); border-radius: var(--r-md);
  padding: 0 1rem; margin-bottom: 1rem;
}
.prepay-details summary {
  cursor: pointer; padding: .8rem .25rem; font-size: .8125rem;
  font-weight: 500; color: var(--text-muted); list-style-position: inside;
}
.prepay-details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 1rem; }

/* Settings: master family-loan sub-groups */
.subfield-group {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 1rem; margin-bottom: 1rem; background: var(--surface-tint);
}
.subfield-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .85rem; }
.subfield-tag {
  font-family: inherit; font-size: .625rem;
  text-transform: uppercase; letter-spacing: .6px; color: var(--text-light);
  background: var(--surface-soft); padding: .2rem .5rem; border-radius: var(--r-pill);
  white-space: nowrap;
}
.inline-label-input {
  font-weight: 600; font-size: .95rem; flex: 1; min-width: 0;
  border: none !important; background: transparent !important;
  padding: .2rem 0 !important; border-radius: 0 !important;
  border-bottom: 1px dashed var(--border-strong) !important;
}
.inline-label-input:focus { border-bottom-color: var(--brand) !important; outline: none; box-shadow: none !important; }

/* Form: live loan preview */
.loan-preview {
  margin-top: 1.25rem; padding: 1rem 1.25rem;
  border: 1px solid var(--brand); border-left-width: 3px;
  border-radius: var(--r-md); background: var(--brand-tint);
}
.lp-title {
  font-family: inherit; font-size: .6875rem;
  text-transform: uppercase; letter-spacing: .6px; color: var(--brand-deep);
  margin-bottom: .6rem; display: flex; justify-content: space-between; gap: 1rem;
}
.lp-note { color: var(--text-light); text-transform: none; letter-spacing: 0; font-weight: 400; }
.lp-row { display: flex; justify-content: space-between; gap: 1rem; font-size: .875rem; padding: .25rem 0; }
.lp-row span { color: var(--text-muted); }
.lp-row b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.lp-warn { color: var(--danger); }
.lp-ok { color: var(--success); }

/* Detail: section labels + colored stat values + alert */
.loan-section-label {
  font-family: inherit; font-size: .6875rem;
  text-transform: uppercase; letter-spacing: .8px; color: var(--text-light);
  margin: 1.75rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border);
}
.finance-grid + .loan-section-label { margin-top: 1.75rem; }
.tab-pane > .loan-section-label:first-child { margin-top: 0; }
.fc-val.fc-danger { color: var(--danger); }
.fc-val.fc-ok { color: var(--success); }

.loan-alert {
  display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem;
  padding: .8rem 1rem; border-radius: var(--r-md); font-size: .875rem; line-height: 1.5;
}
.loan-alert svg { flex-shrink: 0; }
.loan-alert.danger { background: var(--danger-tint); color: var(--danger); border: 1px solid rgba(212,86,86,.25); }

.payoff-grid { margin-top: 1rem; }

/* Detail: payment-over-time chart */
.loan-chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 1.25rem 1.25rem 1rem; box-shadow: var(--shadow-card); margin-top: 1rem;
}
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chart-title { font-weight: 600; font-size: 1rem; letter-spacing: -0.2px; }
.chart-sub { font-size: .75rem; color: var(--text-light); margin-top: .15rem; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; }
.lg-item { display: flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--text-muted); }
.lg-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.lg-swatch.lg-dash { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed #d45656; }
.chart-wrap { position: relative; }
#loan-chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--text-light); font-size: 11px; font-family: inherit; }
.chart-sep { stroke: var(--surface); }
.chart-ceil-lbl { fill: #d45656; font-size: 10px; font-weight: 600; font-family: inherit; }

.chart-tip {
  position: absolute; top: 6px; pointer-events: none; z-index: 5; min-width: 132px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: .5rem .6rem; box-shadow: 0 4px 14px rgba(0,0,0,.14); font-size: .75rem;
}
.tip-m { font-weight: 600; margin-bottom: .3rem; }
.tip-r { display: flex; justify-content: space-between; gap: 1rem; padding: .1rem 0; color: var(--text-muted); }
.tip-r span { display: flex; align-items: center; }
.tip-r i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: .35rem; }
.tip-r b { color: var(--text); font-variant-numeric: tabular-nums; }
.tip-total { border-top: 1px solid var(--border); margin-top: .25rem; padding-top: .3rem; }
.tip-total b { font-weight: 700; }

/* Detail: amortization schedule table */
.schedule-details {
  margin-top: 1rem; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-card);
}
.schedule-details summary { cursor: pointer; padding: 1rem 1.25rem; font-weight: 500; font-size: .9rem; }
.schedule-details[open] summary { border-bottom: 1px solid var(--border); }
.schedule-table-wrap { max-height: 400px; overflow: auto; }
.schedule-table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.schedule-table th, .schedule-table td {
  padding: .5rem .75rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.schedule-table th:first-child, .schedule-table td:first-child { text-align: center; color: var(--text-muted); }
.schedule-table thead th {
  position: sticky; top: 0; background: var(--surface-soft); color: var(--text-muted);
  font-weight: 600; font-size: .625rem; text-transform: uppercase; letter-spacing: .4px;
}
.schedule-table tbody tr:nth-child(even) { background: var(--surface-tint); }
.schedule-table .st-total { font-weight: 600; color: var(--brand-deep); }
/* day-count columns: dates read left-to-right, the shift marker sits on the due date */
.schedule-table .st-date { text-align: left; color: var(--text-muted); }
.st-shift { color: var(--brand-deep); font-weight: 700; margin-left: .15rem; }
.schedule-details > .fc-note { padding: 0 1.25rem 1rem; }
/* date-valued stat (ngày giải ngân, đáo hạn…) — shorter than a money figure */
.fc-val.fc-date { font-size: 1.05rem; letter-spacing: -.01em; }

/* Compare: loan cell adornments */
.cell-sub { display: block; font-size: .6875rem; color: var(--text-light); font-family: inherit; }
.cell-danger { color: var(--danger); font-weight: 600; }

[data-theme="dark"] .st-total,
[data-theme="dark"] .st-shift { color: var(--brand); }
[data-theme="dark"] .section-hint a,
[data-theme="dark"] .lp-title { color: var(--brand); }

/* Detail: transaction cost vs funding reconciliation */
.finance-breakdown {
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem;
}
.fb-col {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 1rem 1.25rem; box-shadow: var(--shadow-card);
}
.fb-head {
  font-family: inherit; font-size: .6875rem; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-light); margin-bottom: .6rem;
}
.fb-row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; font-size: .875rem; }
.fb-row span { color: var(--text-muted); }
.fb-row b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fb-total { border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .5rem; }
.fb-total span, .fb-total b { color: var(--text); font-weight: 700; }
.fb-muted { opacity: .7; font-size: .8125rem; }
.fb-muted span, .fb-muted b { font-weight: 400; font-style: italic; }
.fb-diff {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin-top: .75rem; padding: .7rem 1rem; border-radius: var(--r-md); font-size: .875rem;
}
.fb-diff strong { font-variant-numeric: tabular-nums; }
.fb-diff.ok { background: var(--success-tint); color: var(--success); border: 1px solid rgba(15,167,110,.25); }
.fb-diff.danger { background: var(--danger-tint); color: var(--danger); border: 1px solid rgba(212,86,86,.25); }

@media (max-width: 640px) {
  .finance-breakdown { grid-template-columns: 1fr; }
}

/* Settings: self-fund live total */
.self-total-wrap { margin-left: auto; font-size: .8125rem; color: var(--text-muted); }
.self-total-wrap b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Autofill paste-text fallback */
.autofill-paste { margin-top: .65rem; }
.autofill-paste summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-muted);
  user-select: none;
}
.autofill-paste summary:hover { color: var(--text); }
.autofill-paste textarea {
  margin-top: .5rem;
  width: 100%;
  resize: vertical;
}

/* Loading state for SPA/static page hydration */
.loading-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

