/* Studio ledger — quiet, dense, readable. One accent: working blue. */

:root {
  --paper: #f5f6f4;
  --card: #ffffff;
  --ink: #22262a;
  --muted: #6b7178;
  --hairline: #dde0dc;
  --accent: #275d9f;
  --accent-strong: #1d4a82;
  --accent-soft: #e7eef7;
  --danger: #b3264a;
  --danger-soft: #f8e9ee;
  --warn: #9a6700;
  --warn-soft: #f7efdc;
  --ok: #2f7a4d;
  --ok-soft: #e6f1ea;
  --sans: "Avenir Next", "Seravek", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16181a;
    --card: #1e2124;
    --ink: #e7e6e2;
    --muted: #969ca3;
    --hairline: #33373b;
    --accent: #7faee3;
    --accent-strong: #a3c4ec;
    --accent-soft: #24303f;
    --danger: #e4718f;
    --danger-soft: #3a2430;
    --warn: #d9a431;
    --warn-soft: #37301e;
    --ok: #71b98c;
    --ok-soft: #21322a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Shell ---- */

.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }

.sidebar {
  border-right: 1px solid var(--hairline);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar a {
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.95rem;
}
.sidebar a:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar a.current { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.wordmark {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted) !important;
  margin-bottom: 16px;
  display: block;
}
.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--hairline);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
}
.sidebar-foot a { color: var(--muted); }

.main { min-width: 0; }
.topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-bottom: 1px solid var(--hairline);
}
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; }
.content { padding: 24px 28px 64px; max-width: 1100px; }

/* ---- Page furniture ---- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.head-actions { display: flex; gap: 8px; align-items: center; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--hairline)); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { font-family: var(--mono); font-size: 0.85em; letter-spacing: -0.02em; }
.empty { color: var(--muted); font-size: 0.9rem; }
.quiet-link { font-size: 0.85rem; }
.spacer { flex: 1; }
.inactive { opacity: 0.55; }

.flashes { padding: 12px 28px 0; }
.flashes-bare { padding: 16px; max-width: 420px; margin: 0 auto; }
.flash {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--hairline));
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.flash-error { background: var(--danger-soft); border-color: var(--danger); }

/* ---- Tables ---- */

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 1px solid var(--hairline);
}
.table td { padding: 8px 10px; border-bottom: 1px solid var(--hairline); vertical-align: baseline; }
.table tr:last-child td { border-bottom: none; }
.table-tight td, .table-tight th { padding: 4px 8px; }
.table .num { text-align: right; white-space: nowrap; }
.table th:last-child, .table td.actions-cell { text-align: right; }
.table-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--hairline); border-radius: 8px; }
.table-scroll .table td, .table-scroll .table th { white-space: nowrap; }

.panel .table tr td:first-of-type {
  padding-left: 0;
}

.panel .table tr td:last-of-type {
  padding-right: 0;
}


