/* ==========================================================================
   File Downloader - styles
   The same look as the Address Book: indigo accent, Inter lettering, soft
   cards, light and dark themes. One column: upload box, uploads in progress,
   then the list of files.
   ========================================================================== */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f6;
  --border: #e2e5ee;
  --border-strong: #cdd2df;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0fe;
  --accent-text: #3730a3;
  --hl: #fff4c2;
  --danger: #c4320a;
  --danger-soft: #fdeee8;
  --ok: #047857;
  --focus: rgba(67, 56, 202, 0.35);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.08), 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(17, 24, 39, 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e14;
    --surface: #141720;
    --surface-2: #181c26;
    --surface-3: #1f2430;
    --border: #262b38;
    --border-strong: #353c4d;
    --text: #e8eaf0;
    --text-2: #c4c8d4;
    --muted: #8b91a1;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1e1f3d;
    --accent-text: #a5b4fc;
    --hl: #3b3413;
    --danger: #f97066;
    --danger-soft: #3a1a17;
    --ok: #34d399;
    --focus: rgba(129, 140, 248, 0.45);
    --shadow-sm: none;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.75);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c0e14;
  --surface: #141720;
  --surface-2: #181c26;
  --surface-3: #1f2430;
  --border: #262b38;
  --border-strong: #353c4d;
  --text: #e8eaf0;
  --text-2: #c4c8d4;
  --muted: #8b91a1;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: #1e1f3d;
  --accent-text: #a5b4fc;
  --hl: #3b3413;
  --danger: #f97066;
  --danger-soft: #3a1a17;
  --ok: #34d399;
  --focus: rgba(129, 140, 248, 0.45);
  --shadow-sm: none;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand img { border-radius: 8px; display: block; }
