:root {
  --primary: #e63946;
  --primary-hover: #c1121f;
  --primary-light: #fef2f2;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-img { height: 40px; width: auto; }
.logo-text { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.badge {
  font-size: 0.7rem; font-weight: 600; background: var(--primary-light);
  color: var(--primary); padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: var(--radius-sm); font-size: 0.9rem;
  font-weight: 600; cursor: pointer; border: none; transition: all 0.15s ease;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--border); }
.btn-full { width: 100%; }

.field { margin-bottom: 1.25rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.9rem; color: var(--text);
  background: var(--surface); transition: border-color 0.15s; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(230,57,70,.12); }
.field input::placeholder { color: var(--text-muted); }

.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #fef2f2 0%, #f8fafc 50%, #fff1f2 100%);
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card { background: var(--surface); border-radius: var(--radius); padding: 2.5rem; box-shadow: var(--shadow-lg); }
.login-card .logo { justify-content: center; margin-bottom: 0.5rem; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 2rem; }

header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 1.5rem; position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 900px; margin: 0 auto; height: 60px; display: flex; align-items: center; justify-content: space-between; }

main { max-width: 900px; margin: 2.5rem auto; padding: 0 1.5rem; }
.upload-card { background: var(--surface); border-radius: var(--radius); padding: 2.5rem; box-shadow: var(--shadow); max-width: 640px; margin: 0 auto; }
.upload-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.upload-card .subtitle { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 2rem; }

.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; transition: all 0.2s; cursor: pointer; }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop-icon { margin-bottom: 4px; }
.drop-text { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.drop-sub { font-size: 0.85rem; color: var(--text-muted); }
.drop-formats { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.link-btn { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; font-size: inherit; text-decoration: underline; }

.hint { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }
.file-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.file-selected { display: flex; align-items: center; gap: 12px; text-align: left; }
.file-name { font-weight: 600; font-size: 0.9rem; word-break: break-all; }
.file-size { font-size: 0.8rem; color: var(--text-muted); }
.remove-btn { margin-left: auto; background: none; border: none; font-size: 1.1rem; color: var(--text-muted); cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.remove-btn:hover { background: var(--error-bg); color: var(--error); }

#progressSection { margin-bottom: 1.25rem; }
.progress-bar-track { width: 100%; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; width: 0%; background: var(--primary); border-radius: 4px; transition: width 0.3s ease; }
.progress-text { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }

.error-msg { background: var(--error-bg); color: var(--error); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 1rem; }

.success-panel { text-align: center; padding: 2rem 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.success-panel h2 { font-size: 1.25rem; color: var(--success); }
.success-panel p { color: var(--text-muted); font-size: 0.9rem; }

.success-inline { color: var(--success); font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.success-inline::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

.admin-card { background: var(--surface); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.admin-card h1 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; }
.loading-text { color: var(--text-muted); font-size: 0.85rem; }
.empty-text { color: var(--text-muted); font-size: 0.85rem; font-style: italic; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th { text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border); font-weight: 600; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--bg); }
.cell-filename { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.config-item { background: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm); }
.config-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.config-value { font-size: 0.85rem; color: var(--text); word-break: break-all; }

.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.75rem; }
.project-item { background: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 4px; }
.project-item strong { font-size: 0.9rem; }
.project-item code { font-size: 0.75rem; color: var(--text-muted); word-break: break-all; }

.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-content {
  background: var(--surface); border-radius: var(--radius); padding: 2rem;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 500px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: var(--text-muted); padding: 0; line-height: 1;
}
.modal-close:hover { color: var(--text); }

.client-checkbox {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s;
}
.client-checkbox:hover { background: var(--bg); }
.client-checkbox input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.client-checkbox span { font-size: 0.9rem; font-weight: 500; }

.access-badge {
  display: inline-block; font-size: 0.7rem; padding: 2px 6px;
  border-radius: 3px; font-weight: 600;
}
.access-badge.all { background: var(--success-bg); color: var(--success); }
.access-badge.partial { background: #fef3c7; color: #92400e; }
.access-badge.none { background: var(--error-bg); color: var(--error); }

@media (max-width: 480px) {
  .upload-card, .login-card, .admin-card { padding: 1.5rem; }
  main { margin-top: 1.5rem; }
}
