  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f4f6fa; color: #1f2937; font-size: 14px; line-height: 1.5;
  }
  a { color: inherit; text-decoration: none; }

  .app { display: flex; min-height: 100vh; }

  /* ---------- SIDEBAR ---------- */
  .sidebar {
    width: 240px; background: #0f172a; color: #cbd5e1; padding: 20px 0;
    flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  .logo {
    padding: 0 20px 20px; font-size: 17px; font-weight: 700; color: #fff;
    border-bottom: 1px solid #1e293b; margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
  }
  .logo-dot { width: 10px; height: 10px; background: #38bdf8; border-radius: 50%; }
  .nav-section { font-size: 11px; text-transform: uppercase; color: #64748b;
                 padding: 12px 20px 6px; letter-spacing: .05em; }
  .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px; cursor: pointer; font-size: 14px;
    border-left: 3px solid transparent;
  }
  .nav-item:hover { background: #1e293b; color: #fff; }
  .nav-item.active { background: #1e293b; color: #fff; border-left-color: #38bdf8; }
  .nav-icon { width: 18px; text-align: center; opacity: .85; }
  .nav-badge { margin-left: auto; background: #ef4444; color: white;
               font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }

  /* ---------- MAIN ---------- */
  .main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .topbar {
    background: white; border-bottom: 1px solid #e5e7eb;
    padding: 12px 28px; display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 10;
  }
  .company-switcher {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; background: #f1f5f9; border-radius: 6px; cursor: pointer;
    font-weight: 600;
  }
  .company-switcher select {
    border: none; background: transparent; font-weight: 600; font-size: 14px;
    cursor: pointer; outline: none; min-width: 220px;
  }
  .topbar-search {
    flex: 1; max-width: 420px; padding: 8px 14px;
    border: 1px solid #e5e7eb; border-radius: 6px; font-size: 14px;
  }
  .topbar-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
  .icon-btn {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
  }
  .icon-btn:hover { background: #f1f5f9; }
  .notif-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px;
               background: #ef4444; border-radius: 50%; }
  .user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 600; cursor: pointer;
  }

  .content { padding: 24px 28px; flex: 1; }
  .page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
  .page-title { font-size: 22px; font-weight: 700; color: #111827; }
  .page-subtitle { color: #6b7280; font-size: 13px; margin-top: 2px; }
  .scope-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: #e0f2fe; color: #075985; padding: 2px 10px;
    border-radius: 12px; font-size: 12px; font-weight: 600; margin-left: 8px;
  }

  /* ---------- BUTTONS ---------- */
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
    cursor: pointer; border: 1px solid transparent;
  }
  .btn-primary { background: #0ea5e9; color: white; }
  .btn-primary:hover { background: #0284c7; }
  .btn-secondary { background: white; border-color: #e5e7eb; color: #374151; }
  .btn-secondary:hover { background: #f9fafb; }
  .btn-ghost { background: transparent; color: #6b7280; }
  .btn-ghost:hover { background: #f1f5f9; }
  .btn-danger { background: #fef2f2; color: #dc2626; border-color: #fecaca; }

  /* ---------- CARDS ---------- */
  .card { background: white; border: 1px solid #e5e7eb; border-radius: 8px;
          padding: 18px; margin-bottom: 16px; }
  .stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
  .stat-card { background: white; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; }
  .stat-label { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }
  .stat-value { font-size: 26px; font-weight: 700; color: #111827; margin-top: 6px; }
  .stat-trend { font-size: 12px; margin-top: 6px; }
  .stat-trend.up { color: #059669; }
  .stat-trend.warn { color: #d97706; }

  /* ---------- TABLE ---------- */
  table { width: 100%; border-collapse: collapse; }
  th { text-align: left; font-size: 12px; color: #6b7280; text-transform: uppercase;
       padding: 10px 12px; border-bottom: 1px solid #e5e7eb; font-weight: 600; letter-spacing: .03em; }
  td { padding: 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
  tbody tr:hover { background: #f9fafb; cursor: pointer; }
  .num { text-align: right; font-variant-numeric: tabular-nums; }

  /* ---------- BADGES ---------- */
  .badge { display: inline-flex; align-items: center; gap: 4px;
           padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
  .badge-green { background: #dcfce7; color: #166534; }
  .badge-yellow { background: #fef3c7; color: #92400e; }
  .badge-red { background: #fee2e2; color: #991b1b; }
  .badge-blue { background: #dbeafe; color: #1e40af; }
  .badge-gray { background: #f3f4f6; color: #4b5563; }
  .badge-purple { background: #ede9fe; color: #5b21b6; }

  /* Firm-color tags */
  .firm-print  { background: #fef3c7; color: #92400e; }
  .firm-plegi  { background: #dbeafe; color: #1e40af; }
  .firm-dev1s  { background: #ede9fe; color: #5b21b6; }
  .firm-nadace { background: #dcfce7; color: #166534; }

  /* Středisko / Výkon tags */
  .tag-stred { background: #ecfeff; color: #0e7490; padding: 2px 8px;
               border-radius: 4px; font-size: 12px; font-weight: 600; }
  .tag-vykon { background: #f5f3ff; color: #6d28d9; padding: 2px 8px;
               border-radius: 4px; font-size: 12px; font-weight: 600; }

  .conf-bar { width: 60px; height: 6px; background: #e5e7eb; border-radius: 3px;
              overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
  .conf-fill { height: 100%; background: #10b981; }
  .conf-fill.med { background: #f59e0b; }
  .conf-fill.low { background: #ef4444; }

  /* ---------- FILTERS ---------- */
  .filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
  .filter-input, .filter-select {
    padding: 7px 12px; border: 1px solid #e5e7eb; border-radius: 6px;
    font-size: 13px; background: white;
  }

  .view { display: none; }
  .view.active { display: block; }

  /* ---------- DETAIL ---------- */
  .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
  .detail-section h3 { font-size: 14px; margin-bottom: 12px; color: #111827; }
  .field-row { display: grid; grid-template-columns: 160px 1fr;
               padding: 8px 0; border-bottom: 1px solid #f1f5f9;
               font-size: 13px; align-items: center; }
  .field-label { color: #6b7280; }
  .field-value { font-weight: 500; }
  .field-input { padding: 5px 8px; border: 1px solid #e5e7eb; border-radius: 4px;
                 width: 100%; font-size: 13px; }
  .pdf-preview { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 8px;
                 aspect-ratio: 0.71; display: flex; align-items: center; justify-content: center;
                 color: #94a3b8; font-size: 13px; overflow: hidden; position: relative; }
  .pdf-mock { background: white; width: 88%; height: 92%; border: 1px solid #e5e7eb;
              box-shadow: 0 4px 12px rgba(0,0,0,.06); padding: 22px; font-size: 10px;
              color: #1f2937; overflow: hidden; }
  .pdf-mock h4 { font-size: 13px; margin-bottom: 8px; }
  .pdf-mock .row { display: flex; justify-content: space-between; padding: 2px 0; }
  .pdf-mock hr { border: none; border-top: 1px solid #e5e7eb; margin: 8px 0; }
  .highlight { background: #fef9c3; padding: 1px 3px; border-radius: 2px;
               border: 1px dashed #ca8a04; }

  .email-card { background: #f8fafc; border-left: 3px solid #38bdf8; padding: 12px 14px;
                border-radius: 4px; font-size: 13px; }
  .email-meta { color: #6b7280; font-size: 12px; margin-bottom: 6px; }

  /* ---------- COMPANIES ---------- */
  .companies-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .company-card { background: white; border: 1px solid #e5e7eb; border-radius: 8px;
                  padding: 18px; transition: all .15s; }
  .company-card:hover { border-color: #38bdf8; box-shadow: 0 2px 8px rgba(56,189,248,.1); }
  .company-card h3 { font-size: 16px; margin-bottom: 4px; }
  .company-email { font-family: ui-monospace, monospace; font-size: 12px;
                   background: #f1f5f9; padding: 4px 8px; border-radius: 4px;
                   display: inline-block; margin-top: 6px; }
  .company-stats { display: flex; gap: 18px; margin-top: 14px; padding-top: 14px;
                   border-top: 1px solid #f1f5f9; font-size: 12px; color: #6b7280; }
  .company-stats b { color: #111827; font-size: 14px; display: block; }

  /* ---------- CATEGORIES ---------- */
  .firm-tabs { display: flex; gap: 4px; border-bottom: 1px solid #e5e7eb; margin-bottom: 16px; }
  .firm-tab { padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 600;
              color: #6b7280; border-bottom: 2px solid transparent; margin-bottom: -1px; }
  .firm-tab:hover { color: #111827; }
  .firm-tab.active { color: #0ea5e9; border-bottom-color: #0ea5e9; }
  .cat-pane { display: none; }
  .cat-pane.active { display: block; }

  .cat-group { background: white; border: 1px solid #e5e7eb; border-radius: 8px;
               padding: 16px; margin-bottom: 12px; }
  .cat-group-header { display: flex; align-items: center; justify-content: space-between;
                      margin-bottom: 12px; }
  .cat-tags { display: flex; flex-wrap: wrap; gap: 6px; }
  .cat-tag { background: #f1f5f9; padding: 4px 10px; border-radius: 4px; font-size: 12px;
             display: inline-flex; align-items: center; gap: 6px; }
  .cat-tag .x { color: #94a3b8; cursor: pointer; font-weight: 700; }
  .vykon-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px;
                font-size: 13px; }
  .vykon-row { display: flex; gap: 8px; padding: 4px 8px; border-radius: 4px;
               align-items: center; }
  .vykon-row:hover { background: #f8fafc; }
  .vykon-num { font-family: ui-monospace, monospace; color: #94a3b8;
               font-weight: 600; min-width: 22px; }
  .vykon-name { flex: 1; }
  .vykon-edit { color: #cbd5e1; font-size: 11px; cursor: pointer; }
  .vykon-row:hover .vykon-edit { color: #0ea5e9; }

  /* ---------- RULES ---------- */
  .rule-card { background: white; border: 1px solid #e5e7eb; border-radius: 8px;
               padding: 16px; margin-bottom: 10px; }
  .rule-condition { background: #f8fafc; padding: 8px 12px; border-radius: 4px;
                    font-family: ui-monospace, monospace; font-size: 12px; margin: 6px 0; }
  .arrow { color: #38bdf8; margin: 0 6px; }

  /* ---------- INTEGRATIONS ---------- */
  .int-row { display: flex; align-items: center; gap: 14px; padding: 14px;
             border-bottom: 1px solid #f1f5f9; }
  .int-icon { width: 44px; height: 44px; border-radius: 8px;
              display: flex; align-items: center; justify-content: center;
              font-weight: 700; color: white; font-size: 14px; }

  /* ---------- QUEUE ---------- */
  .queue-item { display: flex; gap: 14px; padding: 14px;
                border-bottom: 1px solid #f1f5f9; cursor: pointer; }
  .queue-item:hover { background: #fafbfc; }
  .queue-thumb { width: 60px; height: 75px; background: #f1f5f9; border-radius: 4px;
                 display: flex; align-items: center; justify-content: center;
                 font-size: 22px; flex-shrink: 0; }
  .queue-info { flex: 1; }
  .queue-actions { display: flex; gap: 6px; align-items: center; }

  /* ---------- ACTIVITY ---------- */
  .activity-item { display: flex; gap: 12px; padding: 10px 0;
                   border-bottom: 1px solid #f1f5f9; font-size: 13px; }
  .activity-icon { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
                   display: flex; align-items: center; justify-content: center;
                   background: #e0f2fe; color: #0284c7; }
  .activity-time { color: #9ca3af; font-size: 12px; }

  .two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

  .ai-suggest { background: linear-gradient(135deg, #ede9fe, #f3e8ff);
                border: 1px solid #c4b5fd; padding: 12px 14px; border-radius: 8px;
                font-size: 13px; margin-bottom: 14px; }
  .ai-suggest-title { font-weight: 600; color: #5b21b6; margin-bottom: 4px;
                      display: flex; align-items: center; gap: 6px; }

  .modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5);
                   display: none; align-items: center; justify-content: center; z-index: 100; }
  .modal-overlay.active { display: flex; }
  .modal { background: white; border-radius: 10px; padding: 22px;
           width: 90%; max-width: 520px; }
  .modal h3 { margin-bottom: 14px; }
  .form-group { margin-bottom: 12px; }
  .form-group label { display: block; font-size: 12px; color: #6b7280;
                      margin-bottom: 4px; font-weight: 600; text-transform: uppercase; }
  .form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 8px 12px; border: 1px solid #e5e7eb;
    border-radius: 6px; font-size: 14px; font-family: inherit;
  }
  .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

  .proto-banner { background: #fef3c7; color: #92400e; padding: 6px 16px;
                  text-align: center; font-size: 12px; font-weight: 600; }

/* ---------- APP ADDITIONS ---------- */
.flash { padding: 10px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; font-weight: 500; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; list-style: none; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 11px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 13px; background: white; color: #374151; }
.pagination .active span { background: #0ea5e9; color: white; border-color: #0ea5e9; }
.pagination [aria-disabled='true'] span { color: #cbd5e1; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f172a; }
.login-card { background: white; border-radius: 12px; padding: 34px; width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.login-card h1 { font-size: 20px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.login-card p { color: #6b7280; font-size: 13px; margin-bottom: 20px; }

.empty { text-align: center; color: #9ca3af; padding: 40px 20px; font-size: 14px; }
.muted { color: #6b7280; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gap-16 { gap: 16px; }
a.nav-item.active, a.firm-tab.active { text-decoration: none; }
.btn-excel { background: #16a34a; color: white; }
.btn-excel:hover { background: #15803d; }
label.req::after { content: ' *'; color: #ef4444; }
.help-q { display: inline-flex; width: 15px; height: 15px; border-radius: 50%; background: #e5e7eb; color: #6b7280; font-size: 10px; align-items: center; justify-content: center; cursor: help; margin-left: 4px; }
.table-wrap { overflow-x: auto; }
.line-items-table tbody tr:hover { background: transparent; cursor: default; }
.line-items-table .field-input { width: 100%; min-width: 0; }
.line-items-table td { padding: 6px 8px; vertical-align: middle; }
.line-items-table th { padding: 8px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
