:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --error: #dc2626;
  --error-light: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
}

.container { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 20px; }

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.header-inner { display: flex; align-items: center; }
.logo {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
}
.logo:hover { color: var(--primary); }

/* Main */
main { flex: 1; padding: 48px 0; }

/* Footer */
footer {
  padding: 20px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); }

/* Page layout */
.page-center { display: flex; justify-content: center; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}
h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}
.subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14px;
}

/* Alerts */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}
.alert-error { background: var(--error-light); color: var(--error); border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #86efac; }

/* Drop zone */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 20px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-icon, .file-icon {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  margin: 0 auto 12px;
  display: block;
}
.drop-zone:hover .upload-icon,
.drop-zone.drag-over .upload-icon { color: var(--primary); }
.drop-label { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.drop-hint { font-size: 13px; color: var(--text-muted); }
.link { color: var(--primary); text-decoration: underline; }
.selected-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; word-break: break-all; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  position: relative;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-secondary:hover:not(:disabled) { background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 14px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-full { width: 100%; }

.btn-hint {
  font-size: 12px;
  opacity: .75;
  font-weight: 400;
  margin-left: 4px;
}

/* Result page */
.result-icon {
  width: 56px;
  height: 56px;
  background: var(--success-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.result-icon svg { width: 32px; height: 32px; color: var(--success); }

.result-card { text-align: center; }
.result-card h1 { margin-bottom: 20px; }

.stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-bottom: 32px;
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -1px; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-divider { width: 1px; height: 40px; background: var(--border); }

.download-group { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.back-link { font-size: 14px; color: var(--text-muted); text-decoration: none; }
.back-link:hover { color: var(--text); }

/* Admin page */
.info-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 24px;
}
.info-card h2 { margin-bottom: 12px; }

.meta-list { margin-bottom: 16px; }
.meta-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.meta-row:last-child { border-bottom: none; }
.meta-row dt { color: var(--text-muted); }

.divider { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.muted { color: var(--text-muted); font-size: 14px; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* Bulk result page */
.bulk-page { width: 100%; }

.bulk-header {
  text-align: center;
  margin-bottom: 28px;
}
.bulk-header h1 { margin-bottom: 20px; }
.bulk-header .stats-row { margin-bottom: 24px; }

.bulk-table-card { padding: 0; overflow: hidden; margin-bottom: 24px; }

.bulk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.bulk-table th {
  background: var(--bg);
  padding: 11px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.bulk-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.bulk-table tbody tr:last-child td { border-bottom: none; }
.bulk-table tbody tr:hover { background: var(--bg); }

.num-col { text-align: center; width: 80px; }
.dl-col  { width: 150px; }
.filename-col { word-break: break-word; }

.file-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}
.file-badge-docx { background: #dbeafe; color: #1d4ed8; }
.file-badge-pptx { background: #ffedd5; color: #c2410c; }

.edit-count { font-weight: 600; }
.edit-count.zero { color: var(--text-muted); font-weight: 400; }

.row-error td { background: var(--error-light); }
.error-msg {
  display: block;
  font-size: 12px;
  color: var(--error);
  margin-top: 3px;
}

@media (max-width: 520px) {
  .card { padding: 28px 20px; }
  .stats-row { gap: 20px; }
  .stat-value { font-size: 26px; }
  .dl-col { width: auto; }
  .bulk-table th, .bulk-table td { padding: 10px 10px; }
}
