:root {
  --navy: #18264f;
  --blue: #1f6fc5;
  --blue-dark: #185a9f;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1b2236;
  --muted: #687089;
  --line: #dde2ec;
  --ok: #1a8f5a;
  --err: #c0392b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
a { color: var(--blue); }
svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Pasek górny */
.topbar { background: var(--navy); padding: 14px 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; padding: 6px; border-radius: 8px; background: var(--blue); color: #fff; display: inline-block; }
.brand-name { white-space: nowrap; font-weight: 700; letter-spacing: .08em; font-size: 16px; }
.brand-name span { font-weight: 400; letter-spacing: .02em; opacity: .8; text-transform: lowercase; }

/* Układ */
#content { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 32px 16px 8px; }
.card, #content > fieldset, #content > div > form > fieldset, #content > form > fieldset {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(24,38,79,.04), 0 8px 24px rgba(24,38,79,.06);
  padding: 28px;
}
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; color: var(--navy); }
h2 { font-size: 18px; color: var(--navy); }
.muted { color: var(--muted); margin: 0 0 20px; }
.small { font-size: 13px; }
.opt { color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }

/* Pole wyboru pliku */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-height: 190px; padding: 24px; text-align: center; cursor: pointer;
  border: 2px dashed #c3cbdb; border-radius: 12px; background: #f8f9fc;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: #eef4fc; }
