@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Worki brand */
  --night-blue: #2E303E;
  --night-blue-2: #24262F;
  --pigeon-grey: #BAC6D3;
  --light-gray: #EDEFF8;
  --bright-purple: #544DE0;
  --bright-purple-hover: #3F39C2;
  --bright-purple-light: #EEF0FE;
  --sunny-cream: #F6EFB1;

  /* Surfaces */
  --bg: #F7F8FC;
  --card: #FFFFFF;
  --border: #E2E4EC;
  --divider: #EEF0F4;

  /* Text */
  --text: #1A1C23;
  --text-mid: #4B5060;
  --text-light: #8B8F9E;

  /* Sidebar */
  --sidebar-bg: #2E303E;
  --sidebar-bg-2: #24262F;
  --sidebar-text: #BAC6D3;
  --sidebar-text-hover: #FFFFFF;
  --sidebar-active-bg: rgba(84,77,224,0.22);
  --sidebar-active-text: #FFFFFF;
  --sidebar-label: rgba(255,255,255,0.35);
  --sidebar-border: rgba(255,255,255,0.06);

  /* Semantic */
  --success: #10B981;
  --success-light: #ECFDF5;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --info: #3B82F6;
  --info-light: #DBEAFE;

  /* Fonts */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Aliasy pro zděděné komponenty */
  --primary: var(--bright-purple);
  --primary-light: var(--bright-purple-light);
  --primary-050: var(--bright-purple-light);
  --primary-300: #A5A1F0;
  --primary-500: var(--bright-purple);
  --primary-600: var(--bright-purple-hover);
  --card-border: var(--border);
  --radius-sm: 8px;
  --radius-full: 999px;
  --text-muted: var(--text-light);

  /* Layout */
  --sidebar-width: 232px;
  --sidebar-width-collapsed: 60px;
  --top-bar-height: 52px;
  --radius: 10px;
  --radius-lg: 14px;
}

