:root {
    --bg: #f5f5f5;
    --bg-elev: #fafafa;
    --card: #ffffff;
    --card-hover: #fafafa;
    --border: #e5e5e5;
    --border-strong: #d4d4d4;
    --red: #c62828;
    --red-hover: #a51e1e;
    --red-soft: #d32f2f;
    --red-glow: rgba(198, 40, 40, .2);
    --text: #1a1a1a;
    --text-muted: #555;
    --text-dim: #8a8a8a;
    --white: #ffffff;
    --black: #0d0d0d;
    --ok: #2e7d32;
    --warn: #e65100;
    --err: #c62828;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.container-narrow { max-width: 440px; margin: 0 auto; padding: 4rem 1.5rem; }

/* Header */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); margin-bottom: 2rem;
}
.app-logo {
    display: flex; align-items: center; gap: .75rem;
    font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; color: var(--text);
}
.app-logo::before { content: ""; width: 8px; height: 32px; background: var(--red); border-radius: 2px; }
.app-logo span { color: var(--red); }
.app-user { display: flex; align-items: center; gap: 1rem; font-size: .9rem; color: var(--text-muted); }
.app-user strong { color: var(--text); font-weight: 600; }
.btn-logout {
    background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted);
    padding: .4rem .9rem; border-radius: var(--radius-sm); cursor: pointer;
    font-size: .85rem; font-family: inherit; transition: all .15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* Cards */
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.75rem; box-shadow: var(--shadow);
}
.card-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.card-title { margin: 0; font-size: 1.15rem; font-weight: 600; color: var(--text); }
.card-subtitle { margin: .25rem 0 0; font-size: .875rem; color: var(--text-muted); font-weight: 400; }

/* Forms */
label.field { display: block; margin-bottom: 1rem; }
label.field > span { display: block; margin-bottom: .5rem; font-size: .875rem; font-weight: 600; color: var(--text-muted); }
input[type=email], input[type=text], input[type=password], input[type=tel],
input[type=date], input[type=number], select, textarea {
    width: 100%; background: var(--white); border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); color: var(--text); padding: .7rem .9rem;
    font-size: 1rem; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-glow);
}
input::placeholder { color: var(--text-dim); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    background: var(--red); color: var(--white); border: none;
    padding: .75rem 1.5rem; border-radius: var(--radius-sm); cursor: pointer;
    font-size: .95rem; font-weight: 600; font-family: inherit;
    transition: all .15s; text-decoration: none;
}
.btn:hover { background: var(--red-hover); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--red); color: var(--red); background: transparent; }
.btn-sm { padding: .4rem .85rem; font-size: .82rem; }
.btn-danger { background: var(--err); }

/* OTP */
.otp-inputs { display: flex; gap: .5rem; justify-content: center; margin: 1.5rem 0; }
.otp-inputs input {
    width: 52px; height: 64px; text-align: center;
    font-size: 1.75rem; font-weight: 700; padding: 0; color: var(--text);
}
.otp-inputs input:focus { transform: scale(1.03); }

