@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f0f2f5;
  --bg-subtle: #e8eaef;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-overlay: rgba(255, 255, 255, 0.88);

  --border: #dfe3ea;
  --border-soft: #eceff4;

  --text: #0f1419;
  --text-muted: #5c6570;
  --text-faint: #929aa5;

  --accent: #d1450f;
  --accent-dark: #b33a0c;
  --accent-darker: #8a2e0a;
  --accent-light: #fef0ea;
  --accent-ring: rgba(209, 69, 15, 0.2);

  --success: #15803d;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #ca8a04;
  --warning-light: #fef9c3;

  --nav-height: 3.5rem;

  --radius-xs: 0.25rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;

  --shadow-xs: 0 0.0625rem 0.125rem rgba(15, 20, 25, 0.04);
  --shadow-sm: 0 0.0625rem 0.1875rem rgba(15, 20, 25, 0.06), 0 0.0625rem 0.125rem rgba(15, 20, 25, 0.04);
  --shadow-md: 0 0.25rem 1rem rgba(15, 20, 25, 0.08), 0 0.125rem 0.375rem rgba(15, 20, 25, 0.04);
  --shadow-lg: 0 1.25rem 3rem rgba(15, 20, 25, 0.12), 0 0.5rem 1rem rgba(15, 20, 25, 0.06);
  --shadow-glow: 0 0 0 0.0625rem rgba(209, 69, 15, 0.08), 0 0.5rem 1.5rem rgba(209, 69, 15, 0.12);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Everything on the site is in rem now, which only actually becomes "responsive to different
   screens" if the root font-size itself moves -- otherwise 1rem is just a fixed 16px alias.
   This scales it fluidly with viewport width: 14px at a small phone (360px) up to today's
   unchanged 16px from a 1280px-wide viewport on up, so desktop looks exactly as it did before
   this pass and phones/tablets get everything (type, spacing, radii, shadows) shrinking
   together in proportion instead of just the handful of properties that had their own
   @media (max-width: ...) override. Written in px/vw, not rem, since the root's own font-size
   can't meaningfully reference rem (that's relative to itself). */
html { font-size: clamp(14px, 13.22px + 0.22vw, 16px); }

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Buttons ── */

.btn {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 0.0625rem solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.5625rem 1rem;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:hover { background: var(--bg); border-color: #c8ced8; }
.btn:active { transform: translateY(0.0625rem); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 0.1875rem var(--accent-ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0.0625rem 0.125rem rgba(209, 69, 15, 0.3);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #166534; border-color: #166534; }

.btn-ghost {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg-subtle); }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  border-radius: var(--radius-xs);
}
.btn-danger:hover { background: #b91c1c; }

/* ── Cards & inputs ── */

.card {
  background: var(--surface);
  border: 0.0625rem solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.field-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 0.0625rem solid var(--border);
  font-family: inherit;
  font-size: 0.84375rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 0.1875rem var(--accent-ring);
}

/* ── Navigation ── */

.top-nav {
  position: relative;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: var(--nav-height);
  background: var(--surface-overlay);
  backdrop-filter: blur(0.75rem);
  -webkit-backdrop-filter: blur(0.75rem);
  border-bottom: 0.0625rem solid var(--border-soft);
  box-shadow: var(--shadow-xs);
}
.top-nav-brand {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0.4375rem;
}
.top-nav-brand-icon {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: contain;
}
.top-nav a.nav-back,
.top-nav button.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.375rem 0.625rem;
  margin-left: -0.625rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}
.top-nav a.nav-back:hover,
.top-nav button.nav-back:hover {
  color: var(--accent);
  background: var(--accent-light);
}

/* ── Page shells ── */

.page-shell {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
}
.page-shell--gradient {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(209, 69, 15, 0.07), transparent),
    radial-gradient(circle at 15% 0%, rgba(209, 69, 15, 0.06), transparent 45%),
    var(--bg);
}
.page-body {
  flex: 1;
  width: 100%;
  max-width: 56.25rem;
  box-sizing: border-box;
  padding: 3rem 1.5rem;
}
.page-body--center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
}
.page-title {
  font-size: 2.625rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
  text-align: center;
  color: var(--text);
}
.page-subtitle {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Tile grid (home, analytics) ── */

.tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
}
.tile-grid--scroll {
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.625rem;
  margin: 0 -1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.tile-grid--scroll::-webkit-scrollbar { height: 0.5rem; }
.tile-grid--scroll::-webkit-scrollbar-track { background: transparent; }
.tile-grid--scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 62.4375rem; }
.tile-grid--scroll::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
.tile-grid--scroll .tile-card,
.tile-grid--scroll .view-card { flex-shrink: 0; }

