/* ═══════════════════════════════════════════════════════════════════════════
   Returno — Mobile-First Design Systém
   Barevná paleta: Tmavá modrá (#1e3a5f) + bílé karty + oranžový akcent
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tokeny ──────────────────────────────────────────────────────────────── */
:root {
  --primary:        #1e3a5f;
  --primary-dark:   #152b48;
  --primary-light:  #2d5a9e;
  --primary-10:     rgba(30,58,95,.10);
  --primary-20:     rgba(30,58,95,.20);

  --accent:         #f59e0b;
  --accent-dark:    #d97706;
  --danger:         #dc2626;
  --danger-bg:      #fef2f2;
  --success:        #16a34a;
  --success-bg:     #f0fdf4;
  --warning:        #d97706;
  --warning-bg:     #fffbeb;

  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #e2e8f0;
  --border-strong:  #cbd5e1;

  --text:           #0f172a;
  --text-2:         #475569;
  --text-3:         #94a3b8;
  --text-inv:       #ffffff;

  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      16px;
  --radius-xl:      20px;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12);

  --topbar-h:       44px;
  --bottomnav-h:    56px;
  --page-pad:       14px;
  --transition:     .15s ease;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ── Topbar (mobile = pryč, jen floating avatar; desktop = full bar) ─────── */
.topbar { display: none; }
@media (min-width: 768px) {
  .topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--topbar-h);
    background: var(--primary);
    color: var(--text-inv);
    display: flex;
    align-items: center;
    padding: 0 var(--page-pad);
    gap: 12px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
  }
}

/* Floating avatar (jen mobile, plovoucí v pravém horním rohu) */
.mobile-avatar {
  position: fixed;
  top: 6px;
  right: 8px;
  z-index: 150;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-inv);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.mobile-avatar:hover { color: var(--text-inv); filter: brightness(1.1); }
@media (min-width: 768px) { .mobile-avatar { display: none; } }
.topbar-brand {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-inv);
  text-decoration: none;
  letter-spacing: .02em;
  flex: 0 0 auto;
}
.topbar-brand span { color: var(--accent); }
.topbar-spacer { flex: 1; }

/* Avatar (logout) — kompaktní iniciála vpravo v topbaru */
.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  color: var(--text-inv);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: .02em;
  transition: background var(--transition);
}
.topbar-avatar:hover { background: rgba(255,255,255,.32); color: var(--text-inv); }
.topbar-action {
  background: none;
  border: none;
  color: var(--text-inv);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  opacity: .85;
  transition: opacity var(--transition), background var(--transition);
  text-decoration: none;
}
.topbar-action:hover { opacity: 1; background: var(--primary-20); color: var(--text-inv); }
.topbar-badge {
  background: var(--accent);
  color: #000;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* ── Bottom nav (mobile) ─────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  height: var(--bottomnav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-3);
  font-size: .68rem;
  font-weight: 500;
  padding: 8px 4px;
  transition: color var(--transition);
  position: relative;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active svg { stroke: var(--primary); }
.bottom-nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 16px);
  background: var(--danger);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* Desktop: skryjeme bottom nav, ukážeme sidebar nav */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
}

/* ── Hlavní obsah ─────────────────────────────────────────────────────────── */
.page-wrap {
  padding-top: 8px;
  padding-bottom: calc(var(--bottomnav-h) + 12px);
  padding-left: var(--page-pad);
  padding-right: var(--page-pad);
  max-width: 720px;
  margin: 0 auto;
}
@media (min-width: 768px) {
  .page-wrap { padding-top: calc(var(--topbar-h) + 12px); }
}
@media (min-width: 768px) {
  .page-wrap {
    padding-bottom: 24px;
    max-width: 960px;
  }
}
@media (min-width: 1200px) {
  .page-wrap {
    max-width: 1200px;
  }
}

