*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:       #0ea5e9;
    --blue-dark:  #0284c7;
    --blue-light: #e0f2fe;
    --bg:         #ffffff;
    --bg2:        #f8fafc;
    --bg3:        #f1f5f9;
    --border:     #e2e8f0;
    --text:       #0f172a;
    --muted:      #64748b;
}

html, body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg2);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

/* ── NAV ─────────────────────────────────────────────────────── */
.panel-nav {
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 12px rgba(0,0,0,.06);
    padding: .9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.panel-nav .nav-left { display: flex; align-items: center; gap: 2rem; }
.panel-nav img.logo { height: 34px; display: block; }
.panel-nav ul { display: flex; gap: 1.5rem; list-style: none; }
.panel-nav ul a { color: var(--text); font-weight: 600; font-size: .9rem; }
.panel-nav ul a:hover { color: var(--blue); }
.panel-nav .nav-right { display: flex; align-items: center; gap: 1rem; font-size: .88rem; color: var(--muted); }
.panel-nav .nav-right strong { color: var(--text); }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .8rem 2rem; border-radius: 8px;
    font-weight: 600; font-size: .95rem; text-decoration: none;
    transition: all .2s; cursor: pointer; border: none; font-family: inherit;
}
.btn-sm { padding: .5rem 1.1rem; font-size: .85rem; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 20px rgba(14,165,233,.25); }
.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 6px 28px rgba(14,165,233,.35); transform: translateY(-2px); color:#fff; }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); transform: translateY(-2px); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }

/* ── CARDS / PANELS ──────────────────────────────────────────── */
.card {
    background: var(--bg); border: 1.5px solid var(--border); border-radius: 14px;
    padding: 2rem; transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: rgba(14,165,233,.4); box-shadow: 0 8px 32px rgba(14,165,233,.1); }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-head h1 { font-size: 1.6rem; font-weight: 800; }
.page-wrap { padding: 2.5rem 0 4rem; }

/* ── FORMS ───────────────────────────────────────────────────── */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.field { margin-bottom: 1.2rem; }
input, textarea, select {
    background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px;
    padding: .8rem 1rem; color: var(--text); font-family: inherit; font-size: .9rem;
    transition: border-color .2s, box-shadow .2s; width: 100%;
}
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(14,165,233,.12);
}
textarea { resize: vertical; min-height: 120px; }
.auth-card { max-width: 400px; margin: 4rem auto; }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge { display: inline-block; padding: .25rem .7rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge--nowe       { background: var(--blue-light); color: var(--blue-dark); }
.badge--w_trakcie  { background: #fef3c7; color: #92400e; }
.badge--rozwiazane { background: #dcfce7; color: #166534; }
.badge--zamkniete  { background: var(--bg3); color: var(--muted); }
.badge--niski     { background: var(--bg3); color: var(--muted); }
.badge--sredni    { background: var(--blue-light); color: var(--blue-dark); }
.badge--wysoki    { background: #fed7aa; color: #9a3412; }
.badge--krytyczny { background: #fee2e2; color: #991b1b; }

/* ── TABLE ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; background: var(--bg); border-radius: 14px; overflow: hidden; border: 1.5px solid var(--border); }
table th, table td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .88rem; }
table th { color: var(--muted); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; background: var(--bg2); }
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--bg2); }
table a.row-link { color: var(--text); font-weight: 600; }
table a.row-link:hover { color: var(--blue); }
table tr.priority-krytyczny td:first-child { border-left: 4px solid #991b1b; }
table tr.priority-wysoki td:first-child { border-left: 4px solid #9a3412; }
table tr.priority-sredni td:first-child { border-left: 4px solid #0284c7; }
table tr.priority-niski td:first-child { border-left: 4px solid var(--border); }

/* ── STAT CARDS ──────────────────────────────────────────────── */
.stat-cards { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 130px; background: var(--bg); border: 1.5px solid var(--border); border-radius: 14px; padding: 1.1rem; text-align: center; }
.stat-card .num { font-size: 1.7rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: .4rem; }
.stat-card.stat-krytyczny .num { color: #991b1b; }

/* ── THREAD ──────────────────────────────────────────────────── */
.thread-msg { border: 1.5px solid var(--border); border-radius: 14px; padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.thread-msg--admin { background: var(--blue-light); border-color: rgba(14,165,233,.3); }
.thread-msg--client { background: var(--bg); }
.thread-msg .meta { font-size: .78rem; color: var(--muted); margin-bottom: .4rem; }
.thread-msg .meta strong { color: var(--text); }
.thread-msg .body { white-space: pre-wrap; font-size: .92rem; }

/* ── FLASH ───────────────────────────────────────────────────── */
.flash { padding: .9rem 1.2rem; border-radius: 10px; margin-bottom: 1.5rem; font-size: .9rem; font-weight: 600; }
.flash--success { background: #dcfce7; color: #166534; }
.flash--error { background: #fee2e2; color: #991b1b; }

/* ── FILTER BAR ──────────────────────────────────────────────── */
.filter-bar { display: flex; gap: .75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.filter-bar select { width: auto; min-width: 160px; }

.muted { color: var(--muted); }
.text-sm { font-size: .85rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }

@media (max-width: 700px) {
    .panel-nav ul { display: none; }

    table.cards-on-mobile { border: none; background: transparent; }
    table.cards-on-mobile thead { display: none; }
    table.cards-on-mobile tr {
        display: block; background: var(--bg); border: 1.5px solid var(--border);
        border-radius: 14px; margin-bottom: .9rem; padding: .4rem .2rem;
    }
    table.cards-on-mobile tr.priority-krytyczny { border-left: 4px solid #991b1b; }
    table.cards-on-mobile tr.priority-wysoki { border-left: 4px solid #9a3412; }
    table.cards-on-mobile tr.priority-sredni { border-left: 4px solid #0284c7; }
    table.cards-on-mobile tr.priority-niski { border-left: 4px solid var(--border); }
    table.cards-on-mobile td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        border-bottom: none; padding: .45rem .8rem; text-align: right;
    }
    table.cards-on-mobile td[data-label]::before {
        content: attr(data-label); font-size: .72rem; font-weight: 700; color: var(--muted);
        text-transform: uppercase; letter-spacing: .04em; text-align: left;
    }
    table.cards-on-mobile td:empty { display: none; }

    .stat-cards { gap: .6rem; }
    .stat-card { min-width: 100px; padding: .8rem; }
    .stat-card .num { font-size: 1.4rem; }
}
