/* ─────────────────────────────────────────────────────────────
   Five Leaf Holdings — clean responsive dark UI
   ───────────────────────────────────────────────────────────── */

/* ── Design tokens ───────────────────────────────────────────── */
:root {
  --green:      #10B981;
  --green-glow: rgba(16,185,129,.15);
  --blue:       #3B82F6;
  --red:        #F87171;
  --amber:      #FBBF24;

  /* backgrounds — darkest to lightest */
  --bg:   #090D12;
  --bg-1: #0D1420;
  --bg-2: #131C2B;
  --bg-3: #192436;
  --bg-4: #1F2E42;

  /* borders */
  --bd:   #243040;
  --bd-2: #2E4058;

  /* text */
  --tx:   #DDE6F0;
  --tx-2: #7A90A8;
  --tx-3: #435568;

  /* layout */
  --sw: 220px;   /* sidebar width  */
  --th: 52px;    /* topbar height  */

  /* misc */
  --r:    9px;
  --r-sm: 6px;
  --r-lg: 13px;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--tx);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02','cv03','cv11';
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
a.link { color: var(--green); }
a.link:hover { color: #34D399; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img { display: block; max-width: 100%; }

/* ══════════════════════════════════════════════════════════════
   LAYOUT  —  fixed sidebar + fixed topbar + scrollable main
   Structure:
     <aside class="sidebar">
     <header class="topbar">
     <div class="nav-overlay">   ← tap-to-close on mobile
     <main class="main">
   ══════════════════════════════════════════════════════════════ */

/* ── Sidebar (fixed, left) ────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sw);
  background: var(--bg-1);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: transform .22s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Topbar (fixed, top-right) ────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: var(--sw); right: 0;
  height: var(--th);
  background: rgba(9,13,18,.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 14px;
  z-index: 200;
}

/* ── Main content (offset by sidebar + topbar) ─────────────────── */
.main {
  margin-left: var(--sw);
  margin-top: var(--th);
  padding: 26px 30px 70px;
  min-height: calc(100vh - var(--th));
}

/* ── Nav overlay (mobile tap-to-close) ─────────────────────────── */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 290;
  backdrop-filter: blur(2px);
}
.nav-overlay.open { display: block; }

/* ══════════════════════════════════════════════════════════════
   SIDEBAR COMPONENTS
   ══════════════════════════════════════════════════════════════ */

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}
.sb-logo {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--bg-3);
  border: 1px solid var(--bd-2);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.sb-logo img { width: 20px; height: 20px; }
.sb-name { font-size: 13px; font-weight: 700; letter-spacing: -.01em; }
.sb-sub  { font-size: 10px; color: var(--tx-3); letter-spacing: .07em; text-transform: uppercase; margin-top: 1px; }

.sb-nav { flex: 1; padding: 6px 8px 0; }
.sb-section {
  font-size: 10px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--tx-3);
  padding: 11px 8px 4px;
}
.sb-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 450; color: var(--tx-2);
  transition: background .1s, color .1s;
  margin-bottom: 1px;
  position: relative;
  white-space: nowrap;
}
.sb-link svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .75; transition: opacity .1s; }
.sb-link:hover { background: var(--bg-3); color: var(--tx); }
.sb-link:hover svg { opacity: 1; }
.sb-link.active {
  background: var(--green-glow);
  color: #A7F3D0;
  font-weight: 550;
}
.sb-link.active::before {
  content: '';
  position: absolute; left: 0; top: 25%; bottom: 25%;
  width: 2.5px; border-radius: 2px;
  background: var(--green);
}
.sb-link.active svg { opacity: 1; color: var(--green); }

.sb-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--bd);
  padding: 10px 10px;
  display: flex; align-items: center; gap: 8px;
}
.sb-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.sb-user-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: 11px; color: var(--tx-3); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--green), var(--blue));
  font-size: 11.5px; font-weight: 700; color: #fff;
  display: grid; place-items: center;
}

/* ══════════════════════════════════════════════════════════════
   TOPBAR COMPONENTS
   ══════════════════════════════════════════════════════════════ */