/* Dark mode — via cookie (data-theme), class, or system preference */
body.dark-mode,
[data-theme="dark"] body,
html[data-theme="dark"] {
  --bg: #13141B;
  --card: #1C1E27;
  --border: #2A2D3A;
  --divider: #24262F;
  --text: #F1F3F8;
  --text-mid: #BAC0CC;
  --text-light: #7B8091;
  --bright-purple-light: rgba(84,77,224,0.15);
  --success-light: rgba(16,185,129,0.12);
  --danger-light: rgba(239,68,68,0.12);
  --warning-light: rgba(245,158,11,0.12);
  --info-light: rgba(59,130,246,0.12);
  --primary-light: rgba(84,77,224,0.15);
  --primary-050: rgba(84,77,224,0.10);
  /* design-tokens overrides */
  --surface-bg: #1C1E27;
  --color-bg: #13141B;
  --color-text: #F1F3F8;
  --color-text-muted: #7B8091;
  --color-border: #2A2D3A;
  color-scheme: dark;
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .ws-container .card,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .source-tab,
html[data-theme="dark"] .source-panel,
html[data-theme="dark"] .wizard-step-num,
html[data-theme="dark"] .file-preview,
html[data-theme="dark"] .dz,
html[data-theme="dark"] .profile-card,
html[data-theme="dark"] .tb-add-menu,
html[data-theme="dark"] .tb-notif-panel,
html[data-theme="dark"] .ef {
  background: var(--card) !important;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .page-content,
html[data-theme="dark"] .embed-content { background: var(--bg); }
html[data-theme="dark"] .tb-token-badge { background: rgba(245,158,11,0.15); color: #FCD34D; }

/* System preference fallback (data-theme="system" or no cookie) */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #13141B;
    --card: #1C1E27;
    --border: #2A2D3A;
    --divider: #24262F;
    --text: #F1F3F8;
    --text-mid: #BAC0CC;
    --text-light: #7B8091;
    --bright-purple-light: rgba(84,77,224,0.15);
    --success-light: rgba(16,185,129,0.12);
    --danger-light: rgba(239,68,68,0.12);
    --warning-light: rgba(245,158,11,0.12);
    --info-light: rgba(59,130,246,0.12);
    --primary-light: rgba(84,77,224,0.15);
    --primary-050: rgba(84,77,224,0.10);
    color-scheme: dark;
  }
  html:not([data-theme="light"]) body {
    background: var(--bg);
    color: var(--text);
  }
  html:not([data-theme="light"]) .card,
  html:not([data-theme="light"]) .topbar,
  html:not([data-theme="light"]) .ws-container .card,
  html:not([data-theme="light"]) input,
  html:not([data-theme="light"]) select,
  html:not([data-theme="light"]) textarea,
  html:not([data-theme="light"]) .source-tab,
  html:not([data-theme="light"]) .source-panel,
  html:not([data-theme="light"]) .wizard-step-num,
  html:not([data-theme="light"]) .file-preview,
  html:not([data-theme="light"]) .dz,
  html:not([data-theme="light"]) .profile-card,
  html:not([data-theme="light"]) .tb-add-menu,
  html:not([data-theme="light"]) .tb-notif-panel,
  html:not([data-theme="light"]) .ef {
    background: var(--card) !important;
    color: var(--text);
    border-color: var(--border);
  }
  html:not([data-theme="light"]) .page-content,
  html:not([data-theme="light"]) .embed-content { background: var(--bg); }
  html:not([data-theme="light"]) .tb-token-badge { background: rgba(245,158,11,0.15); color: #FCD34D; }
}

html { height: 100%; overscroll-behavior: none; }
body { height: 100%; }
/* PWA standalone: safe-area na .app-layout aby topbar nezasahoval pod notch */
@supports (padding-top: env(safe-area-inset-top)) {
  .app-layout { padding-top: env(safe-area-inset-top); }
  .mercanto-sidebar, aside.mercanto-sidebar { padding-top: env(safe-area-inset-top); }
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

a { color: var(--bright-purple); text-decoration: none; }
a:hover { color: var(--bright-purple-hover); }

/* ── Layout ── */
/* Legacy layout — replaced by @mercantoeurope/design-tokens app-layout */
.page-wrapper, .page-content { padding: 24px 28px 48px; width: 100%; }

/* Embed mode — skryj page-header uvnitř iframe (hub page už má vlastní nadpis) */
.embed-content .page-header { display: none; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: width .18s;
  border-right: 1px solid var(--sidebar-border);
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }

.sidebar-header {
  height: var(--top-bar-height);
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; font-family: var(--font-heading); font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.sidebar-logo img { height: 22px; width: auto; }
.sidebar-toggle {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--sidebar-text); cursor: pointer; border-radius: 6px;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.06); color: #fff; }
body.sidebar-collapsed .sidebar-logo span,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .nav-text { display: none; }

.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 6px 16px; scrollbar-width: none; }
.sidebar-scroll::-webkit-scrollbar { display: none; }

.sidebar-section { margin-bottom: 14px; }
.sidebar-label {
  font-family: var(--font-heading);
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--sidebar-label);
  padding: 10px 10px 4px;
  white-space: nowrap; overflow: hidden;
}
.sidebar-nav { list-style: none; }
.sidebar-nav .nav-link {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px;
  color: var(--sidebar-text);
  font-size: 14px; font-weight: 500;
  border-radius: 6px;
  border-left: 2px solid transparent;
  margin-bottom: 1px;
  transition: all .12s;
  white-space: nowrap; overflow: hidden;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.05); color: var(--sidebar-text-hover); }
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--bright-purple);
}
.sidebar-sublabel {
  font-family: var(--font-heading);
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  color: rgba(255,255,255,0.45);
  padding: 6px 10px 3px 14px;
  white-space: nowrap; overflow: hidden;
}
body.sidebar-collapsed .sidebar-sublabel { display: none; }
.nav-icon { width: 18px; height: 18px; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; opacity: 0.85; }
.sidebar-nav .nav-link.active .nav-icon { opacity: 1; }
.nav-text { flex: 1; }
.nav-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 10px;
  background: var(--bright-purple); color: #fff; font-weight: 700;
}

