/* Variables */
:root {
  --bg:#f1f5f9; --surface:#fff; --surface-2:#f8fafc; --border:#e2e8f0;
  --text:#0f172a; --muted:#64748b;
  --primary:#2563eb; --primary-h:#1d4ed8;
  --success:#16a34a; --success-h:#15803d;
  --danger:#dc2626;  --danger-h:#b91c1c;
  --warning:#d97706; --warning-h:#b45309;
  --info:#0284c7;    --info-h:#0369a1;
  --shadow-sm:0 1px 2px rgba(0,0,0,.06);
  --shadow:0 1px 3px rgba(0,0,0,.1),0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:0 10px 25px rgba(0,0,0,.1),0 4px 10px rgba(0,0,0,.05);
  --radius:.5rem; --radius-sm:.25rem; --radius-lg:.75rem;
}
.dark-mode {
  --bg:#0f172a; --surface:#1e293b; --surface-2:#172033;
  --border:#334155; --text:#f1f5f9; --muted:#94a3b8;
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:16px}
body{font-family:"Inter",system-ui,-apple-system,sans-serif;font-size:.9rem;line-height:1.5;background-color:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;transition:background-color .2s,color .2s}
a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}
h2{font-size:1.05rem;font-weight:600;color:var(--text);margin-bottom:1rem}

/* Header */
#header{position:sticky;top:0;z-index:40;width:100%;height:60px;background:var(--surface);border-bottom:1px solid var(--border);box-shadow:var(--shadow-sm);display:flex;align-items:center;padding:0 1.5rem;gap:1.25rem}
#powitanie{font-size:.95rem;font-weight:600;color:var(--text);white-space:nowrap;flex:0 0 auto}
#zajetosc{flex:1;min-width:0}
#proccesbackground{display:flex;align-items:center;height:18px;background:var(--border);border-radius:999px;overflow:hidden;width:100%}
#procces{height:100%;background:linear-gradient(90deg,#16a34a,#22c55e);display:flex;align-items:center;justify-content:center;font-size:.68rem;font-weight:600;color:#fff;white-space:nowrap;overflow:hidden;min-width:0;transition:width .4s ease}
#wolne{flex:1;font-size:.68rem;color:var(--muted);padding:0 .4rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#storage-labels{display:flex;justify-content:space-between;font-size:.65rem;color:var(--muted);margin-top:2px}
#darkmodediv{display:flex;align-items:center;gap:.45rem;font-size:.8rem;color:var(--muted);flex:0 0 auto;margin-left:auto}
#wylogujdiv{flex:0 0 auto}

/* Main */
#main-content{width:960px;max-width:100%;margin:2rem auto;padding:0 1.25rem;display:flex;flex-direction:column;gap:1.5rem}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.5rem;box-shadow:var(--shadow);overflow-x:auto}

/* Forms */
label{display:block;font-size:.8rem;font-weight:500;color:var(--muted);margin-bottom:.3rem}
input[type="text"],input[type="password"],select{width:100%;padding:.48rem .75rem;font-size:.88rem;font-family:inherit;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);outline:none;transition:border-color .15s,box-shadow .15s}
select{appearance:none;padding-right:2.2rem;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right .6rem center;cursor:pointer}
input:focus,select:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(37,99,235,.15)}
.form-row{display:flex;gap:1rem;align-items:flex-end;flex-wrap:wrap}
.form-group{display:flex;flex-direction:column;flex:1;min-width:160px}

