/* App UI styles aligned to the marketing look. */
:root {
  /* Default (light) theme matches the marketing demo dashboards */
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --brand: #5eead4;
  --brand-700: #14b8a6;
  --on-brand: #00130f;
  --border: #e2e8f0;
  --danger: #ff5a6b;
  --success: #2dd4bf;
  --radius: 16px;
  --container: 1040px;
  --pad: 16px;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Manrope", system-ui, sans-serif;
  --shadow-soft: 0 18px 50px rgba(2, 6, 23, 0.10);

  --body-bg: var(--bg);
  --header-bg: rgba(255, 255, 255, 0.9);
  --field-bg: #ffffff;
  --field-bg-muted: rgba(15, 23, 42, 0.03);
  --placeholder: rgba(71, 85, 105, 0.45);

  --brand-soft: rgba(20, 184, 166, 0.10);
  --overlay: rgba(15, 23, 42, 0.55);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--body-bg);
  color: var(--text);
  font: 16px/1.6 var(--font-body);
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.brand a { text-decoration: none; }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--header-bg);
  backdrop-filter: saturate(140%) blur(8px);
  z-index: 100;
}

.impersonation-banner {
  background: rgba(252, 211, 77, 0.3);
  border-bottom: 1px solid rgba(252, 211, 77, 0.5);
  color: #3f2d06;
}

.impersonation-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: 1.1rem;
}

.brand .dot { color: var(--brand); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-quick {
  display: none;
  align-items: center;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--field-bg-muted);
  color: var(--muted);
  font-size: 0.85rem;
}

main {
  padding: 20px 0 56px;
  animation: fadeUp 0.35s ease;
}

h1 { font-size: 1.8rem; margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 22px 0 10px; }

p { margin: 10px 0; }
.muted { color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.activity-card {
  padding: 0;
}

.activity-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.activity-card > summary::-webkit-details-marker { display: none; }

.activity-card[open] > summary {
  border-bottom: 1px solid var(--border);
}

.activity-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  min-width: 0;
}

.activity-summary .activity-title {
  font-weight: 650;
}

.activity-summary .activity-time {
  margin-left: auto;
}

.activity-chevron {
  font-weight: 700;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.activity-card[open] .activity-chevron {
  transform: rotate(180deg);
}

.activity-body {
  padding: 0 18px 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
  min-height: 44px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.btn:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }

.btn.primary {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: var(--on-brand);
}

.btn.primary:hover { filter: brightness(1.05); }

.btn.ghost {
  background: transparent;
}

.btn.active {
  border-color: var(--brand-700);
  background: var(--brand-soft);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

.kpi {
  padding: 16px;
}

.kpi .label {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.kpi .value {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

.kpi .meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
  background: var(--field-bg-muted);
  color: var(--muted);
}

.badge.brand {
  border-color: rgba(20, 184, 166, 0.35);
  color: var(--brand);
  background: rgba(20, 184, 166, 0.10);
}

.badge.success {
  border-color: rgba(45, 212, 191, 0.35);
  color: var(--success);
  background: rgba(45, 212, 191, 0.10);
}

.badge.danger {
  border-color: rgba(255, 90, 107, 0.35);
  color: var(--danger);
  background: rgba(255, 90, 107, 0.10);
}

.badge.muted {
  border-color: rgba(163, 181, 195, 0.22);
  color: var(--muted);
  background: rgba(163, 181, 195, 0.06);
}

form { margin: 0; }
label { display: block; font-weight: 650; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--field-bg);
  color: var(--text);
  min-height: 44px;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: var(--brand-700);
}

input::placeholder, textarea::placeholder { color: var(--placeholder); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.row.one {
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .row { grid-template-columns: repeat(2, 1fr); }
  .row.one { grid-template-columns: 1fr; }
}

.field > .hint {
  margin-top: 6px;
  font-weight: 450;
  color: var(--muted);
  font-size: 0.9rem;
}

.spacer { height: 12px; }

.alert {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--field-bg-muted);
}

.alert.error { border-color: rgba(255, 90, 107, 0.35); color: var(--danger); }
.alert.success { border-color: rgba(45, 212, 191, 0.35); color: var(--success); }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  overflow-x: auto;
}

/* Minimal install modal */
.cc-modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
  background: var(--overlay);
  z-index: 1000;
}

.cc-modal-backdrop.show { display: flex; }

.cc-modal {
  width: min(480px, 100%);
}

.table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: transparent;
}

.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table tr.missing-price td {
  background: rgba(255, 90, 107, 0.06);
}

.table th { color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.table tr:last-child td { border-bottom: none; }

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.pager-label {
  color: var(--muted);
  font-weight: 600;
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: var(--header-bg);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(10px);
  z-index: 120;
}

.mobile-bottom-nav .nav-items {
  display: flex;
  gap: 10px;
}

.mobile-bottom-nav .nav-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 14px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.mobile-bottom-nav .nav-item.active {
  color: var(--text);
  border-color: rgba(20, 184, 166, 0.35);
  background: var(--brand-soft);
}

.mobile-bottom-nav button.nav-item {
  font: inherit;
}

.nav-sheet .nav-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.nav-sheet .nav-sheet-links {
  display: grid;
  gap: 8px;
}

.nav-sheet .btn,
.nav-sheet form {
  width: 100%;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  main { padding: 16px 0 44px; }
  body.has-bottom-nav main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  .nav {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-links {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  body.has-bottom-nav .nav-links { display: none; }
  body.has-bottom-nav .nav-quick { display: flex; }

  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links > * { flex: 0 0 auto; }

  .btn { width: 100%; }
  .nav-links .btn { width: auto; }
  .nav-quick .btn { width: auto; }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .page-actions form input,
  .page-actions form select {
    width: 100% !important;
    min-width: 0;
  }

  .activity-summary .activity-time {
    width: 100%;
    margin-left: 0;
  }

  .pager {
    flex-direction: column;
    align-items: stretch;
  }

  .mobile-bottom-nav { display: block; }

  .table { min-width: 0; }
  .table thead { display: none; }
  .table tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .table td {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 6px 0;
    border: none;
  }
  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
  }
  .table td:last-child { padding-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .site-header { display: none; }
  .btn, .pill { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; }
  .card { background: #fff; border-color: #ddd; }
  .table-wrap { background: #fff; border-color: #ddd; }
  .table { min-width: 0; }
  .table thead { display: table-header-group; }
  .table tr { display: table-row; padding: 0; border-bottom: 1px solid #ddd; }
  .table td { display: table-cell; padding: 10px 12px; border-bottom: 1px solid #ddd; }
  .table td::before { content: none; }
  .table th { color: #333; }
  a { text-decoration: none; }
}
