:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #1f2933;
    --muted: #7b8794;
    --line: #e4e7eb;
    --primary: #1f6feb;
    --primary-ink: #ffffff;
    --danger: #d64545;
    --ok: #2f9e44;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

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

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

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 0 24px;
    height: 56px;
    box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 18px; color: var(--ink); }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a { color: var(--ink); font-size: 14px; }
.user-box { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.user-box form { margin: 0; }

/* Layout */
.container { max-width: 1080px; margin: 28px auto; padding: 0 24px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }

.page-head { display: flex; justify-content: space-between; align-items: center; }

/* Cards / panels */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel, .form-card, .auth-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.panel .row {
    display: flex; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.panel .row:last-child { border-bottom: 0; }

/* Auth */
.auth-card { max-width: 380px; margin: 8vh auto; }
.auth-card h1 { margin-bottom: 4px; }
.btn-block { width: 100%; }

/* Forms */
label { display: block; margin: 14px 0 4px; font-size: 14px; font-weight: 600; }
label.checkbox { font-weight: 400; display: flex; align-items: center; gap: 8px; }
input[type=text], input[type=email], input[type=password], select {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: 7px;
    font-size: 14px; background: #fff;
}
.form-card { max-width: 520px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* Buttons */
.btn {
    display: inline-block; cursor: pointer;
    padding: 9px 16px; border-radius: 7px;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    font-size: 14px; font-weight: 600;
}
.btn:hover { text-decoration: none; background: #f0f2f5; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { background: #1a5fd0; }
.btn-link { border: 0; background: none; padding: 0; color: var(--primary); }
.btn-danger { color: var(--danger); }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: #fff;
    border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 12px; align-items: center; }
.actions form { margin: 0; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-admin { background: #e7f0ff; color: var(--primary); }
.badge-ok { background: #e6f4ea; color: var(--ok); }
.badge-off { background: #fdecec; color: var(--danger); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: #e6f4ea; color: #1b6b32; }
.alert-error { background: #fdecec; color: #9b2c2c; }

/* Filter */
.filter { margin-bottom: 16px; }
.filter select { max-width: 280px; display: inline-block; width: auto; }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 18px; }
.pagination a, .pagination span {
    padding: 6px 11px; border: 1px solid var(--line); border-radius: 7px;
    background: #fff; font-size: 14px; color: var(--ink);
}
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--muted); }

/* Catalog */
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-row input[type=text] { flex: 1; min-width: 220px; width: auto; }
.filter-row select { width: auto; }
.result-count { margin: 6px 0 16px; }

.product-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.product-card {
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    overflow: hidden; box-shadow: var(--shadow); color: var(--ink);
    display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s;
}
.product-card:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-2px); }
.thumb { position: relative; aspect-ratio: 1/1; background: #f7f8fa; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb-empty { color: var(--muted); font-size: 13px; }
.thumb-empty.big { aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); border-radius: 10px; }
.card-flag { position: absolute; top: 8px; left: 8px; }
.card-flag-r { left: auto; right: 8px; }
.product-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.product-title { font-weight: 600; font-size: 14px; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-sku { font-size: 12px; }
.product-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.price { font-weight: 700; color: var(--ink); }

.chip { display: inline-block; background: #eef1f5; color: #4a5568; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.chip-sm { font-size: 11px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.badge-warn { background: #fff4e5; color: #b25e09; }

.pagination-wrap { display: flex; justify-content: center; }

/* Detail */
.detail { display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start; margin-bottom: 20px; }
.detail-media img { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.detail-info h1 { margin-bottom: 10px; }
.detail-badges { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; width: 130px; color: var(--muted); font-weight: 600; padding: 6px 0; vertical-align: top; font-size: 14px; }
.kv td { padding: 6px 0; font-size: 14px; }
.panel-warn { border-color: #f0c98a; background: #fffaf2; }
.panel { margin-top: 18px; }

/* Attributes */
.attr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.attr { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; }
.attr span { font-size: 12px; }
.attr strong { font-size: 14px; }
.feat-line { font-size: 12px; margin-top: 2px; }

/* Vision / profile */
.vision-row { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.profile-img { flex: 0 0 280px; }
.profile-img img { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.vision-info { flex: 1; min-width: 280px; }
.vision-info .kv th { width: 130px; }

/* Feature comparison chips */
.cmp { display: flex; flex-wrap: wrap; gap: 5px; }
.cmp-chip { font-size: 12px; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.cmp-ok { background: #e6f4ea; color: #1b6b32; }
.cmp-no { background: #f3f4f6; color: #98a2b3; }

/* Matches / recommendation */
.reco { display: flex; flex-wrap: wrap; gap: 24px; align-items: center;
    padding: 14px 18px; border-radius: 10px; margin-bottom: 16px; border: 1px solid var(--line); }
.reco-high { background: #fdecec; border-color: #f0bcbc; }
.reco-low  { background: #e6f4ea; border-color: #abdcb8; }
.reco-ok   { background: #eef4ff; border-color: #c2d6f5; }
.reco-num { display: flex; flex-direction: column; }
.reco-num strong { font-size: 18px; }
.reco-msg { flex: 1; min-width: 220px; font-size: 14px; }
.delta-pos { color: var(--danger); font-weight: 600; }
.delta-neg { color: var(--ok); font-weight: 600; }
.row-muted { opacity: .55; }

/* Competitors */
.comp-card .product-body { gap: 8px; padding: 16px 18px; }
.comp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.comp-stats { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.comp-stats strong { font-size: 20px; }
.comp-date { font-size: 12px; margin-top: 4px; }
.cell-thumb { width: 48px; }
.cell-thumb img { width: 40px; height: 40px; object-fit: contain; background: #f7f8fa; border-radius: 4px; }
.nowrap { white-space: nowrap; }

/* Grupy podobnych produktów */
.group-block { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 14px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.group-head h3 { margin: 0; font-size: 15px; color: var(--ink); }
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.gcard { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px;
    overflow: hidden; background: #fff; color: var(--ink); }
.gcard:hover { text-decoration: none; box-shadow: 0 3px 10px rgba(0,0,0,.10); transform: translateY(-1px); }
.gthumb { aspect-ratio: 1/1; background: #f7f8fa; display: flex; align-items: center; justify-content: center; }
.gthumb img { width: 100%; height: 100%; object-fit: contain; }
.gcard-body { padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; }
.gtitle { font-size: 11px; line-height: 1.25; max-height: 42px; overflow: hidden; }
.gmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; justify-content: space-between; }
.gprice { font-size: 12px; font-weight: 700; }

@media (max-width: 720px) {
    .grid { grid-template-columns: 1fr; }
    .nav { display: none; }
    .detail { grid-template-columns: 1fr; }
}
