* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background: #070503;
  color: #E8E0D4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
#app { height: 100%; display: flex; flex-direction: column; }
.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ── Login ── */
#screen-login {
  align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at center, rgba(212,170,80,0.06) 0%, transparent 70%);
}
.login-box {
  width: 100%; max-width: 380px;
  text-align: center;
}
.login-logo {
  font-family: 'Outfit', serif;
  font-size: 30px; font-weight: 300;
  color: #D4AA50;
  letter-spacing: 4px;
  margin-bottom: 4px;
}
.login-greeting {
  font-size: 14px;
  color: #6B6355;
  letter-spacing: 0.3px;
  margin-top: 8px;
  font-weight: 300;
}
.login-sub {
  font-size: 15px;
  color: #9B8F77;
  margin-bottom: 28px;
  font-weight: 300;
}
.login-form { text-align: left; }
.field-label {
  font-size: 12px;
  color: #6B6355;
  margin-bottom: 6px;
  display: block;
  font-weight: 400;
}
.login-link-row {
  display: flex;
  margin-bottom: 14px;
  border: 1px solid rgba(212,170,80,0.12);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.login-link-row:focus-within { border-color: rgba(212,170,80,0.3); }
.login-prefix {
  padding: 12px 0 12px 14px;
  font-size: 14px;
  color: #D4AA50;
  background: rgba(255,255,255,0.02);
  white-space: nowrap;
  display: flex;
  align-items: center;
  font-family: monospace;
}
.login-link-row .login-input {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  padding-left: 6px;
  background: transparent;
}
.login-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(212,170,80,0.12);
  border-radius: 12px;
  color: #E8E0D4;
  font-size: 15px;
  font-family: 'Outfit', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 14px;
  -webkit-appearance: none;
}
.login-input:focus { border-color: rgba(212,170,80,0.3); }
.login-input::placeholder { color: #6B6355; }
.login-error {
  font-size: 12px;
  color: #e74c3c;
  display: none;
  margin-bottom: 10px;
  font-weight: 400;
}
.login-error.visible { display: block; animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

.btn-gold {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #9C7A23, #D4AA50, #F1C463);
  border: none;
  border-radius: 12px;
  color: #070503;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  -webkit-appearance: none;
}


.login-footer { margin-top: 20px; }
.login-footer a {
  color: #6B6355;
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}
.login-footer a:hover { color: #D4AA50; }

/* ── Top Bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(7,5,3,0.92);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  flex-shrink: 0;
  min-height: 46px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.topbar-brand {
  font-size: 14px;
  font-weight: 600;
  color: #D4AA50;
  flex-shrink: 0;
  letter-spacing: 1px;
}
.topbar-sep {
  width: 1px;
  height: 12px;
  background: rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.topbar-agency {
  font-size: 14px;
  font-weight: 400;
  color: #E8E0D4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.topbar-usage {
  font-size: 11px;
  color: #6B6355;
  margin-right: 4px;
  white-space: nowrap;
}
.topbar-btn {
  background: transparent;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  color: #9B8F77;
}
.topbar-btn:hover { background: rgba(255,255,255,0.04); color: #E8E0D4; }
.topbar-btn-logout {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
  gap: 0;
}

/* ── Filters ── */
.filters {
  display: flex;
  align-items: center;
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 0;
}
.filter-btn {
  background: transparent;
  border: none;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  color: #6B6355;
  cursor: pointer;
  padding: 4px 0;
  font-weight: 400;
  transition: color 0.15s;
  white-space: nowrap;
}
.filter-btn:hover { color: #9B8F77; }
.filter-btn.active { color: #D4AA50; font-weight: 500; }
.filter-count {
  font-size: 12px;
  font-weight: 300;
  color: inherit;
  opacity: 0.5;
  margin-left: 1px;
}
.filter-dot {
  color: rgba(255,255,255,0.06);
  margin: 0 10px;
  font-size: 14px;
}

/* ── Feed ── */
.feed {
  flex: 1;
  overflow-y: auto;
  padding: 6px 14px;
  -webkit-overflow-scrolling: touch;
}
.feed::-webkit-scrollbar { width: 3px; }
.feed::-webkit-scrollbar-track { background: transparent; }
.feed::-webkit-scrollbar-thumb { background: rgba(212,170,80,0.1); border-radius: 2px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  display: none;
}
.empty-icon { font-size: 48px; opacity: 0.25; }
.empty-text { font-size: 14px; color: #6B6355; max-width: 260px; line-height: 1.5; font-weight: 300; }
.empty-link { font-size: 12px; color: rgba(212,170,50,0.3); word-break: break-all; font-family: monospace; }

/* Lead row */
.lead-row {
  padding: 12px 0;
  cursor: pointer;
  transition: background 0.1s;
  margin: 0 -14px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  animation: feedIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.lead-row:last-child { border-bottom: none; }
.lead-row:hover { background: rgba(255,255,255,0.015); }
.lr-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}
.lr-name {
  font-size: 15px;
  font-weight: 500;
  color: #D4AA50;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lr-badge {
  font-size: 11px;
  font-weight: 400;
  flex-shrink: 0;
  margin-left: 8px;
}
.lr-badge.HOT { color: #e74c3c; }
.lr-badge.WARM { color: #f1c40f; }
.lr-badge.COLD { color: #3498db; }
.lr-summary {
  font-size: 14px;
  color: #B0A898;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 3px;
}
.lr-time {
  font-size: 11px;
  color: rgba(255,255,255,0.12);
}

/* System notification row */
.sys-row {
  padding: 12px 14px;
  margin: 0 -14px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  animation: feedIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.sys-row .sys-summary {
  font-size: 13px;
  color: #6B6355;
  line-height: 1.4;
}
.sys-row .sys-time {
  font-size: 11px;
  color: rgba(255,255,255,0.06);
  margin-top: 2px;
}

/* Expanded lead details */
.lr-expand {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.03);
}
.lead-row.expanded { background: rgba(212,170,80,0.02); }
.lead-row.expanded .lr-expand { display: block; }
.lead-row.expanded .lr-summary { -webkit-line-clamp: unset; }
.lr-expand .lr-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
}
.lr-expand .lr-detail .lr-label { color: #6B6355; font-weight: 300; }
.lr-expand .lr-detail .lr-value { color: #E8E0D4; text-align: right; }

@keyframes feedIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── Search Bar ── */
.search-bar {
  padding: 6px 14px 10px;
  flex-shrink: 0;
}
.search-wrap {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  padding: 0 10px;
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.search-wrap:focus-within {
  border-color: rgba(212,170,80,0.08);
  background: rgba(255,255,255,0.03);
}
.search-icon {
  color: #6B6355;
  font-size: 13px;
  margin-right: 6px;
  flex-shrink: 0;
  opacity: 0.5;
}
.search-input {
  width: 100%;
  padding: 8px 0;
  background: transparent;
  border: none;
  color: #E8E0D4;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  outline: none;
  font-weight: 300;
}
.search-input::placeholder { color: #6B6355; }

/* ── Modal (Settings sheet) ── */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 100; }
.modal.open { display: block; }
.modal-backdrop {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
}
.modal-sheet {
  position: absolute; bottom: 0; left: 0; width: 100%;
  max-height: 85vh;
  background: #0F0D09;
  border-radius: 20px 20px 0 0;
  animation: sheetUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 32px; height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  margin: 8px auto 0;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 0;
}
.modal-title { font-size: 16px; font-weight: 500; color: #E8E0D4; }
.modal-close {
  background: none; border: none;
  color: #6B6355; font-size: 18px;
  cursor: pointer; padding: 4px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.modal-close:hover { background: rgba(255,255,255,0.04); }
.modal-body {
  padding: 20px 20px 28px;
  overflow-y: auto;
  max-height: 75vh;
}



/* ── Responsive ── */
@media (min-width: 640px) {
  .login-box { max-width: 400px; }
  .feed { max-width: 640px; margin: 0 auto; width: 100%; }
  .filters { justify-content: center; }
  .search-bar { max-width: 640px; margin: 0 auto; width: 100%; }
  .modal-sheet { max-width: 420px; left: 50%; transform: translateX(-50%); border-radius: 20px; bottom: auto; top: 50%; transform: translate(-50%, -50%); max-height: 70vh; }
  @keyframes sheetUp { from { transform: translate(-50%, -50%) scale(0.95); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
}
@media (max-width: 480px) {
  .login-box { max-width: 100%; }
  .topbar { padding: 6px 10px; min-height: 42px; }
  .topbar-agency { font-size: 13px; }
  .topbar-brand { font-size: 13px; }
  .topbar-btn { width: 30px; height: 30px; font-size: 14px; }
  .topbar-btn-logout { width: auto; padding: 0 8px; font-size: 11px; }
  .filters { padding: 8px 10px; }
  .filter-btn { font-size: 12px; }
  .feed { padding: 4px 10px; }
  .lead-row { padding: 10px 10px; margin: 0 -10px; }
  .lr-name { font-size: 14px; }
  .lr-summary { font-size: 13px; }
  .search-bar { padding: 4px 10px 8px; }
  .modal-body { padding: 16px 16px 24px; }
}

/* ── Settings Page shell ── */
.settings-page { height: 100vh; display: flex; flex-direction: column; background: #070503; }
.settings-topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid rgba(255,255,255,0.03); flex-shrink: 0; min-height: 46px; }
.settings-back { color: #D4AA50; text-decoration: none; font-size: 14px; font-weight: 400; }
.settings-title { font-size: 15px; font-weight: 500; color: #E8E0D4; }
.settings-body { flex: 1; overflow-y: auto; padding: 16px 14px; -webkit-overflow-scrolling: touch; }
.settings-footer-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid rgba(255,255,255,0.03); flex-shrink: 0; }
.settings-save-msg { font-size: 11px; color: #6B6355; }