/* Buttons */
button{display:inline-flex;align-items:center;justify-content:center;padding:.48rem 1.1rem;font-size:.85rem;font-family:inherit;font-weight:500;border-radius:var(--radius);border:1px solid var(--success);background:var(--success);color:#fff;cursor:pointer;transition:background .15s,border-color .15s,transform .1s;white-space:nowrap;line-height:1.4;height:auto}
button:hover{background:var(--success-h);border-color:var(--success-h)}
button:active{transform:scale(.97)}
.btn-primary{background:var(--primary);border-color:var(--primary)}
.btn-primary:hover{background:var(--primary-h);border-color:var(--primary-h)}
.btn-danger{background:var(--danger);border-color:var(--danger)}
.btn-danger:hover{background:var(--danger-h);border-color:var(--danger-h)}
.btn-warning{background:var(--warning);border-color:var(--warning)}
.btn-warning:hover{background:var(--warning-h);border-color:var(--warning-h)}
.btn-info{background:var(--info);border-color:var(--info)}
.btn-info:hover{background:var(--info-h);border-color:var(--info-h)}
.btn-ghost{background:transparent;color:var(--muted);border-color:var(--border)}
.btn-ghost:hover{background:var(--surface-2);color:var(--text)}
.btn-sm{padding:.28rem .65rem;font-size:.78rem}
#wyloguj{background:transparent;color:var(--muted);border-color:var(--border)}
#wyloguj:hover{background:var(--danger);color:#fff;border-color:var(--danger)}

/* Login */
.login-wrapper{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--bg)}
.login-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);padding:2.5rem 2rem;width:100%;max-width:360px}
.login-card h1{font-size:1.3rem;font-weight:700;color:var(--text);margin-bottom:.2rem}
.login-subtitle{font-size:.82rem;color:var(--muted);margin-bottom:1.75rem}
.login-card .form-group{margin-bottom:1rem}
.login-card button[type="submit"]{width:100%;margin-top:.5rem;background:var(--primary);border-color:var(--primary);padding:.55rem;font-size:.88rem}
.login-card button[type="submit"]:hover{background:var(--primary-h);border-color:var(--primary-h)}
#loginerror{display:none;margin-top:.75rem;padding:.55rem .75rem;background:#fef2f2;color:var(--danger);border:1px solid #fecaca;border-radius:var(--radius);font-size:.8rem;text-align:center}
.login-dark-toggle{position:fixed;top:1rem;right:1.25rem;display:flex;align-items:center;gap:.5rem;font-size:.8rem;color:var(--muted)}

