/* EHV CRM — a working tool in the brand's colours.
   Layout idea: fixed sidebar of modules, a quiet charcoal canvas, gold only for actions and "needs attention". */
:root {
  --bg: #141215;
  --panel: #1d1a1f;
  --panel-2: #252127;
  --line: #352f36;
  --text: #f1e6d0;
  --muted: #a99d8b;
  --gold: #e8a93a;
  --gold-ink: #1c1406;
  --crimson: #b3202f;
  --good: #7fc59a;
  --warn: #e8a93a;
  --bad: #ff8a80;
  --info: #8fb8e8;

  --f-display: "Oswald", "Arial Narrow", sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14.5px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.num, td.money, .kpi strong { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 70% 20%, rgba(179, 32, 47, .25), transparent 50%), var(--bg); }
.login__card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: grid; gap: 16px; }
.login__card img { width: 150px; margin: 0 auto 4px; }
.login__card h1 { font-family: var(--f-display); font-weight: 300; letter-spacing: .08em; text-transform: uppercase; font-size: 1.5rem; text-align: center; margin: 0; }
.login__note { color: var(--muted); font-size: .85rem; text-align: center; margin: 0; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100%; }
.side { background: #100e11; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side__brand { padding: 16px 18px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.side__brand img { width: 74px; }
.side__brand span { font-family: var(--f-display); letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; color: var(--muted); }
.side nav { overflow-y: auto; padding: 10px 10px 20px; flex: 1; }
.side h4 { font-family: var(--f-display); font-weight: 400; text-transform: uppercase; letter-spacing: .16em; font-size: .7rem; color: var(--muted); margin: 16px 10px 6px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .92rem; }
.side a .ico { width: 18px; text-align: center; color: var(--muted); }
.side a:hover { background: var(--panel); }
.side a[aria-current="page"] { background: rgba(232, 169, 58, .14); color: var(--gold); }
.side a[aria-current="page"] .ico { color: var(--gold); }
.side a .badge { margin-left: auto; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: var(--bg); }
.btn.top__menu { display: none; }
.top__search { flex: 1; max-width: 420px; position: relative; }
.top__search input { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
.results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; z-index: 30; max-height: 360px; overflow: auto; box-shadow: 0 20px 40px rgba(0, 0, 0, .5); }
.results a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.results a:hover, .results a:focus { background: var(--panel-2); }
.results small { color: var(--muted); }
.top__user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { text-align: right; line-height: 1.2; }
.who strong { display: block; font-size: .9rem; }
.who span { color: var(--muted); font-size: .78rem; }
.modebar { background: rgba(232, 169, 58, .1); color: var(--gold); font-size: .8rem; padding: 6px 22px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.modebar button { margin-left: auto; }

.view { flex: 1; overflow-y: auto; padding: 22px; }
.view__head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.view__head h1 { font-family: var(--f-display); font-weight: 300; text-transform: uppercase; letter-spacing: .06em; font-size: 1.7rem; margin: 0; line-height: 1.1; }
.view__head p { margin: 4px 0 0; color: var(--muted); }
.view__head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); }

