/* Clash CRM. Direction: fight-night scoreboard on paper. Ink + warm paper + one red. */
:root {
  --paper: #f6f2ea;
  --paper-2: #ece6da;
  --ink: #15110e;
  --ink-2: #4a423a;
  --ink-3: #8a8178;
  --line: #d9d1c3;
  --red: #d8201c;
  --red-ink: #a3140f;
  --green: #1f7a3c;
  --amber: #b86b00;
  --radius: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 0 rgba(21,17,14,.06), 0 8px 24px -12px rgba(21,17,14,.25);
  --text: clamp(0.95rem, 0.9rem + 0.3vw, 1.05rem);
  --h1: clamp(1.6rem, 1.2rem + 2vw, 2.6rem);
  --gap: clamp(0.75rem, 0.5rem + 1vw, 1.25rem);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--text)/1.45 var(--font); color: var(--ink); background: var(--paper);
  background-image: radial-gradient(rgba(21,17,14,.035) 1px, transparent 1px); background-size: 7px 7px; }
a { color: var(--ink); text-underline-offset: 2px; }
a:hover { color: var(--red-ink); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.1; letter-spacing: -0.01em; }
h1 { font-size: var(--h1); font-weight: 800; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); font-weight: 700; }
h3 { font-size: .95rem; margin-top: 1rem; color: var(--ink-2); }
p { margin: 0 0 .6rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.error { color: var(--red-ink); font-weight: 600; }
.warn { background: #fff4df; border-left: 3px solid var(--amber); padding: .5rem .75rem; border-radius: 0 var(--radius) var(--radius) 0; }
.ok { border-left: 4px solid var(--green); }
.tag { display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; padding: .1rem .4rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap;
  padding: .55rem 16px; background: var(--ink); color: var(--paper); box-shadow: 0 2px 0 var(--red); }
.topbar a { color: var(--paper); text-decoration: none; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; background: var(--red); color: #fff; border-radius: 4px; font-size: .8rem; letter-spacing: .04em; }
.nav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: .4rem .65rem; border-radius: var(--radius); font-weight: 600; white-space: nowrap; opacity: .8; }
.nav a:hover, .nav a[aria-current="page"] { opacity: 1; background: rgba(255,255,255,.1); }
.nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--red); }
.search { margin-left: auto; flex: 1 1 160px; max-width: 320px; }
.search input { width: 100%; padding: .45rem .7rem; border-radius: 999px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: var(--paper); }
.search input::placeholder { color: rgba(246,242,234,.55); }
.who { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.who .link { color: var(--paper); opacity: .8; }
.flash { margin: .75rem 16px 0; padding: .6rem .9rem; background: var(--ink); color: var(--paper); border-radius: var(--radius); border-left: 4px solid var(--red); }

/* Layout */
.page { padding: var(--gap) 16px 4rem; max-width: 1100px; margin: 0 auto; }
.page.wide { max-width: 1500px; }
.card { max-width: 100%; overflow-wrap: anywhere; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--gap); box-shadow: var(--shadow); }
.card.narrow { max-width: 640px; margin: 0 auto; }
.card.center { text-align: center; padding: 3rem var(--gap); }
.grid-2, .grid-3 { display: grid; gap: var(--gap); margin-top: var(--gap); }
.grid-2 > *, .grid-3 > * { min-width: 0; }
@media (min-width: 820px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); flex-wrap: wrap; margin-bottom: var(--gap); }
.views { display: flex; gap: .25rem; flex-wrap: wrap; }
.views a { text-decoration: none; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .9rem; }
.views a[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.count { font-size: .8em; color: var(--ink-3); font-weight: 600; margin-left: .25rem; }

/* Lead head */
.lead-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--gap); flex-wrap: wrap; }
.eyebrow { font-family: var(--mono); font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .2rem; }
.lead-head h1 a { text-decoration: none; }
.contact { font-size: 1.1rem; font-weight: 600; margin-bottom: .25rem; }
.facts { display: flex; gap: .5rem; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); }
.facts span { background: var(--paper-2); padding: .15rem .5rem; border-radius: 999px; }
.dial { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 200px; padding: .9rem 1.4rem; text-decoration: none;
  background: var(--green); color: #fff; border-radius: var(--radius-lg); box-shadow: 0 6px 0 #145428; transition: transform .1s ease; }
.dial:hover { color: #fff; transform: translateY(-1px); }
.dial:active { transform: translateY(4px); box-shadow: 0 2px 0 #145428; }
.dial-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; opacity: .85; }
.dial-number { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.dialbox { display: flex; flex-direction: column; align-items: stretch; gap: .4rem; min-width: 220px; }
.copy { font-size: .85rem; padding: .4rem .6rem; }
.copy.done { background: var(--green); color: #fff; border-color: var(--green); }
.timer { font-family: var(--mono); font-size: .8rem; color: var(--ink-3); text-align: center; }
@media (max-width: 600px) { .dialbox, .dial { width: 100%; } }

/* Status pills */
.status { padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--paper-2); color: var(--ink-2); }
.status-uus { background: #e8eef7; color: #22406b; }
.status-ei_vastanud { background: #efefef; color: #555; }
.status-helistatud, .status-pakkumine_saadetud { background: #fff1d6; color: #7a4a00; }
.status-helista_uuesti { background: #e8f3ff; color: #124a8a; }
.status-broneeritud { background: #fde2e1; color: var(--red-ink); }
.status-voidetud { background: #dcf3e3; color: #145428; }
.status-vabastatud { background: #fbe9d0; color: #7a4a00; }
.status-pole_huvitatud, .status-juba_on_laud { background: #eee; color: #777; text-decoration: line-through; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack.compact { gap: .5rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
label.inline { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea { font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); min-width: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
textarea { resize: vertical; }
.row { display: flex; gap: .75rem; align-items: flex-end; }
.row > label { flex: 1; min-width: 0; }
.row select, .row input { width: 100%; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > label { flex: 1 1 160px; }
button, .button { font: inherit; font-weight: 700; white-space: nowrap; padding: .55rem .95rem; border-radius: var(--radius); border: 1px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
button:hover, .button:hover { background: var(--paper-2); }
.primary { background: var(--ink); color: var(--paper); }
.primary:hover { background: #000; color: #fff; }
.big { padding: .9rem 1.4rem; font-size: 1.05rem; }
.ghost { border-color: var(--line); background: transparent; }
.small { padding: .3rem .6rem; font-size: .85rem; }
.danger { border-color: var(--red); color: var(--red-ink); }
.link { border: 0; background: none; padding: 0; text-decoration: underline; font-weight: 600; }
button[disabled] { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.actions-cell { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.inline { display: inline-flex; gap: .4rem; align-items: center; }

/* Outcome chips */
.choices { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.choices legend { font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .35rem; width: 100%; }
.chip { flex-direction: row; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-block; padding: .55rem .85rem; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-weight: 600; color: var(--ink); min-height: 44px; display: inline-flex; align-items: center; }
.chip:hover span { border-color: var(--ink-3); }
.chip input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 3px solid var(--red); outline-offset: 2px; }
.chip-kokkulepe span, .chip-saada_pakkumine span { border-color: var(--green); color: #145428; }
.chip-kokkulepe input:checked + span, .chip-saada_pakkumine input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.chip-ei input:checked + span { background: #777; border-color: #777; }
.chip-vale_number span { color: var(--ink-3); border-style: dashed; }
.chip-vale_number input:checked + span { background: #777; border-color: #777; color: #fff; }
.chip-tagasihelistamine input:checked + span { background: #124a8a; border-color: #124a8a; color: #fff; }
[data-show-for][hidden] { display: none; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem .75rem; }
.timeline li::before { content: ""; position: absolute; left: -1.45rem; top: .45rem; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); border: 2px solid #fff; }
.timeline li.call::before { background: var(--red); }
.timeline li.mail::before { background: var(--green); }
.timeline time { font-family: var(--mono); font-size: .75rem; color: var(--ink-3); display: block; }
.timeline p { margin: .25rem 0 0; white-space: pre-wrap; }
.note { white-space: pre-wrap; }
.deal { margin-top: 1rem; padding: .9rem; border-radius: var(--radius); background: #fde2e1; border: 1px solid #f5b9b6; }
.deal-paid { background: #dcf3e3; border-color: #a9dbb9; }

/* Tables */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); background: var(--paper-2); position: sticky; top: 0; }
tbody tr:hover { background: #fbf9f5; }
tr.overdue td { background: #fde2e1; }
tr.due-today td { background: #fff1d6; }
tr.paid td { background: #ecf8ef; }
tr.released td { opacity: .55; }
td input[type="date"] { padding: .35rem .4rem; font-size: .85rem; }

/* Board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: 1rem; }
.column { background: var(--paper-2); border-radius: var(--radius-lg); padding: .6rem; min-height: 50vh; }
.column h2 { font-size: .8rem; padding: .2rem .3rem .5rem; }
.column-broneeritud { outline: 2px solid var(--red); outline-offset: -2px; }
.column-voidetud { background: #dcf3e3; }
.lead-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .7rem; margin-bottom: .5rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.lead-card a { text-decoration: none; }
.lead-card small { font-size: .78rem; color: var(--ink-2); }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: .9rem; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.tile span { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; }
.tile b { font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile small { color: var(--ink-2); }
.tile.accent { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tile.accent span, .tile.accent small { color: rgba(246,242,234,.7); }
.tile.warn { border-color: var(--red); }
.bars { display: flex; gap: .3rem; align-items: flex-end; height: 120px; margin-top: .5rem; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .7rem; }
.bar::before { content: ""; display: block; width: 100%; height: var(--h); min-height: 2px; background: var(--red); border-radius: 3px 3px 0 0; }
.bar span { order: -1; color: var(--ink-2); }
.bar small { color: var(--ink-3); font-family: var(--mono); font-size: .65rem; }

/* Login */
.login { max-width: 380px; margin: 10vh auto 0; background: #fff; padding: 2rem; border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow); }
ul.plain { list-style: none; padding: 0; margin: 0 0 .75rem; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); }
details summary { cursor: pointer; font-weight: 700; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.mailbody { white-space: pre-wrap; font: inherit; background: var(--paper-2); padding: 1rem; border-radius: var(--radius); border: 1px solid var(--line); max-height: 60vh; overflow: auto; }
.hint { width: 100%; margin: .25rem 0 0; font-size: .85rem; color: var(--ink-2); min-height: 1.3em; }

.todo { list-style: none; margin: 0 0 .75rem; padding: 0; }
.todo li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.todo li.overdue { background: #fde2e1; margin: 0 -.5rem; padding: .55rem .5rem; border-radius: var(--radius); }
.todo li > div { min-width: 0; }
ul.plain.compact li { padding: .15rem 0; border: 0; }
.result { font-weight: 700; font-size: 1.05rem; padding: .6rem .8rem; background: #dcf3e3; border-radius: var(--radius); min-height: 1.4em; }
.result.error { background: #fde2e1; color: var(--red-ink); }
.result:empty { display: none; }
.chip[hidden] { display: none; }

/* Field grid: wraps instead of squeezing selects */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.fields > label { min-width: 0; justify-content: flex-end; }
.fields select, .fields input { width: 100%; }
.fields label[hidden] { display: none; }

/* Invoice drop zone */
.invoice-cell { flex-direction: column; align-items: stretch; min-width: 220px; }
.dropzone { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; min-height: 44px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; font-size: .85rem; }
.dropzone input[type="file"] { display: none; }
.dropzone-text { flex: 1; color: var(--ink-2); }
.dropzone.over { border-color: var(--red); background: #fff4f3; }
.dropzone.has-file { border-style: solid; border-color: var(--green); background: #ecf8ef; }
.dropzone.has-file .dropzone-text { color: #145428; font-weight: 600; }
.dropzone.busy { opacity: .6; }
.dropzone.error { border-color: var(--red); background: #fde2e1; }
.invoice-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* Arved: one card per deal */
.deal-card { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(300px, 1.5fr) minmax(230px, 1fr); gap: .75rem 1.25rem; align-items: start;
  background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius-lg); padding: .75rem 1rem; margin-bottom: .5rem; box-shadow: var(--shadow); }
.deal-card > form[hidden] { display: none; }
.deal-card.overdue { border-left-color: var(--red); }
.deal-card.due-today { border-left-color: var(--amber); }
.deal-card.paid { border-left-color: var(--green); }
.deal-card.released { opacity: .6; }
.deal-who h2 { font-size: 1.05rem; text-transform: none; letter-spacing: 0; color: var(--ink); margin: .05rem 0 .15rem; }
.deal-who h2 a { text-decoration: none; }
.deal-who p { margin: 0 0 .15rem; overflow-wrap: anywhere; }
.deal-sum { font-size: 1rem; }
.deal-state { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .3rem; }
.deal-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem .6rem; align-items: end; }
.deal-fields label { font-size: .78rem; gap: .15rem; }
.deal-fields .inline { grid-column: 1 / 3; font-size: .85rem; }
.deal-fields .actions { grid-column: 3; justify-content: flex-end; }
.deal-fields input:not([type=checkbox]) { width: 100%; padding: .4rem .5rem; }
.deal-fields .inline { justify-content: flex-start; font-weight: 600; }
.deal-invoice { display: flex; flex-direction: column; gap: .4rem; }
.deal-invoice .invoice-actions form { display: contents; }
.deal-invoice .invoice-actions .primary { flex: 1 1 100%; }
.deal-invoice .muted.small { margin: 0; }
@media (max-width: 900px) { .deal-card { grid-template-columns: 1fr; } }

/* Notifications */
.bell { position: relative; display: inline-flex; align-items: center; padding: .3rem .4rem; border-radius: var(--radius); text-decoration: none; }
.bell:hover { background: rgba(255,255,255,.1); }
.bell-icon { font-size: 1.1rem; filter: grayscale(1) brightness(2); }
.bell-count { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: .7rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { display: flex; gap: 1rem; align-items: baseline; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.notes li.unread { font-weight: 700; }
.notes li time { font-family: var(--mono); font-size: .75rem; color: var(--ink-3); white-space: nowrap; }
.notes .link { text-align: left; font-weight: inherit; }
.notes li.note-money::before { content: "€"; color: var(--green); font-weight: 800; }
.notes li.note-warn::before { content: "!"; color: var(--red); font-weight: 800; }
.notes li.note-action::before { content: "→"; color: var(--amber); font-weight: 800; }

.cancel summary { list-style: none; cursor: pointer; display: inline-flex; }
.cancel summary::-webkit-details-marker { display: none; }
.cancel[open] { margin-top: .5rem; padding: .75rem; border: 1px solid var(--red); border-radius: var(--radius); background: #fff6f5; }
.cancel[open] summary { margin-bottom: .5rem; }
.deal-cancel { margin-top: .5rem; }

/* Lead page: admin row + two columns like the call screen */
.adminrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .5rem .75rem; align-items: end; margin-top: var(--gap); padding: .75rem 1rem; }
.adminrow label { font-size: .78rem; }
.adminrow select { width: 100%; }
.adminrow label[hidden] { display: none; }
.lead-body { grid-template-columns: 1fr 1fr; }
@media (max-width: 820px) { .lead-body { grid-template-columns: 1fr; } }
.contact-edit { margin: .75rem 0; }
.contact-edit summary { font-size: .9rem; color: var(--ink-2); }
.contact-edit form { margin-top: .5rem; }
.queue-counts { margin: 0 0 .5rem; }
.ok-text { color: var(--green); font-weight: 600; }
.who a { color: var(--paper); text-decoration: underline; text-underline-offset: 3px; }
.techlog { margin-top: .75rem; }
.techlog summary { cursor: pointer; }
.timeline.small { font-size: .85rem; margin-top: .5rem; }

/* Tables: headers and action columns never wrap */
th { white-space: nowrap; }
table.leads td:last-child, table.invoices td:last-child { white-space: nowrap; width: 1%; }
.card.table-wrap { overflow-wrap: normal; }
.status-mail { background: #fff1d6; color: #7a4a00; }

/* Owner chip: same look everywhere */
.owner-chip { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: var(--ink); color: var(--paper); white-space: nowrap; vertical-align: middle; }
.owner-chip::before { content: "👤"; font-size: .75rem; }
.lead-card .owner-chip { align-self: flex-start; margin-top: .15rem; }
