/* ================================================================
   Velnix Properties — design system
   Cream / gold / serif headings · light + dark
   ================================================================ */

:root {
  --bg:           #F5F1EA;
  --surface:      #FDFBF6;
  --surface-alt:  #EFE9DF;
  --border:       #E0D8C8;
  --border-strong:#CFC4AE;
  --text:         #1A1A1A;
  --text-soft:    #5A5548;
  --text-mute:    #8E8775;
  --gold:         #B8923A;
  --gold-soft:    #D4B668;
  --gold-wash:    #EFE4C7;
  --accent:       #1F3A3D;
  --danger:       #B84A3A;
  --danger-bg:    rgba(184,74,58,0.12);
  --warn:         #B54708;
  --warn-bg:      #FEF0C7;
  --success:      #4A6B3E;
  --success-bg:   rgba(74,107,62,0.12);
  --shadow:       0 1px 2px rgba(26,26,26,0.04), 0 8px 24px rgba(26,26,26,0.06);
  --shadow-strong:0 2px 4px rgba(26,26,26,0.06), 0 20px 48px rgba(26,26,26,0.10);
  --radius:       10px;
  --radius-sm:    7px;
  --serif:        'Fraunces', 'Times New Roman', serif;
  --sans:         'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html.dark {
  --bg:           #0E0E10;
  --surface:      #17171A;
  --surface-alt:  #1F1F23;
  --border:       #2A2A30;
  --border-strong:#3A3A42;
  --text:         #F2EDE2;
  --text-soft:    #B5AE9E;
  --text-mute:    #7A7467;
  --gold:         #D4B668;
  --gold-soft:    #E6C97A;
  --gold-wash:    #2A2418;
  --accent:       #6FA7A3;
  --danger:       #E07866;
  --danger-bg:    rgba(224,120,102,0.16);
  --warn:         #E0B466;
  --warn-bg:      rgba(224,180,102,0.16);
  --success:      #8FB57C;
  --success-bg:   rgba(143,181,124,0.16);
  --shadow:       0 1px 2px rgba(0,0,0,0.30), 0 8px 24px rgba(0,0,0,0.40);
  --shadow-strong:0 2px 4px rgba(0,0,0,0.40), 0 20px 48px rgba(0,0,0,0.60);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

input, textarea, select, button { font-family: inherit; color: inherit; }

.screen { display: none; }
.screen.active { display: block; }

/* ================================================================
   LOGIN
   ================================================================ */

.login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 600px at 90% -10%, var(--gold-wash), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--gold-wash), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow-strong);
}

.login-mark {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.logo-tile {
  width: 38px; height: 38px;
  background: var(--text); color: var(--bg);
  border-radius: 9px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
}

.logo-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.logo-sub {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-top: 3px;
}

.login-title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
}

.login-sub {
  color: var(--text-mute);
  margin: 6px 0 22px;
  font-size: 13.5px;
}

label {
  display: block;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.field { margin-bottom: 14px; }

.input, .select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash);
}

.btn-main {
  width: 100%;
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}
.btn-main:hover { opacity: 0.9; }
.btn-main:active { transform: translateY(1px); }

.err {
  display: none;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 12px;
  border: 1px solid transparent;
}

.note {
  background: var(--gold-wash);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.note.muted-note {
  background: var(--surface-alt);
}

/* ================================================================
   APP SHELL — sidebar + main
   ================================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0 8px 26px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.nav-label {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0 10px 8px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-family: inherit;
}
.nav-item:hover { background: var(--surface-alt); }
.nav-item.active { background: var(--surface-alt); color: var(--text); font-weight: 600; }
.nav-item > span:nth-child(2) { flex: 1; }

.nav-dot {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--border-strong);
  flex-shrink: 0;
}
.nav-item.active .nav-dot { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-wash); }

.nav-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-mute);
  background: var(--surface-alt);
  padding: 2px 7px;
  border-radius: 99px;
  letter-spacing: 0.02em;
}
.nav-item.active .nav-badge { color: var(--gold); background: var(--gold-wash); }

.data-engine {
  margin-top: 24px;
  padding: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-engine-row { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }

.pulse {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg);
}

.data-engine-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-engine-text {
  font-size: 11px;
  color: var(--text-mute);
  line-height: 1.5;
}

.side-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}

.user-meta { min-width: 0; flex: 1; }
.user-name {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
  font-size: 10.5px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.side-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}
.side-btn:hover { background: var(--surface-alt); }
.side-btn .ico { width: 15px; display: inline-block; text-align: center; font-size: 14px; }

/* ================================================================
   MAIN COLUMN
   ================================================================ */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 18px 36px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.page-sub {
  font-size: 13px;
  color: var(--text-mute);
  margin-top: 2px;
}

.page {
  flex: 1;
  padding: 28px 36px 48px;
  max-width: 1280px;
  width: 100%;
}

/* Admin view switching */
.admin-view { display: none; animation: fadeIn 0.18s ease-out; }
.admin-view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* DLD test console output blocks */
.dld-out {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
  margin-top: 12px;
}
.dld-out.ok  { border-color: var(--success); }
.dld-out.err { border-color: var(--danger);  background: var(--danger-bg); color: var(--text); }
.note code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--text);
}

/* ================================================================
   HERO + KPIs
   ================================================================ */

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

