:root {
  --bg: #000000;
  --surface: #111114;
  --surface-2: #1b1b20;
  --border: #2a2a31;
  --text: #f5f5f7;
  --text-dim: rgba(245, 245, 247, 0.55);
  --text-faint: rgba(245, 245, 247, 0.3);
  --accent: #5e9eff;
  --accent-dim: rgba(94, 158, 255, 0.15);
  --green: #34c759;
  --orange: #ff9f0a;
  --yellow: #ffd60a;
  --red: #ff453a;
  --gray: #8e8e93;
  --radius: 14px;
  --maxw: 760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px 96px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 12px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }
.brand .tag { font-size: 11px; color: var(--text-faint); margin-top: 1px; }

/* Tabs */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  gap: 4px;
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
}
.tabbar button {
  flex: 1;
  max-width: 140px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  cursor: pointer;
}
.tabbar button .ic { font-size: 18px; }
.tabbar button.active { color: var(--accent); }

/* Sections / cards */
.section { margin-top: 22px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 0 0 10px 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: rgba(94, 158, 255, 0.15);
}

/* Search */
.search {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 15px;
  margin-top: 14px;
}
.search::placeholder { color: var(--text-faint); }

/* Category chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* Broker list */
.broker {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-top: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.broker:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 4px 20px rgba(94, 158, 255, 0.06);
  transform: translateY(-1px);
}
.broker .emoji { font-size: 22px; width: 30px; text-align: center; flex-shrink: 0; }
.broker .info { flex: 1; min-width: 0; }
.broker .name { font-size: 15px; font-weight: 600; }
.broker .meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.broker .chev { color: var(--text-faint); font-size: 18px; }

.pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}
.risk-critical { background: rgba(255, 69, 58, 0.16); color: var(--red); }
.risk-high { background: rgba(255, 159, 10, 0.16); color: var(--orange); }
.risk-medium { background: rgba(255, 214, 10, 0.14); color: var(--yellow); }
.risk-low { background: rgba(142, 142, 147, 0.18); color: var(--gray); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--accent);
  color: #06122b;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: rgba(255, 69, 58, 0.14); color: var(--red); }
.btn.ghost { background: none; color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* Form fields */
.field { margin-top: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 15px;
}
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; line-height: 1.4; }

/* Stats grid */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .num { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.stat .lbl { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Receipt rows */
.receipt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 10px;
}
.receipt .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.receipt .rname { font-size: 15px; font-weight: 600; }
.receipt .rmeta { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.status-pill { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 7px; white-space: nowrap; }
.st-pending { background: var(--accent-dim); color: var(--accent); }
.st-confirmed { background: rgba(52, 199, 89, 0.16); color: var(--green); }
.st-action { background: rgba(255, 159, 10, 0.16); color: var(--orange); }
.st-bad { background: rgba(255, 69, 58, 0.16); color: var(--red); }
.st-gray { background: rgba(142, 142, 147, 0.18); color: var(--gray); }
.receipt select { margin-top: 10px; width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; font-size: 13px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: var(--maxw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px 18px 28px;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
.modal h2 { margin: 4px 0 2px; font-size: 21px; }
.modal .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.modal-close { float: right; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); width: 30px; height: 30px; border-radius: 999px; font-size: 16px; cursor: pointer; }

.email-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  color: var(--text-dim);
}

.seg { display: flex; gap: 6px; margin-top: 12px; }
.seg button {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.seg button.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.notice {
  background: rgba(255, 159, 10, 0.1);
  border: 1px solid rgba(255, 159, 10, 0.3);
  color: var(--orange);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 13px;
  margin-top: 12px;
  line-height: 1.45;
}

.empty { text-align: center; color: var(--text-faint); padding: 50px 20px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }

.hero { text-align: center; padding: 30px 10px 6px; }
.hero .logo { width: 72px; height: 72px; border-radius: 17px; margin-bottom: 14px; }
.hero h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: -0.02em; }
.hero p { color: var(--text-dim); font-size: 15px; line-height: 1.5; margin: 0 auto; max-width: 420px; }

.foot { text-align: center; color: var(--text-faint); font-size: 11px; line-height: 1.5; margin-top: 30px; padding: 0 10px; }

.toast {
  position: fixed;
  bottom: 88px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.hidden { display: none !important; }

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--surface-2);
}

/* Responsive & Layout Redesign */
.sidebar {
  display: none;
}

@media (min-width: 768px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }
  .layout-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    background: var(--bg);
    overflow: hidden;
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    width: 280px;
    height: 100vh;
    background: rgba(17, 17, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 32px 24px;
    flex-shrink: 0;
  }
  .sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand img {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }
  .sidebar .brand h1 {
    font-size: 22px;
    margin: 0;
    letter-spacing: -0.03em;
    font-weight: 700;
  }
  .sidebar .brand .tag {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 2px;
  }
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 32px;
    flex: 1;
  }
  .sidebar-nav button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar-nav button:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
  }
  .sidebar-nav button.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: rgba(94, 158, 255, 0.3);
  }
  .sidebar-nav button .ic {
    font-size: 18px;
  }
  .sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }
  .privacy-lock {
    font-size: 12px;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .main-content {
    flex: 1;
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 40px 60px 80px;
  }
  .topbar {
    display: none !important;
  }
  .tabbar {
    display: none !important;
  }
  .app {
    max-width: 840px;
    margin: 0;
    padding: 0;
  }
  .toast {
    left: calc(50% + 140px);
    bottom: 40px;
  }
}

/* Landing & Onboarding Styles */
.landing-container {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 10px 0 40px;
}
.landing-hero {
  text-align: center;
  padding: 30px 10px 10px;
  max-width: 680px;
  margin: 0 auto;
}
.landing-title {
  font-size: 32px;
  line-height: 1.15;
  margin: 0 0 16px;
  letter-spacing: -0.03em;
  font-weight: 800;
}
@media (min-width: 600px) {
  .landing-title { font-size: 42px; }
}
.landing-subtitle {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}
.landing-main-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
@media (min-width: 768px) {
  .landing-main-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 32px;
    align-items: start;
    margin-top: 12px;
  }
}
.landing-left-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.landing-right-col {
  display: flex;
  flex-direction: column;
}
@media (max-width: 767px) {
  .landing-right-col {
    order: -1;
  }
}
.landing-feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.landing-feature-card:hover {
  border-color: rgba(94, 158, 255, 0.15);
}
.landing-feature-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0 6px;
  letter-spacing: -0.01em;
}
.landing-feature-card p {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}
.landing-icon {
  font-size: 24px;
}
.landing-setup-card {
  width: 100%;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.landing-setup-card h2 {
  font-size: 20px;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