/* ── Karty ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  margin-bottom: 10px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.card-subtitle {
  font-size: .8rem;
  color: var(--text-3);
  margin: 2px 0 0 0;
}

/* ── Řádkové položky (returns/tasks list) ────────────────────────────────── */
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.list-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.list-item:last-child { border-bottom: none; border-radius: 0 0 var(--radius) var(--radius); }
.list-item:only-child { border-radius: var(--radius); }
.list-item:hover, .list-item:active { background: var(--surface-2); }
.list-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-10);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
}
.list-item-icon.warning { background: var(--warning-bg); color: var(--warning); }
.list-item-icon.success { background: var(--success-bg); color: var(--success); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title {
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 3px 0;
}
.list-item-meta {
  font-size: .78rem;
  color: var(--text-2);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.list-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.list-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

/* ── Štítky (badges) ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-10); color: var(--primary); }
.badge-warning  { background: var(--warning-bg); color: var(--warning); }
.badge-danger   { background: var(--danger-bg); color: var(--danger); }
.badge-success  { background: var(--success-bg); color: var(--success); }
.badge-neutral  { background: var(--border); color: var(--text-2); }
.badge-custom { display: inline-block; }

/* ── Tlačítka ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: filter var(--transition), transform var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn[disabled], .btn.loading { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: var(--text-inv);
  border-color: var(--primary-dark);
}
.btn-primary:hover { filter: brightness(1.1); color: var(--text-inv); }

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: var(--text-inv);
}
.btn-danger:hover { filter: brightness(.9); color: var(--text-inv); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--border); }

.btn-danger {
  background: var(--danger);
  color: var(--text-inv);
  border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(.9); color: var(--text-inv); }

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 14px 24px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* FAB — floating action button (mobile) */
.fab {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-inv);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(30,58,95,.4);
  z-index: 90;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(30,58,95,.5); }
.fab:active { transform: scale(.96); }
.fab svg { width: 24px; height: 24px; }
@media (min-width: 768px) { .fab { display: none; } }

/* ── Formuláře ───────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 10px;
}
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 3px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-10);
}
.form-control::placeholder { color: var(--text-3); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
}
.form-hint {
  font-size: .77rem;
  color: var(--text-3);
  margin-top: 4px;
}
.form-error {
  font-size: .77rem;
  color: var(--danger);
  margin-top: 4px;
}
.form-control.is-error { border-color: var(--danger); }

/* ── Foto upload ─────────────────────────────────────────────────────────── */
.photo-upload-area {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.photo-upload-area:hover, .photo-upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-10);
}
.photo-upload-area input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  /* iOS Safari registruje dotyk na <input type=file> jen v oblasti nativního
     tlačítka — roztažený overlay tam nereaguje a navíc kradl e.target dotyku.
     pointer-events:none nechá dotyk propadnout na kontejner, který pak
     spustí input programově (viz initPhotoUpload v app.js). */
  pointer-events: none;
}
.photo-upload-icon { color: var(--text-3); margin-bottom: 8px; }
.photo-upload-label { font-size: .85rem; color: var(--text-2); font-weight: 500; }
.photo-upload-hint  { font-size: .75rem; color: var(--text-3); margin-top: 4px; }
.photo-preview {
  position: relative;
  display: inline-block;
  margin-top: 12px;
}
.photo-preview img {
  max-height: 160px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.photo-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
}
.photo-ai-status {
  margin-top: 8px;
  font-size: .78rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.photo-ai-status.processing { color: var(--primary); }
.photo-ai-status.done       { color: var(--success); }
.photo-ai-status.warn       { color: var(--warning); }
.photo-ai-status.error      { color: var(--danger); }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  padding-right: 42px;  /* prostor pro floating avatar v rohu (mobile) */
}
@media (min-width: 768px) {
  .page-header { padding-right: 0; }
}
.page-header h1 {
  font-size: .92rem;
  font-weight: 700;
  margin: 0;
  color: var(--primary);
  flex: 1;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-header-actions { display: flex; gap: 6px; align-items: center; }

/* ── Section headers ─────────────────────────────────────────────────────── */
.section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  margin: 20px 0 8px 0;
}

