/* Roof Linker — design tokens */
:root {
  --bg-app: #F7F2E8;
  --bg-sidebar: #F1ECDF;
  --bg-content: #FAF6EC;
  --bg-card: #FFFFFF;
  --bg-card-soft: #FBF8F1;
  --bg-hover: rgba(0, 0, 0, 0.035);
  --bg-active: rgba(0, 0, 0, 0.055);

  --border: #E8E0CC;
  --border-soft: #EFE9D8;
  --border-strong: #D6CCB0;

  --text-1: #1B1814;
  --text-2: #5B544A;
  --text-3: #8A8275;
  --text-4: #B5AC9A;

  --gold: #C7A24A;
  --gold-dark: #A88431;
  --gold-soft: #F4E6BE;
  --gold-bg: #FBF3DA;

  --red: #C84B3C;
  --green: #2F7A4D;
  --green-soft: #DDEBDF;
  --blue: #3E6FB6;

  --serif: "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(40, 30, 10, 0.04);
  --shadow: 0 1px 3px rgba(40, 30, 10, 0.05), 0 2px 8px rgba(40, 30, 10, 0.03);

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* Serif italic display for headlines */
.serif {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.005em;
}

/* App layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg-app);
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.org-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.org-switch:hover { background: var(--bg-hover); }
.org-logo {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(140deg, #2C4A3E, #6B8A66 80%);
  display: grid; place-items: center;
  color: #F4E9CC;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.08);
}
.org-name { font-weight: 600; font-size: 13.5px; }
.org-tier { font-size: 11px; color: var(--text-3); }
.org-caret { margin-left: auto; color: var(--text-3); }

.search {
  margin: 12px 4px 8px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 13px;
}
.search input { all: unset; flex: 1; font-size: 13px; color: var(--text-1); }
.kbd {
  font-size: 11px; color: var(--text-3);
  padding: 1px 5px; border-radius: 4px;
  background: var(--bg-app);
}

.nav-section { margin-top: 12px; }
.nav-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 6px 10px 4px;
  font-weight: 500;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-1);
  cursor: pointer;
  user-select: none;
  position: relative;
}
.nav-item .nav-icon { width: 16px; height: 16px; color: var(--text-2); flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active {
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.nav-item .chev { margin-left: auto; color: var(--text-3); transition: transform 0.15s; }
.nav-item.open .chev { transform: rotate(90deg); }
.nav-sub {
  margin: 2px 0 6px 28px;
  display: flex; flex-direction: column; gap: 1px;
}
.nav-sub .nav-item {
  padding: 5px 10px;
  font-size: 13px;
  color: var(--text-2);
}
.nav-sub .nav-item.active {
  background: transparent;
  border: none;
  color: var(--text-1);
  box-shadow: none;
}
.nav-sub .nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 2px; background: var(--gold-dark); border-radius: 2px;
}
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--gold-bg);
  color: var(--gold-dark);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.user-card {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(140deg, #4A3F30, #847562);
  flex-shrink: 0;
  display: grid; place-items: center;
  color: #F4E9CC; font-size: 12px; font-weight: 600;
  border: 1px solid rgba(0,0,0,0.1);
}
.user-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-role { font-size: 11.5px; color: var(--text-3); }
.user-card .gear { margin-left: auto; color: var(--text-3); cursor: pointer; }

/* ---------- Main / Content ---------- */
.main {
  background: var(--bg-content);
  display: flex; flex-direction: column;
  min-width: 0;
}
.topbar {
  display: flex; align-items: center;
  padding: 14px 28px 12px;
  border-bottom: 1px solid var(--border-soft);
  gap: 12px;
}
.topbar-title { font-size: 22px; }
.topbar-tabs { display: flex; gap: 4px; margin-left: 8px; }
.topbar-tab {
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; color: var(--text-2);
  border: 1px solid transparent;
  background: transparent;
}
.topbar-tab.active {
  background: var(--bg-card);
  color: var(--text-1);
  border-color: var(--border);
  font-weight: 600;
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn-tour {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--gold-bg);
  border: 1px solid var(--gold-soft);
  color: var(--gold-dark);
  font-weight: 600;
  font-size: 13px;
}
.btn-tour:hover { background: var(--gold-soft); }
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  position: relative;
}
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--bg-card);
}