.burger {
  display: none;            /* visible only on mobile */
  background: none; border: 1px solid var(--bd-2);
  color: var(--tx-2); border-radius: var(--r-sm);
  padding: 6px; cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.burger svg { width: 16px; height: 16px; display: block; }
.burger:hover { background: var(--bg-3); color: var(--tx); }

.topbar-title {
  font-size: 14px; font-weight: 600; color: var(--tx);
  letter-spacing: -.01em;
}
.topbar-gap { flex: 1; }

/* user pill in topbar */
.topbar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 6px;
  border-radius: 99px;
  border: 1px solid var(--bd);
  background: var(--bg-2);
  font-size: 12.5px; color: var(--tx-2);
}
.topbar-user .avatar { width: 24px; height: 24px; font-size: 10.5px; }
.topbar-user span { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ══════════════════════════════════════════════════════════════
   PAGE CONTENT COMPONENTS
   ══════════════════════════════════════════════════════════════ */

/* Page header */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.page-head .sub { font-size: 13px; color: var(--tx-2); margin-top: 3px; }

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.qa-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: #1A2B3E; border: 1px solid #3A5878;
  border-radius: var(--r);
  font-size: 13px; font-weight: 500; color: #A8C0D6;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
  cursor: pointer; text-decoration: none;
}
.qa-btn svg { width: 18px; height: 18px; flex-shrink: 0; color: #5B8DB8; }
.qa-btn:hover { background: #213549; border-color: #4E7AA0; color: #DDE6F0; box-shadow: 0 2px 8px rgba(0,0,0,.35); text-decoration: none; }
.qa-btn:hover svg { color: var(--blue); }
.qa-btn.primary {
  background: linear-gradient(135deg, #0D3028, #112540);
  border-color: rgba(16,185,129,.55); color: #6EE7B7;
}
.qa-btn.primary svg { color: var(--green); }
.qa-btn.primary:hover { border-color: rgba(16,185,129,.8); background: linear-gradient(135deg, #113D32, #152E4D); box-shadow: 0 2px 12px rgba(16,185,129,.18); }
.qa-label { font-size: 11px; color: #607A90; margin-top: 2px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.stat {
  background: var(--bg-2); border: 1px solid var(--bd);
  border-radius: var(--r); padding: 16px 18px;
  position: relative; overflow: hidden;
}
.stat::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--green), var(--blue));
}
.stat .lbl { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--tx-3); }
.stat .val { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 7px; line-height: 1; }
.stat .delta { font-size: 12px; color: var(--tx-2); margin-top: 5px; }

/* Cards */
.card {
  background: var(--bg-2); border: 1px solid var(--bd-2);
  border-radius: var(--r); overflow: hidden;
}
.card-hd {
  padding: 12px 16px; border-bottom: 1px solid var(--bd);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-hd h3 { font-size: 13.5px; font-weight: 600; }
.card-bd { padding: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--bd-2);
  background: var(--bg-3); color: var(--tx);
  font-size: 13px; font-weight: 500; line-height: 1;
  cursor: pointer; white-space: nowrap;
  transition: background .1s, border-color .1s;
  text-decoration: none;
}
.btn:hover { background: var(--bg-4); border-color: #354A62; }
.btn:active { opacity: .85; }
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: linear-gradient(135deg, #0D9669, #1D4ED8);
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 3px 10px -2px rgba(16,185,129,.4);
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, #0D9669, #1D4ED8); border-color: transparent; }
.btn-ghost { background: transparent; border-color: var(--bd); color: var(--tx-2); }
.btn-ghost:hover { background: var(--bg-3); color: var(--tx); border-color: var(--bd-2); }
.btn-danger { background: rgba(248,113,113,.07); border-color: rgba(248,113,113,.25); color: #FCA5A5; }
.btn-danger:hover { background: rgba(248,113,113,.14); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* Forms */
.field { display: block; margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 500; color: var(--tx-2); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--tx-3); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--bd-2);
  border-radius: var(--r-sm); padding: 9px 12px;
  color: var(--tx); font-size: 13.5px;
  transition: border-color .12s, box-shadow .12s;
  appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
  background: var(--bg-3);
}
.input::placeholder { color: var(--tx-3); }
.textarea { min-height: 80px; resize: vertical; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 14px;
  color: var(--tx-3); font-size: 11px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  background: rgba(0,0,0,.15); border-bottom: 1px solid var(--bd);
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--bd); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,.025); }
.table .num  { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.table .date { white-space: nowrap; color: var(--tx-2); font-size: 12px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-4); color: var(--tx-2); border: 1px solid var(--bd-2);
}
.badge-ok   { background: rgba(16,185,129,.1);  color: #6EE7B7; border-color: rgba(16,185,129,.25); }
.badge-warn { background: rgba(251,191,36,.1);  color: #FCD34D; border-color: rgba(251,191,36,.25); }
.badge-bad  { background: rgba(248,113,113,.1); color: #FCA5A5; border-color: rgba(248,113,113,.3); }
.badge-mut  { background: rgba(255,255,255,.04); }

/* Flash */
.flash { border-radius: var(--r-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 13px; border: 1px solid var(--bd-2); background: var(--bg-3); }
.flash-success { border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.09); color: #A7F3D0; }
.flash-error   { border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.09); color: #FCA5A5; }
.flash-warn    { border-color: rgba(251,191,36,.4);  background: rgba(251,191,36,.09);  color: #FDE68A; }

/* Empty states */
.empty { text-align: center; padding: 52px 20px; border: 1.5px dashed var(--bd-2); border-radius: var(--r); }
.empty h3 { font-size: 15px; font-weight: 600; margin-bottom: 7px; }
.empty p  { color: var(--tx-2); font-size: 13px; margin-bottom: 16px; }

/* Auth pages */
.auth-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse 700px 450px at 70% 0%, rgba(16,185,129,.08), transparent 55%),
              radial-gradient(ellipse 600px 450px at 5% 95%,  rgba(59,130,246,.09), transparent 55%),
              var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-2); border: 1px solid var(--bd); border-radius: var(--r-lg);
  padding: 32px; position: relative; overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.auth-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--green), var(--blue)); }
.auth-card .brand { text-align: center; margin-bottom: 22px; }
.auth-card .brand img { width: 56px; height: 56px; margin: 0 auto 10px; }
.auth-card h1 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.auth-card p.sub { color: var(--tx-2); font-size: 13.5px; margin-top: 5px; }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD COMPONENTS
   ══════════════════════════════════════════════════════════════ */

/* Hero banner */
.dash-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, rgba(16,185,129,.07) 0%, rgba(59,130,246,.06) 100%);
  border: 1px solid var(--bd);
  border-radius: var(--r-lg);
  padding: 28px 32px;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
}
.dash-hero::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--green), var(--blue));
}
.dash-hero-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--green); margin-bottom: 6px;
}
.dash-hero-title {
  font-size: 26px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1;
}
.dash-hero-sub {
  font-size: 13px; color: var(--tx-2); margin-top: 6px;
}
.dash-hero-right { flex-shrink: 0; }

