:root {
  --accent: #4f46e5;
  --accent-ink: #fff;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e5ea;
  --text: #15171c;
  --muted: #6a7080;
  --danger: #d23b3b;
  --ok: #1f9d55;
  --warn: #c98a06;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1d2129;
    --border: #2a2f3a;
    --text: #e8eaf0;
    --muted: #9198a8;
    --danger: #f06363;
    --ok: #3cc47c;
    --warn: #e5ac2c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

/* ---------- elementy formularzy ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.field + .field { margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.big { padding: 13px 22px; font-size: 1.05rem; }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }

/* ---------- karty / tabele ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card.narrow { max-width: 460px; margin: 8vh auto 0; }
.card.center { text-align: center; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.empty { padding: 34px 10px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

.alert { padding: 11px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.alert.bad { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.alert.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.alert.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }

/* ---------- layout panelu ---------- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 1.05rem; }
.brand img { max-height: 30px; max-width: 120px; }
.brand .dot { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); flex: none; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.nav .sep { height: 1px; background: var(--border); margin: 10px 6px; }
.side .foot { margin-top: auto; padding: 10px; font-size: .85rem; color: var(--muted); }
.main { padding: 28px 32px 60px; max-width: 1100px; width: 100%; min-width: 0; }
.topline { margin-bottom: 18px; }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px; }
  .brand { padding: 4px 8px; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav .sep, .side .foot { display: none; }
  .main { padding: 18px 16px 50px; }
}

/* ---------- upload ---------- */
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 34px 18px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.drop .big { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.filelist { list-style: none; margin: 12px 0 0; padding: 0; max-height: 300px; overflow: auto; }
.filelist li { display: flex; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: .92rem; }
.filelist li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.progress.thin { height: 5px; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }

/* ---------- strony publiczne ---------- */
body.public { min-height: 100vh; display: flex; flex-direction: column; }
.pub-head { display: flex; align-items: center; gap: 10px; padding: 18px 24px; font-weight: 700; font-size: 1.05rem; }
.pub-head img { max-height: 34px; max-width: 160px; }
.pub-head .dot { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); }
.pub-main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 10px 16px 50px; }
.pub-foot { text-align: center; padding: 16px; font-size: .8rem; color: var(--muted); }
.files-pub { list-style: none; padding: 0; margin: 14px 0; }
.files-pub li { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.files-pub li .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.message { white-space: pre-line; background: var(--surface-2); border-radius: 8px; padding: 12px 14px; }
.big-ico { font-size: 2.4rem; line-height: 1; margin-bottom: 8px; }

/* ---------- toast / modal ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-weight: 600; z-index: 100; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--danger); color: #fff; }
.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 18, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; border: 1px solid var(--border); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 1.35rem; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 1px solid transparent; padding: 6px 12px; border-radius: 8px; font: inherit; color: var(--muted); cursor: pointer; font-weight: 600; }
.tabs button.active { border-color: var(--border); background: var(--surface); color: var(--text); }

/* ---------- podgląd / galeria ---------- */
.lb { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 80; display: flex; align-items: center; justify-content: center; }
.lb-stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 48px 56px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lb-audio { text-align: center; color: #fff; }
.lb-cap { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #ddd; font-size: .9rem; padding: 0 16px; overflow-wrap: anywhere; }
.lb-nav, .lb-close { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 99px; cursor: pointer; font: inherit; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 44px; height: 44px; font-size: 1.8rem; line-height: 1; }
.lb-prev { left: 10px; } .lb-next { right: 10px; }
.lb-close { top: 12px; right: 12px; width: 40px; height: 40px; font-size: 1.1rem; }
.lb-nav:hover, .lb-close:hover { background: rgba(255,255,255,.25); }
@media (max-width: 600px) { .lb-stage { padding: 52px 8px; } .lb-nav { top: auto; bottom: 44px; transform: none; } }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 14px 0; }
.gallery button { padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: var(--surface-2); cursor: pointer; position: relative; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .ico { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 2rem; }
.gallery .tag { position: absolute; bottom: 4px; left: 4px; right: 4px; font-size: .7rem; color: #fff; background: rgba(0,0,0,.55); border-radius: 4px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.files-pub li input[type=checkbox], .sel { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.files-pub .ficon { width: 1.4em; text-align: center; flex: none; }
.selbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 2px 0; }

/* ---------- akceptacja ---------- */
.approval { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }

/* ---------- wykres dysku / limity ---------- */
.diskbar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.diskbar > div { height: 100%; }
.diskbar .ours { background: var(--accent); }
.diskbar .other { background: color-mix(in srgb, var(--muted) 55%, transparent); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .ours { background: var(--accent); } .legend .other { background: color-mix(in srgb, var(--muted) 55%, transparent); } .legend .free { background: var(--surface-2); border: 1px solid var(--border); }
.quota { min-width: 140px; }
.quota .progress { margin-top: 4px; }
.progress.over > div { background: var(--danger); }
.audit-details { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; max-width: 420px; }
.files-pub li button.name { text-align: left; color: var(--text); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }

.logo-preview { display: flex; align-items: center; min-height: 64px; padding: 12px 16px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); }
.logo-preview img { max-height: 48px; max-width: 240px; }

/* ---------- dysk ---------- */
.drive { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.drive-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 16px; }
.drive-side nav { display: flex; flex-direction: column; gap: 2px; }
.drive-nav { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.drive-nav:hover { background: var(--surface); }
.drive-nav.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.drive-side .sep { height: 1px; background: var(--border); margin: 8px 6px; }
.drive-side-h { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 10px 4px; font-weight: 600; }
.drive-usage { padding: 0 4px; display: flex; flex-direction: column; gap: 4px; }
.drive-main { min-height: 360px; transition: outline-color .15s; outline: 2px dashed transparent; outline-offset: -6px; }
.drive-main.over { outline-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.drive-toolbar { margin: 12px 0; }
.drive-search input { width: 260px; max-width: 100%; }
.crumbs { font-size: 1.05rem; display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.crumbs a { color: var(--text); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.drive-selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; margin-bottom: 8px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.drive-table td { padding-top: 7px; padding-bottom: 7px; }
.drive-table .w-sel { width: 34px; }
.drive-table .w-more { width: 44px; text-align: right; }
.drive-table td:nth-child(2) { min-width: 140px; }
.drive-name { color: var(--text); text-align: left; display: inline-flex; gap: 8px; align-items: center; font-weight: 500; overflow-wrap: anywhere; }
.drive-name:hover { color: var(--accent); }
.drive-table .badge { margin-left: 8px; }
.nowrap { white-space: nowrap; }
.drive-upload { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); margin-bottom: 12px; }
.menu { position: absolute; z-index: 60; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 8px 28px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.menu-item { background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; font: inherit; color: var(--text); cursor: pointer; }
.menu-item:hover, .menu-item:focus { background: var(--surface-2); outline: none; }
.menu-item.danger { color: var(--danger); }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.picker-list li { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.picker-list li:last-child { border-bottom: 0; }
.picker-list button:disabled { color: var(--muted); cursor: not-allowed; }
input[type=search] { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
@media (max-width: 820px) {
  .drive { grid-template-columns: minmax(0, 1fr); }
  .drive-side-h, .drive-usage .muted { display: none; }
  .drive-table th:nth-child(4), .drive-table td:nth-child(4) { display: none; }
  .drive-main { padding: 14px; }
  .drive-side { position: static; }
  .drive-side nav { flex-direction: row; flex-wrap: wrap; }
  .drive-side .sep { display: none; }
  .hide-sm { display: none; }
  .drive-search input { width: 100%; }
}
