:root {
  --df-bg: #f3f6f8;
  --df-surface: #ffffff;
  --df-text: #14212b;
  --df-muted: #5b6b78;
  --df-primary: #0f766e;
  --df-primary-dark: #0b5f59;
  --df-border: #d7e0e7;
  --df-shadow: 0 10px 30px rgba(20, 33, 43, 0.06);
  --df-radius: 16px;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --font-sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --df-bg: #0f1419;
    --df-surface: #182128;
    --df-text: #e8eef3;
    --df-muted: #9aa8b5;
    --df-border: #2a3640;
    --df-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: radial-gradient(circle at top left, #dff5f1 0%, var(--df-bg) 42%);
  color: var(--df-text);
  min-height: 100vh;
}

a { color: var(--df-primary); text-decoration: none; }
a:hover { color: var(--df-primary-dark); }

.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #14b8a6, #0f766e);
  color: #fff; font-weight: 700; letter-spacing: 0.02em;
}

.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--df-surface);
  border-right: 1px solid var(--df-border);
  padding: 1.25rem 1rem;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.5rem; }
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-sub { color: var(--df-muted); font-size: 0.75rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-nav .nav-link {
  color: var(--df-text); border-radius: 10px; padding: 0.65rem 0.85rem;
}
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active {
  background: rgba(15, 118, 110, 0.1); color: var(--df-primary);
}
.nav-section {
  margin: 1rem 0 0.35rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--df-muted); padding-left: 0.85rem;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; border-bottom: 1px solid var(--df-border);
  background: rgba(255,255,255,0.75); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 1.15rem; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.app-content { padding: 1.25rem; padding-bottom: 5rem; }

.panel, .kpi-card, .entity-card, .auth-card, .offline-card, .error-card {
  background: var(--df-surface);
  border: 1px solid var(--df-border);
  border-radius: var(--df-radius);
  box-shadow: var(--df-shadow);
}
.panel { padding: 1.1rem 1.2rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.panel-header h2 { font-size: 1.05rem; margin: 0; }

.kpi-grid {
  display: grid; gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.kpi-card { padding: 1rem 1.1rem; }
.kpi-label { color: var(--df-muted); font-size: 0.8rem; margin-bottom: 0.35rem; }
.kpi-value { font-size: 1.35rem; font-weight: 700; }

.card-stack { display: grid; gap: 0.75rem; }
.entity-card { display: block; padding: 1rem; color: inherit; }
.deal-card h3 { font-size: 1.05rem; margin: 0.35rem 0; }
.deal-score { font-weight: 700; color: var(--df-primary); }
.deal-price { font-size: 1.4rem; font-weight: 700; margin: 0.5rem 0; }
.deal-meta { display: grid; gap: 0.35rem; margin: 0; }
.deal-meta div { display: flex; justify-content: space-between; gap: 1rem; }
.deal-meta dt { color: var(--df-muted); font-weight: 500; }
.deal-meta dd { margin: 0; font-weight: 600; }

.detail-grid {
  display: grid; gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.detail-grid .label, .score-box .label { display: block; color: var(--df-muted); font-size: 0.8rem; margin-bottom: 0.2rem; }
.score-row { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.score-box { padding: 0.85rem; border: 1px solid var(--df-border); border-radius: 12px; background: rgba(15,118,110,0.04); }

.settings-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.settings-block { padding: 1rem; border: 1px solid var(--df-border); border-radius: 12px; }
.settings-block h3 { font-size: 0.95rem; margin-bottom: 0.75rem; }

.btn-primary { background: var(--df-primary); border-color: var(--df-primary); }
.btn-primary:hover { background: var(--df-primary-dark); border-color: var(--df-primary-dark); }
.btn-outline-primary { color: var(--df-primary); border-color: var(--df-primary); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--df-surface); border-top: 1px solid var(--df-border);
  padding: 0.45rem 0.25rem calc(0.45rem + env(safe-area-inset-bottom));
}
.bottom-nav a {
  text-align: center; color: var(--df-muted); font-size: 0.75rem; padding: 0.35rem;
}
.bottom-nav a.active { color: var(--df-primary); font-weight: 700; }

.mobile-nav-list { display: flex; flex-direction: column; gap: 0.35rem; }
.mobile-nav-list a { padding: 0.7rem 0.5rem; border-radius: 8px; color: var(--df-text); }
.mobile-nav-list a:hover { background: rgba(15,118,110,0.08); }

.auth-body, .offline-body {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(20,184,166,0.18), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(15,118,110,0.12), transparent 35%),
    var(--df-bg);
}
.auth-card, .offline-card, .error-card { width: min(420px, 100%); padding: 1.75rem; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand h1 { font-size: 1.6rem; margin: 0.75rem 0 0.25rem; }
.auth-brand p { color: var(--df-muted); margin: 0; }
.offline-card, .error-card { text-align: center; }
.error-wrap { min-height: 70vh; display: grid; place-items: center; padding: 1.5rem; }
.mw-420 { max-width: 420px; }

.pwa-update-banner {
  position: fixed; left: 50%; bottom: 4.5rem; transform: translateX(-50%);
  z-index: 50; background: #14212b; color: #fff; border-radius: 999px;
  padding: 0.65rem 0.85rem; display: flex; align-items: center; gap: 0.35rem;
  box-shadow: var(--df-shadow); width: max-content; max-width: calc(100% - 2rem);
}
.demo-banner { border-radius: 12px; }

@media (min-width: 992px) {
  .app-content { padding: 1.5rem 1.75rem 2rem; }
  .bottom-nav { display: none !important; }
  .pwa-update-banner { bottom: 1.5rem; }
}