/* ---------- buttons, pills ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); padding: 7px 13px; cursor: pointer; font-size: .9rem; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--gold); }
.btn--gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 600; }
.btn--gold:hover { background: #f4bd57; }
.btn--danger { color: var(--bad); }
.btn--danger:hover { border-color: var(--bad); }
.btn--sm { padding: 4px 9px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; background: var(--panel-2); color: var(--text); white-space: nowrap; }
.pill--good { background: rgba(127, 197, 154, .15); color: var(--good); }
.pill--warn { background: rgba(232, 169, 58, .15); color: var(--warn); }
.pill--bad { background: rgba(255, 138, 128, .14); color: var(--bad); }
.pill--info { background: rgba(143, 184, 232, .14); color: var(--info); }
.badge { background: var(--crimson); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 7px; min-width: 20px; text-align: center; }
.tag { display: inline-block; font-size: .75rem; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; margin: 1px 3px 1px 0; color: var(--muted); }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 2px; text-decoration: none; color: var(--text); }
.kpi:hover { border-color: var(--gold); }
.kpi span { color: var(--muted); font-size: .8rem; }
.kpi strong { font-family: var(--f-display); font-weight: 400; font-size: 1.7rem; letter-spacing: .02em; }
.kpi small { color: var(--muted); font-size: .78rem; }
.kpi--alert { border-left: 3px solid var(--gold); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.panel h2 { font-family: var(--f-display); font-weight: 400; text-transform: uppercase; letter-spacing: .1em; font-size: .9rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.panel h2 .btn { margin-left: auto; }
.empty { color: var(--muted); font-size: .9rem; padding: 10px 0; }
.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rowlist li:last-child { border-bottom: 0; }
.rowlist .date { font-family: var(--f-display); color: var(--gold); min-width: 58px; font-size: .9rem; letter-spacing: .04em; }
.rowlist a { color: var(--text); text-decoration: none; }
.rowlist a:hover { color: var(--gold); }
.rowlist .meta { color: var(--muted); font-size: .82rem; }
.rowlist .end { margin-left: auto; text-align: right; }
.bars { display: grid; gap: 8px; }
.bars div { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 10px; font-size: .85rem; }
.bars i { display: block; height: 10px; border-radius: 4px; background: var(--gold); min-width: 2px; }
.bars .track { background: var(--panel-2); border-radius: 4px; }
.bars span:last-child { text-align: right; color: var(--muted); }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.toolbar input { min-width: 220px; }
.toolbar .count { color: var(--muted); font-size: .85rem; margin-left: auto; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; background: var(--panel-2); position: sticky; top: 0; }
td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
td.money, th.money { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; background: var(--panel-2); }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.col.is-over { border-color: var(--gold); background: rgba(232, 169, 58, .06); }
.col h3 { margin: 2px 4px 4px; font-family: var(--f-display); font-weight: 400; text-transform: uppercase; letter-spacing: .1em; font-size: .82rem; display: flex; justify-content: space-between; }
.col h3 span { color: var(--muted); font-family: var(--f-body); letter-spacing: 0; }
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: grab; display: grid; gap: 4px; }
.card:hover { border-color: var(--gold); }
.card strong { font-size: .92rem; }
.card .meta { color: var(--muted); font-size: .8rem; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- record ---------- */
.rec { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.fields div { min-width: 0; }
.fields dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.fields dd { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.fields .wide { grid-column: 1 / -1; }
.related { display: grid; gap: 16px; margin-top: 16px; }
.summary { display: grid; gap: 8px; }
.summary div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.summary div:last-child { border-bottom: 0; }
.summary span { color: var(--muted); }
.summary .big { font-family: var(--f-display); font-size: 1.3rem; }
.summary .pos { color: var(--good); }
.summary .neg { color: var(--bad); }

/* ---------- dialogs & forms ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgba(5, 4, 6, .7); }
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 26px); }
.dlg header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg header h2 { margin: 0; font-family: var(--f-display); font-weight: 400; text-transform: uppercase; letter-spacing: .08em; font-size: 1.05rem; }
.dlg .body { padding: 18px 20px; overflow-y: auto; }
.dlg footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form .f { display: grid; gap: 4px; min-width: 0; }
.form .f.wide { grid-column: 1 / -1; }
.form label { font-size: .82rem; color: var(--muted); }
.form label b { color: var(--gold); font-weight: 400; }
.form input, .form select, .form textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--gold); }
.form input[type="checkbox"] { width: auto; accent-color: var(--gold); }
.form .check { display: flex; gap: 8px; align-items: center; padding-top: 22px; }
.form [aria-invalid="true"] { border-color: var(--bad); }
.err { color: var(--bad); margin: 10px 0 0; font-size: .9rem; }
.x { background: none; border: 1px solid var(--line); border-radius: 50%; width: 30px; height: 30px; cursor: pointer; color: var(--text); }

.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix tbody tr { cursor: default; }
.yes { color: var(--good); } .ro { color: var(--info); } .no { color: var(--line); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--gold); padding: 10px 16px; border-radius: 14px; z-index: 60; max-width: calc(100vw - 32px); text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .rec { grid-template-columns: 1fr; } .grid { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.is-open { transform: none; box-shadow: 20px 0 40px rgba(0, 0, 0, .5); }
  .btn.top__menu { display: inline-flex; }
  .who { display: none; }
  .view { padding: 16px; }
  .form, .fields { grid-template-columns: 1fr; }
  .toolbar input { min-width: 0; flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
