/* Colfin Studio – design system. Local fonts only (no external requests). Light + dark. */
:root {
  color-scheme: light dark;
  --bg: #f6f5f2; --surface: #ffffff; --surface-2: #faf9f6; --ink: #1c1f26; --muted: #6a707c;
  --line: #e8e6df; --line-strong: #d5d2c9;
  --accent: #3b5bdb; --accent-hover: #2f49b8; --accent-soft: #edf0ff; --accent-ink: #2a3ea8;
  --ok: #1d8a5a; --warn: #b07400; --bad: #c0362c; --violet: #6d4fc2; --teal: #0f766e; --orange: #c2570c;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(24, 28, 40, .05), 0 6px 20px rgba(24, 28, 40, .05);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
/* Dark theme: explicit choice (data-theme) or, when on Auto, the system setting. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark;
    --bg: #121419; --surface: #1b1e25; --surface-2: #20242c; --ink: #eceef3; --muted: #9aa1ae;
    --line: #2a2f39; --line-strong: #3a4150;
    --accent: #7f96ff; --accent-hover: #a1b2ff; --accent-soft: #232a49; --accent-ink: #bcc8ff;
    --ok: #4cc38a; --warn: #e8ad45; --bad: #ff7f76; --violet: #b29cff; --teal: #4fd1c5; --orange: #ff9a52;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121419; --surface: #1b1e25; --surface-2: #20242c; --ink: #eceef3; --muted: #9aa1ae;
    --line: #2a2f39; --line-strong: #3a4150;
    --accent: #7f96ff; --accent-hover: #a1b2ff; --accent-soft: #232a49; --accent-ink: #bcc8ff;
    --ok: #4cc38a; --warn: #e8ad45; --bad: #ff7f76; --violet: #b29cff; --teal: #4fd1c5; --orange: #ff9a52;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .neg { color: var(--bad); }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .container { display: flex; align-items: center; gap: 28px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), #7a4de8); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: var(--muted); padding: 7px 12px; border-radius: 9px; font-weight: 550; font-size: 14px; }
.topbar nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.topbar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.topbar .spacer { flex: 1; }

/* ---- running timer ---- */
.timerbar { position: sticky; top: 58px; z-index: 25; background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line)); }
.timerbar .container { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.timerbar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 60%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
.timerbar form { display: flex; gap: 8px; margin: 0; }
.timerbar input { width: 260px; }

main.container { padding-top: 28px; padding-bottom: 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { margin: 6px 0 0; color: var(--muted); max-width: 720px; }
.crumb { display: inline-block; margin-bottom: 10px; color: var(--muted); font-size: 14px; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---- buttons ---- */
button, .btn { font: inherit; font-weight: 600; font-size: 14px; padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  line-height: 1.2; transition: background .12s, border-color .12s, box-shadow .12s; white-space: nowrap; }
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
button.ghost, .btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); border-color: var(--muted); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger:hover { filter: brightness(.92); }
.btn.sm, button.sm { padding: 5px 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* copy chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 20px; }
.chips .label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 4px; }
button.copy { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: 0 1px 0 rgba(0,0,0,.03); }
button.copy::before { content: ""; width: 15px; height: 15px; background: var(--accent); flex: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='11' height='11' rx='2'/%3E%3Cpath d='M5 15V6a2 2 0 0 1 2-2h9'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='11' height='11' rx='2'/%3E%3Cpath d='M5 15V6a2 2 0 0 1 2-2h9'/%3E%3C/svg%3E") center/contain no-repeat; }
button.copy:hover { background: var(--accent-soft); border-color: var(--accent); }

/* dropdown menu */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu .pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 250px; z-index: 40; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 34px rgba(20, 24, 40, .18); padding: 6px; }
.menu .pop a { display: block; padding: 9px 11px; border-radius: 8px; color: var(--ink); }
.menu .pop a small { display: block; color: var(--muted); font-size: 12.5px; }
.menu .pop a:hover { background: var(--accent-soft); text-decoration: none; }

/* ---- cards, KPIs ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin: 0 0 18px; }
.card.flush { padding: 0; overflow: hidden; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 26px; }
.kpis.compact { grid-template-columns: repeat(auto-fill, minmax(210px, 260px)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 13px; margin-top: 2px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 30px 0 12px; font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); }
.section-title .count { background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; font-size: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.client-card { display: block; color: inherit; padding: 18px 20px; margin: 0; transition: transform .12s, box-shadow .12s, border-color .12s; }
.client-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--line-strong);
  box-shadow: 0 2px 4px rgba(24,28,40,.06), 0 12px 28px rgba(24,28,40,.10); }
.client-card .name { font-weight: 650; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.metric { margin-top: 14px; }
.metric .big { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric .big small { font-size: 13px; font-weight: 550; color: var(--muted); letter-spacing: 0; }
.metric .sub { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.owed { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.owed .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #7a4de8); }
.bar.over > i { background: var(--bad); }
.empty { color: var(--muted); font-size: 14px; margin-top: 14px; }

/* ---- pills / tags ---- */
.pill, .tag { --c: var(--muted); display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 650;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, var(--surface)); white-space: nowrap; letter-spacing: .01em; }
.tag.fiverr { --c: var(--ok); } .tag.colfin { --c: var(--accent); } .tag.direct { --c: var(--orange); }
.tag.review, .pill.review, .tag.FAIL { --c: var(--bad); } .tag.guess, .tag.explained { --c: var(--warn); } .tag.ok { --c: var(--ok); } .tag.info { --c: var(--muted); }
.st-in-progress { --c: var(--warn); } .st-in-review { --c: var(--violet); } .st-delivered { --c: var(--teal); }
.st-awaiting-payment { --c: var(--orange); } .st-paid { --c: var(--ok); } .st-not-started { --c: var(--muted); } .st-mixed { --c: var(--bad); }