.content { padding: 28px 36px 80px; max-width: 1320px; }

.page-head { margin-bottom: 22px; }
.page-title { font-size: 38px; line-height: 1; margin: 0 0 8px; }
.page-sub { color: var(--text-2); font-size: 13.5px; }

/* Quick actions */
.qa-row { display: flex; gap: 10px; margin: 18px 0 22px; flex-wrap: wrap; }
.qa {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-1);
}
.qa:hover { background: var(--bg-card-soft); }

/* Cards */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; margin-bottom: 14px; }
.card-title { font-size: 18px; }
.card-link {
  margin-left: auto;
  color: var(--text-2);
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 3px;
}
.card-link:hover { color: var(--text-1); }

/* Schedule rows */
.sched-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  padding: 10px 4px;
  border-top: 1px dashed var(--border-soft);
  gap: 10px;
}
.sched-row:first-of-type { border-top: none; }
.sched-time { color: var(--text-3); font-size: 14.5px; }
.sched-title { font-weight: 600; font-size: 13.5px; }
.sched-addr { font-size: 12.5px; color: var(--text-3); }
.chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-app);
  color: var(--text-2);
  border: 1px solid var(--border-soft);
  font-weight: 500;
  white-space: nowrap;
}
.chip.gold { background: var(--gold-bg); color: var(--gold-dark); border-color: var(--gold-soft); }
.chip.green { background: var(--green-soft); color: var(--green); border-color: #c5d9c9; }
.chip.red { background: #FBE3DF; color: var(--red); border-color: #f0c8c2; }

.lead-row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 10px 4px;
  border-top: 1px dashed var(--border-soft);
  gap: 8px;
  align-items: center;
}
.lead-row:first-of-type { border-top: none; }
.lead-name { font-weight: 600; font-size: 13.5px; }
.lead-meta { color: var(--text-3); font-size: 12.5px; }

/* Profitability */
.prof-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-top: 6px;
}
.prof-val { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.prof-label { font-size: 11.5px; color: var(--text-3); margin-top: 4px; letter-spacing: 0.05em; text-transform: uppercase; }
.prof-worst {
  font-size: 17px;
  color: var(--gold-dark);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* On the clock */
.clocked-big {
  font-size: 64px;
  line-height: 1;
}
.clocked-label { color: var(--text-3); font-size: 13.5px; }

/* Empty / states */
.muted { color: var(--text-3); }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 14, 0, 0.32);
  display: grid; place-items: center;
  z-index: 100;
  padding: 24px;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  overflow: hidden;
}
.modal-head {
  padding: 18px 22px 8px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-title { font-size: 26px; margin: 0; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  padding: 14px 22px;
  display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-card-soft);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.input, .textarea, .select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  width: 100%;
  color: var(--text-1);
}
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }
.textarea { resize: vertical; min-height: 80px; }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-1);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg-card-soft); }
.btn.primary {
  background: var(--text-1);
  color: #FBF7EB;
  border-color: var(--text-1);
}
.btn.primary:hover { background: #2E2A24; }
.btn.gold {
  background: var(--gold);
  border-color: var(--gold-dark);
  color: #1B1814;
}
.btn.gold:hover { background: var(--gold-dark); color: #fff8e0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { background: transparent; border-color: var(--border); color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

/* Org switch popover */
.popover {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
  padding: 6px;
  z-index: 50;
}
.popover-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.popover-item:hover { background: var(--bg-hover); }
.popover-item.active { background: var(--gold-bg); }
.popover-section {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 10px 4px;
  font-weight: 500;
}
.popover hr { border: none; border-top: 1px solid var(--border-soft); margin: 4px 0; }

/* Marketplace */
.subtabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  gap: 4px;
  align-items: center;
}
.subtab {
  padding: 10px 4px;
  margin-right: 22px;
  font-size: 14px;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  position: relative;
  top: 1px;
  background: transparent;
  border-left: none; border-right: none; border-top: none;
}
.subtab.active {
  color: var(--text-1);
  border-bottom-color: var(--gold-dark);
  font-weight: 600;
}
.subtab .count {
  margin-left: 6px;
  font-size: 11px; color: var(--text-4);
  font-weight: 500;
}

.filters-row {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filter-input {
  flex: 1; min-width: 220px; max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-1);
}
.filter-pill {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.filter-pill.active { background: var(--text-1); color: #FBF7EB; border-color: var(--text-1); }

.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.mp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.mp-card:hover { box-shadow: var(--shadow); }
.mp-image {
  aspect-ratio: 16 / 11;
  background: var(--bg-card-soft);
  position: relative;
  overflow: hidden;
}
.mp-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.mp-title { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.mp-sub { font-size: 12.5px; color: var(--text-3); }
.mp-foot {
  display: flex; align-items: baseline; gap: 8px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
}
.mp-price { font-size: 16px; font-weight: 600; }
.mp-unit { color: var(--text-3); font-size: 12px; }
.mp-meta-pill {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold-bg);
  color: var(--gold-dark);
}

/* Leads board (marketplace) */
.leads-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.leads-row {
  display: grid;
  grid-template-columns: 60px 2fr 1.4fr 1fr 1fr 0.8fr 130px;
  padding: 12px 16px;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
}
.leads-row.head {
  background: var(--bg-card-soft);
  font-size: 11.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-top: none;
  font-weight: 600;
}
.leads-row .lt {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
}

/* Workflow kanban / doc list */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.kanban-col {
  background: var(--bg-card-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 360px;
}
.kanban-head {
  display: flex; align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.kanban-head .ct {
  margin-left: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--text-3);
  font-weight: 500;
}
.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-sm);
}
.kanban-card .ttl { font-weight: 600; font-size: 13px; }
.kanban-card .meta { font-size: 11.5px; color: var(--text-3); }
.kanban-card .amt { font-size: 13px; font-weight: 600; color: var(--text-1); margin-top: 4px; }

/* Doc list */
.doc-row {
  display: grid;
  grid-template-columns: 36px 2fr 1.2fr 1fr 1fr 110px;
  padding: 12px 16px;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
}
.doc-row.head {
  background: var(--bg-card-soft);
  font-size: 11.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-top: none;
  font-weight: 600;
}
.doc-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--bg-card-soft);
  border-radius: 8px;
  color: var(--text-2);
}