h1 {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 10px;
  color: var(--text);
}

.hero p {
  color: var(--text-soft);
  line-height: 1.6;
  max-width: 720px;
  font-size: 14px;
}

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

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.kpi-label {
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.kpi-value {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-top: 6px;
  color: var(--text);
  line-height: 1;
}

/* ================================================================
   PANELS, ADMIN GRID
   ================================================================ */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.panel h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  color: var(--text);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}
.panel .admin-grid:last-child { margin-bottom: 0; }

.admin-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 14px 0;
}
.admin-row:first-child { border-top: 0; padding-top: 4px; }
.admin-row:last-child { padding-bottom: 4px; }

.row-title { font-weight: 600; color: var(--text); font-size: 14px; }
.row-sub { color: var(--text-mute); font-size: 12.5px; margin-top: 3px; }

/* ================================================================
   AGENT TOOLBAR / TABS / CONTROLS
   ================================================================ */

.toolbar {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--text-mute);
  border-radius: 5px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.tab:hover { color: var(--text-soft); }
.tab.active { background: var(--text); color: var(--bg); }

.search {
  flex: 1; min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash);
}

.controls {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.controls-inner {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.template {
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-soft);
  font-family: inherit;
  transition: all 0.12s;
}
.template:hover { background: var(--surface-alt); }
.template.active {
  border-color: var(--gold);
  background: var(--gold-wash);
  color: var(--gold);
  font-weight: 600;
}

.list-head {
  display: flex; justify-content: space-between;
  color: var(--text-mute);
  font-size: 12.5px;
  margin: 12px 0 14px;
}
.list-head strong { color: var(--text); font-weight: 600; }

/* ================================================================
   OWNER CARDS
   ================================================================ */

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.15s;
}
.card:hover { box-shadow: var(--shadow-strong); }

.card-top {
  display: flex; justify-content: space-between; gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.unit {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
}

.owner {
  font-size: 12.5px;
  color: var(--text-mute);
  margin-top: 4px;
}

.badge {
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}

.safety {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.safety.safe    { background: var(--success-bg); color: var(--success); }
.safety.verify  { background: var(--warn-bg);    color: var(--warn);    }
.safety.sold,
.safety.blocked { background: var(--danger-bg);  color: var(--danger);  }
.safety small {
  display: block; font-weight: 500; margin-top: 3px; opacity: 0.85;
}

.history {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.history-head {
  display: flex; justify-content: space-between; gap: 8px;
  background: var(--surface-alt);
  padding: 9px 12px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.history-row {
  display: grid; grid-template-columns: 84px 1fr 90px;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  align-items: center;
  color: var(--text);
}
.history-row strong { font-size: 12.5px; font-weight: 600; }
.history-row span { color: var(--text-mute); }
.history-empty {
  padding: 9px 12px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-mute);
}

.detail-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px; margin-bottom: 12px;
}
.metric {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.metric small {
  display: block;
  color: var(--text-mute);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.metric strong {
  display: block; margin-top: 4px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
}

.pipeline {
  color: var(--text-mute);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 12px;
}

.msg {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-soft);
  line-height: 1.55;
  font-size: 13px;
  min-height: 96px;
}

.last-contact {
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--gold-wash);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
}

.actions {
  display: flex; gap: 8px;
  margin-top: 12px;
}

.btn {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 9px 14px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-alt); }

.btn.wa {
  flex: 1;
  background: #1DA851; border-color: #1DA851; color: #fff;
}
.btn.wa:hover { background: #189A47; }

.btn.disabled {
  flex: 1;
  background: var(--surface-alt);
  color: var(--text-mute);
  cursor: not-allowed;
  border-color: var(--border);
}

.btn.blocked {
  flex: 1;
  background: var(--danger-bg);
  border-color: transparent;
  color: var(--danger);
  cursor: not-allowed;
}

.btn.danger {
  background: var(--danger-bg);
  border-color: transparent;
  color: var(--danger);
}
.btn.danger:hover { background: var(--danger-bg); opacity: 0.85; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  color: var(--text-mute);
  grid-column: 1/-1;
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--bg);
  border-radius: 99px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  box-shadow: var(--shadow-strong);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.pager {
  display: flex; justify-content: center; gap: 8px;
  margin: 18px 0; grid-column: 1/-1;
}
.pager button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  font-family: inherit;
}
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager span { align-self: center; color: var(--text-mute); font-size: 12.5px; }

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1100px) {
  .sidebar {
    width: 68px; padding: 16px 8px;
  }
  .side-brand { justify-content: center; border-bottom: none; padding-bottom: 16px; }
  .side-brand > div:last-child { display: none; }
  .nav-label { display: none; }
  .nav-item > span:nth-child(2),
  .nav-item > .nav-badge { display: none; }
  .data-engine { display: none; }
  .user-pill .user-meta { display: none; }
  .side-btn span:not(.ico) { display: none; }
  .topbar, .page { padding-left: 22px; padding-right: 22px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .topbar, .page { padding: 18px 16px; }
  .page { padding-bottom: 36px; }
  .hero { flex-direction: column; }
  h1 { font-size: 28px; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 24px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
  .grid { grid-template-columns: 1fr; }
  .admin-row { flex-direction: column; align-items: stretch; }
}