:root {
  --bg: #F3F3F5; --surface: #FFFFFF; --surface-alt: #F4F4F6; --surface-high: #E9E9ED;
  --border: rgba(17,17,20,.08); --border-strong: rgba(17,17,20,.16); --divider: rgba(17,17,20,.06);
  --text: #111114; --text-2: #55555E; --muted: #8C8C96;
  --accent: #DC2B23; --accent-press: #B9221B; --accent-soft: rgba(220,43,35,.09); --accent-border: rgba(220,43,35,.3);
  --success: #14975A; --success-soft: rgba(20,151,90,.1);
  --warning: #C77A06; --warning-soft: rgba(199,122,6,.1);
  --danger: #D92D20; --danger-soft: rgba(217,45,32,.09);
  --info: #2563EB; --info-soft: rgba(37,99,235,.09);
  --gold: #B7860B; --gold-soft: rgba(183,134,11,.12);
  --shadow: 0 1px 2px rgba(17,17,20,.05), 0 8px 24px rgba(17,17,20,.06);
  --r: 14px; --r-sm: 10px;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0A0B; --surface: #161618; --surface-alt: #1E1E21; --surface-high: #29292D;
    --border: rgba(255,255,255,.08); --border-strong: rgba(255,255,255,.16); --divider: rgba(255,255,255,.06);
    --text: #F5F5F6; --text-2: #A9A9B2; --muted: #6E6E78;
    --accent: #EF3E36; --accent-press: #D42F28; --accent-soft: rgba(239,62,54,.14); --accent-border: rgba(239,62,54,.38);
    --success: #2FCB7A; --success-soft: rgba(47,203,122,.14);
    --warning: #F5A524; --warning-soft: rgba(245,165,36,.14);
    --danger: #FF5A52; --danger-soft: rgba(255,90,82,.14);
    --info: #5B8DEF; --info-soft: rgba(91,141,239,.14);
    --gold: #E2B33C; --gold-soft: rgba(226,179,60,.14);
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0A0B; --surface: #161618; --surface-alt: #1E1E21; --surface-high: #29292D;
  --border: rgba(255,255,255,.08); --border-strong: rgba(255,255,255,.16); --divider: rgba(255,255,255,.06);
  --text: #F5F5F6; --text-2: #A9A9B2; --muted: #6E6E78;
  --accent: #EF3E36; --accent-press: #D42F28; --accent-soft: rgba(239,62,54,.14); --accent-border: rgba(239,62,54,.38);
  --success: #2FCB7A; --success-soft: rgba(47,203,122,.14);
  --warning: #F5A524; --warning-soft: rgba(245,165,36,.14);
  --danger: #FF5A52; --danger-soft: rgba(255,90,82,.14);
  --info: #5B8DEF; --info-soft: rgba(91,141,239,.14);
  --gold: #E2B33C; --gold-soft: rgba(226,179,60,.14);
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: 26px; line-height: 1.15; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 10px; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.t2 { color: var(--text-2); }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(140deg, #EA3F37, #C9241D); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .02em; }
.brand-lg .logo { width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
.brand-lg b { font-size: 20px; }

/* Buttons & inputs */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-alt); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-press); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.fld { display: block; margin-bottom: 12px; }
.fld > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.fld small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-alt); outline: none;
}
textarea { height: auto; padding: 10px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.invalid { border-color: var(--danger) !important; background: var(--danger-soft) !important; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 24px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.or::before, .or::after { content: ''; height: 1px; flex: 1; background: var(--divider); }
.msg { color: var(--danger); min-height: 20px; margin: 14px 0 0; font-size: 13px; }
.msg.ok { color: var(--text-2); }

/* Shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 22px; }
.side .brand { padding: 0 6px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 600; }
#nav a svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; }
#nav a:hover { background: var(--surface-alt); color: var(--text); }
#nav a.active { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; padding: 0 6px; word-break: break-all; }
main { padding: 28px 32px 60px; min-width: 0; outline: none; }
.demo { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-soft); padding: 8px 12px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; font-size: 13px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }
.over { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.kpi { padding: 16px 18px; }
.kpi .lbl { color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.kpi .val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.two { grid-template-columns: 1.6fr 1fr; }
.chart { width: 100%; height: 180px; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar.zero { fill: var(--surface-high); }
.chart text { fill: var(--muted); font-size: 10px; font-family: Inter, sans-serif; }
.chart .grid-line { stroke: var(--divider); }
.dist { display: flex; flex-direction: column; gap: 12px; }
.dist .row { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.dist .track { height: 10px; background: var(--surface-alt); border-radius: 6px; overflow: hidden; }
.dist .fill { height: 100%; border-radius: 6px; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 320px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 11px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--text-2); font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg button .c { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* Tables */
.tbl-wrap { overflow: auto; border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
th { font-size: 12px; color: var(--text-2); font-weight: 700; background: var(--surface-alt); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--text); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-alt); }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > div { min-width: 0; }
.who .cell-main, .who .cell-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-free { background: var(--surface-high); color: var(--text-2); }
.b-month { background: var(--accent-soft); color: var(--accent); }
.b-year { background: var(--info-soft); color: var(--info); }
.b-excl { background: var(--gold-soft); color: var(--gold); }
.b-exp { background: var(--warning-soft); color: var(--warning); }
.b-ok { background: var(--success-soft); color: var(--success); }
.b-err { background: var(--danger-soft); color: var(--danger); }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer-bg { position: absolute; inset: 0; background: rgba(10,10,12,.4); animation: fade .15s; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; animation: slide .2s ease-out; }
.drawer-panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--divider); }
.drawer-body { padding: 20px; overflow: auto; flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: .6; } }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; font-size: 13px; margin-bottom: 18px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; word-break: break-word; }
.box { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 14px; background: var(--surface-alt); }
.note { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.note.warn { background: var(--warning-soft); color: var(--warning); }
.note.info { background: var(--info-soft); color: var(--info); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }

/* Material preview (jak v aplikaci) */
.prev { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.prev .cat { font-size: 12px; color: var(--muted); font-weight: 600; }
.prev .nm { font-size: 17px; font-weight: 700; margin: 2px 0 10px; }
.prev .props { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prev .props div { background: var(--surface-alt); border-radius: 10px; padding: 8px 10px; }
.prev .props span { display: block; font-size: 11px; color: var(--muted); }
.prev .props b { font-size: 14px; }

/* Hromadný editor */
.bulk { overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.bulk table { min-width: 1280px; }
.bulk th, .bulk td { padding: 0; border-right: 1px solid var(--divider); }
.bulk th { padding: 8px 10px; }
.bulk td input, .bulk td select { border: 0; border-radius: 0; background: transparent; height: 36px; min-width: 70px; }
.bulk td input:focus, .bulk td select:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.bulk tbody tr { cursor: default; }
.bulk tbody tr:hover { background: transparent; }
.bulk td.st { padding: 0 10px; white-space: nowrap; font-size: 12px; }
.bulk td.ix { padding: 0 10px; color: var(--muted); text-align: right; font-size: 12px; }
.bulk td.del button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 34px; height: 36px; }
.bulk-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.drop { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 14px; text-align: center; color: var(--text-2); margin-bottom: 12px; font-size: 13px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

/* Toasts & boot */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: fade .2s; max-width: 360px; }
.toast.err { background: var(--danger); color: #fff; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 60; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-high); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobil */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .side .brand div, #meEmail, #themeBtn { display: none; }
  #nav { flex-direction: row; }
  #nav a { padding: 8px 10px; white-space: nowrap; }
  #nav a svg { display: none; }
  .side-foot { margin: 0 0 0 auto; }
  main { padding: 20px 16px 48px; }
  .two { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .hide-m { display: none; }
}

/* Notifikace */
.phone { background: linear-gradient(160deg, #2b2f3a, #12141a 70%); border-radius: 26px; padding: 26px 14px 60px; min-height: 230px; }
.phone-time { color: rgba(255,255,255,.92); font-size: 44px; font-weight: 300; text-align: center; letter-spacing: -.02em; margin-bottom: 18px; }
.push { background: rgba(245,245,247,.88); color: #111; border-radius: 16px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.push-head { display: flex; align-items: center; gap: 7px; font-size: 12px; margin-bottom: 4px; }
.push-head b { flex: 1; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; font-size: 11.5px; color: #333; }
.push-head .muted { color: #777; }
.push-ic { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(140deg, #EA3F37, #C9241D); color: #fff; font-size: 8px; font-weight: 800; display: grid; place-items: center; }
.push-title { font-weight: 700; font-size: 14px; }
.push-body { font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.pick-list { display: flex; flex-direction: column; gap: 2px; margin: -6px 0 10px; }
.pick-list button { text-align: left; border: 1px solid var(--border); background: var(--surface-alt); border-radius: 9px; padding: 7px 10px; cursor: pointer; font-size: 13px; }
.pick-list button:hover { border-color: var(--accent-border); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 6px 4px 10px; font-size: 12.5px; font-weight: 600; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 11px; }
.ask { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.ask-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.ask-box { position: relative; width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.ask-box p { margin: 0 0 18px; white-space: pre-line; line-height: 1.5; }
.ask-act { display: flex; justify-content: flex-end; gap: 8px; }