/* Sidebar footer — user card */
.sidebar-user {
  border-top: 1px solid var(--sidebar-border);
  padding: 12px;
  display: flex; align-items: center; gap: 10px;
  color: var(--sidebar-text);
}
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bright-purple), #8B5CF6);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--sidebar-text); }
body.sidebar-collapsed .sidebar-user-info { display: none; }
.sidebar-clerk-btn { width: 100%; }
.sidebar-clerk-trigger { width: 100%; justify-content: flex-start; }
.sidebar-user-login { display: flex; align-items: center; gap: 8px; color: var(--sidebar-text); font-size: 13px; font-weight: 600; text-decoration: none; padding: 6px 0; transition: color .12s; }
.sidebar-user-login:hover { color: #fff; }

/* ── Top bar ── */
.top-bar {
  position: fixed; top: 0; left: var(--sidebar-width); right: 0;
  height: var(--top-bar-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  z-index: 50; gap: 14px;
  transition: left .18s;
}
body.sidebar-collapsed .top-bar { left: var(--sidebar-width-collapsed); }
.top-bar-title { font-family: var(--font-heading); font-size: 14px; font-weight: 700; color: var(--text); }
.top-bar-crumb { font-size: 13px; color: var(--text-light); }
.top-bar-crumb a { color: var(--text-light); }
.top-bar-spacer { flex: 1; }
.top-bar-actions { display: flex; align-items: center; gap: 8px; }
.top-bar-search {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--text-light);
  min-width: 240px;
}
.top-bar-search input { flex: 1; background: transparent; border: none; outline: none; font: inherit; color: var(--text); }
.icon-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  color: var(--text-mid); cursor: pointer; transition: all .12s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ── Page header ── */
.page-header { margin-bottom: 20px; display: flex; align-items: flex-start; gap: 14px; }
.page-header-main { flex: 1; min-width: 0; }
.page-header h1 { margin-bottom: 4px; }
.page-header .page-desc { color: var(--text-light); font-size: 14px; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--divider); }
.card-header h2, .card-header h3 { margin: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .12s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--bright-purple); color: #fff; border-color: var(--bright-purple); }
.btn-primary:hover { background: var(--bright-purple-hover); border-color: var(--bright-purple-hover); color: #fff; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--bright-purple); color: var(--bright-purple); }
.btn-ghost { background: transparent; color: var(--text-mid); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; min-height: 28px; }

/* ── Forms ── */
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text);
  background: var(--card); font-family: inherit;
  transition: border-color .12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--bright-purple); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group { margin-bottom: 16px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-purple { background: var(--bright-purple-light); color: var(--bright-purple); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-neutral { background: var(--bg); color: var(--text-mid); }
.badge-cream { background: var(--sunny-cream); color: var(--text); }

/* ── Tile grids (hub pages) ── */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
  position: relative;
}
.tile:hover {
  border-color: var(--bright-purple);
  box-shadow: 0 6px 20px rgba(84,77,224,0.1);
  transform: translateY(-1px);
}
.tile.disabled { opacity: 0.55; pointer-events: none; }
.tile-top { display: flex; align-items: center; justify-content: space-between; }
.tile-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--bright-purple-light); color: var(--bright-purple);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tile h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.tile p { font-size: 13px; color: var(--text-light); line-height: 1.5; margin: 0; }
.tile-arrow { position: absolute; right: 18px; bottom: 18px; color: var(--border); transition: all .15s; }
.tile:hover .tile-arrow { color: var(--bright-purple); right: 14px; }

/* ── Section headers (inside pages) ── */
.section { margin-bottom: 28px; }
.section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.section-stripe { width: 4px; height: 22px; border-radius: 3px; background: var(--bright-purple); }
.section-title { font-family: var(--font-heading); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mid); }
.section-count { font-size: 11px; font-weight: 600; color: var(--text-light); background: var(--bg); padding: 2px 8px; border-radius: 10px; margin-left: auto; }

/* ── Tables ── */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--card); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th { text-align: left; padding: 10px 14px; background: var(--bg); font-family: var(--font-heading); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-mid); border-bottom: 1px solid var(--border); }
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--divider); color: var(--text); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--bg); }

/* ── Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-light); margin-bottom: 6px; }
.stat-value { font-family: var(--font-heading); font-size: 24px; font-weight: 800; color: var(--text); }
.stat-delta { font-size: 12px; margin-top: 4px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── Mobile ── */
.mobile-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main-content, body.sidebar-collapsed .main-content { margin-left: 0; }
  .top-bar, body.sidebar-collapsed .top-bar { left: 0; }
  .mobile-toggle { display: flex; }
  .top-bar-search { display: none; }
  .page-wrapper { padding: 16px; }
}

