/* ==========================================================================
   REALE / RentalOS — Property Manager Portal
   Operations console design system. Vanilla CSS, REM-first, variable-driven.
   Light theme is primary; a restrained dark theme is layered via
   [data-theme="dark"]. No external fonts or chart libraries.
   ========================================================================== */

:root {
  color-scheme: light;
  /* Surfaces & ink */
  --bg: #f4f6f1;
  --bg-tint: #eef2ec;
  --surface: #ffffff;
  --surface-soft: #eef3ee;
  --surface-strong: #e2eadf;
  --surface-row: #fbfcfa;
  --ink: #17221c;
  --text: #27352c;
  --muted: #667568;
  --muted-2: #6f7d71;
  --line: #d8e0d6;
  --line-strong: #b9c7b8;
  /* Brand sidebar */
  --side-bg: #23342a;
  --side-bg-2: #1d2b23;
  --side-ink: #f8fbf6;
  --side-muted: #bed1c2;
  --side-item: #d7e3d9;
  /* Accents */
  --green: #2d7a46;
  --green-strong: #23633a;
  --green-soft: #e4f2e7;
  --blue: #2b67a5;
  --blue-soft: #e4eef8;
  --teal: #0b7b79;
  --teal-soft: #def2ef;
  --amber: #a16008;
  --amber-soft: #fff0d3;
  --red: #b9413c;
  --red-soft: #fce5e2;
  --violet: #7157a3;
  --violet-soft: #ece7f8;
  --slate: #4a5b66;
  --slate-soft: #e8eef1;
  /* Effects */
  --shadow: 0 0.5rem 1.5rem rgba(37, 54, 42, 0.08);
  --shadow-lg: 0 1.25rem 3rem rgba(20, 32, 24, 0.22);
  --shadow-pop: 0 0.75rem 2rem rgba(20, 32, 24, 0.16);
  --ring: 0 0 0 0.1875rem rgba(45, 122, 70, 0.28);
  /* Metrics */
  --sidebar-width: 16.75rem;
  --topbar-height: 4.5rem;
  --radius: 0.625rem;
  --radius-sm: 0.4375rem;
  --radius-lg: 0.875rem;
  --maxw: 90rem;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1611;
  --bg-tint: #131c16;
  --surface: #17211b;
  --surface-soft: #1c271f;
  --surface-strong: #243027;
  --surface-row: #1a241d;
  --ink: #eef5ee;
  --text: #d4e0d6;
  --muted: #93a497;
  --muted-2: #76877a;
  --line: #2a362d;
  --line-strong: #38483b;
  --side-bg: #0c120e;
  --side-bg-2: #0a0f0b;
  --side-ink: #eef5ee;
  --side-muted: #8fa394;
  --side-item: #b9cabd;
  --green: #4fae6e;
  --green-strong: #3f9a5e;
  --green-soft: #15301f;
  --blue: #5b9bd6;
  --blue-soft: #122336;
  --teal: #45c2bc;
  --teal-soft: #0c2e2c;
  --amber: #e7b15c;
  --amber-soft: #33260f;
  --red: #e07873;
  --red-soft: #361a18;
  --violet: #a890d6;
  --violet-soft: #221a33;
  --slate: #8aa0ad;
  --slate-soft: #16242b;
  --shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 1.25rem 3rem rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 0.75rem 2rem rgba(0, 0, 0, 0.5);
  --ring: 0 0 0 0.1875rem rgba(79, 174, 110, 0.4);
}

* { box-sizing: border-box; }