/* Table */
#containerstable{width:100%;border-collapse:collapse;font-size:.87rem}
#containerstable th{background:var(--surface-2);color:var(--muted);font-weight:600;font-size:.75rem;text-transform:uppercase;letter-spacing:.05em;padding:.6rem .9rem;border-bottom:2px solid var(--border);text-align:left;cursor:pointer;user-select:none;white-space:nowrap}
#containerstable th:hover{color:var(--text)}
#containerstable td{padding:.6rem .9rem;border-bottom:1px solid var(--border);vertical-align:middle;color:var(--text);white-space:nowrap}
#containerstable tr:last-child td{border-bottom:none}
#containerstable tbody tr:hover{background:var(--surface-2)}
.names{font-weight:500}
.badge{display:inline-block;border-radius:999px;padding:.15rem .6rem;font-size:.75rem;font-weight:600;white-space:nowrap}
.badge-on{color:#15803d;background:#dcfce7}
.badge-off{color:var(--muted);background:var(--surface-2);border:1px solid var(--border)}
.table-actions{display:flex;gap:.35rem;align-items:center;white-space:nowrap}
#containerstable td form{display:contents}

/* Modal */
#bcg{display:none;position:fixed;inset:0;background:rgba(0,0,0,.45);backdrop-filter:blur(3px);z-index:50}
#modal{display:none;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);width:460px;max-width:95vw;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);z-index:99;overflow:hidden}
.details-modal-title{padding:1.1rem 1.5rem;border-bottom:1px solid var(--border);background:var(--surface-2)}
.h1{font-size:1rem;font-weight:700;color:var(--text)}
.details-modal-content{padding:1.25rem 1.5rem 1.5rem;font-size:.87rem;color:var(--muted);line-height:1.6}
.details-modal-content input[type="text"]{margin:.75rem 0 1rem}
.modal-actions{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin-top:1rem}

/* Toggle switch */
.switch{position:relative;display:inline-block;width:40px;height:22px}
.switch input{opacity:0;width:0;height:0}
.slider{position:absolute;cursor:pointer;inset:0;background:var(--border);border-radius:999px;transition:background .2s}
.slider::before{content:"";position:absolute;height:16px;width:16px;left:3px;bottom:3px;background:#fff;border-radius:50%;transition:transform .2s;box-shadow:var(--shadow-sm)}
input:checked+.slider{background:var(--primary)}
input:checked+.slider::before{transform:translateX(18px)}

/* Console keyframes */
@keyframes consoleOverlayIn{from{opacity:0}to{opacity:1}}
@keyframes consoleOverlayOut{from{opacity:1}to{opacity:0}}
@keyframes consoleModalIn{from{opacity:0;transform:translateY(24px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}
@keyframes consoleModalOut{from{opacity:1;transform:translateY(0) scale(1)}to{opacity:0;transform:translateY(24px) scale(.97)}}
@keyframes consoleLine{from{opacity:0;transform:translateX(-6px)}to{opacity:1;transform:translateX(0)}}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}
@keyframes spin{to{transform:rotate(360deg)}}

/* Console overlay */
#console-overlay{position:fixed;inset:0;background:rgba(0,0,0,.55);backdrop-filter:blur(4px);z-index:200;display:flex;align-items:center;justify-content:center;visibility:hidden;opacity:0;pointer-events:none}
#console-overlay.active{visibility:visible;opacity:1;pointer-events:auto;animation:consoleOverlayIn .25s ease-out}
#console-overlay.closing{animation:consoleOverlayOut .2s ease-in forwards}
#console-overlay.active #console-modal{animation:consoleModalIn .3s cubic-bezier(.22,1,.36,1)}
#console-overlay.closing #console-modal{animation:consoleModalOut .2s ease-in forwards}
#console-modal{width:860px;max-width:95vw;height:75vh;background:#0d1117;border:1px solid #30363d;border-radius:var(--radius-lg);box-shadow:0 24px 48px rgba(0,0,0,.5);display:flex;flex-direction:column;overflow:hidden}
.console-header{display:flex;align-items:center;justify-content:space-between;padding:.6rem 1rem;background:#161b22;border-bottom:1px solid #30363d;flex-shrink:0}
.console-header span{font-size:.82rem;font-weight:600;color:#e6edf3;letter-spacing:.03em}
.console-header button{background:transparent;border:1px solid #30363d;color:#8b949e;padding:.22rem .7rem;font-size:.78rem;border-radius:var(--radius-sm);cursor:pointer;transition:background .15s,color .15s;height:auto}
.console-header button:hover{background:#21262d;color:#e6edf3;border-color:#8b949e}
.console-header button:disabled{opacity:.35;cursor:not-allowed}
.console-spinner{display:inline-block;width:12px;height:12px;border:2px solid #8b949e;border-top-color:#e6edf3;border-radius:50%;animation:spin .7s linear infinite;vertical-align:middle;margin-right:.3rem}
.console-spinner.done{display:none}
#consoleframe{flex:1;border:none;width:100%;background:#0d1117}

/* Console page content */
pre{margin:0;font:.9rem "Fira Code",Inconsolata,monospace;background:#0d1117;color:#e6edf3;min-height:100vh;padding:1.5rem;line-height:1.7}
.console-output{font:.9rem "Fira Code",Inconsolata,monospace;background:#0d1117;color:#e6edf3;padding:.25rem 1.5rem;line-height:1.7;white-space:pre-wrap;word-break:break-word}
.console-output:first-child{padding-top:1.25rem}
.console-output:last-child{padding-bottom:1.25rem;min-height:0}
.console-line{animation:consoleLine .25s ease-out both;padding:1px 0}
.cline-status{color:#58a6ff;padding-left:.5rem;border-left:2px solid #58a6ff}
.cline-detail{color:#8b949e;padding-left:1rem}
.cline-output{color:#e6edf3}
.cline-success{color:#4ade80;font-weight:600;padding-left:.5rem;border-left:2px solid #4ade80}
.cline-error{color:#f87171;font-weight:600;padding-left:.5rem;border-left:2px solid #f87171}
.cline-header{color:#c9d1d9;font-weight:700;padding-bottom:.25rem;margin-bottom:.25rem;border-bottom:1px solid #21262d}

/* Queue */
#queueStatus{display:flex;align-items:center;gap:.75rem;padding:1rem 1.5rem;font:.9rem "Fira Code",Inconsolata,monospace;color:#d2a8ff;background:#0d1117;animation:pulse 2s ease-in-out infinite}
#queueStatus::before{content:'';width:16px;height:16px;border:2px solid #d2a8ff;border-top-color:transparent;border-radius:50%;animation:spin .8s linear infinite;flex-shrink:0}

/* Pagination */
.pagination-bar{display:flex;align-items:center;justify-content:space-between;padding:.5rem 0;margin-top:.4rem;gap:.5rem;flex-wrap:wrap}
.pg-left,.pg-right{display:flex;align-items:center;gap:.3rem}
.pg-label{font-size:.78rem;color:var(--muted);margin-right:.15rem}
.pg-info{font-size:.78rem;color:var(--muted);padding:0 .4rem;min-width:3.5rem;text-align:center}
.pg-per.pg-active{background:var(--primary);border-color:var(--primary);color:#fff}
thead th[onclick]{cursor:pointer;user-select:none;white-space:nowrap}
thead th[onclick]:hover{color:var(--primary)}
thead th.sort-asc::after{content:" ▲";font-size:.6rem;opacity:.75}
thead th.sort-desc::after{content:" ▼";font-size:.6rem;opacity:.75}