/* ── Tabs (filtry) ───────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 16px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-color: var(--primary); }

/* ── Alerty ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #fecaca; }
.alert-warning  { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.alert-info     { background: var(--primary-10); color: var(--primary); border: 1px solid var(--primary-20); }

/* ── Inline editace (detailページ) ──────────────────────────────────────── */
.detail-field {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-field:last-child { border-bottom: none; }
.detail-field-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
}
.detail-field-value {
  font-size: .92rem;
  color: var(--text);
  min-height: 24px;
}
.detail-field-value.empty { color: var(--text-3); font-style: italic; }
.detail-field-edit { display: none; }
.edit-mode .detail-field-value { display: none; }
.edit-mode .detail-field-edit  { display: block; }
form:not(.edit-mode) .edit-mode { display: none; }

/* ── Timeline / poznámky ─────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 20px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 36px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-10);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .8rem;
  font-weight: 700;
}
.timeline-dot.transfer { background: var(--warning-bg); color: var(--warning); }
.timeline-body {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.timeline-meta {
  font-size: .75rem;
  color: var(--text-3);
  margin-bottom: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.timeline-meta strong { color: var(--text-2); }
.timeline-text { font-size: .88rem; line-height: 1.55; }
.timeline-text a { color: var(--primary); }

/* ── Přehled: statistiky ─────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 480px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-card-number {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.stat-card-label {
  font-size: .73rem;
  color: var(--text-3);
  margin-top: 4px;
  font-weight: 500;
}
.stat-card.warning .stat-card-number { color: var(--warning); }
.stat-card.danger  .stat-card-number { color: var(--danger); }

/* ── Login stránka ───────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px var(--page-pad);
  background: var(--primary);
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
  letter-spacing: -.02em;
}
.login-logo span { color: var(--accent); }
.login-subtitle {
  font-size: .85rem;
  color: var(--text-3);
  margin-bottom: 28px;
}

/* ── Prázdný stav ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state svg { opacity: .3; margin: 0 auto 12px; }
.empty-state p { font-size: .88rem; margin: 0 0 16px 0; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-2) !important; }
.text-small  { font-size: .78rem; }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.hidden      { display: none !important; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16{ margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16{ margin-bottom: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.overdue { color: var(--danger); font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Výběr barev příznaku ────────────────────────────────────────────────── */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform var(--transition), border-color var(--transition);
}
.color-swatch.selected, .color-swatch:hover {
  transform: scale(1.15);
  border-color: var(--text);
}