/* Alerts */
.alert {
    padding: 1rem 1.25rem; border-radius: var(--radius-sm);
    margin: 1rem 0; border-left: 4px solid; font-size: .92rem;
}
.alert-info { background: #e8eaf6; border-color: #3f51b5; color: #1a237e; }
.alert-ok { background: #e8f5e9; border-color: var(--ok); color: #1b5e20; }
.alert-warn { background: #fff3e0; border-color: var(--warn); color: #bf360c; }
.alert-err { background: #ffebee; border-color: var(--err); color: #b71c1c; }
.alert-legal {
    background: #fafafa; border-color: var(--black);
    color: var(--text-muted); font-size: .82rem; line-height: 1.65;
}
.alert-legal strong { color: var(--text); }

/* Badge */
.badge {
    display: inline-block; padding: .15rem .55rem; border-radius: 3px;
    font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.badge-ok { background: #e8f5e9; color: #2e7d32; }
.badge-warn { background: #fff3e0; color: #e65100; }
.badge-err { background: #ffebee; color: #c62828; }
.badge-gray { background: #eeeeee; color: #555; }

/* Nagrania */
.recording-list { display: flex; flex-direction: column; gap: 1rem; }
.recording-item {
    display: grid; grid-template-columns: 180px 1fr auto; gap: 1.25rem;
    align-items: center; padding: 1rem; background: var(--bg-elev);
    border: 1px solid var(--border); border-radius: var(--radius);
    transition: all .2s; cursor: pointer; text-decoration: none; color: inherit;
}
.recording-item:hover { border-color: var(--red); background: var(--card-hover); box-shadow: var(--shadow-md); }
.recording-thumb {
    position: relative; aspect-ratio: 16/9;
    background: linear-gradient(135deg, #e8e8e8 0%, #d4d4d4 100%);
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.recording-thumb::before { content: "▶"; font-size: 2rem; color: var(--red); opacity: .85; transition: transform .2s; }
.recording-item:hover .recording-thumb::before { transform: scale(1.15); }
.recording-duration {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,.75); color: var(--white);
    padding: 2px 6px; border-radius: 3px; font-size: .72rem; font-weight: 600;
}
.recording-info h4 { margin: 0 0 .35rem; font-size: 1rem; font-weight: 600; color: var(--text); }
.recording-info p { margin: 0; font-size: .85rem; color: var(--text-muted); }
.recording-meta { display: flex; gap: .75rem; margin-top: .5rem; font-size: .78rem; color: var(--text-dim); }

/* Materiały */
.materials-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem; margin-top: 1rem;
}
.material-card {
    display: flex; align-items: center; gap: .9rem; padding: 1rem;
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: var(--radius); transition: all .15s; text-decoration: none; color: inherit;
}
.material-card:hover { border-color: var(--red); background: var(--card); box-shadow: var(--shadow); }
.material-icon {
    width: 40px; height: 40px; background: #ffebee; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .75rem; color: var(--red); flex-shrink: 0;
}
.material-info { min-width: 0; }
.material-info h5 { margin: 0; font-size: .9rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-info small { color: var(--text-dim); font-size: .78rem; }

/* Player */
.player-container {
    position: relative; aspect-ratio: 16/9; background: #000;
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border); box-shadow: var(--shadow-md);
}
.player-placeholder {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, #2a2a2a 0%, #000 100%); gap: 1rem;
}
.player-play {
    width: 80px; height: 80px; border-radius: 50%; background: var(--red);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: var(--white); cursor: pointer;
    transition: transform .2s, background .2s; padding-left: 6px;
    box-shadow: 0 8px 32px var(--red-glow); border: none;
}
.player-play:hover { transform: scale(1.08); background: var(--red-hover); }
.player-label { color: #ccc; font-size: .9rem; }

/* Watermark */
.watermark {
    position: absolute; font-size: .62rem; color: rgba(255,255,255,.10);
    font-family: monospace; letter-spacing: .02em; pointer-events: none; user-select: none;
    white-space: nowrap; animation: watermarkDrift 32s linear infinite; z-index: 5; font-weight: 400;
}
.watermark-2 {
    font-size: .55rem; color: rgba(255,255,255,.07);
    animation-duration: 48s; animation-direction: reverse;
}
@keyframes watermarkDrift {
    0%   { top: 12%; left: 8%;  }
    25%  { top: 12%; left: 62%; }
    50%  { top: 78%; left: 62%; }
    75%  { top: 78%; left: 8%;  }
    100% { top: 12%; left: 8%;  }
}

/* Admin */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; }
.admin-sidebar { position: sticky; top: 5rem; align-self: start; }
.admin-sidebar nav { display: flex; flex-direction: column; gap: .25rem; }
.admin-sidebar a {
    display: flex; align-items: center; gap: .75rem; padding: .65rem 1rem;
    color: var(--text-muted); text-decoration: none; border-radius: var(--radius-sm);
    font-size: .92rem; transition: all .15s; border-left: 3px solid transparent;
}
.admin-sidebar a:hover { background: var(--card); color: var(--text); }
.admin-sidebar a.active { background: #ffebee; color: var(--red); border-left-color: var(--red); font-weight: 600; }

/* Tabela */
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: 1rem; }
table.data th {
    text-align: left; padding: .75rem 1rem; border-bottom: 2px solid var(--border-strong);
    font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-dim); font-weight: 700;
}
table.data td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:hover td { background: var(--bg-elev); }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions button {
    background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted);
    padding: .3rem .6rem; border-radius: 3px; cursor: pointer; font-size: .78rem;
    font-family: inherit; margin-left: .25rem; transition: all .15s;
}
table.data td.actions button:hover { border-color: var(--red); color: var(--red); }

/* Stats */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--red);
    border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow);
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 700; margin-bottom: .35rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-sub { font-size: .82rem; color: var(--text-muted); margin-top: .35rem; }

/* Login */
.login-hero { text-align: center; margin-bottom: 2rem; }
.login-hero .logo {
    display: inline-flex; align-items: center; gap: .75rem;
    font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .5rem; color: var(--text);
}
.login-hero .logo::before { content: ""; width: 10px; height: 40px; background: var(--red); border-radius: 2px; }
.login-hero .logo span { color: var(--red); }
.login-hero p { color: var(--text-muted); font-size: .92rem; margin: 0; }

/* Toolbar */
.toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.toolbar input[type=text] { max-width: 300px; }

/* Chip */
.chip {
    display: inline-block; padding: .2rem .55rem; background: var(--bg-elev);
    border: 1px solid var(--border-strong); border-radius: 12px;
    font-size: .75rem; color: var(--text-muted); margin-right: .35rem;
}
.chip-red { background: #ffebee; border-color: #ffcdd2; color: var(--red); }

/* Legal */
.legal-footer {
    margin-top: 2rem; padding: 1.5rem; background: #fafafa;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: .78rem; line-height: 1.7; color: var(--text-muted);
}
.legal-footer h4 {
    margin: 0 0 .5rem; font-size: .78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em; color: var(--text);
    display: flex; align-items: center; gap: .4rem;
}
.legal-footer h4::before { content: "©"; color: var(--red); font-size: 1rem; }
.legal-footer p { margin: 0 0 .5rem; }
.legal-footer p:last-child { margin-bottom: 0; }
.legal-footer strong { color: var(--text); font-weight: 600; }

/* Checkbox */
.checkbox {
    display: flex; align-items: flex-start; gap: .6rem; padding: .75rem;
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: var(--radius-sm); margin-bottom: .75rem; cursor: pointer;
}
.checkbox input { margin-top: .25rem; width: auto; }
.checkbox span { font-size: .9rem; color: var(--text); flex: 1; }

/* Responsive */
@media (max-width: 800px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; }
    .admin-sidebar nav { flex-direction: row; overflow-x: auto; }
    .admin-sidebar a { white-space: nowrap; }
    .recording-item { grid-template-columns: 100px 1fr; }
    .recording-item > :last-child { grid-column: 1 / -1; }
    .otp-inputs input { width: 44px; height: 56px; font-size: 1.5rem; }
    .app-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
    .row, .row-3 { grid-template-columns: 1fr; }
}