@media (max-width: 640px) {
  .page-wrapper, .page-content { padding: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header h1 { font-size: 20px; }
  .stats-grid, .bb-stats { gap: 10px; }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 22px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 640px; }
  .btn { padding: 8px 14px; font-size: 13px; min-height: 44px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; min-height: 36px; }
  .card { padding: 14px; }
  .bb-grid { grid-template-columns: 1fr !important; gap: 8px !important; }
  .drawer { width: 100vw !important; }
  .ws-steps { flex-wrap: wrap; }
  .ws-steps .ws-step { flex: 1 1 100px; font-size: 12px; }
  .bulk-dept-panel [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .bulk-results-tabs { flex-wrap: wrap; }
  .brt { font-size: 12px; padding: 6px 10px; }
  /* Topbar search hide on small screens */
  .topbar-search { display: none; }
}

/* ── Topbar components ── */
.topbar { gap: 10px; position: sticky; top: 0; z-index: 50; }
.topbar-spacer { flex: 1; }

.tb-add-wrap { position: relative; }
.tb-add-btn { padding: 0 18px; height: 28px; background: var(--sidebar-accent, #544DE0); color: #fff; border: none; border-radius: 6px; font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 28px; }
.tb-add-btn:hover { filter: brightness(1.08); }
.tb-add-menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; background: var(--card, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 220px; z-index: 200; overflow: hidden; }
.tb-add-menu.open { display: block; }
.tb-add-menu a { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--text, #1f2937); text-decoration: none; transition: background .1s; }
.tb-add-menu a:hover { background: var(--bg, #f9fafb); }

.tb-token-badge { display: flex; align-items: center; gap: 6px; padding: 5px 12px; height: 32px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #FEF3C7; color: #92400E; text-decoration: none; white-space: nowrap; transition: opacity .15s; }
.tb-token-badge:hover { opacity: .85; color: #78350F; }

.tb-icon-btn { position: relative; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: none; border-radius: 8px; background: transparent; color: var(--text-mid, #6b7280); cursor: pointer; transition: all .12s; text-decoration: none; flex-shrink: 0; }
.tb-icon-btn:hover { background: var(--bg, #f3f4f6); color: var(--sidebar-accent, #544DE0); }
.tb-icon-btn svg { width: 20px; height: 20px; }
.tb-notif-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: #EF4444; border: 2px solid var(--card, #fff); }

.tb-notif-panel { display: none; position: fixed; top: 52px; right: 16px; width: min(360px, calc(100vw - 32px)); background: var(--card, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.15); z-index: 300; overflow: hidden; }
.tb-notif-panel.open { display: block; }
.tb-notif-header { padding: 14px 16px; font-family: var(--font-heading); font-size: 14px; font-weight: 700; border-bottom: 1px solid var(--border, #e5e7eb); }
.tb-notif-body { max-height: 360px; overflow-y: auto; }

.topbar-search { position: relative; display: flex; align-items: center; }
.topbar-search svg { position: absolute; left: 10px; color: var(--color-text-muted, #9ca3af); pointer-events: none; }
.topbar-search input { padding: 5px 40px 5px 30px; height: 32px; border: 1px solid var(--color-border, #e5e7eb); border-radius: 99px; background: var(--color-bg, #f9fafb); font: inherit; font-size: 13px; color: var(--color-text, #1f2937); outline: none; width: 200px; box-sizing: border-box; }
.topbar-search .tb-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 10px; font-weight: 700; color: var(--text-light, #9ca3af); background: var(--color-border, #e5e7eb); padding: 1px 5px; border-radius: 4px; pointer-events: none; }
.topbar-search input:focus { border-color: var(--sidebar-accent, #544DE0); background: var(--surface-bg, #fff); }
@media (max-width: 720px) { .topbar-search input { width: 140px; } .tb-kbd { display: none; } .tb-token-badge { display: none; } }

/* ── Mobile: sidebar off-canvas + hamburger ── */
.sidebar-close-btn { display: none; }
.sidebar-overlay { display: none; }
.tb-mobile-toggle { display: none; }

@media (max-width: 768px) {
  .mercanto-sidebar, aside.mercanto-sidebar {
    position: fixed !important; top: 0; left: 0; bottom: 0; z-index: 200;
    width: var(--sidebar-width, 240px); height: 100% !important;
    transform: translateX(-100%); transition: transform .25s ease;
    flex-shrink: 0;
  }
  /* Sidebar NESMÍ zabírat místo ve flex layoutu když je skrytý */
  .app-layout { display: flex; flex-direction: column; }
  .main-content { width: 100% !important; margin-left: 0 !important; }
  body.sidebar-open .mercanto-sidebar,
  body.sidebar-open aside.mercanto-sidebar { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 199; }
  body.sidebar-open .sidebar-overlay { display: block; }
  .sidebar-close-btn { display: flex; position: absolute; top: 14px; right: 12px; width: 28px; height: 28px; border: none; background: rgba(255,255,255,.1); border-radius: 6px; color: rgba(255,255,255,.7); cursor: pointer; align-items: center; justify-content: center; }
  .tb-mobile-toggle { display: flex !important; }
  .page-header-actions { display: none !important; }
  .tb-token-badge { display: none; }
  .topbar-search .tb-kbd { display: none; }
  .topbar-search input { width: 120px; }
  .page-content { padding: 14px; }
}

/* PWA mobile-native UX */
/* Prevent iOS zoom on input focus — min 16px */
input, select, textarea { font-size: max(16px, 1em); }
/* Touch-friendly targets */
button, .btn, a.nav-link, .sidebar-item { touch-action: manipulation; }
.btn, button { min-height: 44px; }
/* No horizontal scroll leak */
img, video, svg, iframe { max-width: 100%; }
pre, code { overflow-x: auto; word-break: break-word; }

/* ── Utility classes pro zděděné komponenty z Reachio/CRM ── */
.card-body { padding: 0; }
.card-title { font-family: var(--font-heading); font-size: 14px; font-weight: 700; }
.card-header .card-title { margin: 0; }

.required { color: var(--danger); font-weight: 700; margin-left: 2px; }

.btn-lg { padding: 11px 20px; font-size: 14px; }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); background: var(--card); font-size: 12px; font-weight: 600; color: var(--text-mid); cursor: pointer; font-family: inherit; transition: all .12s; }
.chip-btn:hover { border-color: var(--bright-purple); color: var(--bright-purple); }
.chip-btn.active { background: var(--bright-purple-light); border-color: var(--bright-purple); color: var(--bright-purple); }

.empty-state { padding: 48px 24px; text-align: center; background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.empty-state-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state-title { font-family: var(--font-heading); font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.empty-state-text { font-size: 13px; color: var(--text-light); max-width: 420px; margin: 0 auto; }

.divider { height: 1px; background: var(--divider); margin: 14px 0; }
.page-title { font-family: var(--font-heading); font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.page-subtitle { color: var(--text-light); font-size: 14px; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; background: var(--text); color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.2); animation: toast-in .2s ease; }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Badges extra */
.badge-phase-r { background: var(--bright-purple-light); color: var(--bright-purple); }

@keyframes io-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Embed mode — pro iframe bez sidebaru (client-side detekce přes ?embed=1) */
html.embed-mode .sidebar,
html.embed-mode .top-bar { display: none !important; }
html.embed-mode .main-content { margin-left: 0 !important; padding-top: 0 !important; }
html.embed-mode .page-wrapper { padding: 20px 24px !important; }
html.embed-mode body { background: var(--card); }

/* Mode switcher — tile selector nahoře, přepíná iframe obsah pod */
.mode-switcher { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 20px; }
.mode-tile { padding: 16px 18px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--card); cursor: pointer; transition: all .15s; text-align: left; font-family: var(--font); display: flex; align-items: flex-start; gap: 12px; }
.mode-tile:hover { border-color: var(--bright-purple); transform: translateY(-1px); }
.mode-tile.active { border-color: var(--bright-purple); background: var(--bright-purple-light); box-shadow: 0 2px 10px rgba(84,77,224,0.1); }
.mode-tile-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--bright-purple-light); color: var(--bright-purple); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.mode-tile.active .mode-tile-icon { background: var(--bright-purple); color: #fff; }
.mode-tile-body { flex: 1; min-width: 0; }
.mode-tile-name { font-family: var(--font-heading); font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.mode-tile-desc { font-size: 12px; color: var(--text-light); line-height: 1.4; }

/* Iframe frame */
.mode-frame {
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 600px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.mode-frame iframe { width: 100%; height: 100%; border: none; display: block; }