/* ── Filtry ──────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-bar .form-control {
  flex: 1;
  min-width: 140px;
  padding: 8px 12px;
}

/* ── Desktop sidebar (≥768px) ────────────────────────────────────────────── */
@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
    gap: 4px;
    align-items: center;
  }
  .desktop-nav a {
    color: rgba(255,255,255,.75);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 500;
    transition: color var(--transition), background var(--transition);
  }
  .desktop-nav a:hover  { color: #fff; background: var(--primary-20); }
  .desktop-nav a.active { color: #fff; background: rgba(255,255,255,.15); }
}
.desktop-nav { display: none; }
@media (min-width: 768px) { .desktop-nav { display: flex; } }

/* ── Modální okno ────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; padding: 24px; }
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px var(--page-pad);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.modal-backdrop.open .modal { transform: translateY(0); }
@media (min-width: 600px) {
  .modal { border-radius: var(--radius-xl); transform: scale(.95); max-height: 80vh; }
  .modal-backdrop.open .modal { transform: scale(1); }
}
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: 0 auto 16px;
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; color: var(--primary); }

/* ── Skeleton loader ─────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Admin tabulky ───────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-2);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }

/* ── Responzivní obrázky v detailu ───────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  display: none;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); object-fit: contain; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Status dots ─────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  vertical-align: middle;
}
.dot-red    { background: #b91c1c; }
.dot-orange { background: #f59e0b; }
.dot-green  { background: #10b981; }

/* ── HOT / Tasks list row ────────────────────────────────── */
.list-row {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  align-items: center;
}
.list-row:hover { background: rgba(0,0,0,0.03); }
.list-row .col-type  { font-weight: 600; }
.list-row .col-id    { color: var(--accent, #3b82f6); font-weight: 700; font-size: 13px; }
.list-row .col-note  { color: var(--muted, #6b7280); font-size: 12px;
                        overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.list-row .col-date  { font-size: 12px; white-space: nowrap; }
.list-row.unassigned { border-left: 3px solid #ef4444; }

/* HOT list: 5 sloupců */
.hot-list .list-row  { grid-template-columns: 150px 1fr 70px 44px 44px; }
/* Tasks list: 6 sloupců */
.task-list .list-row { grid-template-columns: 140px 120px 60px 90px 90px 1fr; }

/* ── Task history ────────────────────────────────────────── */
.task-history-entry {
  border-left: 3px solid var(--border, #e5e7eb);
  margin-left: 8px;
  padding-left: 16px;
  margin-bottom: 20px;
}
.task-history-entry .entry-header {
  display: flex; gap: 10px; align-items: center; margin-bottom: 6px;
}
.entry-badge {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
}
.entry-badge.creation { border-color: #10b981; color: #10b981; }
.entry-body {
  background: var(--surface, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 12px;
}

/* ── Show-closed checkbox ────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px; font-size: 13px;
}
.filter-bar label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ── Overdue date ────────────────────────────────────────── */
.overdue { color: #ef4444; font-weight: 600; }

/* ── Opacity utility ─────────────────────────────────────── */
.opacity-50 { opacity: 0.5; }

/* ── Tab bar main (HOT / Úkoly) ─────────────────────────────── */
.tab-bar-main {
  display: flex;
  background: var(--surface-2, #f3f4f6);
  border-bottom: 2px solid var(--border, #e5e7eb);
}
.tab-bar-main-link {
  padding: 10px 20px;
  text-decoration: none;
  color: var(--text-2, #6b7280);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
}
.tab-bar-main-link.active {
  color: var(--accent, #3b82f6);
  border-bottom-color: var(--accent, #3b82f6);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Foto dlaždice (return-new.php) — 3 kompaktní pole vedle sebe
   ═══════════════════════════════════════════════════════════════════════════ */
.photo-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: start;
}
.photo-tile-col { display: flex; flex-direction: column; gap: 8px; }
.photo-tile {
  padding: 14px 6px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
}
.photo-tile .photo-upload-icon { margin-bottom: 4px; }
.photo-tile .photo-upload-icon svg { width: 24px; height: 24px; }
.photo-tile .photo-upload-label { font-size: .8rem; font-weight: 600; }
.photo-tile .photo-preview { margin-top: 6px; }
.photo-tile .photo-preview img { max-height: 70px; }
.photo-tile .photo-ai-status {
  font-size: .65rem;
  justify-content: center;
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobilní úpravy — kompaktní layout, karty místo tabulek (2026-05-18)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  :root { --page-pad: 12px; }
  html { font-size: 15px; }

  /* Pojistka proti vodorovnému přetékání */
  body { overflow-x: hidden; }

  /* Kompaktnější obsah — víc se toho vejde na obrazovku */
  .page-wrap { padding-top: 8px; }
  .card { padding: 10px; margin-bottom: 8px; }
  .card-header { margin-bottom: 8px; }
  .page-header { margin-bottom: 6px; padding-bottom: 4px; }
  .section-title { margin: 12px 0 4px; }
  .form-group { margin-bottom: 8px; }

  /* ── Seznamy: tabulkový grid → skládané karty ─────────────────────────── */
  /* Hlavičky tabulky (div) na mobilu nedávají smysl — skryjeme */
  .hot-list div.list-row,
  .task-list div.list-row { display: none; }

  .hot-list a.list-row,
  .task-list a.list-row {
    padding: 9px 12px;
    gap: 3px 10px;
  }

  /* HOT seznam (vratky) */
  .hot-list a.list-row {
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      "customer hot int"
      "type     id  id";
  }
  .hot-list a.list-row > :nth-child(1) {
    grid-area: type; min-width: 0;
    font-size: .8rem; color: var(--text-2);
  }
  .hot-list a.list-row > :nth-child(2) {
    grid-area: customer; min-width: 0;
    font-size: .87rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .hot-list a.list-row > :nth-child(3) { grid-area: id; justify-self: end; }
  .hot-list a.list-row > :nth-child(4),
  .hot-list a.list-row > :nth-child(5) {
    display: flex; align-items: center; gap: 3px;
    font-size: .6rem; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .03em;
  }
  .hot-list a.list-row > :nth-child(4) { grid-area: hot; }
  .hot-list a.list-row > :nth-child(5) { grid-area: int; }
  .hot-list a.list-row > :nth-child(4)::before { content: "HOT"; }
  .hot-list a.list-row > :nth-child(5)::before { content: "INT"; }

  /* Seznam úkolů */
  .task-list a.list-row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "type  type  date"
      "cust  cust  id"
      "owner note  note";
  }
  .task-list a.list-row > :nth-child(1) {
    grid-area: type; min-width: 0;
    font-size: .84rem; font-weight: 600;
  }
  .task-list a.list-row > :nth-child(2) {
    grid-area: cust; min-width: 0;
    font-size: .82rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .task-list a.list-row > :nth-child(3) { grid-area: id; justify-self: end; }
  .task-list a.list-row > :nth-child(4) {
    grid-area: owner; min-width: 0;
    font-size: .72rem; color: var(--text-3);
  }
  .task-list a.list-row > :nth-child(5) {
    grid-area: date; justify-self: end;
    font-size: .72rem;
  }
  .task-list a.list-row > :nth-child(6) { grid-area: note; min-width: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Kompaktní redesign 2026-06 — Nová vratka / Detail
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Inline řada polí (datum + kusy) ─────────────────────────────────────── */
.field-row {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 8px;
  margin-bottom: 8px;
}
.field-row:last-child { margin-bottom: 0; }
.field-row .form-control { padding: 8px 10px; font-size: .88rem; }

/* Vstup s prefixem (mini-label) — místo .form-label nad polem */
.field-prefixed {
  position: relative;
  display: flex;
  align-items: center;
}
.field-prefixed .form-control {
  padding-left: 86px;
}
.field-prefixed .prefix {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  pointer-events: none;
}
textarea.form-control + .prefix { top: 10px; transform: none; }
.field-prefixed:has(textarea) .prefix { top: 10px; transform: none; }
.field-prefixed:has(textarea) .form-control { padding-top: 10px; padding-left: 10px; padding-bottom: 8px; }

/* ── Foto řádky (vlevo malá dlaždice, vpravo AI inputy/preview) ─────────── */
.photo-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.photo-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  align-items: start;
}
.photo-row .photo-tile {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color var(--transition), background var(--transition);
}
.photo-row .photo-tile:hover { border-color: var(--primary); background: var(--primary-10); }
.photo-row .photo-tile.has-image { border-style: solid; border-color: var(--border); background: var(--surface); overflow: hidden; }
.photo-row .photo-tile .photo-upload-icon { color: var(--text-3); margin: 0; line-height: 0; }
.photo-row .photo-tile .photo-upload-icon svg { width: 20px; height: 20px; }
/* Popisek dlaždice (Štítek / Dopis / Zboží) — pod dlaždicí, malý */
.photo-tile-caption {
  font-size: .6rem;
  font-weight: 600;
  color: var(--text-3);
  text-align: center;
  margin-top: 2px;
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.photo-row .photo-upload-label { display: none; } /* legacy */
.photo-row .photo-tile .photo-preview { margin: 0; position: absolute; inset: 0; display: none; }
.photo-row .photo-tile.has-image .photo-preview { display: block; }
.photo-row .photo-tile.has-image .photo-upload-icon { display: none; }
.photo-row .photo-tile .photo-preview img {
  width: 100%; height: 100%;
  max-height: none;
  object-fit: cover;
  border-radius: 0;
}
.photo-row .photo-tile .photo-preview-remove {
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  font-size: 11px;
  z-index: 2;
}
.photo-row .photo-tile input[type=file] { position: absolute; inset: 0; opacity: 0; pointer-events: none; cursor: pointer; }
/* Sloupek dlaždice = dlaždice + popisek + případné akce pod ní */
.photo-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* AI panel — výsledek hned napravo od dlaždice */
.ai-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* AI inputy — kompaktní, přímo editovatelné, prefill z AI */
.ai-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: .82rem;
  line-height: 1.25;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ai-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-10);
}
.ai-input::placeholder { color: var(--text-3); font-size: .78rem; }
.ai-input.filled-by-ai { background: #fffbeb; border-color: #fde68a; }
.ai-input.filled-by-ai:focus { background: var(--surface); border-color: var(--primary); }

.ai-status {
  font-size: .68rem;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}
.ai-status.processing { color: var(--primary); }
.ai-status.done       { color: var(--success); }
.ai-status.warn       { color: var(--warning); }
.ai-status.error      { color: var(--danger); }
.ai-status:empty { display: none; }

/* Dopis: 3-řádkový oříznutý preview + klik = modal */
.ai-doc-preview {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .82rem;
  line-height: 1.4;
  color: var(--text);
  cursor: pointer;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 52px;
  box-sizing: border-box;
}
.ai-doc-preview:hover { border-color: var(--primary); color: var(--primary); }
.ai-doc-preview.empty { color: var(--text-3); font-style: italic; cursor: default; background: transparent; border-style: dashed; }
.ai-doc-preview.empty:hover { border-color: var(--border); color: var(--text-3); }

/* Zboží — kompaktní seznam */
.ai-goods-list { display: flex; flex-direction: column; gap: 2px; }
.ai-goods-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--success-bg);
  color: var(--text);
  line-height: 1.25;
}
.ai-goods-item.unmatched { background: #fff7ed; color: #92400e; border: 1px solid #fbbf2455; }
.ai-goods-item label { display: flex; align-items: center; gap: 6px; cursor: pointer; flex: 1; }
.ai-goods-item .conf { font-size: .66rem; color: var(--text-3); margin-left: auto; }
.ai-goods-empty {
  font-size: .78rem;
  color: var(--text-3);
  font-style: italic;
  padding: 14px 8px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 6px;
}

/* Mini-button pro "+ stránka dopisu" */
.btn-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: border-color var(--transition), color var(--transition);
}
.btn-mini:hover { border-color: var(--primary); color: var(--primary); }

/* RR-label badge */
.rr-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  background: var(--primary-10);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: .04em;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Modal — wide (celá stránka pro dopis) ────────────────────────────── */
.modal--wide {
  max-width: 720px;
  width: calc(100% - 16px);
}
.modal--wide .modal-body {
  white-space: pre-wrap;
  font-size: .92rem;
  line-height: 1.55;
  color: var(--text);
  max-height: 70vh;
  overflow-y: auto;
  padding: 4px 2px;
}

/* ── Sekce ve formu — bez popisků, jen jemný oddělovač ──────────────── */
.form-section {
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  margin-top: 12px;
}
.form-section:first-child { padding-top: 0; border-top: none; margin-top: 0; }

/* ── Detail-field kompaktní — 2-sloupcový grid label:value ────────────── */
.detail-field {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: baseline;
}
.detail-field-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  margin: 0;
}
.detail-field-value {
  font-size: .9rem;
  color: var(--text);
  min-height: 0;
  word-break: break-word;
}
.detail-field-value.empty { color: var(--text-3); font-style: italic; }
.detail-field--full {
  grid-template-columns: 1fr;
  gap: 2px;
}
.detail-field--full .detail-field-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
form.edit-mode .detail-field { grid-template-columns: 1fr; gap: 4px; }
form.edit-mode .detail-field-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
form:not(.edit-mode) .edit-mode-only { display: none; }

/* Cluster akcí formuláře (uložit / zrušit) bez velkého margin */
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ── Mobilní úpravy nového layoutu ──────────────────────────────────────── */
@media (max-width: 767px) {
  .detail-field { grid-template-columns: 96px 1fr; gap: 6px; }
}
