:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1f4ed8;
  --brand-d: #1736a3;
  --green: #0f9d58;
  --green-bg: #e7f6ee;
  --amber: #f59e0b;
  --red: #dc2626;
  --red-bg: #fdecec;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 20px rgba(15, 23, 42, .06);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 22px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand .logo { font-weight: 800; letter-spacing: -.4px; color: var(--brand); font-size: 18px; }
.brand .sub { font-size: 11px; color: var(--muted); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.tabs button:hover { background: #f1f5f9; color: var(--ink); }
.tabs button.active { background: var(--brand); color: #fff; }
.who { font-size: 12px; color: var(--muted); }

main { padding: 22px; max-width: 1280px; margin: 0 auto; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* Section header */
.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 19px; }
.view-head .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.kpi .value { font-size: 21px; font-weight: 800; margin-top: 6px; letter-spacing: -.5px; }
.kpi .value.green { color: var(--green); }
@media (max-width: 1100px){ .kpis { grid-template-columns: repeat(3,1fr);} }
@media (max-width: 640px){ .kpis { grid-template-columns: repeat(2,1fr);} .tabs button{padding:8px 10px;} }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.panel-head { padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px; display:flex; justify-content:space-between; align-items:center;}
.panel-body { padding: 4px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 900px){ .grid2 { grid-template-columns: 1fr; } }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600; background: #fbfcfe; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.totalrow td { font-weight: 800; background: #f1f5f9; }
.table-wrap { overflow-x: auto; }

/* badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.grey { background: #eef2f7; color: var(--muted); }
.badge.blue { background: #e6edfd; color: var(--brand); }
.badge.amber { background: #fef3df; color: #b4730a; }
.badge.red { background: var(--red-bg); color: var(--red); }
.succ { color: var(--green); font-weight: 700; }

/* progress bar */
.bar { background: #eef2f7; border-radius: 6px; height: 8px; width: 120px; overflow: hidden; display: inline-block; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--brand); }

/* buttons */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer; }
.btn:hover { border-color: #cbd5e1; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: #f3c4c4; }
.btn.danger:hover { background: var(--red-bg); }
.row-actions { display: flex; gap: 6px; }
.icon { background: transparent; border: 0; cursor: pointer; font-size: 15px; color: var(--muted); }
.icon:hover { color: var(--ink); }

/* filter input */
input[type=text], input[type=number], input[type=date], select, textarea {
  font-family: inherit; font-size: 13.5px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d6fb; border-color: var(--brand); }
.search { max-width: 230px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
#modal-form { padding: 18px 20px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#modal-form .full { grid-column: 1 / -1; }
#modal-form label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 600; font-size: 13px; z-index: 80; box-shadow: var(--shadow); }
.toast[hidden] { display: none; }
.toast.err { background: var(--red); }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.lnk { color: var(--brand); font-weight: 600; text-decoration: none; }
.lnk:hover { text-decoration: underline; }
.sub2 { font-size: 11px; color: var(--muted); }

/* Client detail */
.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.dgrid > div { font-size: 13.5px; }
.dgrid > div.wide { grid-column: 1 / -1; }
.dgrid span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
.detail-head { background: #f8fafc; border-radius: 10px; padding: 14px 16px; margin-bottom: 6px; }
.detail-sec { margin-top: 14px; }
.detail-sec h4 { margin: 0 0 6px; font-size: 13px; }
#modal-form .full .kpis { grid-template-columns: repeat(3,1fr); }

/* Attention panel */
.attn { border-left: 4px solid var(--amber); }
.att-list { list-style: none; margin: 0; padding: 6px 0; }
.att { display: flex; gap: 10px; align-items: center; padding: 9px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.att:last-child { border-bottom: 0; }
.att-i { font-size: 15px; }
.att.high { color: #991b1b; } .att.high .att-i { color: var(--red); }
.att.med { color: #92560a; }
.att.low { color: var(--muted); }

/* Čerpání cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border-top: 3px solid var(--brand); }
.card.status-ok { border-top-color: var(--green); }
.card.status-warn { border-top-color: var(--amber); }
.card.status-over { border-top-color: var(--red); }
.card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-t { font-weight: 700; font-size: 15px; }
.card-s { font-size: 12px; color: var(--muted); }
.chips { margin: 10px 0; font-size: 12px; color: var(--muted); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef2f7; color: var(--muted); font-weight: 600; }
.chip.on { background: var(--green-bg); color: var(--green); }
.cnums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 8px; text-align: center; }
.cnums span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.cnums b { font-size: 16px; }
.cnums .pos { color: var(--green); } .cnums .neg { color: var(--red); }
.bar.big { width: 100%; height: 12px; border-radius: 7px; }
.bar.big > span.ok { background: var(--green); }
.bar.big > span.warn { background: var(--amber); }
.bar.big > span.over { background: var(--red); }
.card-kc { font-size: 12.5px; color: var(--muted); margin: 8px 0 4px; }
.forecast { font-size: 12.5px; color: var(--ink); background: #f8fafc; border-radius: 8px; padding: 7px 10px; margin: 8px 0; }
.card details { margin-top: 8px; }
.card details summary { cursor: pointer; font-size: 12.5px; color: var(--brand); font-weight: 600; }
table.mini { margin-top: 8px; font-size: 12px; }
table.mini th, table.mini td { padding: 5px 8px; }
