@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope.ttf") format("truetype");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --sage: #607d65;
  --sage-dark: #33503a;
  --sage-light: #e2e8e3;
  --sand: #f2f7f2;
  --sand-deep: #e5eae5;
  --ink: #152318;
  --muted: #5f6b61;
  --divider: #dbdfdb;
  --surface: #ffffff;
  --error: #b3261e;
  --error-bg: #fbeceb;
  --warn: #a3561c;
  --warn-bg: #fbf0e6;
  --ok-bg: #e7f1e8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(21, 35, 24, .06), 0 1px 3px rgba(21, 35, 24, .08);
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sidebar: 236px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--sand); }
a { color: var(--sage-dark); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0 0 .75em; }
small, .muted { color: var(--muted); }
.icon { flex: none; }

/* Layout */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--divider); display: flex; flex-direction: column; padding: 18px 12px; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: 1.1rem; padding: 4px 10px 18px; }
.brand b { color: var(--sage); font-weight: 750; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 550; }
.sidebar nav a:hover { background: var(--sand); }
.sidebar nav a.active { background: var(--sage-light); color: var(--sage-dark); font-weight: 700; }
.nav-heading { margin: 16px 12px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--divider); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.me-link { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); padding: 6px 10px; border-radius: 10px; font-weight: 650; }
.me-link small { display: block; font-weight: 500; }
.me-link.active, .me-link:hover { background: var(--sand); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--sage); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.main { margin-left: var(--sidebar); padding: 28px 32px 48px; max-width: 1280px; }
.main-bare { padding: 24px 16px; }
.topbar, .tabbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 72px 16px 96px; }
  .topbar { display: flex; position: fixed; inset: 0 0 auto 0; height: 56px; align-items: center; gap: 10px; padding: 0 12px 0 6px; background: var(--surface); border-bottom: 1px solid var(--divider); z-index: 20; }
  .topbar .brand { padding: 0 6px; margin-right: auto; }
  .tabbar { display: flex; position: fixed; inset: auto 0 0 0; background: var(--surface); border-top: 1px solid var(--divider); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: .68rem; font-weight: 600; text-decoration: none; color: var(--muted); }
  .tabbar a.active { color: var(--sage-dark); }
  h1 { font-size: 1.35rem; }
}
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 8px; border-radius: 8px; display: grid; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(21,35,24,.14); min-width: 200px; padding: 6px; display: flex; flex-direction: column; }
.menu-panel a, .menu-panel button { padding: 10px 12px; text-decoration: none; color: var(--ink); border-radius: 8px; text-align: left; font: inherit; }
.menu-panel a:hover { background: var(--sand); }

/* Page header */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; margin-right: auto; }
.page-head p { width: 100%; margin: -6px 0 0; color: var(--muted); }
.crumb { display: inline-block; margin-bottom: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; }

/* Cards and grids */
.card { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card > h2:first-child, .card > header:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; margin-right: auto; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .card { padding: 14px 16px; } }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* Stats */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label { font-size: .8rem; font-weight: 650; color: var(--muted); }
.stat .value { font-size: 1.7rem; font-weight: 750; letter-spacing: -.02em; }
.stat .sub { font-size: .82rem; color: var(--muted); }
@media (max-width: 700px) { .stat .value { font-size: 1.35rem; } }
.progress { height: 8px; border-radius: 99px; background: var(--sand-deep); overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: var(--sage); border-radius: 99px; }

/* Priority checks */
.checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .checks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.check { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--divider); background: var(--surface); text-decoration: none; color: var(--ink); }
.check .count { font-size: 1.4rem; font-weight: 800; min-width: 1.6em; text-align: center; }
.check .what { font-weight: 650; font-size: .88rem; line-height: 1.3; }
.check.hot { border-color: #e9b9a4; background: var(--warn-bg); }
.check.hot .count { color: var(--warn); }
.check.calm .count { color: var(--muted); }
.check:hover { border-color: var(--sage); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-top: 1px solid var(--divider); display: flex; gap: 12px; align-items: flex-start; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 650; text-decoration: none; color: var(--ink); }
.list .title:hover { text-decoration: underline; }
.list .meta { font-size: .84rem; color: var(--muted); }
.empty { color: var(--muted); padding: 8px 0; margin: 0; }
.time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; }
.overdue, .meta .overdue, .deal .meta.overdue, td.overdue { color: var(--error); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--divider); vertical-align: top; }
th { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: #fafcfa; }
tfoot td { font-weight: 750; border-bottom: 0; }
.client-cards { display: none; }
@media (max-width: 700px) {
  .clients-table { display: none; }
  .client-cards { display: flex; flex-direction: column; gap: 10px; }
}

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--sand-deep); color: var(--ink); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.risk-high { background: var(--error-bg); color: var(--error); }
.risk-medium { background: var(--warn-bg); color: var(--warn); }
.risk-low { background: var(--ok-bg); color: var(--sage-dark); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .75rem; font-weight: 650; background: var(--sand); border: 1px solid var(--divider); }