/* Tab bar for Workflow / Marketplace */
.tab-and-action {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 22px;
}

/* Floating chat */
.chat-fab {
  position: fixed; bottom: 22px; right: 22px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  display: grid; place-items: center;
  border: none;
  box-shadow: 0 8px 24px rgba(40, 60, 110, 0.35);
  z-index: 40;
}

/* Pulse for "live" */
.pulse-dot {
  width: 8px; height: 8px; background: var(--green);
  border-radius: 50%; display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 0 0 rgba(47, 122, 77, 0.55);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 122, 77, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(47, 122, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 122, 77, 0); }
}

/* Invite chips */
.chip-removable {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 10px;
  background: var(--bg-card-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
}
.chip-removable button { all: unset; cursor: pointer; color: var(--text-3); }
.chip-removable button:hover { color: var(--red); }

/* Seat usage bar */
.seat-bar {
  height: 6px; background: var(--bg-app);
  border-radius: 999px; overflow: hidden;
  margin-top: 6px;
}
.seat-bar > div {
  height: 100%; background: var(--gold);
}

/* Onboarding banner */
.banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(95deg, #FBF3DA, #FAF6EC);
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 22px;
}
.banner .b-title { font-weight: 600; font-size: 14px; }
.banner .b-sub { font-size: 12.5px; color: var(--text-2); }

/* Tweaks panel position override (top-right to avoid chat fab) */
.tweaks-panel-host { left: auto !important; right: 24px !important; top: 80px !important; bottom: auto !important; }

/* Language toggle */
.lang-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-toggle button {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.04em;
  font-family: inherit;
}
.lang-toggle button.active {
  background: var(--text-1);
  color: #FBF7EB;
}
.lang-toggle button:hover:not(.active) { color: var(--text-1); }
