/* ============================================================
   Projektovník — App (administrace majitele)
   Světlý režim, brand: #D35400 / #E6A817 / #2C3C4B
   Fáze A — kostra
============================================================ */
:root {
  --c-primary: #D35400;
  --c-primary-hover: #B84600;
  --c-accent: #E6A817;
  --c-dark: #2C3C4B;
  --c-bg: #F7F8FA;
  --c-surface: #FFFFFF;
  --c-surface-2: #F0F2F5;
  --c-line: #E1E5EA;
  --c-text: #1E2A36;
  --c-muted: #6B7785;
  --c-danger: #C62828;
  --c-success: #2E7D32;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: 'SF Mono', Menlo, Consolas, monospace; }

.muted { color: var(--c-muted); }

/* ===========================================================
   Auth overlay
=========================================================== */
.auth-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #2C3C4B 0%, #1A2733 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
/* `display:flex` vy\u0161\u0161\u00ed specificitou p\u0159ebije UA `[hidden]{display:none}`. */
.auth-overlay[hidden] { display: none !important; }
.shell[hidden] { display: none !important; }

/* -----------------------------------------------------------
   Auth boot splash (Fáze N)
   Překryje vše dokud Firebase neurčí stav přihlášení.
   Pokud je uživatel zapamatovaný → zmizí přímo do dashboardu (bez bliknutí loginu).
   Respektuje světlý/tmavý režim přes existující CSS vars (--c-bg/--c-text).
----------------------------------------------------------- */
.auth-boot {
  position: fixed; inset: 0;
  background: var(--c-bg, #fff);
  color: var(--c-text, #222);
  display: flex; align-items: center; justify-content: center;
  z-index: 1100; /* nad auth-overlay (1000) i appShell */
  padding: 20px;
}
.auth-boot[hidden] { display: none !important; }
.auth-boot__inner {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  text-align: center;
}
.auth-boot__logo {
  width: 110px; height: auto;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.12));
  animation: authBootPulse 1.6s ease-in-out infinite;
}
@keyframes authBootPulse {
  0%, 100% { transform: scale(1);     opacity: .92; }
  50%      { transform: scale(1.06);  opacity: 1;   }
}
.auth-boot__spinner {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--c-text, #222) 15%, transparent);
  border-top-color: var(--c-primary, #D35400);
  animation: authBootSpin 1s linear infinite;
}
@keyframes authBootSpin { to { transform: rotate(360deg); } }
.auth-boot__text {
  margin: 0;
  font-size: 1.02em;
  letter-spacing: .01em;
  opacity: .82;
}

.auth-card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  width: 100%; max-width: 420px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-card__brand {
  text-align: center;
  margin-bottom: 22px;
}
.auth-card__brand img,
.auth-card__logo {
  max-width: 220px;
  max-height: 80px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.auth-card__brand h1 {
  font-size: 1.4em;
  margin: 8px 0 2px;
  color: var(--c-dark);
}
.auth-card__brand p { margin: 0; color: var(--c-muted); font-size: .9em; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label { font-size: .85em; font-weight: 600; color: var(--c-dark); }
.input-group input[type="email"],
.input-group input[type="password"],
.input-group input[type="text"] {
  width: 100%;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 1em;
  background: var(--c-surface);
  color: var(--c-text);
}
.input-group input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(211,84,0,.15);
}

.input-with-action { position: relative; }
.input-with-action input { padding-right: 40px; width: 100%; }
.input-with-action .ibtn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.input-with-action .ibtn:hover { background: var(--c-surface-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: .95em; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-hover); }
.btn-ghost { background: transparent; color: var(--c-text); border-color: var(--c-line); }
.btn-ghost:hover:not(:disabled) { background: var(--c-surface-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: .85em; }

.btn-google {
  background: #fff;
  color: #1F1F1F;
  border-color: var(--c-line);
  font-weight: 500;
}
.btn-google:hover:not(:disabled) { background: var(--c-surface-2); }
.btn-google__icon {
  width: 18px; height: 18px;
  display: inline-block;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="%234285F4" d="M45.12 24.5c0-1.56-.14-3.06-.4-4.5H24v8.51h11.84c-.51 2.75-2.06 5.08-4.39 6.64v5.52h7.11c4.16-3.83 6.56-9.47 6.56-16.17z"/><path fill="%2334A853" d="M24 46c5.94 0 10.92-1.97 14.56-5.33l-7.11-5.52c-1.97 1.32-4.49 2.1-7.45 2.1-5.73 0-10.58-3.87-12.31-9.07H4.34v5.7C7.96 41.07 15.4 46 24 46z"/><path fill="%23FBBC05" d="M11.69 28.18c-.44-1.32-.69-2.73-.69-4.18s.25-2.86.69-4.18v-5.7H4.34C2.85 17.09 2 20.45 2 24s.85 6.91 2.34 9.88l7.35-5.7z"/><path fill="%23EA4335" d="M24 10.75c3.23 0 6.13 1.11 8.41 3.29l6.31-6.31C34.91 4.18 29.93 2 24 2 15.4 2 7.96 6.93 4.34 14.12l7.35 5.7c1.73-5.2 6.58-9.07 12.31-9.07z"/></svg>') center/contain no-repeat;
}

.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 8px;
  color: var(--c-muted); font-size: .8em;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--c-line);
}

/* --- Google login row: button + nápověda jako jeden vizuální blok --- */
.google-row {
  position: relative;
}
.google-row .btn-google {
  padding-right: 44px; /* místo pro ikonu nápovědy */
}

.auth-help {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  outline: none;
}
.auth-help__icon {
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 12px; font-weight: 700;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--c-muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
  line-height: 1;
}
.auth-help:hover .auth-help__icon,
.auth-help:focus .auth-help__icon {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}
.auth-help__tip {
  position: absolute;
  bottom: calc(100% + 10px);
  right: -8px;
  background: var(--c-dark);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .8em; line-height: 1.45;
  font-weight: 400;
  white-space: normal;
  width: 260px;
  z-index: 10;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s, visibility .15s;
  pointer-events: none;
  text-align: left;
}
.auth-help__tip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 14px;
  border: 6px solid transparent;
  border-top-color: var(--c-dark);
}
.auth-help:hover .auth-help__tip,
.auth-help:focus .auth-help__tip,
.auth-help.is-open .auth-help__tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.auth-error {
  padding: 10px 12px;
  background: #FEEBEE;
  border: 1px solid #F8C8CC;
  border-radius: var(--r-md);
  color: var(--c-danger);
  font-size: .88em;
  margin-bottom: 4px;
}

.auth-footer {
  text-align: center;
  font-size: .82em;
  color: var(--c-muted);
  margin-top: 18px;
}
.auth-footer a { color: var(--c-muted); text-decoration: underline; }

/* ===========================================================
   App shell
=========================================================== */
.topbar {
  background: var(--c-dark);
  color: #fff;
  padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 3px solid var(--c-primary);
}
.topbar__left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar__brand {
  height: 40px; width: 40px;
  background: #fff;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 2px 6px rgba(0,0,0,.18);
  object-fit: contain;
}
.topbar__sep {
  width: 1px; height: 28px;
  background: rgba(255,255,255,.18);
}
.topbar__logo-firma-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  height: 40px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 2px 6px rgba(0,0,0,.14);
}
.topbar__logo-firma {
  max-width: 140px; max-height: 32px; width: auto; height: auto;
  object-fit: contain; display: block;
}
.topbar__firma {
  font-size: 1.05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #fff; font-weight: 700; letter-spacing: .01em;
  max-width: 240px;
}
.topbar__right { display: flex; align-items: center; gap: 12px; }
.topbar__user { color: rgba(255,255,255,.78); font-size: .9em; font-weight: 500; }
.topbar__right .btn-ghost {
  color: #fff;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.04);
}
.topbar__right .btn-ghost:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.32); }

