/* NLK style: graphite + red accent (as novalk site and logo), calm light background */
:root {
  --bg: #f4f4f5; --card: #fff; --ink: #202020; --muted: #6b6b72; --line: #e3e3e6;
  --brand: #e20021; --brand-dark: #b8001b; --brand-ink: #fff; --top: #1c1c1e; --link: #26262b;
  --pos: #187a44; --neg: #c0262d; --warn: #9a6200;
  --pos-bg: #e6f4ec; --neg-bg: #fdecec; --warn-bg: #fdf3d8;
  --inc: #5b5f68; --pr: #2a9d5c; --ls: #e20021;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* .btn / flex rules must not show hidden parts */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14.5px/1.5 Montserrat, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--brand-dark); }
.more, .range summary { color: var(--brand-dark); }
h1 { font-size: 1.4rem; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; margin: 0 0 .6rem; font-weight: 700; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); }

/* top bar */
.top { background: var(--top); color: #fff; display: flex; align-items: center; gap: 1rem; padding: 0 16px; position: sticky; top: 0; z-index: 10;
  box-shadow: inset 0 -2px 0 var(--brand); }
.brand { color: #fff; height: 62px; white-space: nowrap; overflow: hidden; display: flex; align-items: center; gap: 14px; flex: none; }
.brand img { height: 40px; width: auto; display: block; flex: none; }
/* company name (Unbounded, wide capitals) over a quiet grey line, separated from the logo by a thin red rule */
.brand-txt { display: flex; flex-direction: column; gap: 5px; padding-left: 14px; border-left: 2px solid var(--brand); }
.brand-name { color: #fff; font-family: Unbounded, Montserrat, sans-serif; font-weight: 700; font-size: 16px;
  letter-spacing: .02em; text-transform: uppercase; line-height: 1.05; }
.brand-sub { color: #a1a1aa; font-size: 11.5px; font-weight: 500; letter-spacing: .06em; line-height: 1; }
@media (max-width: 1340px) { .brand-name { font-size: 14px; } .brand-sub { font-size: 10.5px; } .brand { gap: 10px; } .brand-txt { padding-left: 10px; } }
@media (max-width: 1240px) { .brand-txt { display: none; } }
.brand:hover { text-decoration: none; }
.nav { display: flex; align-items: stretch; gap: 2px; margin-left: auto; align-self: stretch; }
.nav > a, .nav summary { color: #d6d6da; padding: 0 10px; height: 62px; display: flex; align-items: center; cursor: pointer; list-style: none; white-space: nowrap; font-size: .92rem; font-weight: 500; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after { content: " ▾"; font-size: .7em; }
.nav > a:hover, .nav summary:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,.06); }
.nav > a.on { color: #fff; box-shadow: inset 0 -3px 0 var(--brand); }
.nav details { position: relative; }
.nav details > div { position: absolute; right: 0; top: 100%; background: var(--card); min-width: 250px; border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 6px; z-index: 20; }
.nav details > div a, .linkbtn { display: block; padding: 9px 12px; color: var(--ink); border-radius: 6px; width: 100%; text-align: left; }
.nav details > div a:hover, .linkbtn:hover { background: var(--bg); text-decoration: none; }
.linkbtn { background: none; border: 0; font: inherit; cursor: pointer; }
.burger { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.5rem; padding: 8px; cursor: pointer; }

.wrap { max-width: 1600px; margin: 0 auto; padding: 16px; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card.narrow, form.narrow { max-width: 460px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; background: var(--pos-bg); color: var(--pos); }
.flash.error { background: var(--neg-bg); color: var(--neg); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.meta { margin: 0 0 10px; }

/* buttons & inputs */
.btn { display: inline-block; border: 1px solid #d4d4d8; background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { text-decoration: none; border-color: #a1a1aa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--neg-bg); color: var(--neg); border-color: #f1bcbc; }
.btn.small { padding: 5px 10px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #d0d0d6; border-radius: 8px; padding: 8px 10px; min-height: 40px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(226, 0, 33, .15); border-color: #8f8f96; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
.quick, .filters, .period { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.period { margin: 0; }
.period .pname { margin: 0 6px; }
.range { position: relative; }
.range summary { cursor: pointer; color: var(--brand); list-style: none; }
.range[open] { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chk { display: inline-flex; gap: 6px; align-items: center; }
.chk input { min-height: auto; width: 18px; height: 18px; }

/* forms */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: .9rem; color: var(--muted); }
.field small { color: var(--muted); font-size: .8rem; }
.field.wide { grid-column: 1 / -1; }
.field.chkfield { justify-content: flex-end; padding-bottom: 8px; }
.calc { margin: 14px 0 0; padding: 10px 12px; background: #f4f4f6; border-radius: 8px; display: flex; flex-wrap: wrap; gap: 4px 24px; }
.calc:empty { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.delete { display: flex; gap: 12px; align-items: center; margin-top: -4px; }
fieldset.ck { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 6px 12px; }
fieldset.ck legend { font-weight: 600; padding: 0 6px; }
.ckrow { display: flex; align-items: center; gap: 14px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ckrow:last-child { border-bottom: 0; }
.ckrow span { flex: 1; }
.ckrow label { display: inline-flex; gap: 4px; align-items: center; }
.ckrow input { min-height: auto; width: 20px; height: 20px; }
form.inline { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0; }
.login { max-width: 380px; margin: 8vh auto; display: flex; flex-direction: column; gap: 12px; border-top: 3px solid var(--brand); }
.login-logo { width: 220px; max-width: 80%; margin: 4px auto 6px; display: block; }
.login h1, .login > p { text-align: center; margin: 0; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi b { font-size: 1.3rem; margin: 2px 0; white-space: nowrap; }
.kpi small { color: var(--muted); font-size: .8rem; }
.kpi.big.pos { background: var(--pos-bg); border-color: #b9e3c9; } .kpi.big.pos b { color: var(--pos); }
.kpi.big.neg { background: var(--neg-bg); border-color: #f3c0c0; } .kpi.big.neg b { color: var(--neg); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.more { float: right; font-size: .85rem; font-weight: 400; }

.alerts { background: var(--neg-bg); border: 1px solid #f3c0c0; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; color: var(--neg); }
.alerts summary { font-weight: 700; cursor: pointer; }
.alerts ul { margin: 8px 0 0; padding-left: 18px; }
.alerts a { color: var(--neg); }

.status { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.st { flex: 1 1 90px; border-radius: 8px; padding: 8px 10px; background: var(--bg); color: var(--ink); display: flex; flex-direction: column; }
.st b { font-size: 1.5rem; }
.st:hover { text-decoration: none; filter: brightness(.97); }
.st-trip { background: #ececef; } .st-base { background: var(--pos-bg); } .st-repair { background: var(--neg-bg); } .st-idle { background: var(--warn-bg); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--bg); font-size: .82rem; white-space: nowrap; }
.badge.ok { background: var(--pos-bg); color: var(--pos); }
.badge.bad { background: var(--neg-bg); color: var(--neg); font-weight: 600; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* tables */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.card .tablewrap { border: 0; margin: 0; }
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: .82rem; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #f7f7f8; white-space: nowrap; position: sticky; top: 0; }
.list td { padding: 8px 10px; border-bottom: 1px solid #efeff1; vertical-align: top; }
.list tbody tr:hover { background: #fafafa; }
.list tfoot td { font-weight: 700; background: #f7f7f8; border-top: 2px solid var(--line); }
.list tr.loss td { background: #fff6f6; }
.list tr.idle td { color: var(--muted); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.act { text-align: right; white-space: nowrap; width: 1%; }
.empty { text-align: center; color: var(--muted); padding: 24px !important; }
.sums { margin: 0 0 8px; color: var(--muted); }
.sums b { color: var(--ink); }
table.mini { width: 100%; border-collapse: collapse; }
.mini td, .mini th { padding: 5px 4px; border-bottom: 1px solid #efeff1; }
.mini th { text-align: left; font-size: .8rem; color: var(--muted); padding-top: 10px; }

/* bar chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-bottom: 22px; }
.bar { flex: 1; height: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar i { display: block; width: 42%; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar em { position: absolute; bottom: -20px; font-style: normal; font-size: .75rem; color: var(--muted); }
i.inc { background: var(--inc); } i.pr { background: var(--pr); } i.ls { background: var(--ls); }
.legend { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -1px; margin-left: 10px; }

.steps li { margin-bottom: 6px; }
.errors { color: var(--neg); max-height: 400px; overflow: auto; }

/* phones */
@media (max-width: 900px) {
  .burger { display: block; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--top); flex-direction: column; align-items: stretch; padding: 6px 10px 12px; max-height: calc(100vh - 50px); overflow: auto; }
  body.nav-open .nav { display: flex; }
  .nav > a, .nav summary { height: auto; padding: 12px 10px; }
  .brand { height: 56px; }
  .nav details > div { position: static; box-shadow: none; background: rgba(255,255,255,.06); }
  .nav details > div a, .nav .linkbtn { color: #e6edf5; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .wrap { padding: 12px; }
  h1 { font-size: 1.2rem; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi b { font-size: 1.05rem; }
  .tablewrap { background: transparent; border: 0; overflow: visible; }
  table.list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list thead { display: none; }
  .list tr { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; padding: 6px 10px; }
  .list td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 10px; text-align: right; }
  .list td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: .85rem; text-align: left; }
  .list td:empty { display: none; }
  .list td.act { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .list tfoot { display: block; }
  .list tfoot tr { background: #f7f7f8; }
  .list tfoot td:empty { display: none; }
  .fields { grid-template-columns: 1fr; }
  .bars { height: 140px; }
}

/* garage */
.gtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.gtabs a { padding: 7px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.gtabs a:hover { text-decoration: none; border-color: var(--brand); }
.gtabs.sub { margin-top: -6px; align-items: center; }
.gtabs.sub a { padding: 4px 10px; font-size: .88rem; }
.gtabs a.on { background: var(--top); color: #fff; border-color: var(--top); box-shadow: inset 0 -3px 0 var(--brand); }
.gcell { display: inline-flex; flex-direction: column; padding: 3px 8px; border-radius: 6px; color: var(--ink); white-space: nowrap; line-height: 1.25; }
.gcell:hover { text-decoration: none; outline: 1px solid var(--brand); }
.gcell small { font-size: .75rem; }
.gcell.ok { background: var(--pos-bg); }
.gcell.warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.gcell.bad { background: var(--neg-bg); color: var(--neg); font-weight: 700; }
.gtable tr.trk td { border-top: 2px solid var(--line); }
.gtable tr.trl td:first-child { color: var(--muted); }
.galert { position: fixed; inset: 0; z-index: 1000; background: rgba(150, 20, 20, .88); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto; }
.galert-box { background: var(--card); color: var(--ink); border-radius: 14px; padding: 18px 20px; width: 100%; max-width: 860px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.galert-box h2 { margin: 0 0 12px; color: var(--neg); }

@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
input.shake { animation: shake .28s ease-in-out; border-color: var(--neg) !important; }

/* searchable truck / trailer / driver picker */
.combo { position: relative; }
.combo > input { width: 100%; }
.combo-list { position: absolute; z-index: 30; top: calc(100% + 2px); left: 0; right: 0; max-height: 280px; overflow-y: auto; background: var(--card);
  border: 1px solid #d0d0d6; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; }
.combo-list div { padding: 7px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-list div.on, .combo-list div:hover { background: #f1f1f3; }
.combo-list div.on { box-shadow: inset 3px 0 0 var(--brand); }
.combo-list div.none { color: var(--muted); cursor: default; background: none; box-shadow: none; }

.list input.rate { width: 90px; min-height: 34px; padding: 5px 8px; text-align: right; }

/* receivables: date + «Оплачено» + edit in one compact row, no horizontal scroll */
.paycell form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; width: 168px; margin-left: auto; }
.paycell .btn { padding: 5px 9px; }
.paycell .btn.primary { flex: 1; text-align: center; }
.paycell input[type=date] { width: 168px; min-height: 34px; padding: 4px 8px; }

.delask { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--neg); font-size: .9rem; }
