/* crm.danielhorn.ch – provisional brand tokens from ~/CLAUDE.md */

@font-face { font-family: "Space Grotesk"; src: url("../fonts/space-grotesk-500.ab4861869c91.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("../fonts/space-grotesk-700.f9e147a59a93.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-400.77bc02670657.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-500.f7016cd446d2.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-600.196e3cbc5fee.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-400.79936b18df9f.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --navy: #14283C;
  --navy-deep: #0E1E2E;
  --navy-line: #2A3F55;
  --copper: #A85A1E;
  --copper-dark: #8F4C17;
  --copper-light: #E39A5C;
  --paper: #F4F6F8;
  --white: #FFFFFF;
  --ink: #14283C;
  --muted: #55667A;
  --line: #D6DEE6;
  --on-navy: #E8EEF4;
  --on-navy-muted: #A9B8C7;
  --success: #1E7A4C;
  --warning: #9A6700;
  --danger: #B42318;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --sidebar-w: 15rem;
  --radius: 0.5rem;
  --gutter: clamp(1rem, 3vw, 2rem);
}

/* Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 0.9375rem/1.55 var(--font-body); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 0.6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
p { margin: 0 0 1em; }
a { color: var(--copper); text-underline-offset: 0.18em; }
code { font-family: var(--font-mono); font-size: 0.875em; }
svg { display: block; flex-shrink: 0; width: 1.25rem; height: 1.25rem; }
:focus-visible { outline: 2px solid var(--copper-light); outline-offset: 2px; border-radius: 2px; }
[x-cloak] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }

/* Brand ----------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 0.6rem; color: inherit; text-decoration: none; }
.brand svg { width: 2rem; height: 2rem; }
.brand-text { font-family: var(--font-display); font-size: 1.125rem; }
.brand-text span { font-weight: 500; opacity: 0.75; }

/* App layout ------------------------------------------------------------ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; gap: 1.5rem; padding: 1.25rem 1rem; background: var(--navy); color: var(--on-navy); }
.sidebar .brand { padding: 0 0.5rem; }
.nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.6rem; border-radius: var(--radius); color: var(--on-navy-muted); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--navy-line); color: var(--on-navy); }
.nav-link.is-active { background: var(--navy-line); color: var(--white); box-shadow: inset 3px 0 0 var(--copper-light); }
.sidebar-footer { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem 0.5rem 0; border-top: 1px solid var(--navy-line); font-size: 0.8125rem; }
.sidebar-footer .muted { color: var(--on-navy-muted); }
.sidebar-footer .link-button { color: var(--on-navy); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 1rem var(--gutter); background: var(--white); border-bottom: 1px solid var(--line); }
.page-title { margin: 0; font-size: 1.375rem; flex: 1; }
.topbar-actions { display: flex; gap: 0.5rem; }
.nav-toggle { display: none; }
.content { padding: var(--gutter); display: grid; gap: var(--gutter); align-content: start; }

@media (max-width: 52rem) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 50; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.is-open { transform: none; box-shadow: 0 0 0 100vmax rgba(14, 30, 46, 0.4); }
  .nav-toggle { display: inline-flex; }
}

/* Components ------------------------------------------------------------ */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card > :last-child { margin-bottom: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.65rem 1.1rem; font: 600 0.9375rem/1 var(--font-body); color: var(--white); background: var(--copper); border: 1px solid var(--copper); border-radius: var(--radius); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--copper-dark); border-color: var(--copper-dark); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--paper); border-color: var(--muted); }
.link-button { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0; background: none; border: 0; color: var(--copper); font: inherit; cursor: pointer; }
.link-button svg { width: 1rem; height: 1rem; }
.icon-button { display: inline-flex; padding: 0.4rem; background: none; border: 1px solid var(--line); border-radius: var(--radius); color: inherit; cursor: pointer; }

.stack { display: grid; gap: 1rem; margin-bottom: 1rem; }
.field { display: grid; gap: 0.35rem; }
.field label { font-weight: 600; font-size: 0.875rem; }
.field input, .field select, .field textarea { width: 100%; padding: 0.6rem 0.75rem; font: inherit; color: inherit; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--copper-light); outline-offset: 0; border-color: var(--copper); }
.field.has-error input { border-color: var(--danger); }
.field-error { margin: 0; color: var(--danger); font-size: 0.875rem; }

.messages { display: grid; gap: 0.5rem; padding: var(--gutter) var(--gutter) 0; }
.page-auth .messages { padding: 0 0 1rem; }
.message { margin: 0; padding: 0.7rem 1rem; border-radius: var(--radius); background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--muted); }
.message-success { border-left-color: var(--success); }
.message-warning { border-left-color: var(--warning); }
.message-error { border-left-color: var(--danger); }

/* Auth pages ------------------------------------------------------------ */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--navy); }
.auth-card { width: 100%; max-width: 25rem; padding: 2rem; background: var(--white); border-radius: calc(var(--radius) * 2); }
.auth-card .brand { margin-bottom: 1.5rem; }
.steps { padding-left: 1.25rem; }
.qr { display: flex; justify-content: center; margin: 1rem 0; }
.qr svg { width: 12rem; height: 12rem; }
.secret { word-spacing: 0.2em; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; padding: 0; margin: 0 0 1.5rem; list-style: none; }
.codes code { display: block; padding: 0.4rem; text-align: center; background: var(--paper); border-radius: var(--radius); }

