:root {
  --green: #2D3F36; --green-deep: #22302A; --green-soft: #3A4F45;
  --beige: #E9E1D2; --beige-light: #F4EFE6; --line: #D9CFBB;
  --bronze: #b87333; --gold: #C9A96E;
  --ink: #1F2621; --ink-soft: #4A544E; --muted: #6B756E;
  --ok: #4F8A63; --warn: #C98A3A; --bad: #B8483F;
  --font-display: 'Playfair Display', Georgia, serif; --font-body: 'DM Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--beige); }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--green); }
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--beige); }
.brand__mark { width: 36px; height: 36px; border: 1.5px solid var(--gold); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 14px; color: var(--gold); }
.brand__name { font-family: var(--font-display); font-size: 19px; }
.brand__name em { color: var(--gold); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 4px; font-weight: 600; font-size: 14px; border: 1.5px solid transparent; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--gold { background: var(--gold); color: var(--green); }
.btn--gold:hover { background: #d6b87c; }
.btn--green { background: var(--green); color: var(--beige); }
.btn--green:hover { background: var(--green-soft); }
.btn--ghost { border-color: var(--line); color: var(--green); background: transparent; }
.btn--ghost:hover { border-color: var(--green); }
.topbar .btn--ghost { color: var(--beige); border-color: rgba(201,169,110,.4); }
.topbar .btn--ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn--danger { border-color: transparent; background: transparent; color: var(--bad); padding-left: 0; }
.btn--danger:hover { text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.field input, .field select, .field textarea, .search, .filters select, .note-form textarea {
  border: 1.5px solid var(--line); border-radius: 4px; background: #fff; padding: 10px 12px; font-size: 14px; outline: none; width: 100%;
}
.field input:focus, .field select:focus, .search:focus, .note-form textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(45,63,54,.1); }
.error { color: var(--bad); font-size: 13px; margin: 0; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--green); padding: 20px; }
.login__card { width: 100%; max-width: 400px; background: var(--beige); border-radius: 8px; padding: 36px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.login__card .brand { color: var(--green); }
.login__card .brand__mark { border-color: var(--bronze); color: var(--bronze); }
.login__card .brand__name em { color: var(--bronze); }
.login__lead { margin: -8px 0 4px; color: var(--ink-soft); font-size: 14px; }

/* Layout */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--green); color: var(--beige); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar__right { display: flex; align-items: center; gap: 10px; }
.me { font-size: 13px; color: var(--gold); margin: 0 6px; }
.layout { flex: 1; display: grid; grid-template-columns: 400px 1fr; min-height: 0; }
.list { border-right: 1px solid var(--line); background: var(--beige-light); display: flex; flex-direction: column; height: calc(100vh - 60px); position: sticky; top: 60px; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px 6px; padding: 14px 12px 0; }
.tab { border: none; background: none; padding: 10px 12px; font-size: 15px; font-weight: 600; color: var(--ink-soft); border-bottom: 2.5px solid transparent; white-space: nowrap; transition: color .15s, border-color .15s; }
.tab:hover { color: var(--green); }
.tab.is-active { color: var(--green); border-bottom-color: var(--bronze); }
.tab .n { display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 6px; border-radius: 10px; background: var(--line); font-size: 12px; font-weight: 600; text-align: center; }
.tab.is-active .n { background: var(--green); color: var(--beige); }
.filters { display: grid; grid-template-columns: 1fr 130px; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.leads { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.lead-item { padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.lead-item:hover { background: #fff; }
.lead-item.is-active { background: #fff; box-shadow: inset 3px 0 0 var(--bronze); }
.lead-item__top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.lead-item__name { font-weight: 600; color: var(--green); }
.lead-item__time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.lead-item__sub { font-size: 13px; color: var(--ink-soft); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 2px 8px; border-radius: 10px; background: var(--line); color: var(--ink-soft); }
.badge--novy { background: var(--gold); color: var(--green); }
.badge--kontaktovan { background: #d9e3dc; color: var(--green); }
.badge--schuzka { background: var(--green); color: var(--beige); }
.badge--uzavreno { background: var(--ok); color: #fff; }
.badge--ztraceno { background: #e3d4d2; color: var(--bad); }
.badge--late { background: var(--bad); color: #fff; }
.badge--who { background: transparent; border: 1px solid var(--line); }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

/* Detail */
.detail { padding: 28px 36px 60px; min-width: 0; }
.detail__empty { height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 8px; }
.detail__big { font-family: var(--font-display); font-size: 32px; color: var(--green); }
.lead { max-width: 860px; display: flex; flex-direction: column; gap: 28px; }
.lead__head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.lead__form { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--bronze); }
.lead__head h1 { font-size: 34px; margin: 4px 0 6px; }
.lead__meta { font-size: 14px; color: var(--ink-soft); display: flex; gap: 14px; flex-wrap: wrap; }
.lead__meta a { font-weight: 500; }
.lead__actions { display: flex; gap: 8px; }
.lead__controls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 520px; }
.lead__section { display: flex; flex-direction: column; gap: 12px; }
.lead__section h2 { font-size: 20px; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--green); color: var(--beige); border-radius: 6px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.tile small { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #B9B0A0; }
.tile strong { font-family: var(--font-display); font-size: 22px; color: var(--gold); }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notes li { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; font-size: 14px; }
.notes li small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.note-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.history { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--green); color: var(--beige); padding: 10px 18px; border-radius: 4px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 50; }
.toast.is-error { background: var(--bad); color: #fff; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .list { height: auto; position: static; max-height: 50vh; }
  .detail { padding: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
  .lead__controls { grid-template-columns: 1fr; }
  .topbar__right .me { display: none; }
}