.brand-lg { font-size: 22px; }
.brand-light { color: #fff; font-size: 19px; }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
:root[data-theme="dark"] .btn-primary { color: #0c0e14; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #0c0e14; } }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--danger) 86%, #000); border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg { width: 17px; height: 17px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 14px 0 6px; }
.input, .select {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.input-lg { height: 46px; font-size: 15px; }
.select-sm { width: auto; height: 34px; font-size: 13.5px; font-weight: 600; padding: 0 8px; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }

.notice { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin: 12px 0; }
.notice-error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---------- Login page ---------- */

.login-body { background: var(--surface); min-height: 100vh; }
.login-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.login-hero {
  position: relative; overflow: hidden; color: #e0e7ff;
  background:
    radial-gradient(1200px 600px at -10% -20%, rgba(129, 140, 248, .55), transparent 60%),
    radial-gradient(900px 500px at 110% 120%, rgba(56, 189, 248, .35), transparent 60%),
    linear-gradient(150deg, #1e1b4b 0%, #312e81 55%, #3730a3 100%);
}
.login-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: radial-gradient(rgba(255,255,255,.55) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.login-hero-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: 48px 56px; max-width: 640px; }
.hero-copy { margin-top: auto; }
.hero-copy h1 { color: #fff; font-size: clamp(30px, 3.4vw, 44px); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 16px; font-weight: 700; }
.hero-copy p { font-size: 17px; color: #c7d2fe; margin: 0; max-width: 460px; }
.hero-points { list-style: none; padding: 0; margin: 40px 0 auto; display: grid; gap: 18px; }
.hero-points li { display: flex; gap: 14px; align-items: flex-start; font-size: 14.5px; color: #c7d2fe; line-height: 1.45; }
.hero-points strong { color: #fff; font-weight: 600; }
.hero-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); color: #fff; flex: none; }
.hero-foot { font-size: 13px; color: #a5b4fc; margin: 32px 0 0; }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.login-form { width: 100%; max-width: 380px; }
.login-mobile-brand { display: none; margin-bottom: 28px; }
.login-title { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; }
.login-sub { color: var(--muted); margin: 0 0 18px; }
.login-form .btn-block { margin-top: 24px; }
.login-foot { color: var(--muted); font-size: 13px; text-align: center; margin: 16px 0 0; }
.login-version { color: var(--muted); font-size: 12px; text-align: center; margin: 28px 0 0; opacity: .75; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.pw-toggle:hover, .pw-toggle.on { color: var(--accent); }

@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-mobile-brand { display: inline-flex; }
  .login-panel { align-items: flex-start; padding-top: 12vh; }
}

/* ---------- Top bar ---------- */

.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { height: var(--topbar-h); display: flex; align-items: center; gap: 20px; padding: 0 20px; }
.search { position: relative; flex: 1; min-width: 0; max-width: 640px; margin: 0 auto; }
.search > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input {
  width: 100%; height: 42px; padding: 0 44px 0 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-3); color: var(--text); font-size: 15px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.search input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search-kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 11px/1 "Inter", sans-serif; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 5px; padding: 4px 6px; background: var(--surface); }
.search input:focus + .search-kbd { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-actions form { margin: 0; }

.banner { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; align-items: center; padding: 9px 16px; font-size: 14px; background: #fef3c7; color: #92400e; border-bottom: 1px solid #fde68a; }
.banner a { color: inherit; font-weight: 700; }

/* ---------- Page ---------- */

.page { max-width: 980px; margin: 0 auto; padding: 28px 32px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; line-height: 1.2; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.sort-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.page-foot { color: var(--muted); font-size: 12px; text-align: center; margin: 28px 0 0; opacity: .8; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: .01em; display: flex; gap: 8px; align-items: center; }
.card-head h2 svg { color: var(--accent); width: 18px; height: 18px; }
.card-body { padding: 6px 18px; }
.count { font-weight: 600; font-size: 12px; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 2px 9px; }

/* Upload box */
.dropzone {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 26px 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.dropzone:hover { background: var(--surface-2); border-color: var(--accent); }
.dropzone.over { background: var(--accent-soft); border-color: var(--accent); }
.dropzone > svg { width: 32px; height: 32px; color: var(--accent); }
.dropzone strong { display: block; color: var(--text); font-size: 15px; }
.dropzone span { font-size: 13.5px; color: var(--muted); }

/* One row per file */
.file-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.file-row:last-child { border-bottom: 0; }
.file-body { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-actions { display: flex; align-items: center; gap: 6px; flex: none; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }

/* The coloured square showing the kind of file (PDF, ZIP, ...) */
.avatar { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; color: #fff; flex: none; letter-spacing: .03em; text-transform: uppercase; }
.av0 { background: linear-gradient(135deg, #6366f1, #4338ca); }
.av1 { background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.av2 { background: linear-gradient(135deg, #10b981, #047857); }
.av3 { background: linear-gradient(135deg, #f59e0b, #b45309); }
.av4 { background: linear-gradient(135deg, #ec4899, #be185d); }
.av5 { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.av6 { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.av7 { background: linear-gradient(135deg, #f43f5e, #be123c); }

/* Uploads in progress */
.up-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.up-row:last-child { border-bottom: 0; }
.up-top { display: flex; align-items: center; gap: 10px; }
.up-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 8px 0 6px; }
.up-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .25s ease-out; }
.up-status { color: var(--muted); font-size: 12.5px; }
.up-row.done .up-fill { background: var(--ok); }
.up-row.done .up-status { color: var(--ok); font-weight: 600; }
.up-row.error .up-fill { background: var(--danger); }
.up-row.error .up-status { color: var(--danger); font-weight: 600; }

/* ---------- Settings (change 02) ---------- */

.settings h1 { font-size: 28px; letter-spacing: -0.02em; line-height: 1.2; margin: 0 0 4px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.back-link:hover { color: var(--accent); }
.back-link svg { width: 18px; height: 18px; }
.avatar.round { border-radius: 50%; font-size: 15px; letter-spacing: .02em; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; vertical-align: 1px; margin-left: 6px; }
.chip.admin { background: var(--accent-soft); color: var(--accent-text); }
.chip.warn { background: #fef3c7; color: #92400e; }
.card-note { margin: 0; padding: 12px 18px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.card-note strong { color: var(--text-2); }
.radio-row { display: grid; gap: 6px; margin-top: 4px; }
.radio { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; }
.radio:hover { background: var(--surface-2); }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio input { width: 17px; height: 17px; accent-color: var(--accent); margin: 2px 0 0; flex: none; }
.radio small { display: block; color: var(--muted); font-size: 12.5px; }

/* Empty and loading states */
.empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 34px 10px; color: var(--muted); text-align: center; font-size: 14px; }
.empty svg { width: 34px; height: 34px; color: var(--accent); margin-bottom: 6px; }
.empty strong { color: var(--text); font-size: 15px; }
.loading { display: flex; align-items: center; gap: 10px; padding: 22px 0; color: var(--muted); font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }

/* ---------- Pop-up boxes ---------- */

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 20, .5); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px; overflow-y: auto; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 6px; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.modal-body { padding: 0 22px 8px; }
.modal-body p { margin: 8px 0; color: var(--text-2); font-size: 14.5px; overflow-wrap: anywhere; }
.modal-foot { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 18px 22px 20px; }

/* ---------- Short messages at the bottom ---------- */

.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #111827; color: #f9fafb; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; overflow-wrap: anywhere; }
.toast.err { background: #b42318; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- Phones ---------- */

@media (max-width: 720px) {
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .brand span { display: none; }
  .search-kbd { display: none; }
  .search input { padding-right: 14px; }
  .btn-new span { display: none; }
  .btn-new { width: 38px; padding: 0; }
  .topbar-actions { gap: 2px; }
  .page { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head h1 { font-size: 24px; }
  .dropzone { padding: 20px 16px; }
  .card-body { padding: 4px 14px; }
  .card-head { padding: 12px 14px; }
  .file-actions .btn span { display: none; }
  .file-actions a.btn { width: 36px; padding: 0; height: 36px; }
  .card-note { padding: 12px 14px 14px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; }
}
