/* ============================================================================
   Kovac Property Command Center — design overhaul + mobile layer
   Loaded AFTER the Vite bundle CSS; restyles the compiled app via the
   shadcn/ui CSS-variable tokens plus a small set of surgical selectors.

   Direction: dense, calm, scannable finance ops tool ("forest ledger").
   Brand-aligned deep pine sidebar, emerald primary, warm paper canvas,
   Space Grotesk display numerals. Light + dark themes both remapped.
   ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&display=swap");

/* ── 1. Theme tokens ─────────────────────────────────────────────────────── */
:root {
  --background: 45 25% 97%;
  --foreground: 165 25% 10%;
  --card: 0 0% 100%;
  --card-foreground: 165 25% 10%;
  --popover: 0 0% 100%;
  --popover-foreground: 165 25% 10%;
  --primary: 160 65% 26%;
  --primary-foreground: 0 0% 100%;
  --secondary: 150 12% 91%;
  --secondary-foreground: 165 25% 12%;
  --muted: 48 14% 93%;
  --muted-foreground: 180 8% 40%;
  --accent: 158 45% 92%;
  --accent-foreground: 160 70% 20%;
  --border: 45 12% 86%;
  --input: 45 12% 84%;
  --ring: 160 65% 30%;
  --success: 152 68% 27%;
  --success-bg: 150 60% 93%;
  --warning: 36 92% 42%;
  --warning-bg: 45 96% 89%;
  --info: 210 80% 42%;
  --info-bg: 210 80% 94%;
  --radius: 0.55rem;
}

.dark {
  --background: 168 24% 7%;
  --foreground: 100 12% 94%;
  --card: 166 20% 10%;
  --card-foreground: 100 12% 94%;
  --popover: 166 20% 10%;
  --popover-foreground: 100 12% 94%;
  --primary: 155 55% 52%;
  --primary-foreground: 168 30% 8%;
  --secondary: 165 15% 16%;
  --secondary-foreground: 100 12% 94%;
  --muted: 165 15% 14%;
  --muted-foreground: 150 8% 62%;
  --accent: 160 40% 17%;
  --accent-foreground: 150 55% 75%;
  --border: 163 14% 18%;
  --input: 163 14% 20%;
  --ring: 155 55% 52%;
}

/* ── 2. Command sidebar — deep pine, both themes ─────────────────────────── */
/* Every Tailwind utility inside <aside> resolves against these values.      */
aside.border-r {
  --card: 168 32% 9%;
  --card-foreground: 90 15% 95%;
  --foreground: 90 15% 95%;
  --muted: 163 24% 15%;
  --muted-foreground: 150 9% 62%;
  --accent: 159 48% 17%;
  --accent-foreground: 145 55% 74%;
  --border: 163 22% 16%;
  --primary: 150 60% 60%;
  --ring: 150 60% 60%;
  color-scheme: dark;
  border-right: 1px solid hsl(163 22% 14%);
}
/* the compiled wordmark uses inline `color: var(--foreground)` (missing hsl()),
   which is invalid and inherits — give the parent the pine-theme ink */
aside.border-r .leading-none { color: hsl(var(--foreground)); }

/* ── 3. Typography — display numerals + titles ───────────────────────────── */
h1, h2,
.kpi-value,
.text-3xl.font-bold,
.text-2xl.font-bold {
  font-family: "Space Grotesk", Inter, system-ui, sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.02em;
}
.tabular-nums { font-variant-numeric: tabular-nums lining-nums; }

/* ── 4. Surfaces — quieter cards, soft ledger shadow ─────────────────────── */
.rounded-2xl.border.bg-card,
.rounded-xl.border.bg-card {
  box-shadow:
    0 1px 2px hsl(165 30% 12% / 0.05),
    0 2px 8px -4px hsl(165 30% 12% / 0.06);
}
.dark .rounded-2xl.border.bg-card,
.dark .rounded-xl.border.bg-card { box-shadow: none; }

/* ── 5. Hero (YTD profit) — retint compiled blues to brand emerald.
      Scoped to the hero container so info/entity blues elsewhere survive. ── */
