:root {
  --primary: #1e3a5f;
  --primary-hover: #16304f;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
}

* { 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;
}

/* ── Full-screen centered wrapper (login + loading) ── */
.fullscreen-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a9e 100%);
}

/* ── Loading spinner ── */
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: rgba(255,255,255,.7); margin-top: 16px; font-size: .95rem; }

/* ── Login card ── */
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  margin: 16px;
}
.login-logo { width: 220px; max-width: 100%; margin: 0 auto 20px; display: block; }
.nav-logo { height: 32px; width: auto; display: block; }
.login-title { font-size: 1.6rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.login-subtitle { color: var(--text-muted); font-size: .95rem; margin-bottom: 32px; line-height: 1.5; }
.btn-ms {
  width: 100%;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  padding: 13px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 600;
  transition: background .15s, transform .1s;
}
.btn-ms:hover { background: var(--primary-hover); }
.btn-ms:active { transform: scale(.98); }
.login-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0 16px; }
.login-anon-text { font-size: .85rem; color: var(--text-muted); margin-bottom: 10px; }

/* ── Navbar ── */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.navbar-brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.navbar-brand .logo { font-size: 1.5rem; } /* legacy, kept for safety */
.navbar-right { display: flex; align-items: center; gap: 12px; }
.user-info { text-align: right; line-height: 1.3; }
.user-info .name { font-weight: 600; font-size: .9rem; }
.user-info .email { font-size: .78rem; opacity: .8; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,.5); }
.btn-outline:hover { background: rgba(255,255,255,.1); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-icon {
  background: none; border: none; font-size: 1.1rem;
  cursor: pointer; padding: 4px 8px; border-radius: 4px;
  opacity: .7; transition: opacity .15s, background .15s;
}
.btn-icon:hover { opacity: 1; background: var(--border); }
.btn-icon.btn-delete:hover { background: #fee2e2; }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.hidden { display: none !important; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card-title {
  font-size: 1rem; font-weight: 600; color: var(--primary);
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}

/* ── File table ── */
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 12px; flex-wrap: wrap;
}
.search-box { flex: 1; max-width: 320px; position: relative; }
.search-box input {
  width: 100%; padding: 8px 12px 8px 36px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .9rem; outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.file-table { width: 100%; border-collapse: collapse; }
.file-table th {
  text-align: left; padding: 10px 12px;
  font-size: .8rem; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid var(--border); text-transform: uppercase; letter-spacing: .5px;
}
.file-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.file-table tr:last-child td { border-bottom: none; }
.file-table tr:hover td { background: #f8fafc; }
.file-name-cell { display: flex; align-items: center; gap: 8px; }
.file-icon { font-size: 1.2rem; flex-shrink: 0; }
.file-name { font-weight: 500; word-break: break-all; }
.actions-cell { white-space: nowrap; }
.audit-details { min-width: 360px; max-width: 620px; white-space: normal; word-break: break-word; }
.loading-cell, .empty-cell, .error-cell { text-align: center; padding: 40px; color: var(--text-muted); }
.error-cell { color: var(--danger); }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  color: var(--text-muted);
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: #eff6ff; }
.drop-zone .dz-icon { font-size: 2.5rem; margin-bottom: 8px; }
.drop-zone p { font-size: .95rem; margin-bottom: 4px; }
.drop-zone small { font-size: .8rem; }

/* ── Fetch URL ── */
.fetch-url-row { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.fetch-url-input {
  flex: 1; padding: 8px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .9rem; outline: none; font-family: inherit;
}
.fetch-url-input:focus { border-color: var(--accent); }

/* ── Upload progress ── */
#upload-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.upload-item { display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.upload-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-track { flex: 2; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.upload-bar { height: 100%; background: var(--accent); transition: width .2s; border-radius: 3px; }
.upload-pct { width: 80px; text-align: right; color: var(--text-muted); }

/* ── Request form ── */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; color: var(--text-muted); }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .9rem; font-family: inherit; outline: none;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { border-color: var(--accent); }
.form-row textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Success box ── */
.success-box {
  background: #f0fdf4; border: 1.5px solid #86efac; border-radius: var(--radius);
  padding: 20px; text-align: center; color: #166534;
}
.success-box .icon { font-size: 2rem; margin-bottom: 8px; }

/* ── Breadcrumb ── */
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: .9rem; flex: 1; min-width: 0; }
.bc-item {
  cursor: pointer; color: var(--accent); padding: 2px 4px; border-radius: 4px; white-space: nowrap;
  background: none; border: 0; font: inherit;
}
.bc-item:hover { background: #eff6ff; }
.bc-root { font-weight: 600; }
.bc-current { color: var(--text); cursor: default; font-weight: 600; }
.bc-current:hover { background: none; }
.bc-sep { color: var(--text-muted); }
.folder-link { cursor: pointer; color: var(--accent); background: none; border: 0; font: inherit; padding: 0; }
.folder-link:hover { text-decoration: underline; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; width: 360px; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-title { font-size: 1rem; font-weight: 600; color: var(--primary); margin-bottom: 16px; }
.modal-input {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; outline: none; margin-bottom: 6px;
}
.modal-input:focus { border-color: var(--accent); }
.modal-hint { font-size: .78rem; color: var(--text-muted); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── External share links ── */
.external-container { max-width: 640px; margin-top: 40px; }
.external-title {
  font-size: 1.25rem;
  color: var(--primary);
  margin-bottom: 10px;
}
.external-meta { color: var(--text-muted); font-size: .9rem; line-height: 1.5; margin-bottom: 18px; }
.external-message {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 18px;
  white-space: pre-wrap;
}
.external-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.external-progress { color: var(--text-muted); font-size: .9rem; }

/* ── Toasts ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  background: var(--primary); color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: .9rem; max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  transform: translateX(120%); transition: transform .3s;
}
.toast.show { transform: translateX(0); }
.toast.toast-success { background: #166534; }
.toast.toast-error { background: #991b1b; }
.toast.toast-info { background: var(--primary); }
