/* Alpha Codes CRM — design systém.
   Portováno z edge-ant-gui/src/index.css do čistého CSS bez build kroku.
   Jediný stylesheet, tokeny v :root, světlé téma. */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);

  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }

/* ── Formuláře ───────────────────────────────────────────────────────────── */

input, select, textarea, button { font: inherit; color: inherit; }

input[type='text'], input[type='email'], input[type='number'], input[type='date'],
input[type='datetime-local'], input[type='search'], input[type='file'], select, textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}
textarea { resize: vertical; font-family: inherit; min-height: 90px; }

/* Popisek a pole jsou sourozenci uvnitř <label>, takže není potřeba for/id. */
label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}
label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }
label.checkbox input { width: auto; }

.input-lg { font-size: 1.05rem; font-weight: 600; letter-spacing: 0.15em; text-align: center; }
.input-invalid { border-color: var(--danger) !important; }

/* ── Kostra stránky ──────────────────────────────────────────────────────── */

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

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.05rem; }
.brand-mark { width: 28px; height: 28px; border-radius: 6px; display: block; object-fit: contain; }
.brand-name {
  background: linear-gradient(90deg, #1e1b4b 0%, #4f46e5 60%, #ec4899 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.nav { display: flex; gap: 0.25rem; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: 0.4rem 0.85rem; border-radius: 8px;
  color: var(--text-muted); font-weight: 500; font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active {
  background: linear-gradient(135deg, #eef2ff 0%, #fce7f3 100%);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.12);
}

.account { display: flex; align-items: center; gap: 0.6rem; }
.account-mail {
  font-size: 0.85rem; color: var(--text-muted);
  max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.content { flex: 1; padding: 1.75rem; max-width: 1240px; margin: 0 auto; width: 100%; }

/* ── Primitiva ───────────────────────────────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm);
}
.page { display: flex; flex-direction: column; gap: 1rem; }
.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row.right { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 0.85rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grow { flex: 1; min-width: 180px; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace; }
.error-text { color: var(--danger); font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ── Tlačítka ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 8px; border: 1px solid transparent;
  background: var(--surface); color: var(--text);
  font-weight: 500; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.btn-cta {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff; border: none;
  padding: 0.6rem 1.15rem; border-radius: 10px;
  font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  text-decoration: none; white-space: nowrap;
  box-shadow: 0 6px 18px -6px rgba(79, 70, 229, 0.5);
  transition: transform 0.12s, box-shadow 0.18s, opacity 0.15s;
}
.btn-cta:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -6px rgba(79, 70, 229, 0.55);
  text-decoration: none;
}
.btn-cta:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

/* ── Štítky ──────────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
}
.pill-muted { background: var(--surface-2); color: var(--text-muted); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-view { background: var(--info-soft); color: var(--info); }
.pill-write { background: var(--success-soft); color: var(--success); }
.pill-admin { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary); font-weight: 700; }

/* ── Hlášky ──────────────────────────────────────────────────────────────── */

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.7rem 1rem; border-radius: 8px;
  border-left: 4px solid; font-size: 0.9rem;
}
.banner-error { background: var(--danger-soft); color: #7f1d1d; border-color: var(--danger); }
.banner-success { background: var(--success-soft); color: #14532d; border-color: var(--success); }
.banner-info { background: var(--info-soft); color: #075985; border-color: var(--info); }
.banner-close { background: transparent; border: none; cursor: pointer; font-size: 0.95rem; color: inherit; opacity: 0.6; }
.banner-close:hover { opacity: 1; }

/* ── Přihlášení ──────────────────────────────────────────────────────────── */

.auth-shell {
  position: relative; min-height: 100vh;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4rem 1rem;
  background:
    radial-gradient(60% 50% at 0% 0%, #eef2ff 0%, transparent 60%),
    radial-gradient(60% 50% at 100% 0%, #fce7f3 0%, transparent 60%),
    radial-gradient(60% 60% at 50% 100%, #f5f3ff 0%, transparent 60%),
    var(--bg);
}
.auth-card {
  position: relative; width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2rem;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.05),
    0 22px 48px -22px rgba(79, 70, 229, 0.28),
    0 8px 16px -10px rgba(15, 23, 42, 0.12);
  display: flex; flex-direction: column; gap: 1rem;
}
.auth-logo { width: 100%; max-width: 220px; height: auto; align-self: center; border-radius: var(--radius); display: block; }
.auth-card h1 {
  background: linear-gradient(90deg, #1e1b4b 0%, #4f46e5 60%, #ec4899 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ── Hlavička stránky ────────────────────────────────────────────────────── */

.page-hero {
  position: relative; overflow: hidden;
  border-radius: 16px; padding: 1.5rem 1.75rem 1.4rem;
  background:
    radial-gradient(120% 140% at 0% 0%, #eef2ff 0%, transparent 55%),
    radial-gradient(120% 140% at 100% 0%, #fce7f3 0%, transparent 55%),
    linear-gradient(135deg, #f5f3ff 0%, #fdf2f8 100%);
  border: 1px solid #e0e7ff;
}
.page-hero::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(80% 60% at 80% 110%, rgba(99, 102, 241, 0.1), transparent 60%);
  pointer-events: none;
}
.page-hero-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.75rem; position: relative; z-index: 1; flex-wrap: wrap;
}
.page-hero-title {
  margin: 0; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem);
  line-height: 1.2; letter-spacing: -0.01em; font-weight: 700;
  background: linear-gradient(90deg, #1e1b4b 0%, #4f46e5 60%, #ec4899 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.page-hero-description { margin-top: 0.4rem; color: var(--text-muted); font-size: 0.95rem; max-width: 70ch; position: relative; z-index: 1; }
.page-hero-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; position: relative; z-index: 1; }

/* ── Kachlíky ────────────────────────────────────────────────────────────── */

.tiles { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 0.25rem;
}
.tile-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; }
.tile-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; }
.tile-hint { font-size: 0.8rem; color: var(--text-muted); }
.tile-value.positive { color: var(--success); }
.tile-value.negative { color: var(--danger); }

/* ── Seznamy ─────────────────────────────────────────────────────────────── */

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.85rem 1rem;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.list-item:hover {
  background: var(--surface-2); border-color: var(--border-strong);
  box-shadow: 0 10px 22px -16px rgba(15, 23, 42, 0.18), 0 4px 8px -6px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}
.list-item-main { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.list-item-title { font-weight: 600; }
.list-item-meta { font-size: 0.82rem; color: var(--text-muted); }
.list-item-actions { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }

/* Časová osa poznámek */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.timeline-item { border-left: 3px solid var(--primary); padding: 0.15rem 0 0.15rem 0.85rem; }
.timeline-head { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.82rem; color: var(--text-muted); flex-wrap: wrap; }
.timeline-author { font-weight: 600; color: var(--text); }
.timeline-body { white-space: pre-wrap; margin-top: 0.2rem; }

/* ── Tabulky ─────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.table thead th {
  text-align: left; padding: 0.6rem 0.8rem;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); font-weight: 700; white-space: nowrap;
}
.table tbody td { padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.right, .table th.right { text-align: right; }

/* ── Pipeline ────────────────────────────────────────────────────────────── */

.pipeline { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); align-items: start; }
.pipeline-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.pipeline-col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.4rem; margin-bottom: 0.6rem; }
.pipeline-col-name { font-weight: 700; font-size: 0.9rem; }
.pipeline-col-sum { font-size: 0.8rem; color: var(--text-muted); }
.pipeline-deal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.7rem; margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
}
.pipeline-deal:last-child { margin-bottom: 0; }
.pipeline-deal-title { font-weight: 600; font-size: 0.88rem; }
.pipeline-deal-meta { font-size: 0.78rem; color: var(--text-muted); }

/* ── Graf ────────────────────────────────────────────────────────────────── */

.chart-wrap { position: relative; width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-muted); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.chart-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #1e293b; color: #f1f5f9; font-size: 0.78rem;
  padding: 0.45rem 0.6rem; border-radius: 6px; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
  opacity: 0; transition: opacity 0.12s;
}
.chart-tooltip.visible { opacity: 1; }
.chart-bar { transition: opacity 0.12s; cursor: pointer; }
.chart-bar:hover { opacity: 0.8; }

/* ── Modál ───────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4rem 1rem; z-index: 100; overflow-y: auto;
  animation: modalFade 0.18s ease-out;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 14px;
  width: 100%; max-width: 560px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 24px 60px -20px rgba(15, 23, 42, 0.35);
  animation: modalPop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-wide { max-width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); border-radius: 14px 14px 0 0;
}
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.85rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ── Stavy ───────────────────────────────────────────────────────────────── */

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block;
}
.spinner-inline { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 2rem; color: var(--text-muted); }
.empty {
  text-align: center; padding: 2.5rem 1rem; color: var(--text-muted);
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty h3 { color: var(--text); margin-bottom: 0.4rem; }

/* ── Responzivita ────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
  .content { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; gap: 0.75rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .auth-shell { padding: 1.5rem 1rem; }
  .auth-card { padding: 1.5rem; }
  .list-item { flex-direction: column; align-items: stretch; }
  .list-item-actions { justify-content: flex-end; }
}
@media (max-width: 420px) {
  .brand-name, .account-mail { display: none; }
  .auth-shell { padding: 1rem; }
  .auth-card { padding: 1.25rem; }
}