/* ---- Chips ---- */

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid var(--hairline);
  color: var(--muted);
  vertical-align: middle;
  white-space: nowrap;
}
.chip-active, .chip-won { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.chip-prospect, .chip-qualified, .chip-negotiation, .chip-primary
  { background: var(--accent-soft); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.chip-proposal_sent, .chip-paused, .chip-renewal, .chip-reminder
  { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.chip-lost { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ---- Buttons & forms ---- */

.btn {
  display: inline-block;
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #14171a; } }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-small { font-size: 0.78rem; padding: 2px 10px; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--hairline)); background: none; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
.link-danger {
  font: inherit; font-size: 0.78rem;
  background: none; border: none; padding: 0;
  color: var(--muted); cursor: pointer; text-decoration: underline;
}
.link-danger:hover { color: var(--danger); }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 7px 10px;
}
select {
  /* Native macOS selects ignore the shared padding and render shorter than
     text inputs; opt out of the system appearance and draw our own chevron. */
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7178' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
@media (prefers-color-scheme: dark) {
  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23969ca3' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  }
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled { color: var(--muted); background: var(--paper); }
textarea { width: 100%; resize: vertical; }

.form-card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 20px 22px;
  max-width: 660px;
}
.form-card .eyebrow { margin-top: 20px; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.field label, .field-checks > label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 14px; }
.field-check label { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; }
.field-check { margin-bottom: 10px; }
.field-checks ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.field-checks li label { display: flex; gap: 6px; align-items: center; font-size: 0.9rem; }
.field-error { color: var(--danger); font-size: 0.8rem; margin: 2px 0 0; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
.inline-form { display: inline; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---- Dashboard ---- */

.dash { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.dash .panel { margin-bottom: 0; min-height: 100%; }
.panel-wide { grid-column: 1 / -1; }

.nudges { list-style: none; margin: 0; padding: 0; }
.nudge {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0 7px 10px;
  border-bottom: 1px solid var(--hairline);
  border-left: 3px solid var(--warn);
  flex-wrap: wrap;
}
.nudge:last-child { border-bottom: none; }
.nudge-overdue_reminder { border-left-color: var(--danger); }
.nudge-stale_client, .nudge-stale_prospect { border-left-color: var(--muted); }
.nudge-renewal, .nudge-aging_proposal { border-left-color: var(--warn); }
.nudge-client { font-weight: 600; }
.nudge-msg { font-size: 0.9rem; }

/* ---- Ledger (timeline / activity) ---- */

.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline);
}
.ledger li:last-child { border-bottom: none; }
.ledger-date { color: var(--muted); white-space: nowrap; padding-top: 2px; }
.ledger-body { min-width: 0; }
.ledger li.done .ledger-body { opacity: 0.55; }
.ledger li.overdue .ledger-date { color: var(--danger); font-weight: 600; }
.chip-type { background: none; }

.no-list-style {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ---- Client page ---- */

.client-head { align-items: center; }
.client-meta { display: flex; gap: 10px; align-items: center; margin: 4px 0 0; font-size: 0.9rem; }
.linkout { display: flex; gap: 14px; margin: 0 0 16px; font-size: 0.9rem; }
.linkout a { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
.client-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; align-items: start; }
.client-col { min-width: 0; }
.contact, .engagement { padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.contact:last-child, .engagement:last-child { border-bottom: none; }
.contact p, .engagement p { margin: 0 0 2px; }
.contact-notes { color: var(--muted); margin-top: 2px; }
.notes { margin: 0; }

.reminder-form { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; }

/* ---- Tabs, misc ---- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline); margin-bottom: 18px; }
.tabs a { padding: 6px 12px; color: var(--muted); border-radius: 6px 6px 0 0; }
.tabs a.current { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.pager { display: flex; gap: 12px; align-items: baseline; padding: 10px 0 0; font-size: 0.85rem; }

.linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
}
.sidebar-foot .linklike {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 100%;
}
.sidebar-foot .linklike:hover { background: var(--accent-soft); }
.sidebar-foot form { display: contents; }

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 5px 0; border-bottom: 1px solid var(--hairline); }
.plain-list li:last-child { border-bottom: none; }

dialog {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 22px;
  width: min(480px, 92vw);
}
dialog::backdrop { background: rgb(20 22 24 / 0.45); }
dialog h2 { font-size: 1.05rem; margin-bottom: 14px; }

/* ---- Login ---- */

.login-page { display: grid; place-items: center; min-height: 80vh; padding: 20px; }
.login-card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 32px;
  width: min(400px, 92vw);
}
.login-card h1 { margin-bottom: 4px; }
.login-card .btn { width: 100%; margin-top: 4px; }

/* ---- Responsive ---- */

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--hairline);
    padding: 10px 16px;
    overflow-x: auto;
  }
  .wordmark { margin-bottom: 0; margin-right: 8px; }
  .sidebar-foot { margin-top: 0; margin-left: auto; border-top: none; padding-top: 0; flex-direction: row; gap: 10px; }
  .dash, .client-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .reminder-form { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .sidebar a, .tabs a { transition: background-color 120ms ease, border-color 120ms ease; }
}