/* Hamburger button (mobile only) */
.topbar__menu {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px; height: 44px;
  padding: 10px 9px;
  background: rgba(255,255,255,.14);
  border: 1.5px solid rgba(255,255,255,.42);
  border-radius: 10px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s, border-color .15s;
  -webkit-tap-highlight-color: rgba(255,255,255,.18);
}
.topbar__menu:hover,
.topbar__menu:focus-visible {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.6);
  outline: none;
}
.topbar__menu-bar {
  display: block;
  width: 22px; height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
}
.topbar__menu.is-open .topbar__menu-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.topbar__menu.is-open .topbar__menu-bar:nth-child(2) { opacity: 0; }
.topbar__menu.is-open .topbar__menu-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Sidebar backdrop (mobile drawer) */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,30,45,.55);
  z-index: 95;
  opacity: 0;
  transition: opacity .22s ease;
  pointer-events: none;
}
.sidebar-backdrop.is-shown {
  opacity: 1;
  pointer-events: auto;
}
.sidebar-backdrop[hidden] { display: none; }

/* Mobile-only sidebar footer (email + logout) — desktop má v topbaru */
.sidebar__mobile-footer { display: none; }

body.has-drawer-open { overflow: hidden; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 63px);
}
.sidebar {
  background: var(--c-surface);
  border-right: 1px solid var(--c-line);
  padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--c-text);
  font-weight: 500;
  position: relative;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar__item:hover { background: var(--c-surface-2); text-decoration: none; }
.sidebar__item.is-active { background: rgba(211,84,0,.12); color: var(--c-primary); font-weight: 600; }
.sidebar__icon { font-size: 1.15em; width: 22px; text-align: center; flex: 0 0 22px; }
.sidebar__label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sidebar group (Aplikace) */
.sidebar__group { display: flex; flex-direction: column; }
.sidebar__group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: transparent; border: 0; cursor: pointer;
  color: var(--c-text); font: inherit; font-weight: 500;
  width: 100%; text-align: left;
  transition: background .15s;
}
.sidebar__group-head:hover { background: var(--c-surface-2); }
.sidebar__chev {
  margin-left: auto; font-size: .85em; color: var(--c-muted);
  transition: transform .2s;
}
.sidebar__group.is-expanded .sidebar__chev { transform: rotate(180deg); }
.sidebar__sub {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateX(-12px);
  transition: max-height .28s ease, opacity .22s ease, transform .28s ease;
  will-change: max-height, opacity, transform;
}
.sidebar__group.is-expanded .sidebar__sub {
  opacity: 1;
  transform: translateX(0);
}
.sidebar__group:not(.is-expanded) .sidebar__sub > * { pointer-events: none; }
.sidebar__item--sub {
  padding-left: 24px;
  font-size: .98em;
  font-weight: 500;
  gap: 12px;
  transition: opacity .25s ease, transform .25s ease, max-height .25s ease, padding .25s ease;
}
.sidebar__item--sub.is-removing {
  opacity: 0;
  transform: translateX(-8px);
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  pointer-events: none;
}
.sidebar__img {
  width: 32px; height: 32px; object-fit: contain;
  flex: 0 0 32px;
  border-radius: 6px;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Sidebar notif badge */
.sidebar__badge {
  margin-left: auto;
  background: #DC2626;
  color: #fff;
  font-size: .72em;
  font-weight: 700;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--c-surface);
}
.sidebar__badge[hidden] { display: none !important; }

.main {
  padding: 28px clamp(20px, 4vw, 56px);
  width: 100%;
  max-width: none;
  min-width: 0;
}
.main > * { max-width: 1600px; margin-left: auto; margin-right: auto; }
.page-header__app-icon {
  height: 1.3em; width: auto; vertical-align: -0.18em;
  margin-right: 6px;
}

/* ===========================================================
   Karty, mřížky, page header
=========================================================== */
.page-header { margin-bottom: 20px; padding: 0; }
.page-header h1 { margin: 0 0 4px; font-size: 1.6em; color: var(--c-dark); }
.page-header__sub { margin: 0; color: var(--c-muted); }
.page-header--hero {
  background: linear-gradient(135deg, rgba(211,84,0,.08) 0%, rgba(230,168,23,.08) 100%);
  border: 1px solid rgba(211,84,0,.18);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin-bottom: 22px;
}
.page-header--hero h1 { font-size: 1.8em; }

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card__title { font-size: 1.05em; margin: 0; color: var(--c-dark); }
.card__actions { margin-top: 14px; display: flex; gap: 8px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.grid-2 > .card { margin-bottom: 0; display: flex; flex-direction: column; }
.grid-2 > .card > .card__actions { margin-top: auto; padding-top: 14px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 16px;
}
.kv-grid > div { display: flex; flex-direction: column; gap: 2px; }
.kv-grid .muted { font-size: .8em; }
.kv-grid strong { color: var(--c-dark); }

.code-chip {
  display: inline-block;
  background: var(--c-surface-2);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: .88em;
  color: var(--c-dark);
}
.code-chip--lg { font-size: 1.1em; padding: 8px 14px; letter-spacing: .5px; }

/* ===========================================================
   Přehled — vylepšení (Block 1)
=========================================================== */
.card--accent {
  position: relative;
  overflow: hidden;
}
.card--accent::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--c-primary), var(--c-secondary));
  opacity: .85;
}
.kv-grid--padded { margin-top: 4px; }
.card__actions--padded { padding-top: 14px; }
.card__lead { margin: 0 0 12px; color: var(--c-text); }

