/* Herbalus RFM — vizuální styl vychází z herbalus.cz */
:root {
    --green: #2F5241;
    --green-dark: #284637;
    --green-light: #9EC7B3;
    --green-soft: #EAF1ED;
    --beige: #C0B593;
    --beige-light: #D3C796;
    --beige-soft: #F6F3EA;
    --text: #232930;
    --gray: #54677B;
    --gray-light: #F5F8F9;
    --stroke: #E6E6E6;
    --white: #fff;
    --success: #85B446;
    --orange: #F98A10;
    --red: #F15F64;
    --sunset: #F4AD98;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(35,41,48,.04), 0 8px 24px rgba(35,41,48,.06);
    --shadow-lg: 0 2px 4px rgba(35,41,48,.05), 0 16px 40px rgba(35,41,48,.09);
    --font: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--gray-light);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--gray); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- hlavička ---------- */
.topbar {
    background: var(--green);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 12px rgba(35,41,48,.12);
}
.topbar-inner {
    max-width: 1360px; margin: 0 auto; padding: 0 24px;
    display: flex; align-items: center; gap: 28px; min-height: 66px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand svg { display: block; }
.brand small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; opacity: .72; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a {
    color: rgba(255,255,255,.82); padding: 8px 15px; border-radius: 999px;
    font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.nav a.active { background: #fff; color: var(--green); }
.topbar .logout { color: rgba(255,255,255,.62); font-size: 13px; padding: 8px 4px 8px 14px; }
.topbar .logout:hover { color: #fff; }

/* ---------- layout ---------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin-bottom: 4px; }
.page-head .sub { color: var(--gray); font-size: 14px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.card {
    background: #fff; border-radius: var(--radius); padding: 22px 24px;
    box-shadow: var(--shadow); margin-bottom: 20px; border: 1px solid rgba(230,230,230,.7);
}
.card > h2, .card > h3 { display: flex; align-items: baseline; gap: 10px; }
.card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .hint { color: var(--gray); font-size: 13px; }
.card-head .actions { margin-left: auto; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px)  { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px)  { .kpis { grid-template-columns: 1fr; } }
.kpi {
    background: #fff; border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow); border: 1px solid rgba(230,230,230,.7);
    display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden;
}
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--green); }
.kpi.accent-beige::before { background: var(--beige); }
.kpi.accent-red::before { background: var(--red); }
.kpi.accent-green::before { background: var(--success); }
.kpi.accent-orange::before { background: var(--orange); }
.kpi .label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--gray); }
.kpi .value { font-size: 27px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .value.sm { font-size: 22px; }
.kpi .note { font-size: 12.5px; color: var(--gray); }

/* ---------- tlačítka ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    background: var(--green); color: #fff; border: 1px solid var(--green);
    padding: 9px 20px; border-radius: 999px; font-weight: 600; font-size: 14px;
    font-family: var(--font); cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--green-dark); border-color: var(--green-dark); text-decoration: none; color: #fff; }
.btn.ghost { background: #fff; color: var(--green); border-color: var(--stroke); }
.btn.ghost:hover { background: var(--green-soft); border-color: var(--green-light); color: var(--green); }
.btn.sm { padding: 6px 14px; font-size: 13px; }
.btn.beige { background: var(--beige); border-color: var(--beige); color: #fff; }
.btn.beige:hover { background: #ada284; border-color: #ada284; }

/* ---------- formuláře ---------- */
label { font-size: 13px; font-weight: 600; color: var(--text); display: block; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select {
    width: 100%; padding: 9px 13px; border: 1px solid var(--stroke); border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 14px; color: var(--text); background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--green-light); outline-offset: -1px; border-color: var(--green-light); }
.field { margin-bottom: 16px; }
.field .help { font-size: 12px; color: var(--gray); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border: 1px solid var(--stroke);
    border-radius: var(--radius-sm); font-size: 13.5px; background: #fff; cursor: pointer; font-weight: 500; }
.check input { margin: 0; accent-color: var(--green); width: 16px; height: 16px; }
.check.on { border-color: var(--green-light); background: var(--green-soft); }

/* ---------- tabulky ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--stroke); vertical-align: middle; }
th {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--gray);
    font-weight: 700; background: var(--gray-light); white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
th a { color: var(--gray); }
th a:hover { color: var(--green); }
tbody tr:hover { background: #FAFCFC; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: var(--gray-light); border-bottom: none; }
.table-compact th, .table-compact td { padding: 7px 10px; font-size: 13px; }

/* ---------- štítky ---------- */
.tag {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 700;
    background: var(--gray-light); color: var(--gray); font-variant-numeric: tabular-nums; }
.badge.g { background: var(--green-soft); color: var(--green); }
.badge.r { background: #FDEEEF; color: #C23A40; }
.badge.o { background: #FEF2E4; color: #B86A0B; }

/* ---------- grafy ---------- */
.chart { width: 100%; height: auto; display: block; font-family: var(--font); }
.chart.donut { max-width: 290px; margin: 0 auto; }
.chart .c-label { font-size: 13px; fill: var(--text); font-weight: 600; }
.chart .c-value { font-size: 13px; fill: var(--gray); font-variant-numeric: tabular-nums; }
.chart .c-axis { font-size: 11.5px; fill: var(--gray); font-variant-numeric: tabular-nums; }
.chart .c-axis2 { fill: #A79A73; }
.chart .c-axis-title { font-size: 12px; fill: var(--gray); font-weight: 600; }
.chart .c-legend { font-size: 12.5px; fill: var(--gray); font-weight: 600; }
.chart .c-bubble { font-size: 11px; fill: #fff; font-weight: 700; }
.chart .c-donut-top { font-size: 25px; font-weight: 700; fill: var(--text); }
.chart .c-donut-sub { font-size: 12px; fill: var(--gray); }
.legend-list { display: flex; flex-direction: column; gap: 7px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-item .vl { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- matice RFM ---------- */
.matrix { border-collapse: separate; border-spacing: 4px; width: auto; }
.matrix td, .matrix th { border: none; padding: 0; }
.matrix th { background: none; position: static; text-transform: none; letter-spacing: 0; font-size: 12px; }
.mcell {
    width: 118px; height: 74px; border-radius: 10px; padding: 8px 10px; color: #fff;
    display: flex; flex-direction: column; justify-content: space-between; position: relative;
}
.mcell .mn { font-size: 19px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.mcell .ms { font-size: 10.5px; opacity: .9; line-height: 1.25; font-weight: 600; }
.mcell .mr { font-size: 10.5px; opacity: .8; font-variant-numeric: tabular-nums; }
.axis-label { font-size: 12px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- kohorty ---------- */
.cohort td, .cohort th { padding: 5px 6px; font-size: 12px; text-align: center; border: none; }
.cohort th { background: none; position: static; }
.cohort .cc { border-radius: 5px; padding: 5px 4px; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- zjištění ---------- */
.insight { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--stroke); }
.insight:last-child { border-bottom: none; padding-bottom: 0; }
.insight:first-child { padding-top: 0; }
.insight .ico { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center;
    background: var(--green-soft); color: var(--green); font-weight: 800; font-size: 16px; }
.insight.warning .ico { background: #FEF2E4; color: #B86A0B; }
.insight.danger .ico { background: #FDEEEF; color: #C23A40; }
.insight.positive .ico { background: #EFF6E6; color: #5E8B2C; }
.insight h4 { margin: 0 0 3px; font-size: 15.5px; }
.insight .body { font-size: 14px; color: var(--text); }
.insight .act { margin-top: 7px; font-size: 13.5px; color: var(--gray); padding-left: 12px; border-left: 3px solid var(--beige); }
.insight .act strong { color: var(--text); }

/* ---------- segmentové karty ---------- */
.segcard { display: block; background: #fff; border-radius: var(--radius); border: 1px solid var(--stroke);
    padding: 18px 20px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; position: relative;
    overflow: hidden; color: var(--text); }
.segcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; }
.segcard::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; }
.segcard h3 { margin: 0 0 2px; font-size: 16px; }
.segcard .metrics { display: flex; gap: 18px; margin-top: 12px; flex-wrap: wrap; }
.segcard .metrics div { font-size: 12px; color: var(--gray); }
.segcard .metrics b { display: block; font-size: 17px; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.segcard .bar { height: 5px; border-radius: 3px; background: var(--gray-light); margin-top: 12px; overflow: hidden; }
.segcard .bar i { display: block; height: 100%; border-radius: 3px; }

.alert { padding: 13px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; font-weight: 500; }
.alert.err { background: #FDEEEF; color: #A3262C; border: 1px solid #F7C9CB; }
.alert.ok { background: #EFF6E6; color: #4E7523; border: 1px solid #D6E8BF; }
.alert.info { background: var(--green-soft); color: var(--green); border: 1px solid var(--green-light); }

.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; border: 1px solid var(--stroke); background: #fff; }
.pager .cur { background: var(--green); color: #fff; border-color: var(--green); }
.pager .gap { border: none; background: none; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.filters .btns { display: flex; gap: 8px; }

.split { display: grid; grid-template-columns: 1fr 300px; gap: 26px; align-items: center; }
.stat-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--stroke); font-size: 14px; }
.stat-line:last-child { border-bottom: none; }
.stat-line b { font-variant-numeric: tabular-nums; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
    linear-gradient(160deg, var(--green) 0%, var(--green-dark) 55%, #1E3529 100%); padding: 24px; }
.login-card { background: #fff; border-radius: 22px; padding: 40px 38px; width: 100%; max-width: 400px; box-shadow: 0 30px 70px rgba(0,0,0,.28); }
.login-card .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; }
.login-card h1 { font-size: 21px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--gray); font-size: 13.5px; margin-bottom: 24px; }
.login-card .btn { width: 100%; margin-top: 6px; }

.footer { text-align: center; color: var(--gray); font-size: 12.5px; padding: 8px 0 0; }

.scroll-x { overflow-x: auto; }
.rank { color: var(--gray); font-size: 12px; font-weight: 700; width: 26px; }

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
    .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .topbar-inner { flex-wrap: wrap; padding: 10px 16px; gap: 12px; }
    .nav { width: 100%; margin-left: 0; overflow-x: auto; }
    .wrap { padding: 20px 16px 48px; }
    h1 { font-size: 24px; }
}

@media print {
    .topbar, .page-head .actions, .filters, .pager { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid var(--stroke); break-inside: avoid; }
}
