@font-face { font-family: "DM Sans"; src: url("./fonts/dm-sans-latin.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("./fonts/manrope-latin.woff2") format("woff2"); font-weight: 400 800; font-style: normal; font-display: swap; }

:root {
  --ink: #16201a;
  --muted: #64716a;
  --line: #e3e7e2;
  --paper: #fbfbf8;
  --card: #ffffff;
  --shell: #12211a;
  --shell-ink: #e8efe9;
  --shell-muted: #93a398;
  --accent: #2f6f47;
  --accent-soft: #e7f1ea;
  --warn: #9a5a18;
  --warn-soft: #fbf1e4;
  --danger: #a33a32;
  --danger-soft: #f9eceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 32, 26, .05), 0 8px 24px rgba(20, 32, 26, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background: var(--paper);
  font: 14px/1.5 "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: "Manrope", sans-serif; letter-spacing: -.015em; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }

/* Shell */
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px 16px;
  background: var(--shell); color: var(--shell-ink);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 12px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: #d7e6da; color: #123; font-weight: 800; }
.brand-name { font-family: "Manrope", sans-serif; font-weight: 800; font-size: 14px; line-height: 1.15; }
.brand-sub { color: var(--shell-muted); font-size: 11px; }

.nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--shell-muted); font-weight: 600; font-size: 13.5px;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--shell-ink); }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-count { margin-left: auto; font-size: 11px; color: var(--shell-muted); background: rgba(255,255,255,.08); border-radius: 20px; padding: 1px 7px; }
.nav-item.active .nav-count { color: #fff; background: rgba(255,255,255,.18); }

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.shell-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 9px;
  background: rgba(255,255,255,.07); color: var(--shell-muted); font-size: 12px;
}
.shell-search kbd { margin-left: auto; font: 10px "DM Sans"; padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.1); }
.profile-card { display: flex; align-items: center; gap: 9px; padding: 9px 8px; border-top: 1px solid rgba(255,255,255,.09); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #d7e6da; color: #123; font-weight: 800; font-size: 11px; }
.profile-name { font-size: 12.5px; font-weight: 700; }
.profile-meta { font-size: 11px; color: var(--shell-muted); }
.profile-card select { margin-left: auto; background: transparent; border: 0; color: var(--shell-muted); font-size: 11px; max-width: 74px; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  min-height: 56px; padding: 10px clamp(16px, 3vw, 34px);
  background: rgba(251,251,248,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.crumbs b { color: var(--ink); font-weight: 700; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-search {
  display: flex; align-items: center; gap: 7px;
  width: 240px; height: 34px; flex: 0 0 240px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--muted);
}
.top-search:focus-within, .searchbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.top-search svg, .searchbox svg { width: 15px; height: 15px; flex: 0 0 auto; }
.top-search input { border: 0; outline: 0; min-width: 0; height: 100%; padding: 0; width: 100%; background: transparent; font-size: 12.5px; }
.top-search kbd { flex: 0 0 auto; font: 10px "DM Sans"; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }

.page { padding: 26px clamp(16px, 3vw, 34px) 60px; max-width: 1220px; }
.page-head { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 20px; }
.eyebrow { color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 5px; }
.page-title { font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; }
.page-sub { margin: 5px 0 0; color: var(--muted); max-width: 62ch; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); font-weight: 650; font-size: 12.5px; }
.btn:hover { border-color: #c9d2c9; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #275e3c; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 29px; padding: 4px 10px; font-size: 11.5px; }
.btn.danger { color: var(--danger); }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
.icon-btn:hover { border-color: #c9d2c9; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: #f3f5f1; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.input, select.input, textarea.input {
  width: 100%; min-height: 36px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card);
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { display: grid; gap: 5px; }
.field > span { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Cards and tables */
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { padding: 16px 16px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-label { color: var(--muted); font-size: 11.5px; font-weight: 700; }
.metric-value { margin: 6px 0 3px; font-family: "Manrope", sans-serif; font-size: 23px; font-weight: 750; letter-spacing: -.02em; }
.metric-note { color: var(--muted); font-size: 11.5px; }
.metric.warn .metric-value { color: var(--warn); }
.metric .metric-link { margin-top: 8px; font-size: 11.5px; font-weight: 700; color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 16px; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 14px; font-weight: 750; }
.card-sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }

.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid #eef0ed; }
.list-row:first-child { border-top: 0; }
.list-row:hover { background: #fafbf8; }
.row-main { min-width: 0; flex: 1; }
.row-title { font-weight: 700; font-size: 13px; }
.row-sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; align-items: center; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; text-align: left; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: #fafbf8; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid #eef0ed; vertical-align: middle; font-size: 12.5px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbf8; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill.current, .pill.paid, .pill.signed, .pill.clear, .pill.completed { color: #23603c; background: var(--accent-soft); }
.pill.open, .pill.issued, .pill.active, .pill.sent { color: #2c5570; background: #e9f1f7; }
.pill.overdue, .pill.attention { color: var(--warn); background: var(--warn-soft); }
.pill.draft, .pill.planned { color: #665d4a; background: #f4f0e4; }
.pill.void { color: var(--danger); background: var(--danger-soft); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1; }
.searchbox { display: flex; align-items: center; gap: 7px; width: 260px; min-width: 0; height: 34px; flex: 0 1 260px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.searchbox input { border: 0; outline: 0; min-width: 0; height: 100%; padding: 0; width: 100%; background: transparent; font-size: 12.5px; }
.results-note { color: var(--muted); font-size: 11.5px; margin-left: auto; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.section-gap { margin-top: 16px; }
.disclosure { border-top: 1px solid var(--line); }
.disclosure summary { padding: 11px 16px; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); }
.disclosure summary:hover { color: var(--ink); }
.disclosure[open] summary { color: var(--ink); }
.disclosure-body { padding: 0 16px 14px; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.timeline { display: grid; gap: 14px; padding: 4px 0; }
.timeline-item { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; }
.timeline-dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; }
.timeline-item.warn .timeline-dot { background: var(--warn-soft); color: var(--warn); }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.setting-card { display: block; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.setting-card:hover { border-color: #c9d2c9; }
.setting-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: #f1f4ef; color: var(--accent); margin-bottom: 10px; }
.setting-card h3 { font-size: 13.5px; }
.setting-card p { margin: 4px 0 0; color: var(--muted); font-size: 11.5px; }

/* Modal + command palette */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(12,20,15,.42); display: grid; place-items: start center; padding: 8vh 16px 16px; }
.dialog { width: min(560px, 100%); background: var(--card); border-radius: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.28); overflow: hidden; }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dialog-title { font-weight: 750; font-size: 14px; }
.dialog-body { padding: 16px; display: grid; gap: 12px; max-height: 62vh; overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.dialog p { margin: 0; color: var(--muted); font-size: 12.5px; }

.palette { width: min(520px, 100%); background: var(--card); border-radius: 13px; box-shadow: 0 30px 80px rgba(0,0,0,.3); overflow: hidden; }
.palette input { width: 100%; padding: 15px 16px; border: 0; outline: 0; font-size: 14px; border-bottom: 1px solid var(--line); }
.palette-list { max-height: 320px; overflow: auto; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; }
.palette-item:hover, .palette-item.active { background: #f5f8f4; }
.palette-item b { font-size: 12.5px; }
.palette-item small { margin-left: auto; color: var(--muted); font-size: 11px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; padding: 9px 14px; border-radius: 9px; background: #17251d; color: #fff; font-size: 12.5px; box-shadow: var(--shadow); }
.mobile-nav { display: none; }

@media (max-width: 1020px) {
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; padding-bottom: 62px; }
  .sidebar { display: none; }
  .topbar { padding-inline: 14px; }
  .top-search { display: none; }
  .page { padding: 18px 14px 36px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-actions { margin-left: 0; width: 100%; }
  .metrics { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
  .row-sub { white-space: normal; }
  .mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--shell); color: var(--shell-ink);
    border-top: 1px solid rgba(255,255,255,.1);
  }
  .mobile-nav a { display: grid; justify-items: center; gap: 2px; padding: 8px 4px 7px; font-size: 10.5px; color: var(--shell-muted); }
  .mobile-nav a.active { color: #fff; }
  .mobile-nav svg { width: 19px; height: 19px; }
}
