:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1e2433;
  --muted: #667085;
  --accent: #4f6df5;
  --accent-dark: #3a55d9;
  --ok: #12945f;
  --err: #d43d51;
  --border: #e3e8f2;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

header {
  text-align: center;
  padding: 28px 16px 8px;
}
header h1 { margin: 0; font-size: 1.9rem; }
.subtitle { color: var(--muted); margin: 4px 0 0; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- dropzone ---------- */
.dropzone {
  background: var(--card);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.dropzone:hover, .dropzone:focus { background: #eef2ff; }
.dropzone.dragover {
  background: #e4ebff;
  border-color: var(--accent-dark);
  transform: scale(1.01);
}
.dz-icon { font-size: 2.6rem; }
.dz-hint { color: var(--muted); margin: 4px 0 0; font-size: .9rem; }

.progress {
  margin-top: 14px;
  font-size: .95rem;
  color: var(--accent-dark);
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(30, 36, 51, .05);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.card-head h2 { margin: 0; font-size: 1.15rem; }
.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: .75rem;
  padding: 2px 9px;
  vertical-align: middle;
}

/* ---------- file list ---------- */
.file-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}
.file-item:last-child { margin-bottom: 0; }
.file-name { font-weight: 600; }
.file-meta { color: var(--muted); font-size: .85rem; }
.file-columns { color: var(--muted); font-size: .8rem; margin-top: 3px; }
.file-preview {
  border-top: 1px dashed var(--border);
  margin-top: 10px;
  padding-top: 10px;
}
.pivot-box {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.pivot-box h4 { margin: 0 0 8px; font-size: .95rem; }

.wiz-step { padding: 4px 0; }
.wiz-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.wiz-stepno {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.wiz-bar {
  flex: 1;
  height: 6px;
  background: #e8ecf6;
  border-radius: 999px;
  overflow: hidden;
}
.wiz-bar div {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .25s;
}
.wiz-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.wiz-opt { text-align: left; max-width: 100%; }
.sheet-chip { margin-top: 6px; font-size: .85rem; }
.mini-badge {
  display: inline-block;
  background: #eef2ff;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: .72rem;
  margin-left: 4px;
}
.file-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: .9rem;
  cursor: pointer;
  background: #eef1f8;
  color: var(--ink);
  transition: background .15s;
}
.btn:hover { background: #e2e7f3; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.small { padding: 4px 10px; font-size: .8rem; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--err); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- presets ---------- */
.presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.preset {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  font-family: inherit;
}
.preset:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(79, 109, 245, .13);
  border-color: var(--accent);
}
.preset-icon { font-size: 1.7rem; }
.preset-name { font-weight: 700; font-size: 1.02rem; }
.preset-desc { color: var(--muted); font-size: .84rem; }
.preset:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- result ---------- */
#result-body { font-size: .93rem; }
.sprava {
  background: #eef7f1;
  border-left: 4px solid var(--ok);
  padding: 10px 14px;
  border-radius: 8px;
  margin: 10px 0;
}
.group-card, .analyza-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0;
}
.group-card h4, .analyza-card h4 { margin: 0 0 6px; }
.klarita { font-size: .78rem; color: var(--muted); }

table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: .85rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 5px 9px;
  text-align: left;
}
th { background: #f0f3fa; }
tr:nth-child(even) td { background: #fafbff; }

.download-link {
  display: inline-block;
  margin-top: 8px;
  background: var(--ok);
  color: #fff;
  padding: 8px 14px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 600;
}
.download-link:hover { filter: brightness(1.08); }

ul.kroky { padding-left: 20px; }
ul.kroky li { margin: 5px 0; }

/* ---------- bars & inputs ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 10px 0; }
label.check input { width: auto; }
textarea, input[type="text"], select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: .92rem;
  background: #fff;
}
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.row { display: flex; gap: 10px; margin-top: 10px; align-items: center; }
.row select { flex: 1; }
.hint { color: var(--muted); font-size: .83rem; margin-top: 8px; }

/* ---------- states ---------- */
.hidden { display: none !important; }

.error {
  background: #fdeef0;
  border: 1px solid var(--err);
  color: var(--err);
  border-radius: 10px;
  padding: 12px 16px;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-dark);
  font-weight: 600;
  padding: 8px 2px;
}
.spinner {
  width: 20px; height: 20px;
  border: 3px solid #c9d4ff;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  padding: 14px;
}

@media (max-width: 640px) {
  .file-item { flex-direction: column; }
}
