*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f8f9fb;
  --surface:  #ffffff;
  --border:   #e4e7ec;
  --text:     #111827;
  --muted:    #6b7280;
  --primary:  #2563eb;
  --primary-h:#1d4ed8;
  --danger:   #dc2626;
  --danger-h: #b91c1c;
  --radius:   10px;
  --shadow:   0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);
}

html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; min-height: 100vh; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.logo { font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }

/* ── Container ── */
.container { max-width: 900px; margin: 0 auto; padding: 32px 20px 80px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: .875rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent; transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-h); }
.btn-ghost     { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-logout    { font-size: .875rem; color: var(--muted); background: none; border: none; cursor: pointer; padding: 6px 10px; border-radius: 6px; }
.btn-logout:hover { background: var(--bg); }
.btn-sm        { padding: 4px 10px; font-size: .8rem; }
.btn-copy      { background: var(--bg); border-color: var(--border); color: var(--text); }
.btn-copy:hover { background: #e9ebef; }
.btn-copy.copied { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }

/* ── Upload section ── */
.upload-section { margin-bottom: 28px; }
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary); background: #eff6ff;
}
.drop-zone svg { color: var(--primary); margin-bottom: 12px; }
.drop-zone p { font-size: .95rem; }
.drop-zone .link { color: var(--primary); cursor: pointer; font-weight: 500; }

/* ── Collection bar ── */
.collection-bar {
  display: flex; align-items: center; gap: 12px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: var(--radius); padding: 10px 16px;
  margin-bottom: 20px; font-size: .9rem;
}
.collection-bar span { color: var(--primary); font-weight: 500; flex: 1; }

/* ── File table ── */
.files-section { margin-bottom: 40px; }
.files-section h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.count-badge { background: var(--border); color: var(--muted); font-size: .75rem; font-weight: 600; padding: 2px 7px; border-radius: 99px; }

.file-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.file-table th, .file-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.file-table th { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafafa; }
.file-table tbody tr:last-child td { border-bottom: none; }
.file-table tbody tr:hover { background: #fafbff; }
.col-check { width: 36px; }
.col-name  { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-size  { width: 80px; color: var(--muted); font-size: .85rem; }
.col-date  { width: 160px; color: var(--muted); font-size: .85rem; }
.col-actions { width: 180px; }
.col-actions { display: flex; gap: 6px; }

.empty-state { color: var(--muted); font-size: .9rem; padding: 24px 0; }

/* ── Login page ── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 40px 36px; width: 100%; max-width: 360px; text-align: center;
}
.login-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.login-card .subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }
.login-card input[type=password] {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 1rem; margin-bottom: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input[type=password]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #dbeafe; }
.login-card button { width: 100%; padding: 10px; font-size: 1rem; border-radius: 7px; }

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: 7px; font-size: .875rem; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* ── Modal ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 200; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 300; width: 100%; max-width: 460px; padding: 0 16px;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 24px;
}
.modal-box h3 { font-size: 1.1rem; margin-bottom: 16px; }
.modal-box input[type=text] {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border); border-radius: 7px;
  font-size: .95rem; margin-bottom: 14px; outline: none;
}
.modal-box input[type=text]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #dbeafe; }
.modal-actions { display: flex; gap: 10px; }
.dupe-message  { font-size: .9rem; color: var(--muted); margin-bottom: 14px; }
.input-label   { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }

/* Upload list inside modal */
#upload-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.upload-item { display: flex; flex-direction: column; gap: 4px; }
.upload-item-name { font-size: .875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-status { font-size: .8rem; color: var(--muted); }
.upload-item-url {
  display: flex; gap: 6px; align-items: center; margin-top: 2px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
}
.upload-item-url a { font-size: .8rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-bar-wrap { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); width: 0; transition: width .2s; border-radius: 99px; }

/* ── Public collection page ── */
.public-page { display: flex; align-items: flex-start; justify-content: center; min-height: 100vh; padding: 48px 16px; background: var(--bg); }
.public-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 28px; width: 100%; max-width: 560px; }
.public-brand { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 16px; }
.public-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.public-meta  { color: var(--muted); font-size: .875rem; margin-bottom: 24px; }

.file-list-public { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.file-link-public {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); transition: background .15s, border-color .15s;
}
.file-link-public:hover { background: #f0f5ff; border-color: #93c5fd; text-decoration: none; }
.file-icon { font-size: 1.4rem; width: 28px; text-align: center; }
.file-info  { flex: 1; overflow: hidden; }
.file-name  { display: block; font-weight: 500; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size  { display: block; font-size: .78rem; color: var(--muted); }
.file-action { color: var(--primary); font-weight: 700; font-size: 1rem; }

/* ── Section header ── */
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-header h2 { margin-bottom: 0; }
.filter-results { font-size: .8rem; color: var(--muted); }

/* ── Filter bar ── */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-search {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 180px;
  border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 10px; background: var(--bg);
  transition: border-color .15s;
}
.filter-search:focus-within { border-color: var(--primary); }
.filter-search svg { color: var(--muted); flex-shrink: 0; }
.filter-search input {
  border: none; background: transparent; outline: none;
  font-size: .875rem; flex: 1; min-width: 0;
}
.search-clear {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; line-height: 1; color: var(--muted); padding: 0 2px;
}
.search-clear:hover { color: var(--text); }

.filter-bar select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px;
  font-size: .875rem; background: var(--bg); cursor: pointer; outline: none;
  transition: border-color .15s;
}
.filter-bar select:focus { border-color: var(--primary); }

.date-range { display: flex; align-items: center; gap: 6px; }
.date-range input[type=date] {
  padding: 5px 9px; border: 1px solid var(--border); border-radius: 7px;
  font-size: .85rem; background: var(--bg); outline: none;
  transition: border-color .15s; cursor: pointer;
}
.date-range input[type=date]:focus { border-color: var(--primary); }
.date-sep { color: var(--muted); font-size: .85rem; }

/* ── Sortable columns ── */
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary); }
.sort-icon { font-size: .75rem; margin-left: 2px; color: var(--muted); }
.sort-active { color: var(--primary); }
.sort-active .sort-icon { color: var(--primary); }

/* ── Type colour dots ── */
.type-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 7px; flex-shrink: 0;
  vertical-align: middle; position: relative; top: -1px;
}
.type-image    { background: #3b82f6; }
.type-video    { background: #8b5cf6; }
.type-audio    { background: #ec4899; }
.type-document { background: #f59e0b; }
.type-archive  { background: #6b7280; }
.type-other    { background: #d1d5db; }

/* ── Hidden utility ── */
.hidden { display: none !important; }