/* Navigation extras ------------------------------------------------------- */
.nav-search { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.6rem; background: var(--navy-line); border-radius: var(--radius); color: var(--on-navy-muted); }
.nav-search svg { width: 1rem; height: 1rem; }
.nav-search input { width: 100%; background: none; border: 0; color: var(--on-navy); font: inherit; outline: none; }
.nav-search input::placeholder { color: var(--on-navy-muted); }
.nav-section { margin: 0.9rem 0.6rem 0.2rem; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-navy-muted); opacity: 0.7; }
.sidebar { overflow-y: auto; }

/* Layout helpers ----------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: var(--gutter); align-items: start; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.row-actions form { display: inline; }
.mt { margin-top: 1rem; }
.prewrap { white-space: pre-line; }
.inline { display: inline; }
.is-inactive, .is-inactive a { color: var(--muted); }
.topbar-actions { flex-wrap: wrap; }
.btn-small { padding: 0.45rem 0.8rem; font-size: 0.875rem; }
.btn-small svg { width: 1rem; height: 1rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #8E1B12; border-color: #8E1B12; }
.page-title .small { font-weight: 500; }

/* Cards ------------------------------------------------------------------- */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.card-head h2 { margin: 0; }
.card-head a { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.875rem; font-weight: 500; text-decoration: none; }
.card-head a svg { width: 1rem; height: 1rem; }
.card-flush { padding: 0; overflow-x: auto; }
.card-title { padding: 1rem 1.25rem 0; }
.card-highlight { border-left: 4px solid var(--copper); }
.card h3 { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.4rem; }
.form-card { max-width: 52rem; }

/* Lists, facts, tables ---------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li > a { text-decoration: none; color: var(--ink); }
.list li > a:hover { color: var(--copper); }
.list .muted { font-size: 0.8125rem; text-align: right; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.875rem; }
.facts dd { margin: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:hover { background: var(--paper); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { border-top: 2px solid var(--navy); border-bottom: 0; }
.table a { text-decoration: none; }
.num { text-align: right; white-space: nowrap; }
.actions { display: flex; gap: 0.35rem; justify-content: flex-end; align-items: center; }
.actions form { display: inline; }
.actions a, .icon-link { display: inline-flex; padding: 0.15rem; background: none; border: 0; color: var(--muted); cursor: pointer; }
.actions a:hover, .icon-link:hover { color: var(--copper); }
.actions svg, .icon-link svg { width: 1rem; height: 1rem; }

/* Badges ------------------------------------------------------------------ */
.badge { display: inline-block; padding: 0.1rem 0.5rem; font-size: 0.75rem; font-weight: 600; border-radius: 999px; background: var(--paper); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge-active, .badge-open, .badge-planned, .badge-sent { background: #EAF1F8; color: #1D4F7A; border-color: #C9DCEC; }
.badge-paid, .badge-done, .badge-accepted { background: #E7F4EC; color: var(--success); border-color: #BFE0CB; }
.badge-partial, .badge-draft, .badge-lead { background: #FDF3E6; color: var(--warning); border-color: #F2D9B3; }
.badge-overdue { background: #FCECEA; color: var(--danger); border-color: #F4C7C2; }
.badge-cancelled, .badge-declined, .badge-ended, .badge-inactive { background: var(--paper); color: var(--muted); text-decoration: line-through; }

/* KPIs -------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--gutter); }
.kpi { display: grid; gap: 0.2rem; padding: 1rem 1.25rem; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.kpi strong { font-family: var(--font-display); font-size: 1.375rem; }
.kpi-alert { border-color: #F4C7C2; }
.kpi-alert strong, .kpi-note { color: var(--danger); }
.kpi-note { font-size: 0.8125rem; }

/* Toolbar, tabs, forms ---------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.toolbar input, .toolbar select, .inline-form input, .inline-form select { padding: 0.5rem 0.7rem; font: inherit; color: inherit; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar input[type=search] { flex: 1; min-width: 14rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline-form input[type=text], .inline-form select { flex: 1; min-width: 10rem; }
.input-narrow { width: 6rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: 0.5rem 0.9rem; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.is-active { color: var(--ink); border-bottom-color: var(--copper); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 1rem 1.25rem; }
.field-wide { grid-column: 1 / -1; }
.field-check label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; padding-top: 1.6rem; }
.field-check input { width: auto; }
.field ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.field ul label { display: flex; gap: 0.4rem; align-items: center; font-weight: 400; }
.field ul input { width: auto; }
.help { margin: 0; color: var(--muted); font-size: 0.8125rem; }
.req { color: var(--copper); }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.form-errors { margin-bottom: 1rem; padding: 0.75rem 1rem; border-left: 4px solid var(--danger); background: #FCECEA; }
.form-errors p { margin: 0; }
.check { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.notice { padding: 0.65rem 0.9rem; background: var(--paper); border-left: 4px solid var(--muted); border-radius: var(--radius); }
.notice-warning { border-left-color: var(--warning); background: #FDF3E6; }
.pdf-preview iframe { display: block; width: 100%; height: 75vh; border: 0; }