/* ---- order cards & tables ---- */
.order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; padding: 18px 20px 12px; }
.order-head .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.order-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px; padding: 4px 20px 16px; align-items: end; }
.order-stats .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.order-stats .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2);
  text-align: left; padding: 9px 14px; white-space: nowrap; }
td { padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
tfoot td, tr.total td, tr.total th { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--line-strong); }
td.act { text-align: right; white-space: nowrap; }
a.rowlink { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink); }
a.rowlink:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
tr.review td { background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.note-cell { color: var(--muted); max-width: 320px; }
td.act-text { white-space: pre-line; }
.stack > * + * { margin-top: 0; }

/* collapsible order cards: only the newest order starts open */
details.order-card > summary { list-style: none; cursor: pointer; align-items: center; gap: 16px; padding-bottom: 18px; }
details.order-card > summary::-webkit-details-marker { display: none; }
details.order-card > summary:hover { background: var(--surface-2); }
details.order-card[open] > summary { border-bottom: 1px solid var(--line); }
details.order-card > summary > div:first-child { flex: 1; min-width: 0; }
.oh-fig { text-align: right; color: var(--muted); font-size: 13px; line-height: 1.35; white-space: nowrap; }
.oh-fig b { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.chev { width: 9px; height: 9px; flex: none; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
        transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
details.order-card[open] > summary .chev { transform: rotate(45deg); }
.order-actions { padding: 14px 20px 4px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--line); padding: 14px; border-radius: 10px;
  font: 13.5px/1.55 var(--font); margin: 12px 0 8px; max-height: 360px; overflow: auto; }

/* ---- forms ---- */
.form-card { max-width: 700px; }
.form .row { margin: 0 0 18px; }
.form label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.form .check label { display: inline; margin: 0 0 0 8px; font-weight: 600; }
.form .check { display: flex; flex-wrap: wrap; align-items: center; }
.form .check .help, .form .check .err { flex-basis: 100%; margin-left: 26px; }
input[type=text], input[type=date], input[type=time], select, textarea {
  width: 100%; max-width: 560px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; }
textarea { max-width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.form .help { color: var(--muted); font-size: 13px; margin-top: 5px; }
.form .bad input, .form .bad select, .form .bad textarea { border-color: var(--bad); }
.err { color: var(--bad); font-size: 13px; margin-top: 5px; font-weight: 550; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.banner { border-radius: var(--radius-sm); padding: 12px 16px; margin: 0 0 18px; max-width: 700px; border: 1px solid var(--line); background: var(--surface); }
.banner.info { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.banner.error { background: color-mix(in srgb, var(--bad) 11%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); font-weight: 550; }
.danger-zone { margin-top: 26px; padding-top: 18px; border-top: 1px dashed var(--line-strong); max-width: 700px; }

/* ---- snackbar ---- */
#snackbar { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; z-index: 100;
  background: #1d2129; color: #fff; padding: 11px 18px 11px 14px; border-radius: 12px; font-size: 14px; font-weight: 550;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28); display: flex; align-items: center; gap: 10px; max-width: min(92vw, 520px);
  transition: opacity .18s ease, transform .18s ease; }
#snackbar.show { opacity: 1; transform: translate(-50%, 0); }
#snackbar .ico { width: 20px; height: 20px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; font-size: 12px; flex: none; color: #fff; }
#snackbar.error .ico { background: var(--bad); }
:root[data-theme="dark"] #snackbar { background: #eceef3; color: #14161b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #snackbar { background: #eceef3; color: #14161b; } }
#theme-toggle { min-width: 92px; justify-content: center; }

@media (max-width: 720px) {
  .container { padding: 0 14px; } .topbar .container { gap: 12px; } h1 { font-size: 22px; }
  .timerbar input { width: 100%; }
}

/* quick status change: the pill itself is the dropdown */
.stform { margin: 0; }
select.pill { display: inline-block; width: auto; max-width: none; appearance: none; -webkit-appearance: none; border: 0; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 650; line-height: 1.5; height: auto; padding: 3px 24px 3px 12px; border-radius: 99px;
  color: var(--c); background-color: color-mix(in srgb, var(--c) 13%, var(--surface));
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 9px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
select.pill:hover { background-color: color-mix(in srgb, var(--c) 24%, var(--surface)); }
select.pill option { color: var(--ink); background: var(--surface); font-weight: 500; }

/* Angebot: add-line form under the lines table */
.offer-add { display: grid; grid-template-columns: minmax(0, 1fr) 80px 120px 120px auto; gap: 10px; align-items: end;
  padding: 16px 20px 8px; border-top: 1px solid var(--line); }
.offer-add label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.offer-add textarea, .offer-add input { max-width: none; }
@media (max-width: 760px) { .offer-add { grid-template-columns: 1fr 1fr; } .offer-add .desc { grid-column: 1 / -1; } }

/* order / project notes (e.g. the client's wishlist), shown on the card */
.order-notes { margin: 0 20px 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--line); white-space: pre-line; font-size: 14px; color: var(--ink); max-height: 340px; overflow: auto; }

/* tasks: to-do list on /tasks and on the client page */
.topbar nav .nav-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 99px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.tasks { list-style: none; margin: 0; padding: 0; }
.tasks li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.tasks li:first-child { border-top: 0; }
.tasks li form { margin: 0; }
.tasks .t-body { flex: 1; min-width: 0; }
.tasks .t-text { white-space: pre-line; overflow-wrap: anywhere; }
.tasks li.done .t-text { text-decoration: line-through; color: var(--muted); }
.task-add { display: grid; grid-template-columns: minmax(0, 1fr) 240px 180px auto; gap: 10px; align-items: end; }
.client-tasks .task-add { grid-template-columns: minmax(0, 1fr) 240px auto; margin-top: 12px; }
.task-add label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.task-add input, .task-add select { max-width: none; width: 100%; }
.client-tasks > summary { cursor: pointer; list-style: none; }
.client-tasks > summary::-webkit-details-marker { display: none; }
.client-tasks[open] > summary { margin-bottom: 8px; }
@media (max-width: 760px) { .task-add, .client-tasks .task-add { grid-template-columns: 1fr; } }