.tile-card {
  width: 16.25rem;
  box-sizing: border-box;
  padding: 2rem 1.5rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.tile-card:hover {
  transform: translateY(-0.25rem);
  box-shadow: var(--shadow-glow);
  border-color: rgba(209, 69, 15, 0.2);
}
.tile-card-icon {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1.125rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-light) 0%, #fff5f0 100%);
  border: 0.0625rem solid rgba(209, 69, 15, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.625rem;
}
.tile-card-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}
.tile-card-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.tile-card--orange .tile-card-icon { background: #ffe3d3; border-color: transparent; }
.tile-card--orange:hover { border-color: #ffd0b3; background: #fff9f5; }

.tile-card--blue .tile-card-icon { background: #dbeafe; border-color: transparent; }
.tile-card--blue:hover { border-color: #bfdbfe; background: #f7fbff; }

.tile-card--purple .tile-card-icon { background: #ede9fe; border-color: transparent; }
.tile-card--purple:hover { border-color: #ddd6fe; background: #faf9ff; }

.tile-card--add {
  background: var(--bg);
  border: 0.09375rem dashed var(--border);
  box-shadow: none;
  color: var(--text-muted);
}
.tile-card--add:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  box-shadow: none;
}
.tile-card--add .tile-card-icon {
  background: var(--surface);
  border: 0.09375rem dashed var(--border);
  color: var(--text-muted);
  font-size: 1.375rem;
}
.tile-card--add:hover .tile-card-icon {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Home page ── */

.home-title {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 3.5rem 0 0.875rem;
  text-align: center;
  color: var(--text);
}
.home-tagline {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0 0 3.5rem;
  text-align: center;
  max-width: 26.25rem;
  line-height: 1.5;
}
.home-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  max-width: 62.5rem;
  padding: 0 1.5rem 4rem;
}
.home-card {
  width: 18.75rem;
  box-sizing: border-box;
  background: var(--surface);
  border: 0.0625rem solid var(--border-soft);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 2rem 1.75rem;
  text-align: left;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.home-card:hover {
  transform: translateY(-0.25rem);
  box-shadow: var(--shadow-glow);
}
.home-card-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.625rem;
  margin-bottom: 1.375rem;
}
.home-card-title {
  font-size: 1.1875rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}
.home-card-tag {
  font-size: 0.78125rem;
  font-weight: 700;
  margin-bottom: 0.875rem;
}
.home-card-desc {
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.home-card--blue .home-card-icon { background: #dbeafe; }
.home-card--blue .home-card-tag { color: #2563eb; }
.home-card--blue:hover { border-color: #bfdbfe; background: #f7fbff; }

.home-card--orange .home-card-icon { background: #ffe3d3; }
.home-card--orange .home-card-tag { color: #ea580c; }
.home-card--orange:hover { border-color: #ffd0b3; background: #fff9f5; }

.home-card--purple .home-card-icon { background: #ede9fe; }
.home-card--purple .home-card-tag { color: #7c3aed; }
.home-card--purple:hover { border-color: #ddd6fe; background: #faf9ff; }

.home-help-btn {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--surface);
  border: 0.0625rem solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.home-help-btn:hover { background: var(--bg); color: var(--text); }

/* ── Login page ── */

.login-page {
  margin: 0;
  height: 100vh;
  overflow: auto;
  position: relative;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(209, 69, 15, 0.09), transparent),
    radial-gradient(circle at 85% 90%, rgba(209, 69, 15, 0.06), transparent 45%),
    var(--bg);
}
.login-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0;
  width: 100%;
}
.login-logo {
  width: 7rem;
  max-width: 60vw;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 0.375rem 1rem rgba(0, 0, 0, 0.08));
}
.login-card {
  width: 23.75rem;
  max-width: 92vw;
  padding: 2.25rem 2rem;
}
.login-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0 0 0.375rem;
  text-align: center;
  letter-spacing: -0.02em;
}
.login-subtitle {
  font-size: 0.84375rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 1.75rem;
  line-height: 1.4;
}
.login-field { margin-bottom: 1.125rem; }
.login-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.login-error {
  display: none;
  font-size: 0.78125rem;
  color: var(--danger);
  background: var(--danger-light);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin: -0.25rem 0 1rem;
}
.login-error.visible { display: block; }
.login-submit {
  width: 100%;
  padding: 0.75rem 0;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ── Coming soon / empty states ── */

.empty-state-icon {
  width: 5rem;
  height: 5rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--accent-light) 0%, #fff5f0 100%);
  border: 0.0625rem solid rgba(209, 69, 15, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
}

/* ── Details pages (analytics datasets) ── */

.details-page {
  margin: 0;
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.details-page .top-nav { flex-shrink: 0; }

.details-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.details-sidebar {
  width: 18.75rem;
  min-width: 17.5rem;
  max-width: 20rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 0.0625rem solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
}

.sidebar-hero {
  padding: 1.75rem 1.5rem 1.25rem;
  background: linear-gradient(160deg, var(--accent-light) 0%, #fff 55%);
  border-bottom: 0.0625rem solid var(--border-soft);
}
.sidebar-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 0.0625rem solid rgba(209, 69, 15, 0.15);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  margin-bottom: 0.875rem;
}
.meta-title {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 0.75rem;
  word-break: break-word;
  line-height: 1.2;
  color: var(--text);
}
.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.71875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.8);
  border: 0.0625rem solid var(--border-soft);
  border-radius: 62.4375rem;
  padding: 0.25rem 0.625rem;
}
.meta-badge-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.meta-box {
  padding: 1.25rem 1.5rem;
  border-bottom: 0.0625rem solid var(--border-soft);
  font-size: 0.8125rem;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
  line-height: 1.4;
}
.meta-row:last-child { margin-bottom: 0; }
.meta-label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.78125rem;
  flex-shrink: 0;
}
.meta-value {
  font-weight: 600;
  font-size: 0.78125rem;
  text-align: right;
}

.description-box {
  padding: 1.25rem 1.5rem 1.75rem;
  flex: 1;
  font-size: 0.8125rem;
}
.description-label {
  font-weight: 700;
  margin-bottom: 0.625rem;
  font-size: 0.65625rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.description-text {
  line-height: 1.7;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.details-view {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.75rem;
  box-sizing: border-box;
  min-width: 0;
}

.details-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}
.details-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}
.details-table-title {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}
.record-count-badge {
  font-size: 0.71875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 0.0625rem solid var(--border-soft);
  border-radius: 62.4375rem;
  padding: 0.1875rem 0.625rem;
  white-space: nowrap;
}

.details-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  flex-shrink: 0;
  font-size: 0.78125rem;
  padding: 0.5rem 0.875rem;
}
.details-expand-btn svg {
  width: 0.875rem;
  height: 0.875rem;
  opacity: 0.7;
}

.details-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
#filterBuilderBtn.active {
  color: var(--accent);
  border-color: rgba(209, 69, 15, 0.3);
  background: var(--accent-light);
}

/* ── Filter Builder modal ── */

.filter-condition-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.filter-condition-row select {
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  border: 0.0625rem solid var(--border);
  font-family: inherit;
  font-size: 0.8125rem;
  background: var(--surface);
  color: var(--text);
}
.filter-connector-select {
  width: 5.25rem;
  flex-shrink: 0;
  font-weight: 700;
  color: var(--accent);
  padding-right: 0.375rem;
}
.filter-condition-row:first-child .filter-connector-select { visibility: hidden; }
.filter-column-select {
  flex: 1;
  min-width: 0;
}
.filter-operator-select {
  width: 5.75rem;
  flex-shrink: 0;
}
.filter-value-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex: 1;
  min-width: 0;
}
.filter-value-select { flex: 1; min-width: 0; }
.filter-value-from-select, .filter-value-to-select { display: none; flex: 1; min-width: 0; }
.filter-between-sep { display: none; font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0; }
.filter-condition-row.operator-between .filter-value-select { display: none; }
.filter-condition-row.operator-between .filter-value-from-select,
.filter-condition-row.operator-between .filter-value-to-select,
.filter-condition-row.operator-between .filter-between-sep { display: inline-block; }
.filter-row-remove-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: var(--radius-xs);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.filter-row-remove-btn:hover { background: var(--danger-light); color: var(--danger); }
.filter-add-condition-btn {
  margin-top: 0.25rem;
  color: var(--accent);
  font-weight: 600;
}
.filter-add-condition-btn:hover { color: var(--accent-dark); }

.table-card {
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 0.0625rem solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.table-scroll {
  flex: 1;
  overflow: auto;
}

.data-table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
}
.data-table th,
.data-table td {
  border-bottom: 0.0625rem solid var(--border-soft);
  padding: 0.8125rem 1.125rem;
  text-align: left;
  font-size: 0.8125rem;
  vertical-align: middle;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f6f7f9;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  box-shadow: 0 0.0625rem 0 var(--border-soft);
}
.data-table tbody tr { transition: background 0.1s var(--ease); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(209, 69, 15, 0.035); }

.col-address { min-width: 17.5rem; max-width: 22.5rem; }
.col-numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table th.col-numeric { text-align: right; }

.cell-address {
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
}
.cell-address-icon {
  display: inline-block;
  margin-right: 0.375rem;
  opacity: 0.45;
  font-size: 0.75rem;
}

.cell-calls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  width: 100%;
}
.calls-bar-wrap {
  width: 3rem;
  height: 0.3125rem;
  background: var(--bg-subtle);
  border-radius: 62.4375rem;
  overflow: hidden;
  flex-shrink: 0;
}
.calls-bar {
  height: 100%;
  border-radius: 62.4375rem;
  background: var(--accent);
  opacity: 0.7;
}
.calls-num {
  font-weight: 700;
  font-size: 0.84375rem;
  min-width: 1.125rem;
  text-align: right;
}
.calls-num--high { color: var(--accent); }
.calls-num--med { color: #b45309; }
.calls-num--low { color: var(--text-muted); }

.tag {
  display: inline-block;
  font-size: 0.71875rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: 62.4375rem;
  white-space: nowrap;
  line-height: 1.3;
}
.tag--traffic { background: #dbeafe; color: #1d4ed8; }
.tag--medical { background: #fee2e2; color: #b91c1c; }
.tag--chest { background: #ffedd5; color: #c2410c; }
.tag--breathing { background: #ede9fe; color: #6d28d9; }
.tag--lift { background: #ccfbf1; color: #0f766e; }
.tag--welfare { background: #f3f4f6; color: #4b5563; }
.tag--fire { background: #fef3c7; color: #b45309; }
.tag--default { background: var(--bg); color: var(--text-muted); border: 0.0625rem solid var(--border-soft); }

.cell-sqft {
  color: var(--text-muted);
  font-weight: 500;
}

.page-subtitle--center {
  text-align: center;
  margin-bottom: 2.25rem;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 2.5rem 0 1rem;
}
.section-title:first-of-type { margin-top: 0; }

.empty-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 3rem 1.5rem;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.0625rem dashed var(--border);
  margin: auto;
  max-width: 25rem;
}

/* Full-screen editing overlay */
.fullscreen-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--surface);
  z-index: 20;
  flex-direction: column;
  padding: 1.75rem 2rem;
  box-sizing: border-box;
  overflow: auto;
}
.fullscreen-overlay.open { display: flex; }

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 0.0625rem solid var(--border-soft);
}
.overlay-header h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.header-actions { display: flex; gap: 0.5rem; align-items: center; }

td[contenteditable="true"] {
  background: var(--warning-light);
  outline: 0.125rem solid var(--warning);
  outline-offset: -0.125rem;
  border-radius: 0.125rem;
}

.row-action-col,
.row-action-cell {
  border: none;
  background: transparent;
  width: 2.25rem;
  padding: 0.25rem;
}
.row-delete-btn {
  display: none;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  width: 1.625rem;
  height: 1.625rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font-size: 0.8125rem;
  transition: background 0.15s var(--ease);
}
.row-delete-btn:hover { background: #b91c1c; }
tbody.editing .row-delete-btn { display: inline-flex; align-items: center; justify-content: center; }

.overlay-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.625rem;
  padding-top: 1rem;
  border-top: 0.0625rem solid var(--border-soft);
}

.overlay-actions .edit-btn,
.header-actions .edit-btn,
.overlay-actions .save-btn,
.header-actions .save-btn,
.overlay-actions .add-row-btn,
.header-actions .close-btn {
  padding: 0.5625rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.edit-btn { background: var(--accent); color: #fff; }
.edit-btn:hover { background: var(--accent-dark); }
.save-btn { background: var(--success); color: #fff; }
.save-btn:hover { background: #166534; }
.add-row-btn { background: var(--bg); color: var(--text); border: 0.0625rem solid var(--border) !important; }
.add-row-btn:hover { background: var(--bg-subtle); }
.close-btn { background: var(--bg); color: var(--text); border: 0.0625rem solid var(--border) !important; }
.close-btn:hover { background: var(--bg-subtle); }

/* ── Saved Data Views ── */

.view-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}
.view-card {
  width: 16.25rem;
  box-sizing: border-box;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}
.view-card:hover {
  transform: translateY(-0.1875rem);
  box-shadow: var(--shadow-glow);
  border-color: rgba(209, 69, 15, 0.2);
}
.view-card-thumb {
  width: 100%;
  height: 8.75rem;
  object-fit: cover;
  display: block;
  background: var(--bg);
  border-bottom: 0.0625rem solid var(--border-soft);
}
.view-card-icon-area {
  width: 100%;
  height: 8.75rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 0.0625rem solid var(--border-soft);
}
.view-card-icon-area--purple { background: #ede9fe; }
.view-card-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  color: #7c3aed;
  box-shadow: var(--shadow-sm);
}
.view-card-body {
  padding: 0.875rem 1rem;
}
.view-card-title {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
  word-break: break-word;
}
.view-card-meta {
  font-size: 0.71875rem;
  color: var(--text-muted);
}
.view-card-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  border: none;
  background: rgba(15, 20, 25, 0.55);
  color: #fff;
  font-size: 0.8125rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s var(--ease);
}
.view-card-delete:hover { background: var(--danger); }

/* ── Modals ── */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 20, 25, 0.5);
  backdrop-filter: blur(0.25rem);
  -webkit-backdrop-filter: blur(0.25rem);
  z-index: 10;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 25rem;
  max-width: 100%;
  font-family: inherit;
  overflow: hidden;
  border: 0.0625rem solid var(--border-soft);
  animation: modal-in 0.2s var(--ease);
}
.filter-builder-modal { width: 40rem; }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(0.5rem); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.375rem;
  border-bottom: 0.0625rem solid var(--border-soft);
  background: #fafbfc;
}
.modal-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-xs);
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.modal-close-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.modal-body {
  padding: 1.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.modal-footer {
  padding: 1rem 1.375rem;
  border-top: 0.0625rem solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: #fafbfc;
}

.modal-body label {
  font-size: 0.71875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.modal-body input[type="text"] {
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 0.0625rem solid var(--border);
  font-family: inherit;
  font-size: 0.8125rem;
  box-sizing: border-box;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.modal-body input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 0.1875rem var(--accent-ring);
}
.modal-body input[type="file"] {
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 0.5rem 0;
}

@media (max-width: 56.25rem) {
  .details-layout { flex-direction: column; }
  .details-sidebar {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex-shrink: 0;
    max-height: 40vh;
  }
  .details-view { padding: 1rem; }
}