.dropzone.has-file { border-style: solid; border-color: var(--blue); background: #eef4fc; min-height: 120px; }
.dropzone #file_select {
  position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important;
  left: 0 !important; opacity: 0 !important; cursor: pointer;
}
.dz-icon { width: 46px; height: 46px; padding: 10px; border-radius: 50%; background: #dde9f8; color: var(--blue); margin-bottom: 8px; }
.has-file .dz-icon { background: var(--blue); color: #fff; }
.dz-title { font-weight: 600; color: var(--navy); word-break: break-all; }
.dz-sub { color: var(--muted); font-size: 14px; }

/* Opcje */
#options { margin-top: 22px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=password], select {
  width: 100%; font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
input[type=text]:focus, input[type=password]:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,197,.15); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }
.check .small { font-weight: 400; }
.config { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.config:empty { display: none; }

/* Przyciski */
.btn, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 600; border-radius: 10px; padding: 11px 20px; cursor: pointer;
  border: 1px solid transparent; background: var(--blue); color: #fff; text-decoration: none;
  transition: background .15s;
}
.btn:hover, input[type=submit]:hover { background: var(--blue-dark); }
.btn-primary, #send { width: 100%; margin-top: 22px; padding: 13px 20px; font-size: 16px; }
.btn-ghost { background: transparent; color: var(--blue); border-color: var(--line); margin-top: 8px; }
.btn-ghost:hover { background: #f1f5fb; }
.btn-small { padding: 7px 14px; font-size: 14px; flex: none; }
.btn.ok { background: var(--ok); }
.logout { text-align: center; margin-top: 14px; }
.linkbtn { background: none !important; color: var(--muted) !important; border: 0 !important; font-weight: 400 !important; padding: 4px !important; text-decoration: underline; }

/* Wysyłanie i wynik */
.state { text-align: center; }
.state-icon { width: 56px; height: 56px; margin: 0 auto 14px; padding: 14px; border-radius: 50%; }
.state-icon.ok { background: #e3f4ec; color: var(--ok); }
.progress { height: 10px; background: #e6eaf2; border-radius: 99px; overflow: hidden; margin: 6px 0 12px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), #3d8ce0); border-radius: 99px; transition: width .3s; }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
#uploaded_percentage { font-weight: 700; color: var(--navy); }
.linkbox { display: flex; gap: 8px; align-items: center; background: #f6f8fb; border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 14px; margin-bottom: 12px; text-align: left; }
.linkbox a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; text-decoration: none; }

/* Komunikaty */
.error, .message { border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; }
.error { background: #fdecea; color: var(--err); border: 1px solid #f5c6c0; }
.message { background: #e3f4ec; color: var(--ok); border: 1px solid #bfe5d2; }
.error p, .message p { margin: 0; }

/* Strona pobierania / logowanie / admin (fieldset + table z Jirafeau) */
fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 24px; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 700; color: var(--navy); font-size: 17px; padding: 0 8px; word-break: break-all; }
fieldset table { width: 100%; border-collapse: collapse; }
fieldset td { padding: 6px 0; vertical-align: middle; }
fieldset td.label { padding-right: 12px; white-space: nowrap; font-weight: 600; }
#submit_download, #submit_preview { width: 100%; margin-top: 8px; }
#submit_preview { background: transparent; color: var(--blue); border-color: var(--line); }
#self_destruct { color: var(--err); font-weight: 600; }

/* Instrukcja */
.steps { list-style: none; counter-reset: s; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.steps li { counter-increment: s; font-size: 13px; color: var(--muted); }
.steps li::before { content: counter(s); display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 50%; background: #dde9f8; color: var(--blue); font-weight: 700; margin-bottom: 6px; }
.steps strong { display: block; color: var(--text); font-size: 14px; }

/* Stopka */
#copyright { max-width: 560px; margin: 0 auto; padding: 24px 16px 32px; font-size: 12px; color: #8a91a6; }
#copyright p { margin: 0 0 8px; }

@media (max-width: 520px) {
  #content { padding-top: 20px; }
  .card { padding: 20px; }
  .steps { grid-template-columns: 1fr; }
  .dropzone { min-height: 150px; }
}

/* v2: logowanie */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.userbox { display: flex; align-items: center; gap: 12px; min-width: 0; }
.userbox form { margin: 0; }
.user-email { color: #c9d3ea; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar input.btn-logout {
  font: inherit; font-size: 14px; font-weight: 600; color: #fff; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 6px 14px; cursor: pointer;
  width: auto; margin: 0;
}
.topbar input.btn-logout:hover { background: rgba(255,255,255,.22); }
.center { text-align: center; }
.state-icon.info { background: #dde9f8; color: var(--blue); }
.card > .state-icon { display: block; }
.login-form { margin-top: 8px; }
.login-form .btn-primary { margin-top: 6px; }
input[type=email] {
  width: 100%; font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none;
}
input[type=email]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,197,.15); }
.email { color: var(--navy); word-break: break-all; }
.note { margin: 18px 0 0; }
.state form .btn-primary { margin-top: 4px; }
@media (max-width: 520px) {
  .user-email { max-width: 110px; font-size: 13px; }
  .brand { gap: 8px; }
  .brand-name { font-size: 15px; }
}

/* v2: panel administracyjny */
#content.wide { max-width: 1280px; padding-top: 28px; }
.admin h1 { margin: 0; font-size: 24px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-head .muted { margin: 2px 0 0; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin form { margin: 0; }
.tbtn {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 14px; font-weight: 600;
  height: 38px; padding: 0 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  background: var(--card); color: var(--navy); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(24,38,79,.05);
}
.tbtn svg { width: 17px; height: 17px; }
.tbtn:hover { border-color: #c3cbdb; background: #f8f9fc; }
.tbtn-dark { background: var(--navy); color: #fff; border-color: var(--navy); }
.tbtn-dark:hover { background: #22336a; border-color: #22336a; }
.toast { margin-bottom: 16px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(24,38,79,.04); }
.stat > div { display: flex; flex-direction: column; min-width: 0; }
.stat .grow { flex: 1; }
.stat-i { flex: none; width: 42px; height: 42px; padding: 10px; border-radius: 12px; background: #e8f0fb; color: var(--blue); }
.stat-i.warn { background: #fdf2e0; color: #b9770e; }
.stat-v { font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat-l { font-size: 13px; color: var(--muted); }
.meter { display: block; height: 6px; background: #e6eaf2; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.meter span.warn { background: #d68910; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(24,38,79,.04), 0 8px 24px rgba(24,38,79,.05); overflow: hidden; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1 1 280px; display: block; }
.search svg { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; height: 38px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px 0 36px; background: #f8f9fc; outline: none; }
.search input:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,197,.15); }
.filters select { width: auto; height: 38px; padding: 0 10px; font-size: 14px; flex: 0 1 270px; background: #fff; }
.seg { display: inline-flex; background: #eef1f6; border-radius: 10px; padding: 3px; }
.seg a { padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; }
.seg a.on { background: #fff; color: var(--navy); box-shadow: 0 1px 2px rgba(24,38,79,.12); }
.count { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table.files { width: 100%; border-collapse: collapse; font-size: 14px; }
table.files th { position: sticky; top: 0; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .03em; color: var(--muted); background: #f8f9fc; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.files td { padding: 12px 16px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
table.files tbody tr:last-child td { border-bottom: 0; }
table.files tbody tr:hover td { background: #fafbfe; }
table.files tr.is-expired .name, table.files tr.is-expired .ficon { opacity: .55; }
table.files .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.files .right { text-align: right; }
table.files .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.c-file { min-width: 260px; max-width: 460px; }
.fcell { display: flex; gap: 12px; align-items: center; min-width: 0; }
.fmeta { min-width: 0; }
.fmeta .name { display: block; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmeta code { font: 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
.ficon { flex: none; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; letter-spacing: .03em; background: #eef1f6; color: #5b6478; }
.k-arc { background: #fdf2e0; color: #a5650a; } .k-pdf { background: #fdecea; color: #c0392b; }
.k-doc { background: #e6effc; color: #1f5fae; } .k-xls { background: #e3f4ec; color: #17784c; }
.k-img { background: #f3e8fb; color: #7d3cb5; } .k-vid { background: #fce8f3; color: #b0347b; }
.k-cad { background: #e5f5f7; color: #1b7c8a; } .k-exe { background: #eceef2; color: #444c5e; }
.person { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.person .email { display: block; font-weight: 500; color: var(--text); white-space: nowrap; }
a.person:hover .email { color: var(--blue); }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: hsl(var(--h, 215), 55%, 32%); background: hsl(var(--h, 215), 70%, 91%); }
.person.anon .avatar { background: #eef1f6; color: #9aa1b3; }
.person.anon .email { color: var(--muted); font-weight: 400; }
.c-date { white-space: nowrap; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #eef1f6; color: #5b6478; }
.pill.green { background: #e3f4ec; color: #17784c; } .pill.amber { background: #fdf2e0; color: #a5650a; } .pill.red { background: #fdecea; color: #c0392b; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: #e8eef8; color: var(--blue); margin-left: 6px; }
.acts { display: flex; gap: 4px; justify-content: flex-end; }
.ibtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 8px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: #5b6478; cursor: pointer; }
.ibtn:hover { background: #eef3fb; color: var(--blue); border-color: #d6e2f5; }
.ibtn.danger:hover { background: #fdecea; color: var(--err); border-color: #f5c6c0; }
table.files .empty { text-align: center; color: var(--muted); padding: 40px; }
.pager { display: flex; gap: 4px; justify-content: center; align-items: center; padding: 14px; border-top: 1px solid var(--line); }
.pager a { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 9px; text-decoration: none; font-size: 14px; color: var(--navy); }
.pager a svg { width: 18px; height: 18px; }
.pager a:hover { background: #eef3fb; }
.pager a.cur { background: var(--navy); color: #fff; }
.pager .gap { color: var(--muted); padding: 0 4px; }
.copied { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--navy); color: #fff; font-size: 14px; font-weight: 600; padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: all .2s; }
.copied.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .count { margin-left: 0; }
}
@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-i { width: 34px; height: 34px; padding: 7px; }
  .stat-v { font-size: 18px; }
  .admin-actions .tbtn span { display: none; }
  .admin-actions .tbtn { padding: 0 10px; }
  .filters select { flex: 1 1 100%; }
  table.files thead { display: none; }
  table.files, table.files tbody, table.files tr, table.files td { display: block; width: 100%; }
  table.files tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.files td { border: 0; padding: 4px 0; max-width: none; }
  table.files td.num, table.files td.c-date { display: inline-block; width: auto; margin-right: 14px; text-align: left; }
  table.files td[data-label]:not([data-label=""]):not(.c-file):not(.c-who)::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
  .c-file { max-width: none; min-width: 0; }
  .acts { justify-content: flex-start; margin-top: 4px; }
}
