:root {
    --p-accent: #a259ff;
    --p-blue: #1cb5e0;
    --p-green: #59b43f;
    --p-red: #ff4d6d;
    --p-amber: #ffb020;
    --p-bg: #0b0f1a;
    --p-surface: #141a2c;
    --p-surface-alt: #1a2138;
    --p-border: #2a3352;
    --p-text: #e8ecf5;
    --p-muted: #8a93ad;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--p-bg);
    color: var(--p-text);
    -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

a { color: inherit; }

button {
    font-family: inherit;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    color: var(--p-text);
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: 8px;
    padding: 9px 11px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--p-accent);
}

/* ---------------- LOGIN ---------------- */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 360px;
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: 16px;
    padding: 32px 28px;
}

.login-box h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

.login-box .login-sub {
    color: var(--p-muted);
    font-size: 13px;
    margin: 0 0 24px;
}

.login-box label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--p-muted);
    margin: 14px 0 6px;
}

.login-box input {
    width: 100%;
}

.login-box .btn-primary {
    width: 100%;
    margin-top: 22px;
}

.login-error {
    margin-top: 14px;
    color: var(--p-red);
    font-size: 13px;
}

/* ---------------- SHELL / LAYOUT ---------------- */

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex: 0 0 auto;
    background: var(--p-surface);
    border-right: 1px solid var(--p-border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-weight: 800;
    font-size: 17px;
    padding: 6px 10px 22px;
    background: linear-gradient(90deg, var(--p-blue), var(--p-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 9px;
    color: var(--p-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.nav-link:hover { background: var(--p-surface-alt); color: var(--p-text); }

.nav-link.is-active {
    background: linear-gradient(90deg, rgba(28,181,224,0.18), rgba(162,89,255,0.18));
    color: var(--p-text);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--p-border);
}

.btn-logout {
    width: 100%;
    background: transparent;
    border: 1px solid var(--p-border);
    color: var(--p-muted);
    border-radius: 9px;
    padding: 9px;
    font-size: 13px;
    font-weight: 600;
}

.btn-logout:hover { color: var(--p-red); border-color: var(--p-red); }

.main {
    flex: 1;
    min-width: 0;
    padding: 28px 32px 60px;
}

.page-title {
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 22px;
}

/* ---------------- COMMON UI ---------------- */

.btn {
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 700;
    background: var(--p-surface-alt);
    color: var(--p-text);
    border: 1px solid var(--p-border);
}

.btn:hover { border-color: var(--p-muted); }

.btn-primary {
    background: linear-gradient(90deg, var(--p-blue), var(--p-accent));
    color: #fff;
    border: none;
}

.btn-danger { color: var(--p-red); border-color: rgba(255,77,109,0.4); }
.btn-danger:hover { background: rgba(255,77,109,0.1); }

.btn-sm { padding: 6px 10px; font-size: 12px; }

.cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: 14px;
    padding: 18px 20px;
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 800;
}

.stat-card .stat-label {
    color: var(--p-muted);
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
}

.panel-block {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: 14px;
    padding: 18px 20px;
}

.panel-block h2 {
    font-size: 15px;
    margin: 0 0 12px;
}

.recent-row {
    display: flex;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid var(--p-border);
    font-size: 13px;
}

.recent-row:last-child { border-bottom: none; }
.recent-row .rr-date { color: var(--p-muted); }

/* ---------------- TOOLBAR / SEARCH ---------------- */

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar input[type="text"], .toolbar select {
    min-width: 220px;
}

.toolbar .spacer { flex: 1; }

/* ---------------- TABLE ---------------- */

.table-wrap {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: 14px;
    overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--p-muted);
    background: var(--p-surface-alt);
    border-bottom: 1px solid var(--p-border);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--p-border);
    vertical-align: top;
}

tr:last-child td { border-bottom: none; }

tr.is-clickable { cursor: pointer; }
tr.is-clickable:hover td { background: var(--p-surface-alt); }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.badge-green { background: rgba(89,180,63,0.15); color: var(--p-green); }
.badge-red { background: rgba(255,77,109,0.15); color: var(--p-red); }

.row-actions { display: flex; gap: 6px; }

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--p-muted);
    font-size: 13px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    padding: 16px;
    font-size: 13px;
    color: var(--p-muted);
}

/* ---------------- DRAWER (edycja) ---------------- */

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: flex-end;
    z-index: 50;
}

.drawer {
    width: 100%;
    max-width: 560px;
    height: 100%;
    background: var(--p-surface);
    border-left: 1px solid var(--p-border);
    padding: 24px 26px;
    overflow-y: auto;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.drawer-header h2 { margin: 0; font-size: 18px; }

.drawer-close {
    background: none;
    border: none;
    color: var(--p-muted);
    font-size: 20px;
    line-height: 1;
    padding: 4px;
}

.field-group { margin-bottom: 16px; }

.field-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--p-muted);
    margin-bottom: 6px;
}

.field-group input, .field-group select, .field-group textarea { width: 100%; }

.field-group textarea { resize: vertical; min-height: 90px; }

.field-list-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.field-list-row input { flex: 1; }

.field-list-row .btn-sm { flex: 0 0 auto; }

.section-heading {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--p-muted);
    margin: 22px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--p-border);
}

.section-heading:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.offer-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 8px 10px;
    align-items: center;
    margin-bottom: 8px;
}

.offer-grid .offer-portal-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--p-text);
}

.drawer-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--p-border);
}

.drawer-actions .btn-primary { flex: 1; }

/* ---------------- OPINIONS ---------------- */

.opinion-card {
    background: var(--p-surface);
    border: 1px solid var(--p-border);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 12px;
}

.opinion-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.opinion-meta { font-size: 12px; color: var(--p-muted); margin-top: 4px; }
.opinion-product { font-size: 12px; color: var(--p-blue); font-weight: 700; margin-bottom: 4px; }
.opinion-text { font-size: 14px; margin: 10px 0; white-space: pre-wrap; }
.opinion-nick { font-weight: 700; }
.opinion-avg { color: var(--p-accent); font-weight: 700; }

.opinion-comments {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--p-border);
}

.comment-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    padding: 6px 0;
    color: var(--p-muted);
}

.comment-row strong { color: var(--p-text); }

.opinion-edit-box textarea { width: 100%; margin-top: 8px; }
.opinion-edit-box input { width: 100%; margin-top: 8px; }

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--p-surface-alt);
    border: 1px solid var(--p-border);
    color: var(--p-text);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 100;
}

.toast.is-error { border-color: var(--p-red); color: var(--p-red); }

.loading-state { padding: 40px; text-align: center; color: var(--p-muted); }

@media (max-width: 720px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 14px; }
    .sidebar-logo { display: none; }
    .nav-link { padding: 8px 10px; font-size: 13px; }
    .sidebar-footer { margin-top: 0; margin-left: auto; border-top: none; padding-top: 0; }
    .main { padding: 18px; }
    .drawer { max-width: 100%; }
}