/* 5-column stat grid */
.stat-grid-5 { grid-template-columns: repeat(5, 1fr); }

.stat-icon {
  color: var(--tx-3); margin-bottom: 6px;
}

/* Chart legend */
.chart-legend {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--tx-2);
}
.legend-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
}

/* Middle section grid: chart 60%, health 40% */
.dash-mid-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 14px;
}

/* Bottom section grid: overdue 60%, expenses 40% */
.dash-bottom-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 14px;
}

/* Occupancy donut */
.occ-donut {
  width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.occ-inner {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--green);
}

/* Expiring lease rows */
.expiring-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--bd);
}
.expiring-row:last-child { border-bottom: none; }

/* Portfolio cards (on dashboard) */
.port-card {
  display: flex; flex-direction: column;
  background: var(--bg-3); border: 1px solid var(--bd);
  border-radius: var(--r); overflow: hidden;
  text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.port-card:hover { border-color: var(--bd-2); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.port-card-img {
  height: 110px; background: var(--bg-4);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
}
.port-card-body { padding: 10px 12px; }
.port-card-name { font-size: 13px; font-weight: 600; }
.port-card-addr { font-size: 11px; color: var(--tx-3); margin-top: 2px; }

/* Property cards */

/* ══════════════════════════════════════════════════════════════
   PROPERTY CARDS
   ══════════════════════════════════════════════════════════════ */

.prop-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.prop-card-wrap { display: flex; flex-direction: column; gap: 8px; }
.prop-card-actions { display: flex; gap: 8px; }
.prop-card {
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--bd-2);
  border-radius: var(--r); overflow: hidden;
  text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.prop-card:hover { border-color: var(--bd); box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.prop-card .img {
  height: 140px; background: var(--bg-3);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
}
.prop-card .body { padding: 14px 16px; }
.prop-card .body h3 { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.prop-card .body .addr { font-size: 12px; color: var(--tx-3); }

/* ══════════════════════════════════════════════════════════════
   MOBILE  (≤ 768 px)
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* Sidebar slides off-screen by default; .open brings it back */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.5);
  }

  /* Topbar spans full width on mobile */
  .topbar {
    left: 0;
    padding: 0 14px;
  }

  /* Show the hamburger button */
  .burger {
    display: flex;
  }

  /* Main content: no sidebar offset, tighter padding */
  .main {
    margin-left: 0;
    padding: 18px 14px 60px;
  }

  /* Page header: stack vertically */
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  /* Tables: horizontal scroll so columns aren't crushed */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 520px; }

  /* Forms: single column */
  .form-row-2,
  .form-row-3,
  .form-row-4 { grid-template-columns: 1fr; }

  /* Filter bar: wrap */
  .filter-bar { flex-wrap: wrap; gap: 8px; }

  /* Property grid: single column */
  .prop-grid { grid-template-columns: 1fr; }

  /* Quick-action buttons: two columns */
  .qa-grid { grid-template-columns: repeat(2, 1fr); }

  /* Dashboard stat rows: two columns */
  .stat-grid,
  .stat-grid-5 { grid-template-columns: repeat(2, 1fr); }

  /* Dashboard hero: stack vertically */
  .dash-hero { grid-template-columns: 1fr; padding: 20px 18px; }
  .dash-hero-right { display: none; }
  .dash-hero-title { font-size: 20px; }

  /* Dashboard grids: stack vertically */
  .dash-mid-grid,
  .dash-bottom-grid { grid-template-columns: 1fr; }

  /* Hide topbar user name text on very narrow screens */
  .topbar-user span { display: none; }
}

@media (max-width: 420px) {
  .qa-grid  { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