html {
  min-width: 20rem;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
a { color: var(--green); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

.skip-link {
  position: fixed;
  left: 0.75rem;
  top: -3rem;
  z-index: 200;
  background: var(--green);
  color: #fff;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  font-weight: 700;
  transition: top 0.15s ease;
  text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

.sr-only {
  position: absolute;
  width: 0.0625rem; height: 0.0625rem;
  padding: 0; margin: -0.0625rem;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* -------------------------------------------------------------- Landing */
.landing-page {
  background:
    linear-gradient(135deg, #f7faf4 0%, #edf5f7 52%, #f8f2e7 100%);
}

.landing-shell {
  min-height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.landing-panel {
  width: min(72rem, 100%);
  min-height: min(43rem, calc(100vh - 2rem));
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(20rem, 1.08fr);
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: center;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 0.0625rem solid color-mix(in srgb, var(--line) 80%, #ffffff);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.2rem, 3vw, 2.25rem);
  overflow: hidden;
}

.landing-copy {
  min-width: 0;
  display: grid;
  gap: 1rem;
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
}

.landing-mark {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  border: 0.0625rem solid color-mix(in srgb, var(--green) 18%, var(--line));
}

.landing-brand-name {
  display: block;
  font-weight: 850;
  font-size: 1.05rem;
  line-height: 1.15;
}

.landing-brand-subtitle {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.05rem;
}

.landing-path {
  width: fit-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
}

.landing-path i {
  font-size: 0.68rem;
  color: var(--line-strong);
}

.landing-path-item {
  min-height: 1.6rem;
  display: inline-flex;
  align-items: center;
  border-radius: 99rem;
  border: 0.0625rem solid var(--line);
  background: var(--surface);
  padding: 0 0.55rem;
  font-weight: 700;
  white-space: nowrap;
}

.landing-path-item.active {
  background: var(--blue-soft);
  border-color: color-mix(in srgb, var(--blue) 30%, var(--line));
  color: var(--blue);
}

.landing-eyebrow {
  margin: 0.25rem 0 -0.25rem;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.landing-copy h1 {
  margin: 0;
  max-width: 14ch;
  color: var(--ink);
  font-size: clamp(2.15rem, 4.6vw, 3.65rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.landing-lede {
  margin: 0;
  max-width: 42rem;
  color: var(--text);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.62;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.2rem;
}

.landing-button {
  min-height: 3rem;
  padding-inline: 1rem;
}

.landing-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 0.35rem;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-row);
}

.landing-metric {
  min-height: 5rem;
  display: grid;
  align-content: center;
  gap: 0.15rem;
  padding: 0.85rem;
  border-right: 0.0625rem solid var(--line);
}

.landing-metric:last-child { border-right: 0; }

.landing-metric-value {
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 850;
}

.landing-metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.landing-preview {
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.landing-preview-top {
  min-height: 2.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.85rem;
  border-bottom: 0.0625rem solid var(--line);
  background: var(--surface-soft);
}

.landing-preview-top span {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--line-strong);
}

.landing-preview-top span:nth-child(1) { background: var(--red); }
.landing-preview-top span:nth-child(2) { background: var(--amber); }
.landing-preview-top span:nth-child(3) { background: var(--green); }

.landing-preview img {
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  object-fit: cover;
  object-position: left top;
  display: block;
  background: var(--surface-soft);
}

.landing-preview-caption {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.85rem;
  border-top: 0.0625rem solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

.landing-preview-caption span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.landing-preview-caption i { color: var(--green); }

/* ------------------------------------------------------------------ Shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 17, 0.5);
  z-index: 60;
  border: 0;
}

.sidebar {
  background: linear-gradient(180deg, var(--side-bg), var(--side-bg-2));
  color: var(--side-ink);
  padding: 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 100vh;
  position: sticky;
  top: 0;
  max-height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 3rem;
  padding: 0 0.25rem;
}
.brand-mark {
  width: 2.5rem; height: 2.5rem;
  border-radius: var(--radius);
  background: #e7f4e8;
  color: #235a36;
  display: grid; place-items: center;
  flex: 0 0 auto;
  font-size: 1.05rem;
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 800; line-height: 1.15; letter-spacing: 0.02em; }
.brand-subtitle { color: var(--side-muted); font-size: 0.78rem; }
.sidebar-close { display: none; margin-left: auto; background: transparent; border-color: rgba(255,255,255,0.16); color: var(--side-item); }

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
  padding-right: 0.15rem;
  margin-right: -0.15rem;
}
.nav-list::-webkit-scrollbar { width: 0.4rem; }
.nav-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99rem; }

.nav-group { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-group-label {
  margin: 0.25rem 0.55rem 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--side-muted);
  font-weight: 700;
}

.nav-item {
  position: relative;
  min-height: 2.6rem;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--side-item);
  cursor: pointer;
  padding: 0.5rem 0.7rem;
  text-align: left;
  font-size: 0.92rem;
}
.nav-item > i { width: 1.2rem; text-align: center; font-size: 0.95rem; flex: 0 0 auto; }
.nav-item > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.nav-item:hover, .nav-item:focus-visible {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  outline: none;
}
.nav-item.active {
  background: var(--side-item);
  background: #f6faf4;
  color: #1c2c22;
  font-weight: 700;
}
[data-theme="dark"] .nav-item.active { background: #243a2c; color: #eafff0; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -0.85rem;
  top: 0.45rem; bottom: 0.45rem;
  width: 0.22rem;
  border-radius: 0 99rem 99rem 0;
  background: var(--green);
}
.nav-count {
  margin-left: auto;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 99rem;
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
}
.nav-item.active .nav-count { background: var(--green); color: #fff; }

.sidebar-footer { margin-top: auto; padding-top: 0.4rem; }
.sidebar-user {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  border: 0.0625rem solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.04);
  color: var(--side-item);
  cursor: pointer;
  text-align: left;
}
.sidebar-user:hover { background: rgba(255,255,255,0.09); }
.sidebar-user-text { min-width: 0; flex: 1 1 auto; }
.sidebar-user-name { display: block; font-weight: 700; color: #fff; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { display: block; font-size: 0.74rem; color: var(--side-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 2.1rem; height: 2.1rem;
  flex: 0 0 auto;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #cfe6d4;
  color: #235a36;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.avatar.lg { width: 2.85rem; height: 2.85rem; font-size: 0.95rem; }
.avatar.sm { width: 1.75rem; height: 1.75rem; font-size: 0.68rem; }
.avatar.blue { background: var(--blue-soft); color: var(--blue); }
.avatar.amber { background: var(--amber-soft); color: var(--amber); }
.avatar.violet { background: var(--violet-soft); color: var(--violet); }
.avatar.teal { background: var(--teal-soft); color: var(--teal); }
.avatar.slate { background: var(--slate-soft); color: var(--slate); }

/* --------------------------------------------------------------- Workspace */
.workspace { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  border-bottom: 0.0625rem solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(0.75rem);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-lead { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.nav-toggle { display: none; }
.title-block { min-width: 0; }
.title-block h1 { margin: 0; font-size: 1.3rem; line-height: 1.2; color: var(--ink); overflow-wrap: break-word; }
.title-block p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36rem; }

.topbar-actions {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 0.55rem; flex-wrap: wrap;
}

.select-control {
  min-height: 2.6rem;
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: 0.0625rem solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0 0.7rem;
  color: var(--muted);
}
.select-control select {
  min-height: 2.45rem; max-width: 14rem;
  border: 0; background: transparent; color: var(--text); outline: none;
  cursor: pointer;
}

.segmented {
  min-height: 2.6rem;
  display: inline-flex; align-items: center;
  border: 0.0625rem solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.2rem;
}
.segment {
  min-height: 2.1rem;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted);
  cursor: pointer; padding: 0 0.8rem; font-size: 0.86rem;
}
.segment.active { background: var(--green-soft); color: var(--green); font-weight: 700; }

.menu-anchor { position: relative; }

/* ------------------------------------------------------------------ Buttons */
.icon-button, .primary-button, .secondary-button, .ghost-button, .danger-button, .row-action {
  min-height: 2.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  border: 0.0625rem solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.icon-button { width: 2.6rem; position: relative; flex: 0 0 auto; color: var(--muted); }
.icon-button:hover, .secondary-button:hover, .ghost-button:hover, .row-action:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
}
.badge {
  position: absolute; top: 0.2rem; right: 0.2rem;
  min-width: 1.1rem; height: 1.1rem;
  border-radius: 99rem;
  display: grid; place-items: center;
  padding: 0 0.25rem;
  background: var(--red); color: #fff;
  font-size: 0.66rem; font-weight: 800;
  border: 0.125rem solid var(--surface);
}
.primary-button { background: var(--green); border-color: var(--green); color: #fff; padding: 0 0.95rem; font-weight: 700; }
.primary-button:hover { background: var(--green-strong); border-color: var(--green-strong); }
.secondary-button, .ghost-button, .row-action { padding: 0 0.8rem; }
.ghost-button { border-color: transparent; background: transparent; color: var(--muted); }
.ghost-button:hover { background: var(--surface-soft); }
.danger-button { background: var(--red); border-color: var(--red); color: #fff; padding: 0 0.85rem; font-weight: 700; }
.danger-button:hover { filter: brightness(0.94); }
.row-action { min-height: 2.15rem; font-size: 0.82rem; padding: 0 0.65rem; color: var(--text); }
.row-action.primary { background: var(--green); border-color: var(--green); color: #fff; }
.row-action.primary:hover { background: var(--green-strong); }
.row-action.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.row-action.danger:hover { background: var(--red-soft); }
.row-action:disabled, .primary-button:disabled, .secondary-button:disabled, .danger-button:disabled {
  opacity: 0.5; cursor: not-allowed;
}
.link-button {
  border: 0; background: transparent; color: var(--green);
  cursor: pointer; padding: 0; font-weight: 700; text-decoration: underline;
  text-underline-offset: 0.15rem;
}
.btn-block { width: 100%; }

/* ------------------------------------------------------------------- Views */
.view-root { padding: 1.25rem; max-width: var(--maxw); width: 100%; }
.view-root:focus { outline: none; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; }
.span-12 { grid-column: 1 / -1; }

/* KPIs */
.kpi-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
}
.kpi-card, .panel, .table-panel {
  background: var(--surface);
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi-card {
  min-height: 7rem;
  padding: 1rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.kpi-card:hover { border-color: var(--line-strong); transform: translateY(-0.0625rem); }
.kpi-card.flat { cursor: default; }
.kpi-card.flat:hover { transform: none; border-color: var(--line); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.kpi-label { color: var(--muted); font-size: 0.8rem; line-height: 1.3; }
.kpi-icon {
  width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.kpi-icon.green { background: var(--green-soft); color: var(--green); }
.kpi-icon.blue { background: var(--blue-soft); color: var(--blue); }
.kpi-icon.teal { background: var(--teal-soft); color: var(--teal); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.red { background: var(--red-soft); color: var(--red); }
.kpi-icon.violet { background: var(--violet-soft); color: var(--violet); }
.kpi-icon.slate { background: var(--slate-soft); color: var(--slate); }
.kpi-value { font-size: 1.65rem; line-height: 1.05; font-weight: 800; color: var(--ink); }
.kpi-foot { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; display: flex; align-items: center; gap: 0.3rem; }
.kpi-trend { font-weight: 700; display: inline-flex; align-items: center; gap: 0.2rem; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }
.kpi-trend.warn { color: var(--amber); }

/* Panels */
.panel { padding: 1rem; overflow: hidden; display: flex; flex-direction: column; }
.panel.tall { min-height: 22rem; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.85rem;
}
.panel-header h2, .table-title { margin: 0; color: var(--ink); font-size: 1rem; line-height: 1.3; font-weight: 750; }
.panel-kicker { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.panel-actions { display: inline-flex; align-items: center; gap: 0.4rem; }
.panel-body { flex: 1 1 auto; min-height: 0; }

/* Alerts strip */
.alerts-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.75rem;
}
.alert-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  border: 0.0625rem solid var(--line);
  border-left-width: 0.25rem;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.alert-card.high { border-left-color: var(--red); }
.alert-card.medium { border-left-color: var(--amber); }
.alert-card.info { border-left-color: var(--blue); }
.alert-icon {
  width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm);
  display: grid; place-items: center; flex: 0 0 auto;
}
.alert-card.high .alert-icon { background: var(--red-soft); color: var(--red); }
.alert-card.medium .alert-icon { background: var(--amber-soft); color: var(--amber); }
.alert-card.info .alert-icon { background: var(--blue-soft); color: var(--blue); }
.alert-title { font-weight: 750; color: var(--ink); line-height: 1.3; }
.alert-meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.1rem; }
.alert-actions { margin-top: 0.5rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Generic stacks & rows */
.stack { display: grid; gap: 0.6rem; }
.timeline, .queue-list, .readiness-list, .ai-list { display: grid; gap: 0.55rem; }

.data-row, .timeline-item, .queue-row, .readiness-row, .ai-row {
  min-height: 3.4rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-row);
}
.queue-row.interactive, .timeline-item.interactive, .readiness-row.interactive {
  cursor: pointer;
}
.queue-row.interactive:hover, .timeline-item.interactive:hover, .readiness-row.interactive:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}
.readiness-row { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
.row-lead { display: inline-grid; place-items: center; }
.row-icon {
  width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm);
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--surface-soft); color: var(--muted);
}
.row-icon.green { background: var(--green-soft); color: var(--green); }
.row-icon.blue { background: var(--blue-soft); color: var(--blue); }
.row-icon.amber { background: var(--amber-soft); color: var(--amber); }
.row-icon.red { background: var(--red-soft); color: var(--red); }
.row-icon.teal { background: var(--teal-soft); color: var(--teal); }
.row-icon.violet { background: var(--violet-soft); color: var(--violet); }
.row-title { color: var(--ink); font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.row-meta { color: var(--muted); font-size: 0.8rem; line-height: 1.4; margin-top: 0.1rem; overflow-wrap: anywhere; }
.row-actions { display: inline-flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row-trailing { text-align: right; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }

/* Chips & badges */
.time-chip, .status-chip, .priority-chip, .tag {
  min-height: 1.65rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
  border-radius: 99rem;
  padding: 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.time-chip { background: var(--surface-strong); color: var(--text); font-variant-numeric: tabular-nums; }
.tag { background: var(--surface-soft); color: var(--muted); font-weight: 700; border: 0.0625rem solid var(--line); }

/* status color families */
.status-chip.confirmed, .status-chip.ready, .status-chip.resolved, .status-chip.sent, .status-chip.active, .status-chip.approved, .priority-chip.low, .status-chip.paid, .status-chip.healthy {
  background: var(--green-soft); color: var(--green);
}
.status-chip.requested, .status-chip.pending, .status-chip.review, .priority-chip.medium, .status-chip.draft, .status-chip.scheduled, .status-chip.unassigned, .status-chip.due {
  background: var(--amber-soft); color: var(--amber);
}
.status-chip.open, .status-chip.blocked, .status-chip.rejected, .status-chip.overdue, .status-chip.cancelled, .priority-chip.high, .priority-chip.urgent, .status-chip.failed {
  background: var(--red-soft); color: var(--red);
}
.status-chip.progress, .status-chip.dispatched, .status-chip.instay, .status-chip.confirming {
  background: var(--blue-soft); color: var(--blue);
}
.status-chip.checkedout, .status-chip.inspection, .status-chip.cleaning {
  background: var(--teal-soft); color: var(--teal);
}
.status-chip.flagged, .status-chip.escalated { background: var(--violet-soft); color: var(--violet); }
.status-chip.dot::before {
  content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%;
  background: currentColor; display: inline-block;
}

/* Meter / progress bar */
.meter {
  height: 0.5rem; border-radius: 99rem;
  background: var(--surface-strong); overflow: hidden;
  min-width: 6rem; width: 100%;
}
.meter.thin { height: 0.35rem; }
.meter > span { display: block; height: 100%; background: var(--green); border-radius: 99rem; }
.meter > span.blue { background: var(--blue); }
.meter > span.amber { background: var(--amber); }
.meter > span.red { background: var(--red); }
.meter > span.teal { background: var(--teal); }

/* ------------------------------------------------------------------ Tables */
.table-panel { overflow: hidden; display: flex; flex-direction: column; }
.table-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.75rem; padding: 0.85rem 1rem;
  border-bottom: 0.0625rem solid var(--line);
  flex-wrap: wrap;
}
.table-tools { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.table-search {
  min-height: 2.4rem;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  padding: 0 0.7rem 0 2rem;
  color: var(--text);
  min-width: 13rem;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23667568' stroke-width='1.5'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M11 11l3 3'/%3E%3C/svg%3E") no-repeat 0.6rem center / 0.95rem;
}
.filter-pills { display: inline-flex; gap: 0.3rem; flex-wrap: wrap; }
.filter-pill {
  min-height: 2.1rem;
  border: 0.0625rem solid var(--line);
  background: var(--surface);
  border-radius: 99rem;
  padding: 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.35rem;
}
.filter-pill .count-pill {
  background: var(--surface-strong); color: var(--muted);
  border-radius: 99rem; padding: 0 0.35rem; font-size: 0.7rem; font-weight: 800; min-width: 1.1rem; text-align: center;
}
.filter-pill:hover { border-color: var(--line-strong); }
.filter-pill.active { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 35%, var(--line)); color: var(--green); font-weight: 700; }
.filter-pill.active .count-pill { background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green); }

.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 44rem; }
.data-table.wide { min-width: 56rem; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 0.0625rem solid var(--line);
  vertical-align: middle;
}
.data-table th {
  color: var(--muted); font-size: 0.72rem; font-weight: 800;
  background: var(--surface-soft);
  text-transform: uppercase; letter-spacing: 0.04em;
  position: sticky; top: 0; z-index: 1;
}
.data-table td { color: var(--text); font-size: 0.875rem; }
.data-table tbody tr { transition: background 0.1s ease; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: var(--surface-soft); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .t-actions { white-space: nowrap; }
.cell-strong { color: var(--ink); font-weight: 700; }
.cell-sub { color: var(--muted); font-size: 0.78rem; margin-top: 0.1rem; }
.cell-stack { display: flex; align-items: center; gap: 0.6rem; }

.table-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 0.7rem 1rem;
  border-top: 0.0625rem solid var(--line);
  color: var(--muted); font-size: 0.82rem; flex-wrap: wrap;
}
.pager { display: inline-flex; gap: 0.25rem; align-items: center; }
.pager-button {
  min-width: 2.1rem; min-height: 2.1rem;
  border: 0.0625rem solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text);
  display: inline-grid; place-items: center; padding: 0 0.5rem;
}
.pager-button:hover:not(:disabled) { background: var(--surface-soft); }
.pager-button.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.pager-button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ------------------------------------------------------ Loading/empty/error */
.state-block {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 0.6rem;
  padding: 3rem 1.5rem; min-height: 14rem;
  color: var(--muted);
}
.state-icon {
  width: 3.25rem; height: 3.25rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-soft); color: var(--muted);
  font-size: 1.25rem;
}
.state-block.error .state-icon { background: var(--red-soft); color: var(--red); }
.state-block.empty .state-icon { background: var(--green-soft); color: var(--green); }
.state-title { color: var(--ink); font-weight: 750; font-size: 1rem; }
.state-desc { color: var(--muted); font-size: 0.86rem; max-width: 26rem; }
.spinner {
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 0.22rem solid var(--surface-strong);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { position: relative; overflow: hidden; background: var(--surface-soft); border-radius: var(--radius-sm); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton-line { height: 0.8rem; margin: 0.4rem 0; }
.skeleton-row { height: 3.2rem; margin-bottom: 0.55rem; border-radius: var(--radius); }
.skeleton-kpi { height: 7rem; border-radius: var(--radius); }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
  .skeleton::after { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------------- Tabs */
.tabs { display: inline-flex; gap: 0.2rem; border-bottom: 0.0625rem solid var(--line); flex-wrap: wrap; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 0.6rem 0.85rem; color: var(--muted);
  border-bottom: 0.18rem solid transparent; margin-bottom: -0.0625rem;
  font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 750; }

/* ------------------------------------------------------------ Detail layout */
.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1rem; align-items: start; }
.detail-rail {
  background: var(--surface);
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.rail-section + .rail-section { border-top: 0.0625rem solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.rail-title { margin: 0 0 0.6rem; font-size: 0.92rem; color: var(--ink); font-weight: 750; }

.detail-section + .detail-section { margin-top: 1.15rem; }
.detail-section-title {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 800; margin: 0 0 0.55rem;
}
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem 1rem; }
.detail-item label { display: block; font-size: 0.74rem; color: var(--muted); font-weight: 700; margin-bottom: 0.15rem; }
.detail-item .value { color: var(--ink); font-weight: 650; overflow-wrap: anywhere; }
.meta-line { color: var(--muted); font-size: 0.85rem; }
.badge-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* vertical timeline */
.timeline-vertical { display: grid; gap: 0; position: relative; margin-left: 0.4rem; }
.tl-node { position: relative; padding: 0 0 1rem 1.35rem; border-left: 0.125rem solid var(--line); }
.tl-node:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -0.5rem; top: 0.1rem;
  width: 0.85rem; height: 0.85rem; border-radius: 50%;
  background: var(--surface); border: 0.18rem solid var(--green);
}
.tl-dot.amber { border-color: var(--amber); }
.tl-dot.blue { border-color: var(--blue); }
.tl-dot.red { border-color: var(--red); }
.tl-dot.muted { border-color: var(--line-strong); }
.tl-content .row-title { font-size: 0.9rem; }
.tl-time { color: var(--muted-2); font-size: 0.74rem; margin-top: 0.1rem; }

/* ------------------------------------------------------------------ Calendar */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.cal-nav { display: inline-flex; align-items: center; gap: 0.4rem; }
.cal-range { font-weight: 750; color: var(--ink); min-width: 9rem; text-align: center; }
.cal-legend { display: flex; gap: 0.85rem; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--muted); }
.legend-swatch { width: 0.85rem; height: 0.85rem; border-radius: 0.25rem; }
.legend-swatch.confirmed { background: var(--green); }
.legend-swatch.requested { background: var(--amber); }
.legend-swatch.cleaning { background: var(--blue); }
.legend-swatch.maintenance { background: var(--red); }
.legend-swatch.blocked { background: var(--violet); }

.calendar-grid {
  display: grid;
  grid-template-columns: 11rem repeat(7, minmax(7rem, 1fr));
  overflow-x: auto;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.calendar-cell, .calendar-head {
  min-height: 4rem;
  padding: 0.5rem;
  border-right: 0.0625rem solid var(--line);
  border-bottom: 0.0625rem solid var(--line);
  display: flex; flex-direction: column; gap: 0.25rem;
}
.calendar-head { min-height: 3rem; background: var(--surface-soft); font-weight: 800; color: var(--ink); justify-content: center; }
.calendar-head.today { color: var(--green); }
.calendar-head small { display: block; font-weight: 600; color: var(--muted); font-size: 0.72rem; }
.calendar-property { font-weight: 750; color: var(--ink); background: var(--surface-row); justify-content: center; }
.calendar-property .row-meta { font-weight: 500; }
.calendar-cell.is-today { background: color-mix(in srgb, var(--green-soft) 55%, var(--surface)); }
.cal-pill {
  display: inline-flex; max-width: 100%; align-items: center;
  min-height: 1.55rem; border-radius: 0.4rem;
  padding: 0 0.45rem; font-size: 0.72rem; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; border: 0; text-align: left;
}
.cal-pill.confirmed { background: var(--green-soft); color: var(--green); }
.cal-pill.requested { background: var(--amber-soft); color: var(--amber); }
.cal-pill.cleaning { background: var(--blue-soft); color: var(--blue); }
.cal-pill.maintenance { background: var(--red-soft); color: var(--red); }
.cal-pill.blocked { background: var(--violet-soft); color: var(--violet); }
.cal-pill.static { cursor: default; }

/* Shared horizontal-scroll frame so week/month grids never overflow the card. */
.cal-scroll { overflow-x: auto; border: 0.0625rem solid var(--line); border-radius: var(--radius); background: var(--surface); }

/* Week view — header row and per-property lane rows share one 11rem + 7-col track set. */
.cal-week { min-width: 60rem; }
.cal-wk-head { display: grid; grid-template-columns: 11rem repeat(7, minmax(7rem, 1fr)); }
.cal-wk-row { display: grid; grid-template-columns: 11rem minmax(0, 1fr); border-bottom: 0.0625rem solid var(--line); }
.cal-wk-row:last-child { border-bottom: 0; }
.cal-wk-row .calendar-property { border-bottom: 0; border-right: 0.0625rem solid var(--line); }
.cal-wk-lanes { display: grid; grid-template-columns: repeat(7, minmax(7rem, 1fr)); row-gap: 0.3rem; padding: 0.3rem 0; align-items: center; }
.cal-wk-cell { border-right: 0.0625rem solid var(--line); }
.cal-wk-cell.is-today { background: color-mix(in srgb, var(--green-soft) 55%, var(--surface)); }
.cal-bar { min-height: 2.75rem; align-self: center; margin: 0 0.3rem; justify-content: flex-start; position: relative; z-index: 1; }
.cal-row-more { display: inline-block; margin-top: 0.4rem; font-size: 0.72rem; font-weight: 700; color: var(--muted); }

/* Day view — portfolio summary tiles + per-property agenda cards. */
.cal-day-summary { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.9rem; }
.cal-stat { flex: 1 1 7rem; min-width: 7rem; display: flex; flex-direction: column; gap: 0.15rem; padding: 0.7rem 0.8rem; border-radius: var(--radius); border: 0.0625rem solid var(--line); background: var(--surface-row); }
.cal-stat-n { font-size: 1.4rem; font-weight: 800; color: var(--ink); line-height: 1; }
.cal-stat-l { font-size: 0.78rem; color: var(--muted); }
.cal-stat.confirmed .cal-stat-n { color: var(--green); }
.cal-stat.requested .cal-stat-n { color: var(--amber); }
.cal-stat.cleaning .cal-stat-n { color: var(--blue); }
.cal-stat.maintenance .cal-stat-n { color: var(--red); }
.cal-stat.blocked .cal-stat-n { color: var(--violet); }
.cal-agenda-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.8rem; }
.cal-agenda-card { border: 0.0625rem solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0.8rem; }
.cal-agenda-head { display: flex; flex-direction: column; gap: 0.1rem; margin-bottom: 0.6rem; }
.cal-agenda-name { font-weight: 750; color: var(--ink); }
.cal-agenda-list { display: flex; flex-direction: column; gap: 0.4rem; }
.cal-agenda-item { display: flex; align-items: center; gap: 0.5rem; }
.cal-agenda-pill { min-height: 2.75rem; flex: 0 1 auto; max-width: 62%; }
.cal-agenda-when { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.cal-agenda-empty { font-size: 0.82rem; color: var(--muted); padding: 0.5rem 0; }

/* Month view — 6×7 calendar grid; each day cell is a deep-link button. */
.calendar-month { min-width: 46rem; }
.cal-month-dow, .cal-month-grid { display: grid; grid-template-columns: repeat(7, minmax(6rem, 1fr)); }
.cal-dow { padding: 0.5rem; text-align: center; font-weight: 800; color: var(--ink); background: var(--surface-soft); border-right: 0.0625rem solid var(--line); border-bottom: 0.0625rem solid var(--line); }
.cal-dow:last-child { border-right: 0; }
.cal-day { display: flex; flex-direction: column; gap: 0.3rem; align-items: stretch; text-align: left; min-height: 6rem; padding: 0.4rem; background: var(--surface); border: 0; border-right: 0.0625rem solid var(--line); border-bottom: 0.0625rem solid var(--line); cursor: pointer; color: var(--ink); font: inherit; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: var(--surface-soft); }
.cal-day.out { background: var(--surface-soft); }
.cal-day.out .cal-day-num { color: var(--muted); }
.cal-day.is-today { background: color-mix(in srgb, var(--green-soft) 45%, var(--surface)); }
.cal-day.is-today .cal-day-num { color: var(--green); font-weight: 850; }
.cal-day-num { font-weight: 750; font-size: 0.82rem; color: var(--ink); }
.cal-day-events { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.cal-chip { font-size: 0.68rem; font-weight: 700; padding: 0.12rem 0.35rem; border-radius: 0.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.cal-chip.confirmed { background: var(--green-soft); color: var(--green); }
.cal-chip.requested { background: var(--amber-soft); color: var(--amber); }
.cal-chip.cleaning { background: var(--blue-soft); color: var(--blue); }
.cal-chip.maintenance { background: var(--red-soft); color: var(--red); }
.cal-chip.blocked { background: var(--violet-soft); color: var(--violet); }
.cal-more { font-size: 0.68rem; color: var(--muted); font-weight: 700; }

/* Mobile week reflow — a day-by-day agenda rendered alongside the grid; the
   40rem query below shows exactly one. Hidden by default (desktop shows grid). */
.cal-wk-agenda { display: none; }
.cal-wk-ag-day { border: 0.0625rem solid var(--line); border-radius: var(--radius); margin-bottom: 0.6rem; padding: 0.6rem 0.7rem; background: var(--surface); }
.cal-wk-ag-day.is-today { border-color: var(--green); }
.cal-wk-ag-head { display: flex; align-items: center; gap: 0.4rem; font-weight: 800; color: var(--ink); margin-bottom: 0.5rem; }
.cal-wk-ag-head > span { font-weight: 600; color: var(--muted); }
.cal-wk-ag-count { margin-left: auto; font-weight: 700; color: var(--muted); background: var(--surface-soft); border-radius: 1rem; padding: 0.1rem 0.55rem; font-size: 0.74rem; }
.cal-wk-ag-prop { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; color: var(--text); }
.cal-wk-agenda .cal-agenda-pill { max-width: 45%; }

@media (max-width: 30rem) {
  .cal-stat { flex-basis: 5.5rem; min-width: 5.5rem; }
  .cal-agenda-pill { max-width: 52%; }
}

/* <=40rem: Week -> day agenda, Month -> compact dot grid (no horizontal scroll). */
@media (max-width: 40rem) {
  .cal-wk-desktop { display: none; }
  .cal-wk-agenda { display: block; }
  .calendar-month { min-width: 0; }
  .cal-month-dow, .cal-month-grid { grid-template-columns: repeat(7, 1fr); }
  .cal-dow { padding: 0.3rem 0; font-size: 0.72rem; }
  .cal-day { min-height: 3.5rem; padding: 0.25rem; gap: 0.25rem; }
  .cal-day-num { font-size: 0.74rem; }
  .cal-day-events { flex-direction: row; flex-wrap: wrap; gap: 0.2rem; align-content: flex-start; }
  .cal-chip { font-size: 0; line-height: 0; width: 0.5rem; height: 0.5rem; min-width: 0.5rem; padding: 0; border-radius: 50%; }
  .cal-more { width: 100%; font-size: 0.62rem; line-height: 1; }
}

/* ------------------------------------------------------------------ AI brief */
.ai-brief {
  background: var(--surface-row);
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  color: var(--text);
  line-height: 1.55;
  font-size: 0.9rem;
}
.ai-brief ul { margin: 0.5rem 0 0; padding-left: 1.1rem; }
.ai-brief li { margin: 0.3rem 0; }
.ai-brief strong { color: var(--ink); }
.governance-note {
  display: flex; align-items: flex-start; gap: 0.5rem;
  margin-top: 0.75rem; padding: 0.6rem 0.7rem;
  background: var(--violet-soft); color: var(--violet);
  border-radius: var(--radius); font-size: 0.8rem; line-height: 1.4;
}
.governance-note i { margin-top: 0.1rem; }
.draft-box {
  min-height: 9rem;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-row);
  padding: 0.85rem;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
}
.draft-box.placeholder { color: var(--muted); }

/* AI chat */
.ai-chat { display: flex; flex-direction: column; gap: 0.7rem; min-height: 18rem; }
.chat-thread { display: flex; flex-direction: column; gap: 0.7rem; max-height: 26rem; overflow-y: auto; padding: 0.25rem; }
.chat-msg { max-width: 85%; padding: 0.65rem 0.85rem; border-radius: var(--radius); line-height: 1.5; font-size: 0.9rem; }
.chat-msg.user { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 0.25rem; }
.chat-msg.assistant { align-self: flex-start; background: var(--surface-soft); color: var(--text); border-bottom-left-radius: 0.25rem; }
.chat-msg.assistant strong { color: var(--ink); }
.chat-suggestions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chat-suggestion {
  border: 0.0625rem solid var(--line); background: var(--surface);
  border-radius: 99rem; padding: 0.4rem 0.75rem; font-size: 0.82rem;
  cursor: pointer; color: var(--text);
}
.chat-suggestion:hover { background: var(--surface-soft); border-color: var(--line-strong); }
.chat-input { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-input textarea {
  flex: 1 1 auto; resize: none; min-height: 2.75rem; max-height: 9rem;
  border: 0.0625rem solid var(--line); border-radius: var(--radius);
  padding: 0.6rem 0.7rem; background: var(--surface); color: var(--text);
}

/* ------------------------------------------------------------------ Checklist */
.checklist { display: grid; gap: 0.4rem; }
.check-item {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.65rem; border: 0.0625rem solid var(--line); border-radius: var(--radius);
  background: var(--surface-row); cursor: pointer; text-align: left; width: 100%;
}
.check-item:hover { border-color: var(--line-strong); }
.check-box {
  width: 1.3rem; height: 1.3rem; border-radius: 0.35rem; flex: 0 0 auto;
  border: 0.125rem solid var(--line-strong); display: grid; place-items: center;
  color: #fff; font-size: 0.72rem;
}
.check-item.done .check-box { background: var(--green); border-color: var(--green); }
.check-item.done .check-label { color: var(--muted); text-decoration: line-through; }
.check-label { color: var(--ink); font-weight: 600; }
.check-progress { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.check-progress .meter { flex: 1 1 auto; }
.check-progress .pct { font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }

/* photo proof grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 0.55rem; }
.photo-thumb {
  aspect-ratio: 4 / 3; border-radius: var(--radius-sm); border: 0.0625rem solid var(--line);
  background: var(--surface-soft); display: grid; place-items: center; color: var(--muted);
  position: relative; overflow: hidden; text-align: center; font-size: 0.74rem; padding: 0.4rem;
}
.photo-thumb i { font-size: 1.2rem; }
.photo-thumb .tag { position: absolute; top: 0.3rem; left: 0.3rem; }
.photo-drop {
  border: 0.125rem dashed var(--line-strong); border-radius: var(--radius);
  padding: 1.1rem; text-align: center; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
}
.photo-drop:hover { border-color: var(--green); color: var(--green); background: var(--green-soft); }

/* ------------------------------------------------------------------ Messages */
.messages-layout {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  gap: 0;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-height: 32rem;
  height: calc(100vh - var(--topbar-height) - 4rem);
}
.thread-list { border-right: 0.0625rem solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.thread-list-head { padding: 0.85rem; border-bottom: 0.0625rem solid var(--line); display: grid; gap: 0.6rem; }
.thread-search { width: 100%; }
.thread-scroll { overflow-y: auto; flex: 1 1 auto; }
.thread-item {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 0.6rem;
  padding: 0.7rem 0.85rem; border: 0; border-bottom: 0.0625rem solid var(--line);
  width: 100%; background: transparent; cursor: pointer; text-align: left; align-items: start;
}
.thread-item:hover { background: var(--surface-soft); }
.thread-item.active { background: var(--green-soft); }
.thread-main { min-width: 0; }
.thread-name { font-weight: 750; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-preview { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 0.1rem; }
.thread-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; }
.thread-time { color: var(--muted-2); font-size: 0.72rem; white-space: nowrap; }
.unread-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--green); }

.message-pane { display: flex; flex-direction: column; min-height: 0; }
.message-pane-head {
  padding: 0.75rem 1rem; border-bottom: 0.0625rem solid var(--line);
  display: flex; align-items: center; gap: 0.7rem;
}
.message-pane-head .thread-name { font-size: 0.98rem; }
.message-scroll { flex: 1 1 auto; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; background: var(--bg-tint); }
.bubble-row { display: flex; }
.bubble-row.sent { justify-content: flex-end; }
.bubble {
  max-width: 75%; padding: 0.6rem 0.8rem; border-radius: var(--radius);
  line-height: 1.45; font-size: 0.88rem;
}
.bubble-received { background: var(--surface); border: 0.0625rem solid var(--line); color: var(--text); border-bottom-left-radius: 0.25rem; }
.bubble-sent { background: var(--green); color: #fff; border-bottom-right-radius: 0.25rem; }
.bubble-meta { font-size: 0.7rem; margin-top: 0.25rem; opacity: 0.75; }
.composer { padding: 0.75rem 1rem; border-top: 0.0625rem solid var(--line); display: grid; gap: 0.5rem; }
.composer textarea {
  width: 100%; resize: none; min-height: 2.75rem; max-height: 9rem;
  border: 0.0625rem solid var(--line); border-radius: var(--radius);
  padding: 0.6rem 0.7rem; background: var(--surface); color: var(--text);
}
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.message-pane-empty { flex: 1 1 auto; display: grid; place-items: center; padding: 2rem; }
.thread-back { display: none; }

/* ------------------------------------------------------------------ Modal */
.modal-root, .drawer-root, .menu-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-root[aria-hidden="false"], .drawer-root[aria-hidden="false"], .menu-root[aria-hidden="false"] { pointer-events: auto; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 22, 17, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
  opacity: 0; transition: opacity 0.16s ease;
}
.modal-overlay.open { opacity: 1; }
.modal-panel {
  background: var(--surface);
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 32rem;
  max-height: calc(100vh - 2.5rem);
  display: flex; flex-direction: column;
  transform: translateY(0.75rem) scale(0.985); opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.modal-overlay.open .modal-panel { transform: none; opacity: 1; }
.modal-panel.small { max-width: 26rem; }
.modal-panel.large { max-width: 44rem; }
.modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  padding: 1.1rem 1.25rem 0.75rem;
}
.modal-header h2 { margin: 0; font-size: 1.1rem; color: var(--ink); }
.modal-eyebrow { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 800; margin-bottom: 0.2rem; }
.modal-close {
  width: 2.25rem; height: 2.25rem; flex: 0 0 auto;
  border: 0; background: var(--surface-soft); color: var(--muted);
  border-radius: var(--radius); cursor: pointer;
}
.modal-close:hover { background: var(--surface-strong); color: var(--text); }
.modal-body { padding: 0.5rem 1.25rem 1rem; overflow-y: auto; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem;
  padding: 0.9rem 1.25rem; border-top: 0.0625rem solid var(--line);
  flex-wrap: wrap;
}
.modal-footer.spread { justify-content: space-between; }

/* ------------------------------------------------------------------ Drawer */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 22, 17, 0.5);
  opacity: 0; transition: opacity 0.18s ease;
}
.drawer-overlay.open { opacity: 1; }
.drawer-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(34rem, 100vw);
  background: var(--surface);
  border-left: 0.0625rem solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.22s ease;
}
.drawer-overlay.open .drawer-panel { transform: none; }
.drawer-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 0.0625rem solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
}
.drawer-eyebrow { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 800; }
.drawer-title { margin: 0.15rem 0 0; font-size: 1.2rem; color: var(--ink); line-height: 1.25; }
.drawer-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.drawer-close {
  width: 2.25rem; height: 2.25rem; flex: 0 0 auto;
  border: 0; background: var(--surface-soft); color: var(--muted);
  border-radius: var(--radius); cursor: pointer;
}
.drawer-close:hover { background: var(--surface-strong); color: var(--text); }
.drawer-body { padding: 1.25rem; overflow-y: auto; flex: 1 1 auto; }
.drawer-footer {
  padding: 0.9rem 1.25rem; border-top: 0.0625rem solid var(--line);
  display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end;
}

/* ------------------------------------------------------------------ Forms */
.form-grid { display: grid; gap: 0.85rem; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.field { display: grid; gap: 0.3rem; }
.field > label { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.field .required { color: var(--red); }
.field input, .field select, .field textarea {
  min-height: 2.6rem;
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  background: var(--surface); color: var(--text);
  width: 100%;
}
.field textarea { min-height: 5.5rem; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); box-shadow: var(--ring); outline: none; }
.field-hint { font-size: 0.76rem; color: var(--muted); }
.field-error { font-size: 0.78rem; color: var(--red); display: none; align-items: center; gap: 0.3rem; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); }
.field.invalid .field-error { display: flex; }
.choice-grid { display: grid; gap: 0.45rem; }
.choice {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.7rem; border: 0.0625rem solid var(--line);
  border-radius: var(--radius); cursor: pointer; background: var(--surface);
}
.choice:hover { border-color: var(--line-strong); }
.choice input { width: auto; min-height: auto; }
.choice.selected { border-color: var(--green); background: var(--green-soft); }
.choice-main { min-width: 0; }
.choice-title { font-weight: 700; color: var(--ink); }
.choice-sub { font-size: 0.8rem; color: var(--muted); }

/* Wizard stepper */
.stepper { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.84rem; font-weight: 600; }
.step-dot {
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--surface-soft); color: var(--muted);
  border: 0.0625rem solid var(--line); font-size: 0.76rem; font-weight: 800;
}
.step.active .step-dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.active { color: var(--ink); }
.step.done .step-dot { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.step-line { flex: 1 1 1.5rem; height: 0.125rem; background: var(--line); min-width: 1rem; }
.step.done + .step-line, .step-line.done { background: var(--green); }

/* ------------------------------------------------------------------ Menus */
.menu {
  position: fixed;
  background: var(--surface);
  border: 0.0625rem solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  min-width: 16rem; max-width: 22rem;
  padding: 0.4rem;
  opacity: 0; transform: translateY(-0.35rem);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.menu.open { opacity: 1; transform: none; }
.menu-header {
  padding: 0.5rem 0.6rem; display: flex; align-items: center; justify-content: space-between;
  font-weight: 800; color: var(--ink); font-size: 0.86rem;
}
.menu-list { max-height: 22rem; overflow-y: auto; }
.menu-item {
  display: grid; grid-template-columns: auto minmax(0,1fr); gap: 0.6rem; align-items: start;
  width: 100%; border: 0; background: transparent; cursor: pointer;
  padding: 0.55rem 0.6rem; border-radius: var(--radius-sm); text-align: left; color: var(--text);
}
.menu-item:hover { background: var(--surface-soft); }
.menu-item .row-meta { margin-top: 0.05rem; }
.menu-sep { height: 0.0625rem; background: var(--line); margin: 0.3rem 0; }
.menu-empty { padding: 1.25rem 0.6rem; text-align: center; color: var(--muted); font-size: 0.85rem; }
.notif-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--green); margin-top: 0.45rem; }
.notif-dot.high { background: var(--red); }
.notif-dot.medium { background: var(--amber); }
.notif-dot.read { background: var(--line-strong); }

/* ------------------------------------------------------------------ Toasts */
.toast-region {
  position: fixed; right: 1rem; bottom: 1rem;
  display: grid; gap: 0.5rem; z-index: 120;
  max-width: calc(100vw - 2rem);
}
.toast {
  min-height: 2.75rem; max-width: 24rem;
  border-radius: var(--radius);
  background: #1f2e25; color: #fff;
  padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow-lg);
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 0.6rem; align-items: center;
  transform: translateY(0.5rem); opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { transform: none; opacity: 1; }
.toast-icon { width: 1.5rem; height: 1.5rem; display: grid; place-items: center; border-radius: 50%; flex: 0 0 auto; font-size: 0.8rem; }
.toast.success .toast-icon { background: var(--green); color: #fff; }
.toast.error .toast-icon { background: var(--red); color: #fff; }
.toast.warning .toast-icon { background: var(--amber); color: #1f2e25; }
.toast.info .toast-icon { background: var(--blue); color: #fff; }
.toast-body { font-size: 0.88rem; line-height: 1.35; }
.toast-close { border: 0; background: transparent; color: rgba(255,255,255,0.7); cursor: pointer; padding: 0.2rem; }
.toast-close:hover { color: #fff; }

/* ------------------------------------------------------------------ Helpers */
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 0.5rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.gap-wrap { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.mt-0 { margin-top: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 1.05rem; color: var(--ink); }
.callout {
  display: flex; gap: 0.6rem; align-items: flex-start;
  padding: 0.75rem 0.85rem; border-radius: var(--radius);
  background: var(--blue-soft); color: var(--blue); font-size: 0.85rem; line-height: 1.45;
}
.callout.amber { background: var(--amber-soft); color: var(--amber); }
.callout i { margin-top: 0.1rem; }

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 75rem) {
  .landing-panel {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .landing-copy h1 { max-width: 14ch; }
  .landing-preview { max-height: 30rem; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .span-3, .span-4, .span-5, .span-7, .span-8, .span-9 { grid-column: span 6; }
  .span-6 { grid-column: span 6; }
  .split-layout { grid-template-columns: minmax(0, 1fr) 17rem; }
}

@media (max-width: 60rem) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(18rem, 86vw); z-index: 70;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    max-height: 100vh;
  }
  .app-shell.nav-open .sidebar { transform: none; }
  .sidebar-close { display: inline-flex; }
  .nav-toggle { display: inline-flex; }
  .split-layout { grid-template-columns: 1fr; }
  .messages-layout { grid-template-columns: 1fr; height: auto; min-height: 28rem; }
  .messages-layout.thread-open .thread-list { display: none; }
  .messages-layout:not(.thread-open) .message-pane { display: none; }
  .messages-layout.thread-open .thread-back { display: inline-flex; }
}

@media (max-width: 52rem) {
  .landing-shell { place-items: start; }
  .landing-panel { padding: 1rem; }
  .landing-copy h1 { max-width: 100%; }
  .landing-metrics { grid-template-columns: 1fr; }
  .landing-metric {
    min-height: 4rem;
    border-right: 0;
    border-bottom: 0.0625rem solid var(--line);
  }
  .landing-metric:last-child { border-bottom: 0; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8, .span-9, .span-12 { grid-column: 1 / -1; }
  .topbar { flex-wrap: wrap; }
  .topbar-lead { width: 100%; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .title-block h1 { font-size: 1.15rem; }
  .title-block p { max-width: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 36rem) {
  .landing-shell { padding: 0.75rem; }
  .landing-brand { align-items: flex-start; }
  .landing-actions .landing-button { width: 100%; }
  .landing-preview-caption { display: grid; }
  .view-root { padding: 0.85rem; }
  .topbar { padding: 0.6rem 0.85rem; }
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar-actions { gap: 0.4rem; }
  .select-control select { max-width: 9rem; }
  .primary-button span { display: none; }
  .table-toolbar { align-items: stretch; }
  .table-search { width: 100%; min-width: 0; }
  .messages-layout { grid-template-columns: 1fr; }
}

/* ====================================================================
   DEV_GUIDE compliance (DOCS/DEV_GUIDE.txt CRITICAL CONSTRAINTS)
   #1 all-rem (no px), #2 light/dark, #6 touch targets >= 2.75rem (44px).
   The shared interactive bases were 2.6rem (~41.6px) — bump them above the
   44px floor. Unconditional so touch targets hold at every breakpoint
   (they matter most on mobile). The console already toggles theme via the
   user menu; this adds the missing toggle + dark surface to the landing page.
   ==================================================================== */
.icon-button, .primary-button, .secondary-button, .ghost-button, .danger-button,
.row-action, .nav-item, .select-control, .segmented { min-height: 2.75rem; }
.icon-button { width: 2.75rem; }
.landing-actions .landing-button { min-height: 3rem; }   /* hero CTAs a touch taller */

/* Landing dark theme: the .landing-page gradient is hard-coded light, so give
   it a dark counterpart; everything else on the landing already uses theme vars. */
[data-theme="dark"] .landing-page {
  background: linear-gradient(135deg, #0f1611 0%, #131c16 52%, #16130d 100%);
}

/* Fixed landing theme toggle (rem-based, 2.75rem touch target). */
.landing-theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 20;
  width: 2.75rem; height: 2.75rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 62.5rem;
  border: 0.0625rem solid var(--line);
  background: var(--surface); color: var(--muted);
  cursor: pointer; box-shadow: var(--shadow);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.landing-theme-toggle:hover { color: var(--green); border-color: var(--green); }
.landing-theme-toggle:focus-visible { outline: none; box-shadow: var(--ring); }

/* DEV_GUIDE #2: native <select> dropdowns ignored dark mode (white popup, e.g.
   the topbar portfolio filter) because the control is background:transparent.
   Force the select into the dark color-scheme + theme the option list so the
   popup follows the theme. Applies to every select (filters + modal forms). */
[data-theme="dark"] select { color-scheme: dark; }
.select-control select option,
select option { background: var(--surface); color: var(--text); }