/* Forms */
label { display: block; font-weight: 650; font-size: .88rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field small { display: block; margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=url], input[type=number], input[type=date], input[type=time], input[type=search], input[type=color], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #c7cec8; border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input[type=color] { padding: 4px; width: 56px; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(96,125,101,.45); border-color: var(--sage); }
.error-text { color: var(--error); font-size: .84rem; margin-top: 4px; }
.has-error input, .has-error select { border-color: var(--error); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 140px; min-width: 0; }
.row > .shrink { flex: 0 0 auto; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 550; }
.checkbox input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--sage); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters > * { flex: 1 1 160px; }
.filters input[type=search] { flex: 2 1 220px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 750; margin-bottom: 10px; font-size: 1rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; border-radius: 10px; padding: 10px 16px; min-height: 44px; border: 1px solid var(--sage-dark); background: var(--sage-dark); color: #fff; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--ink); }
.btn-secondary { background: var(--surface); color: var(--sage-dark); border-color: #c7cec8; }
.btn-secondary:hover { background: var(--sand); }
.btn-danger { background: var(--surface); color: var(--error); border-color: #e3b6b2; }
.btn-danger:hover { background: var(--error-bg); }
.btn-small { min-height: 34px; padding: 5px 12px; font-size: .86rem; }
.link-button { background: none; border: 0; padding: 6px 10px; font: inherit; color: var(--muted); cursor: pointer; text-align: left; font-weight: 600; }
.link-button:hover { color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; background: var(--ok-bg); color: var(--sage-dark); border: 1px solid #c4dbc7; }
.flash-error { background: var(--error-bg); color: var(--error); border-color: #efc7c4; }
.notice { padding: 12px 16px; border-radius: 10px; background: var(--warn-bg); border: 1px solid #ecd2bb; margin-bottom: 16px; }

/* Client page */
.contact-line { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 4px 0 0; color: var(--muted); font-weight: 550; }
.contact-line a, .contact-line span { display: inline-flex; gap: 6px; align-items: center; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--divider); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--sage); }
.timeline li.system::before { border-color: var(--divider); }
.timeline .body { white-space: pre-wrap; word-wrap: break-word; }
.timeline li:last-child { padding-bottom: 0; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--divider); }
.checklist li:first-child { border-top: 0; }
.checklist form { margin: 0; }
.tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #c7cec8; background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; color: #fff; }
.tick.done { background: var(--sage); border-color: var(--sage); }
.checklist .done-label { color: var(--muted); text-decoration: line-through; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-weight: 600; font-size: .88rem; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
details.inline > summary { cursor: pointer; font-weight: 700; color: var(--sage-dark); list-style: none; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline[open] > summary { margin-bottom: 10px; }
.follow-up { border: 1px solid var(--divider); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface); }
.follow-up .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

/* Pipeline board */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.column { flex: 0 0 236px; background: var(--sand-deep); border-radius: var(--radius); padding: 10px; scroll-snap-align: start; max-height: calc(100vh - 200px); display: flex; flex-direction: column; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; font-weight: 750; }
.column-head .n { margin-left: auto; font-weight: 700; color: var(--muted); font-size: .85rem; }
.column-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; overflow-y: auto; border-radius: 8px; }
.column-cards.drag-over { background: rgba(96,125,101,.14); }
.deal { background: var(--surface); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); border-left: 4px solid var(--c, var(--sage)); cursor: grab; }
.deal.dragging { opacity: .5; }
.deal a { font-weight: 700; text-decoration: none; color: var(--ink); }
.deal .meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.deal select { margin-top: 8px; min-height: 34px; padding: 4px 8px; font-size: .84rem; display: none; }
@media (hover: none), (max-width: 700px) { .deal select { display: block; } .deal { cursor: default; } .column { flex-basis: 82vw; max-height: none; } }

/* Schedule */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.day.today { border-color: var(--sage); box-shadow: 0 0 0 2px var(--sage-light); }
.day h3 { font-size: .85rem; margin-bottom: 8px; }
.day .slot { display: block; padding: 6px 8px; border-radius: 8px; background: var(--sand); margin-bottom: 6px; text-decoration: none; color: var(--ink); font-size: .84rem; border-left: 3px solid var(--sage); }
.day .slot.demo { border-left-color: #8c7ab8; }
.day .slot b { display: block; }
@media (max-width: 1000px) { .week { grid-template-columns: 1fr; } .day { min-height: 0; } }

/* Login */
.login { max-width: 400px; margin: 8vh auto 0; }
.login .brand { justify-content: center; font-size: 1.4rem; padding-bottom: 24px; }

/* Statement */
.statement { max-width: 820px; margin: 0 auto; }
@media print {
  .sidebar, .topbar, .tabbar, .no-print, .flash { display: none !important; }
  .main { margin: 0; padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