[class*="border-blue-500/25"] {
  border-color: hsl(160 55% 30% / 0.28) !important;
  background:
    linear-gradient(135deg, hsl(158 50% 96%) 0%, hsl(152 45% 93%) 100%) !important;
}
.dark [class*="border-blue-500/25"] {
  background: linear-gradient(135deg, hsl(163 28% 12%) 0%, hsl(160 30% 10%) 100%) !important;
  border-color: hsl(155 45% 40% / 0.35) !important;
}
[class*="border-blue-500/25"] .text-blue-400,
[class*="border-blue-500/25"] .text-blue-500,
[class*="border-blue-500/25"] .text-blue-600 { color: hsl(160 70% 26%); }
.dark [class*="border-blue-500/25"] .text-blue-400,
.dark [class*="border-blue-500/25"] .text-blue-500,
.dark [class*="border-blue-500/25"] .text-blue-600 { color: hsl(152 60% 62%); }
[class*="border-blue-500/25"] [class*="bg-blue-500/10"],
[class*="border-blue-500/25"] [class*="bg-blue-500/15"] {
  background-color: hsl(160 55% 30% / 0.14) !important;
}
/* progress bar fill */
[class*="border-blue-500/25"] .h-2 > div {
  background: linear-gradient(90deg, hsl(160 65% 30%), hsl(150 60% 42%)) !important;
}

/* ── 6. Small refinements ────────────────────────────────────────────────── */
::selection { background: hsl(160 60% 30% / 0.22); }
button, a { -webkit-tap-highlight-color: transparent; }
main { scrollbar-gutter: stable; }
.h-screen { height: 100dvh; }

/* focus visibility for keyboard + touch users */
a:focus-visible, button:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* ── 7. Mobile top bar + drawer chrome (hidden on desktop) ───────────────── */
.kpcc-topbar { display: none; }
.kpcc-scrim { display: none; }

@media (max-width: 860px) {
  /* Off-canvas pine drawer. Width forced over compiled w-[200px]/w-[52px]. */
  aside.border-r {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: 276px !important;
    max-width: 84vw;
    transform: translateX(-108%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.33, 1);
    box-shadow: none;
  }
  body.kpcc-nav-open aside.border-r {
    transform: none;
    box-shadow: 24px 0 60px -24px hsl(165 40% 6% / 0.55);
  }
  /* the desktop collapse chevron makes no sense inside a drawer */
  aside.border-r > div:first-child > button { display: none; }

  /* comfortable 44px touch targets in the drawer */
  aside.border-r nav a {
    min-height: 44px;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  body.kpcc-nav-open .kpcc-scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .kpcc-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: hsl(168 40% 5% / 0.52);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  /* Frosted app bar — only when the app shell (not login) is mounted */
  body.kpcc-has-nav .kpcc-topbar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    height: 56px;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.625rem;
    padding-top: env(safe-area-inset-top);
    background: hsl(var(--background) / 0.85);
    -webkit-backdrop-filter: blur(14px) saturate(1.5);
    backdrop-filter: blur(14px) saturate(1.5);
    border-bottom: 1px solid hsl(var(--border));
  }
  body.kpcc-has-nav main { padding-top: calc(56px + env(safe-area-inset-top)); }

  .kpcc-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: hsl(var(--foreground));
    cursor: pointer;
  }
  .kpcc-burger:active { background: hsl(var(--muted)); }
  .kpcc-topbar-brand {
    font-family: "Space Grotesk", Inter, sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    color: hsl(var(--foreground));
  }
  .kpcc-topbar-brand span {
    color: hsl(160 65% 32%);
    font-size: 0.6rem;
    letter-spacing: 0.3em;
    display: block;
    line-height: 1;
    margin-top: 1px;
  }
  .dark .kpcc-topbar-brand span { color: hsl(152 55% 58%); }

  /* content breathing room + safe areas */
  main > div {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
  .grid.gap-4 { gap: 0.75rem; }

  /* prevent iOS focus zoom */
  input, select, textarea { font-size: 16px !important; }

  /* tables scroll inside their wrapper instead of stretching the page */
  main table { min-width: 560px; }
  main .overflow-auto, main .overflow-x-auto { -webkit-overflow-scrolling: touch; }

  /* floating chat: clear the home indicator; panel spans the phone width */
  .fixed.bottom-6.right-6 { bottom: calc(1.25rem + env(safe-area-inset-bottom)); }
  [class*="bottom-22"] {
    left: 0.625rem !important;
    right: 0.625rem !important;
    width: auto !important;
    max-height: 70dvh;
    bottom: calc(84px + env(safe-area-inset-bottom)) !important;
  }
}