.plan-badge {
  display: inline-flex; align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .8em;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--c-surface-2);
  color: var(--c-dark);
  border: 1px solid var(--c-line);
}
.plan-badge--start    { background: #E8F0F7; color: #2C3C4B; border-color: #C5D5E3; }
.plan-badge--profi    { background: #FFE9D5; color: #8C3D00; border-color: #F2B98A; }
.plan-badge--komplet  { background: linear-gradient(135deg,#D35400,#E6A817); color: #fff; border-color: transparent; }
.plan-badge--trial    { background: #FEF3C7; color: #92400E; border-color: #FCD34D; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .85em; font-weight: 600; }
.chip--ok     { background: #DCFCE7; color: #166534; }
.chip--warn   { background: #FEF3C7; color: #92400E; }
.chip--danger { background: #FEE2E2; color: #991B1B; }

.referral-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.referral-row__url {
  margin: 0;
  font-size: .82em;
  word-break: break-all;
}
.btn-icon {
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1.05em;
  transition: background .15s, transform .1s;
}
.btn-icon:hover { background: var(--c-surface); transform: translateY(-1px); }
.btn-icon:active { transform: translateY(0); }

/* ===========================================================
   Předplatné — vylepšení (Block 4)
=========================================================== */
.plan-summary {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--c-line);
  margin-bottom: 14px;
}
.plan-summary__price-num {
  font-size: 1.8em; font-weight: 700; color: var(--c-primary);
  letter-spacing: -.5px;
}
.plan-summary__price-suffix { color: var(--c-muted); font-size: .9em; margin-left: 4px; }
.plan-summary__period { text-align: right; display: flex; flex-direction: column; gap: 2px; }

.plan-countdown { margin-bottom: 16px; }
.plan-countdown__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; gap: 8px; flex-wrap: wrap;
}

.plan-stat { margin-bottom: 16px; }
.plan-stat__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}

.progress-bar {
  width: 100%; height: 8px;
  background: var(--c-surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-primary), var(--c-secondary));
  border-radius: 999px;
  transition: width .4s ease;
}
.progress-bar--people .progress-bar__fill {
  background: linear-gradient(90deg, #2C3C4B, #4A6178);
}

.plan-features {
  margin-bottom: 14px;
  border: 1px solid var(--c-line);
  border-radius: 10px;
  padding: 0;
  background: var(--c-surface-2);
}
.plan-features summary {
  cursor: pointer; padding: 10px 14px;
  font-weight: 600; font-size: .92em;
  list-style: none;
}
.plan-features summary::-webkit-details-marker { display: none; }
.plan-features summary::after { content: "▾"; float: right; transition: transform .2s; }
.plan-features[open] summary::after { transform: rotate(180deg); }
.plan-features__list {
  margin: 0; padding: 0 14px 12px 30px;
  font-size: .92em; color: var(--c-text);
}
.plan-features__list li { margin: 4px 0; }

html[data-theme="dark"] .plan-features { background: rgba(255,255,255,.03); }


.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--c-muted);
}
.empty-state__icon { font-size: 2.4em; margin-bottom: 8px; }

.loader {
  width: 36px; height: 36px;
  border: 3px solid var(--c-surface-2);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================
   Section heading (mezi grupami karet)
=========================================================== */
.section-heading {
  margin: 8px 0 12px;
  font-size: 1.05em;
  color: var(--c-dark);
  font-weight: 600;
  letter-spacing: .2px;
}

/* ===========================================================
   Spotřeba & limity (Fáze C) — donut karty
=========================================================== */
.usage-card { display: flex; flex-direction: column; }
.donut-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 10px;
}
.donut {
  --p: 0;
  --size: 140px;
  --track: #EEF2F6;
  --fg: var(--c-donut, var(--c-primary));
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  position: relative;
  background:
    conic-gradient(var(--fg) calc(var(--p) * 1%), var(--track) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .4s ease;
}
.donut::before {
  content: "";
  position: absolute;
  inset: 14px;
  background: var(--c-surface);
  border-radius: 50%;
}
.donut__center {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.15;
}
.donut__num { font-size: 1.15em; font-weight: 700; color: var(--c-dark); }
.donut__lim { font-size: .78em; color: var(--c-muted); margin-top: 2px; }
.donut--warn { --fg: #E6A817; }
.donut--over { --fg: #C0392B; }
.usage-status {
  margin: 4px 0 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: .82em;
  text-align: center;
}
.usage-status--warn { background: #FFF6E0; color: #8A5A00; }
.usage-status--over { background: #FDECEA; color: #962B22; }
.small { font-size: .82em; }

/* ===========================================================
   Pozvi přátele (Fáze D)
=========================================================== */
.referral-hero {
  background: linear-gradient(135deg, #FFF7EE 0%, #FFE9D2 100%);
  border: 1px solid #F5D4A8;
}
.referral-hero__inner { text-align: center; padding: 8px 0; }
.referral-hero__label {
  text-transform: uppercase;
  font-size: .75em;
  letter-spacing: 1px;
  color: var(--c-muted);
  margin-bottom: 8px;
}
.referral-hero__code-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.referral-hero__code {
  font-size: 1.6em;
  font-weight: 800;
  letter-spacing: 2px;
  background: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  border: 2px dashed var(--c-primary);
  color: var(--c-dark);
  user-select: all;
}
.share-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.share-btn {
  flex: 1 1 160px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  color: #fff;
  border: 0;
  cursor: pointer;
  font-size: .95em;
  transition: filter .15s ease;
}
.share-btn:hover { filter: brightness(1.07); }
.share-btn--whatsapp { background: #25D366; }
.share-btn--facebook { background: #1877F2; }
.share-btn--email    { background: #2C3C4B; }
.share-btn--link     { background: var(--c-primary); }

/* ===========================================================
   Responsive — mobile/tablet shell + drawer
=========================================================== */

/* Tablet (≤ 900px) — drawer pattern začíná tady. */
@media (max-width: 900px) {
  .topbar { padding: 8px 12px; gap: 8px; min-height: 56px; }
  .topbar__menu { display: inline-flex; }
  .topbar__sep { display: none; }
  .topbar__user { display: none; }
  /* Odhlásit se udá na mobilu ze sidebar footeru, v topbaru už není. */
  .topbar__right { display: none; }

  /* Sjednocená velikost všech tří prvků v topbaru — stejná výška, vertikálně centrované. */
  .topbar__menu,
  .topbar__brand,
  .topbar__logo-firma-wrap {
    height: 40px;
    box-sizing: border-box;
    align-self: center;
  }
  .topbar__menu          { width: 40px; padding: 0; gap: 5px; }
  .topbar__brand         { width: 40px; padding: 4px; }
  .topbar__logo-firma-wrap { padding: 4px 8px; max-width: 56vw; }
  .topbar__logo-firma    { max-height: 30px; max-width: 100%; width: auto; height: auto; }
  .topbar__firma         { font-size: .95em; max-width: 50vw; }

  /* Mobile topbar layout: hamburger (left) | firma logo (center) | brand icon (right)
     — vše ve stejném gridovém řádku, deterministicky (žádné auto-placement). */
  .topbar__left {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 40px;
    grid-auto-rows: 0;
    grid-auto-flow: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    flex: 1;
    min-width: 0;
  }
  .topbar__menu          { grid-column: 1; grid-row: 1; justify-self: start; place-self: center start; }
  .topbar__logo-firma-wrap { grid-column: 2; grid-row: 1; justify-self: center; place-self: center; margin: 0; }
  .topbar__firma         { grid-column: 2; grid-row: 1; justify-self: center; place-self: center; text-align: center; }
  .topbar__brand         { grid-column: 3; grid-row: 1; justify-self: end; place-self: center end; }
  /* Na mobilu skryj textový název firmy úplně — logo (pokud je) má prioritu, jinak je zbytečné. */
  .topbar__firma         { display: none; }
  /* Když firma NEMÁ logo, ukaž alespoň název. */
  .topbar__left:not(:has(.topbar__logo-firma-wrap)) .topbar__firma { display: inline; }

  .shell { grid-template-columns: 1fr; min-height: calc(100vh - 56px); }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    max-width: 84vw;
    background: var(--c-surface);
    border-right: 1px solid var(--c-line);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
    box-shadow: 4px 0 16px rgba(0,0,0,.12);
    padding: 16px 12px 24px;
    /* Status bar safe-area horní */
    padding-top: max(16px, env(safe-area-inset-top));
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar__item { flex: initial; }
  .sidebar__label { display: inline; }

  /* Mobile drawer footer (email + logout) */
  .sidebar__mobile-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--c-line);
  }
  .sidebar__user-info {
    font-size: .82em;
    color: var(--c-muted);
    word-break: break-all;
    padding: 0 12px;
  }
  .sidebar__logout {
    margin: 0 8px;
  }

  .main { padding: 16px 14px; }
}

/* Telefon (≤ 540px) — kompaktnější topbar, vše stejně velké (36px). */
@media (max-width: 540px) {
  .topbar { padding: 7px 10px; min-height: 52px; }
  .topbar__left { grid-template-rows: 36px; }
  .topbar__menu,
  .topbar__brand,
  .topbar__logo-firma-wrap {
    height: 36px;
  }
  .topbar__menu          { width: 36px; }
  .topbar__brand         { width: 36px; padding: 3px; }
  .topbar__logo-firma-wrap { padding: 3px 7px; max-width: 54vw; }
  .topbar__logo-firma    { max-height: 26px; }
  .topbar__firma         { font-size: .9em; max-width: 50vw; }
  .topbar__right .btn-ghost { padding: 6px 10px; font-size: .85em; }
  .main { padding: 14px 12px; }
}

/* Velmi malý telefon (≤ 380px) — vše stejně velké (32px), logo zachovat uprostřed. */
@media (max-width: 380px) {
  .topbar { min-height: 48px; }
  .topbar__left { grid-template-rows: 32px; }
  .topbar__menu,
  .topbar__brand,
  .topbar__logo-firma-wrap {
    height: 32px;
  }
  .topbar__menu          { width: 32px; }
  .topbar__brand         { width: 32px; padding: 3px; }
  .topbar__logo-firma-wrap { padding: 2px 6px; max-width: 52vw; }
  .topbar__logo-firma    { max-height: 22px; }
}

/* ===========================================================
   Mobile-friendly: card header, page header, filter bar, modal
=========================================================== */
@media (max-width: 640px) {
  /* Card header s tlačítky — wrap na mobil */
  .card { padding: 14px 14px; }
  .card__header,
  .card__header[style] {
    flex-wrap: wrap !important;
    gap: 10px !important;
    align-items: flex-start !important;
  }
  .card__header > div[style*="display:flex"],
  .card__header > div[style*="display: flex"] {
    flex-wrap: wrap !important;
    width: 100%;
  }
  .card__header .btn { flex: 1 1 auto; min-width: 0; }

  /* Page header — pokud má sub-elementy s buttony, povol wrap */
  .page-header { flex-wrap: wrap; }
  .page-header h1 { font-size: 1.35em; }
  .page-header--hero { padding: 16px 16px; }
  .page-header--hero h1 { font-size: 1.45em; }

  /* Filter bar — buttons wrap */
  .filter-bar { flex-wrap: wrap; gap: 6px; }
  .filter-bar .btn { flex: 1 1 auto; }

  /* Modal — fullscreen na mobilu */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 96vh;
    border-radius: 16px 16px 0 0;
  }
  .modal__body { padding: 14px 16px; }

  /* Buttons — větší touch target */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }

  /* Forma — inputy plné šířky */
  .form-row input,
  .form-row select,
  .form-row textarea { width: 100%; box-sizing: border-box; }
}


/* ============================================================
   Zamestnanci ? tabulka, role badge, modal, toasts, alerts
   ============================================================ */
.table-wrap { overflow-x: visible; max-width: 100%; }
@media (max-width: 760px) {
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th,
.data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--c-border, #e5e7eb); font-size: .95em; }
.data-table th { background: #fafafa; color: var(--c-muted); font-weight: 600; font-size: .85em; letter-spacing: .03em; text-transform: uppercase; }
.data-table tbody tr:hover { background: #fcfaf7; }

.role-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: .8em; font-weight: 600; line-height: 1.4; }
.role-owner    { background: #FEF3C7; color: #92400E; }
.role-admin    { background: #FFE7D6; color: #9A3A0C; }
.role-employee { background: #E0F2FE; color: #075985; }
.role-viewer   { background: #F3F4F6; color: #4B5563; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 30, 45, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: 0 18px 48px rgba(0,0,0,.25);
  width: 100%; max-width: 560px; max-height: 92vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.modal__header { padding: 16px 20px; border-bottom: 1px solid var(--c-border, #e5e7eb); display: flex; align-items: center; justify-content: space-between; }
.modal__header h2 { margin: 0; font-size: 1.15em; }
.modal__close { background: transparent; border: 0; font-size: 1.8em; line-height: 1; cursor: pointer; color: var(--c-muted); }
.modal__close:hover { color: var(--c-ink); }
.modal__body { padding: 18px 20px; overflow-y: auto; overflow-x: visible; display: flex; flex-direction: column; gap: 14px; }
/* Info-tipy uvnitř modal__body se ukotvují do pravého horního rohu okolo ikonky;
   stačí jim povolit přesah přes okraj formulářového řádku. */
.modal__body .info-tip { position: relative; z-index: 10; }
.modal__body .info-tip::after { z-index: 10000; }
.modal__body label { display: flex; flex-direction: column; gap: 4px; font-size: .9em; font-weight: 500; }
.modal__body label.checkbox,
.modal__body label.radio { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.modal__body input[type="text"],
.modal__body input[type="email"],
.modal__body input[type="password"],
.modal__body select { width: 100%; padding: 8px 10px; border: 1px solid var(--c-border, #d1d5db); border-radius: 8px; font-size: 1em; font-family: inherit; }
.modal__body input:focus,
.modal__body select:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.modal__body fieldset { border: 1px solid var(--c-border, #e5e7eb); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.modal__body fieldset legend { padding: 0 6px; font-weight: 600; font-size: .9em; }
.modal__footer { padding: 12px 20px 16px; border-top: 1px solid var(--c-border, #e5e7eb); display: flex; justify-content: flex-end; gap: 8px; }

/* Grid 2 helper inside modal */
.modal .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .modal .grid-2 { grid-template-columns: 1fr; } }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 10px; font-size: .9em; line-height: 1.4; }
.alert-error  { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-info   { background: #E0F2FE; color: #075985; border: 1px solid #BAE6FD; }
.error-text   { color: #991B1B; }

/* Toast */
#appToastHost { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { background: #2C3C4B; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.18); font-size: .9em; animation: toastIn .25s ease; }
.toast--success { background: #166534; }
.toast--out { opacity: 0; transform: translateY(8px); transition: all .3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* btn-danger */
.btn-danger { background: #B91C1C; color: #fff; border: 0; }
.btn-danger:hover { background: #991B1B; }
.btn-danger:disabled { background: #FCA5A5; cursor: not-allowed; }

.form-error { margin-bottom: 8px; }
.small { font-size: .85em; }

/* ===========================================================
   Fáze E — Notifikace
   =========================================================== */
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif {
  background: #fff;
  border: 1px solid var(--c-border, #e5e7eb);
  border-left: 4px solid var(--c-muted, #888);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.notif--unread { box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.notif--read { opacity: .68; }
.notif--info    { border-left-color: #3b82f6; }
.notif--success { border-left-color: #16a34a; }
.notif--warning { border-left-color: #E6A817; }
.notif--danger  { border-left-color: #dc2626; }
.notif__head { display: flex; align-items: center; gap: 10px; }
.notif__icon { font-size: 1.2em; }
.notif__title { font-weight: 600; flex: 1; }
.notif__date { font-size: .82em; color: var(--c-muted); }
.notif__body { font-size: .95em; color: var(--c-dark); white-space: pre-wrap; }
.notif__actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ===========================================================
   Fáze E — Tickety
   =========================================================== */
.ticket-toolbar { margin-bottom: 14px; display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

/* Two-column shell — list left, chat right */
.tickety-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  align-items: start;
}
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 4px;
}
.ticket-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--c-surface);
  border: 1px solid var(--c-border, #e5e7eb);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease, background .15s ease;
}
.ticket-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
  border-color: color-mix(in srgb, var(--c-primary, #D35400) 35%, var(--c-border, #e5e7eb));
}
/* Status barevný proužek vlevo (před .is-active aby ho mohl přepsat). */
.ticket-item.is-open   { border-left: 3px solid #16a34a; }
.ticket-item.is-closed { border-left: 3px solid #9ca3af; opacity: .82; }
/* Aktivní (vybraný) ticket — vyhrává nad status barvami, plné obarvení. */
.ticket-item.is-active,
.ticket-item.is-active.is-open,
.ticket-item.is-active.is-closed {
  background: color-mix(in srgb, var(--c-primary, #D35400) 8%, var(--c-surface));
  border-color: var(--c-primary, #D35400);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--c-primary, #D35400) 22%, transparent);
  opacity: 1;
}
.ticket-item__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ticket-item__stav { font-size: .85em; color: var(--c-muted); }
.ticket-item__meta { font-size: .82em; color: var(--c-muted); display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
/* Červená tečka „nová odpověď" — dot 10px (font-size:0 schová znak). */
.ticket-item__unread {
  display: inline-block;
  width: 10px; height: 10px;
  background: #dc2626;
  border-radius: 999px;
  font-size: 0;
  vertical-align: middle;
  margin-left: auto;
  box-shadow: 0 0 0 2px var(--c-surface);
}

.ticket-pane { min-height: 240px; }
.ticket-pane__empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--c-muted);
  border: 2px dashed var(--c-border, #e5e7eb);
  border-radius: 12px;
}

.ticket-detail-card { display:flex; flex-direction:column; height: auto; }
.ticket-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: .9em;
  color: var(--c-muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--c-border, #e5e7eb);
}
.ticket-meta__actions { margin-left:auto; display:flex; gap:8px; }
.ticket-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  max-height: 52vh;
  min-height: 220px;
  overflow-y: auto;
  padding: 8px 6px;
  scroll-behavior: smooth;
  background: rgba(0,0,0,.02);
  border-radius: 10px;
  border: 1px solid var(--c-border, #e5e7eb);
}
.ticket-msg {
  border-radius: 12px;
  padding: 10px 14px;
  max-width: 85%;
}
.ticket-msg.is-owner { background: #fff4ea; border: 1px solid #f3d3b4; align-self: flex-end; }
.ticket-msg.is-admin { background: #f3f6fb; border: 1px solid #d6dde7; align-self: flex-start; }
.ticket-msg__head { display: flex; justify-content: space-between; gap: 12px; font-size: .82em; margin-bottom: 4px; }
.ticket-msg__body { white-space: pre-wrap; word-break: break-word; }
.ticket-reply textarea {
  width: 100%;
  border: 1px solid var(--c-border, #e5e7eb);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: .95em;
  resize: vertical;
}

/* Mobil: stack, list nahoře, detail dole; klik na ticket schová list. */
@media (max-width: 900px) {
  .tickety-shell { grid-template-columns: 1fr; }
  .ticket-list { max-height: none; padding-right: 0; }
  .ticket-list.is-hidden-mobile { display: none; }
  .ticket-thread { max-height: 60vh; }

  /* Fáze Q — mobile detail polish: title centered top, back compact, delete inline. */
  .ticket-detail-card > .card__header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
  }
  .ticket-detail-card > .card__header #btnBackTickets {
    grid-column: 1;
    padding: 5px 9px;
    font-size: .82em;
    line-height: 1;
    min-width: 0;
  }
  .ticket-detail-card > .card__header .card__title {
    grid-column: 2;
    text-align: center;
    font-size: 1.02em;
    margin: 0;
    line-height: 1.25;
    word-break: break-word;
  }
  .ticket-detail-card .ticket-meta {
    gap: 8px 12px;
    align-items: center;
    font-size: .85em;
    margin-bottom: 10px;
  }
  .ticket-detail-card .ticket-meta__actions { margin-left: auto; }
  .ticket-detail-card .ticket-meta__actions .btn-sm {
    padding: 4px 9px;
    font-size: .82em;
  }
}
@media (min-width: 901px) {
  /* Na desktopu nikdy neskryj list. */
  .ticket-list.is-hidden-mobile { display: flex; }
  /* "Zpět" tlačítko ukaž jen na mobilu. */
  .ticket-pane #btnBackTickets { display: none !important; }
}

/* ===========================================================
   Fáze Q — Mobile: data-table overflow uvnitř karty
   (předplatné → Tvé faktury, audit list) — stránka se nesmí
   posouvat doprava, scrollovat může jen tabulka sama.
=========================================================== */
@media (max-width: 900px) {
  .audit-list .card,
  #fakturyList {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .audit-list .data-table,
  #fakturyList .data-table {
    min-width: 560px; /* zachová čitelnost sloupců, scrolluje se uvnitř karty */
  }
  /* Safety net: hlavní oblast nikdy nepřeteče horizontálně. */
  .main { overflow-x: hidden; }
}

/* ===========================================================
   Fáze E — Audit
   =========================================================== */
.audit-list .data-table td { vertical-align: top; }
.audit-list .data-table td code {
  background: rgba(0,0,0,.04);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .85em;
}

/* ===========================================================
   Fáze G — Nastavení (toggle-row + data-theme)
   =========================================================== */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--c-border, #e5e7eb);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.toggle-row input[type=checkbox] { width: 18px; height: 18px; }
.toggle-row:hover { background: #fafafa; }

input[type=color] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--c-border, #e5e7eb);
  border-radius: 8px;
  padding: 4px;
  cursor: pointer;
}

/* Dark theme (data-theme="dark" na <html>) ------------------ */
html[data-theme="dark"] {
  --c-bg: #1a1f26;
  --c-surface: #232a33;
  --c-border: #364151;
  --c-dark: #f3f4f6;
  --c-muted: #9ca3af;
  --c-text: #f3f4f6;
  --c-line: #364151;
  --c-surface-2: #2a323d;
}
html[data-theme="dark"] body { background: var(--c-bg); color: var(--c-dark); }
html[data-theme="dark"] .card,
html[data-theme="dark"] .notif,
html[data-theme="dark"] .toggle-row { background: var(--c-surface); border-color: var(--c-border); color: var(--c-dark); }
html[data-theme="dark"] .data-table th { background: #2a323d; color: var(--c-muted); }
html[data-theme="dark"] .data-table tbody tr:hover { background: #2a323d; }
html[data-theme="dark"] .ticket-msg.is-owner { background: #3a2a1d; border-color: #6b4a2a; }
html[data-theme="dark"] .ticket-msg.is-admin { background: #2a3340; border-color: #3e4a59; }
html[data-theme="dark"] .modal { background: var(--c-surface); color: var(--c-dark); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #1a1f26; color: var(--c-dark); border-color: var(--c-border);
}


/* ===========================================================
   F?ze H ? design polish (badge faktur, mini-donut, info-tip,
   theme-pills, module cards s img, dark mode fix, copy-icon)
=========================================================== */

/* Status badges (v tabulk?ch / row-icons) */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .78em; font-weight: 600; line-height: 1.4;
  background: #F3F4F6; color: #374151;
}
.badge--success { background: #DCFCE7; color: #166534; }
.badge--warning { background: #FEF3C7; color: #92400E; }
.badge--danger  { background: #FEE2E2; color: #991B1B; }
.badge--info    { background: #DBEAFE; color: #1E40AF; }

/* Mini donut (4-grid) */
.grid-4 {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.mini-donut-grid { padding: 6px 0; }
.mini-donut-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center;
}
.mini-donut-card__title { font-size: .82em; color: var(--c-muted); font-weight: 600; }
.donut--mini { width: 96px; height: 96px; }
.donut--mini .donut__num { font-size: 1.05em; }
.donut--mini .donut__lim { font-size: .7em; }

/* Info tooltip (i ikonka v rohu karty) */
.info-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border-radius: 999px;
  background: var(--c-surface-2, #f3f4f6);
  color: var(--c-muted);
  font-size: .78em; font-weight: 700; font-style: italic;
  cursor: help;
  border: 1px solid var(--c-line);
  position: relative;
  user-select: none;
}
.info-tip:hover { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: #1f2937; color: #fff;
  font-size: 0.98em; font-weight: 400; font-style: normal;
  padding: 12px 14px; border-radius: 10px;
  width: max-content; max-width: 340px;
  box-shadow: 0 8px 22px rgba(0,0,0,.22);
  opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .15s, transform .15s;
  z-index: 9999;
  white-space: normal; text-align: left; line-height: 1.5;
}
.info-tip:hover::after,
.info-tip:focus::after { opacity: 1; transform: translateY(0); }

/* Skrýt info-tipy globálně (preference firmy) */
body.no-info-tips .info-tip { display: none !important; }

/* Modal close pozice ? pro varianty bez header flex-justify */
.modal__close { position: relative; padding: 0 6px; }

/* Theme switcher ? pills */
.theme-pills {
  display: inline-flex;
  background: var(--c-surface-2, #f3f4f6);
  border: 1px solid var(--c-line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.theme-pills__btn {
  background: transparent; border: 0;
  padding: 6px 14px; border-radius: 999px;
  font: inherit; font-weight: 500; cursor: pointer;
  color: var(--c-text);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
.theme-pills__btn:hover { background: rgba(0,0,0,.04); }
.theme-pills__btn.is-active {
  background: var(--c-primary); color: #fff;
  box-shadow: 0 1px 3px rgba(211,84,0,.3);
}

/* Module card (Aplikace v Nastaven?) s img ikonkou */
.module-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 14px 16px;
}

/* Custom toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 48px; height: 26px; flex: 0 0 48px; }
.toggle-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.toggle-switch__track {
  position: absolute; inset: 0;
  background: #cbd5e1; border-radius: 999px;
  transition: background .18s;
}
.toggle-switch__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  transition: left .18s;
}
.toggle-switch input:checked ~ .toggle-switch__track { background: var(--c-primary); }
.toggle-switch input:checked ~ .toggle-switch__track .toggle-switch__thumb { left: 25px; }
.toggle-switch input:focus-visible ~ .toggle-switch__track { box-shadow: 0 0 0 3px rgba(211,84,0,.28); }
html[data-theme="dark"] .toggle-switch__track { background: #475569; }
.module-card__icon {
  width: 48px; height: 48px;
  object-fit: contain;
  flex: 0 0 48px;
}
.module-card__title { font-weight: 600; margin: 0 0 2px; color: var(--c-dark); }
.module-card__sub { color: var(--c-muted); font-size: .85em; margin: 0; }

/* Copy icon button (referral k?d) */
.copy-row {
  display: flex; align-items: stretch; gap: 0;
  background: var(--c-surface-2, #f8fafc);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  overflow: hidden;
  max-width: 520px;
  margin: 0 auto;
}
.copy-row__code {
  flex: 1;
  padding: 16px 20px;
  font: 700 1.7em/1 'Menlo', 'Consolas', 'Courier New', monospace;
  letter-spacing: .12em;
  color: var(--c-dark);
  background: transparent;
  text-align: center;
}
.copy-row__btn {
  background: var(--c-primary); color: #fff;
  border: 0;
  padding: 0 18px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600;
  font-size: .95em;
  transition: background .15s;
}
.copy-row__btn:hover { background: var(--c-primary-dark, #b94900); }
.copy-row__btn.is-copied { background: #16a34a; }

/* Notifikace card (klikateln?) */
.notif-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-left: 4px solid var(--c-muted);
  border-radius: var(--r-md);
  padding: 14px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.notif-card:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.notif-card.notif--info    { border-left-color: #3B82F6; }
.notif-card.notif--success { border-left-color: #16A34A; }
.notif-card.notif--warning { border-left-color: #F59E0B; }
.notif-card.notif--danger  { border-left-color: #DC2626; }
.notif-card.notif--unread { background: rgba(211,84,0,.04); }
.notif-card .notif__head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.notif-card .notif__title { font-size: 1em; }
.notif-card .notif__date { margin-left: auto; color: var(--c-muted); font-size: .82em; }
.notif-card .notif__body {
  color: var(--c-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .92em;
  line-height: 1.45;
}
.modal--notif .notif-detail__body {
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: .98em;
}

/* Dark mode ? fix topbar / sidebar / muted */
html[data-theme="dark"] .topbar {
  background: #0f1419;
  border-bottom-color: var(--c-primary);
}
html[data-theme="dark"] .topbar__user { color: rgba(255,255,255,.78); }
html[data-theme="dark"] .topbar__firma { color: #fff; }
html[data-theme="dark"] .sidebar {
  background: var(--c-surface);
  border-right-color: var(--c-border);
}
html[data-theme="dark"] .sidebar__item { color: #e5e7eb; }
html[data-theme="dark"] .sidebar__item:hover,
html[data-theme="dark"] .sidebar__group-head:hover { background: rgba(255,255,255,.05); }
html[data-theme="dark"] .sidebar__group-head { color: #e5e7eb; }
html[data-theme="dark"] .sidebar__item.is-active {
  background: rgba(211,84,0,.18); color: #ffb380;
}
html[data-theme="dark"] .sidebar__badge { box-shadow: 0 0 0 2px var(--c-surface); }
html[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .card__title,
html[data-theme="dark"] .module-card__title { color: var(--c-dark); }
html[data-theme="dark"] .mini-donut-card { background: var(--c-surface); border-color: var(--c-border); }
html[data-theme="dark"] .info-tip { background: #2a323d; border-color: var(--c-border); color: var(--c-muted); }
html[data-theme="dark"] .info-tip:hover { background: var(--c-primary); color: #fff; }
html[data-theme="dark"] .theme-pills { background: #2a323d; border-color: var(--c-border); }
html[data-theme="dark"] .theme-pills__btn { color: #e5e7eb; }
html[data-theme="dark"] .theme-pills__btn:hover { background: rgba(255,255,255,.05); }
html[data-theme="dark"] .badge { background: #2a323d; color: #d1d5db; }
html[data-theme="dark"] .module-card { background: var(--c-surface); border-color: var(--c-border); }
html[data-theme="dark"] .copy-row { background: #2a323d; border-color: var(--c-border); }
html[data-theme="dark"] .copy-row__code { color: #fff; }
html[data-theme="dark"] .notif-card { background: var(--c-surface); border-color: var(--c-border); }
html[data-theme="dark"] .notif-card.notif--unread { background: rgba(211,84,0,.08); }

/* =====================================================================
 *  Copilot (Asistent) — Fáze R
 * ===================================================================== */
.copilot-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.copilot-list {
  flex: 1 1 auto;
  min-height: 320px;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: color-mix(in srgb, var(--c-surface) 92%, var(--c-primary) 4%);
}
.copilot-empty {
  margin: auto;
  text-align: center;
  max-width: 520px;
  padding: 24px 12px;
}
.copilot-empty__icon { font-size: 48px; margin-bottom: 10px; }
.copilot-empty__title { font-size: 1.25em; font-weight: 600; margin-bottom: 6px; }
.copilot-empty__sub { font-size: .95em; line-height: 1.5; margin-bottom: 14px; }
.copilot-empty__hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.copilot-empty__hints .chip {
  cursor: pointer;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .85em;
  transition: all .15s ease;
}
.copilot-empty__hints .chip:hover {
  border-color: var(--c-primary);
  background: color-mix(in srgb, var(--c-primary) 8%, var(--c-surface));
}

.copilot-msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.copilot-msg--user { align-self: flex-end; align-items: flex-end; }
.copilot-msg--ai   { align-self: flex-start; align-items: flex-start; }
.copilot-msg__bubble {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: .96em;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.copilot-msg--user .copilot-msg__bubble {
  background: var(--c-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.copilot-msg--ai .copilot-msg__bubble {
  background: var(--c-surface);
  color: var(--c-ink);
  border: 1px solid var(--c-line);
  border-bottom-left-radius: 4px;
}
.copilot-msg__time {
  font-size: .72em;
  color: color-mix(in srgb, var(--c-ink) 50%, transparent);
  margin-top: 3px;
  padding: 0 4px;
}
.copilot-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
.copilot-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: color-mix(in srgb, var(--c-ink) 40%, transparent);
  display: inline-block;
  animation: copilotTyping 1.2s infinite ease-in-out;
}
.copilot-typing i:nth-child(2) { animation-delay: .15s; }
.copilot-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes copilotTyping {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.copilot-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--c-line);
  background: var(--c-surface);
}
.copilot-input {
  flex: 1 1 auto;
  resize: none;
  min-height: 40px;
  max-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--c-line);
  border-radius: 10px;
  font: inherit;
  background: var(--c-bg);
  color: var(--c-ink);
  line-height: 1.4;
}
.copilot-input:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 1px;
}
.copilot-send { min-height: 40px; padding: 8px 16px; }
.copilot-disclaimer {
  padding: 8px 14px 12px;
  font-size: .82em;
  border-top: 1px solid color-mix(in srgb, var(--c-line) 60%, transparent);
}

/* Dark mode */
html[data-theme="dark"] .copilot-list {
  background: color-mix(in srgb, var(--c-surface) 86%, var(--c-primary) 6%);
}

/* Mobile polish (≤640px) */
@media (max-width: 640px) {
  .copilot-list {
    max-height: calc(100vh - 280px);
    padding: 14px 12px;
  }
  .copilot-msg { max-width: 92%; }
  .copilot-form { padding: 10px 10px; }
  .copilot-empty__hints .chip { font-size: .8em; padding: 5px 10px; }
}
.ticket-chat-attach {
  margin-top: 8px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--c-primary) 6%, var(--c-surface));
  border: 1px dashed color-mix(in srgb, var(--c-primary) 40%, var(--c-line));
  border-radius: 10px;
}
.ticket-chat-attach__head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: .92em;
}
.ticket-chat-attach__head input[type=checkbox] {
  margin-top: 3px;
  flex: 0 0 auto;
}
.ticket-chat-attach__preview {
  margin-top: 8px;
}
.ticket-chat-attach__preview summary {
  cursor: pointer;
  font-size: .85em;
}
.ticket-chat-attach__preview pre {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  font-size: .8em;
  white-space: pre-wrap;
  word-wrap: break-word;
}
/* === Copilot v2 — spinner, typewriter, markdown, scrollbar hide === */
.copilot-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, #ff8a00 25%, transparent);
  border-top-color: #ff8a00;
  display: inline-block;
  animation: copilot-spin 0.8s linear infinite;
}
@keyframes copilot-spin { to { transform: rotate(360deg); } }
.copilot-msg__bubble--spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px !important;
}

.copilot-cursor {
  display: inline-block;
  width: .5ch;
  color: #ff8a00;
  font-weight: 600;
  margin-left: 1px;
  animation: copilot-cursor-blink 1s steps(2, start) infinite;
}
@keyframes copilot-cursor-blink { 50% { opacity: 0; } }

/* Markdown polish uvnitř AI bubliny */
.copilot-msg--ai .copilot-msg__bubble p { margin: 0; }
.copilot-msg--ai .copilot-msg__bubble p + p,
.copilot-msg--ai .copilot-msg__bubble p + ul,
.copilot-msg--ai .copilot-msg__bubble p + ol,
.copilot-msg--ai .copilot-msg__bubble ul + p,
.copilot-msg--ai .copilot-msg__bubble ol + p { margin-top: 8px; }
.copilot-msg--ai .copilot-ul,
.copilot-msg--ai .copilot-ol {
  margin: 4px 0 0 0;
  padding-left: 20px;
}
.copilot-msg--ai .copilot-ul li,
.copilot-msg--ai .copilot-ol li {
  margin: 2px 0;
}
.copilot-msg--ai .copilot-msg__bubble h3,
.copilot-msg--ai .copilot-msg__bubble h4 {
  margin: 6px 0 4px;
  font-size: 1em;
  font-weight: 700;
}
.copilot-msg--ai .copilot-msg__bubble code {
  background: color-mix(in srgb, var(--c-primary) 8%, transparent);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .88em;
}
.copilot-msg--ai .copilot-msg__bubble pre.copilot-code {
  margin: 6px 0;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--c-primary) 8%, transparent);
  border-radius: 6px;
  overflow-x: auto;
  font-size: .85em;
}
.copilot-msg--ai .copilot-msg__bubble a {
  color: var(--c-primary);
  text-decoration: underline;
}
.copilot-msg--ai .copilot-msg__bubble strong { font-weight: 700; }
.copilot-msg--ai .copilot-msg__bubble em { font-style: italic; }

/* Hide scrollbar in textarea — uživatel chce čistý vzhled */
.copilot-input {
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE / Edge legacy */
}
.copilot-input::-webkit-scrollbar { width: 0; height: 0; display: none; }