:root {
  --color-primary: #006633;
  --color-primary-dark: #004d26;
  --color-primary-light: #008844;
  --color-primary-soft: #e8f3ee;
  --color-accent: #c9a961;
  --color-accent-soft: #f7f1e1;
  --color-bg: #f5f6f7;
  --color-card: #ffffff;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-text-faint: #9ca3af;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;
  --color-success: #10b981;
  --color-success-soft: #d1fae5;
  --color-warn: #f59e0b;
  --color-warn-soft: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;
  --font-main: 'Tajawal', system-ui, sans-serif;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
  --sidebar-width: 264px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font-main); background: var(--color-bg); color: var(--color-text); font-size: 14.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }

.public-page { min-height: 100vh; background: linear-gradient(180deg, var(--color-bg) 0%, #fff 100%); display: flex; flex-direction: column; }
.public-topbar { background: var(--color-card); border-bottom: 1px solid var(--color-border); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.public-brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 42px; height: 42px; border-radius: 10px; background: var(--color-primary-soft); display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid var(--color-border); flex-shrink: 0; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-logo .placeholder { font-weight: 900; color: var(--color-primary); font-size: 18px; }
.brand-text h1 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-text p { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.admin-entry-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--color-border-strong); border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--color-text-muted); background: var(--color-card); transition: all 0.15s; }
.admin-entry-btn:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-soft); }
.public-content { flex: 1; padding: 50px 24px 80px; display: flex; flex-direction: column; align-items: center; }
.public-hero { text-align: center; max-width: 640px; margin-bottom: 40px; }
.public-hero-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; background: var(--color-primary-soft); color: var(--color-primary-dark); border-radius: 20px; font-size: 12px; font-weight: 600; margin-bottom: 20px; }
.public-hero-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-success); animation: pulse 2s infinite; }
.public-hero h2 { font-size: 32px; font-weight: 800; letter-spacing: -0.6px; margin-bottom: 10px; line-height: 1.3; }
.public-hero p { font-size: 15.5px; color: var(--color-text-muted); line-height: 1.7; }
.upload-card { width: 100%; max-width: 760px; background: var(--color-card); border: 1px solid var(--color-border); border-radius: 18px; padding: 32px; box-shadow: var(--shadow-lg); }
.step-row { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; margin-bottom: 24px; border-bottom: 1px solid var(--color-border); }
.step-num { width: 30px; height: 30px; border-radius: 50%; background: var(--color-primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.step-title { font-size: 16px; font-weight: 700; }
.step-desc { font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px; }
.coordinator-detected { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--color-primary-soft); border: 1px solid rgba(0,102,51,0.2); border-radius: 12px; margin-top: 16px; animation: slideIn 0.3s ease; }
.coordinator-detected.hidden { display: none; }
.coordinator-avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.coordinator-info { flex: 1; }
.coordinator-info .label { font-size: 11.5px; color: var(--color-primary-dark); font-weight: 600; }
.coordinator-info .name { font-size: 15px; font-weight: 700; }
.coordinator-check { width: 28px; height: 28px; border-radius: 50%; background: var(--color-success); color: white; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.form-group { margin-bottom: 18px; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.label .req { color: var(--color-danger); margin-left: 3px; }
.label .hint { font-weight: 400; color: var(--color-text-faint); font-size: 12px; margin-right: 6px; }
.input, .select, .textarea { width: 100%; padding: 11px 14px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); background: var(--color-card); color: var(--color-text); font-size: 14px; transition: all 0.15s; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.select { cursor: pointer; }
.textarea { resize: vertical; min-height: 80px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; transition: all 0.15s; border: 1px solid transparent; white-space: nowrap; }
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--color-card); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-danger { background: var(--color-danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn .icon { width: 16px; height: 16px; }

.dropzone { border: 2px dashed var(--color-border-strong); border-radius: var(--radius-lg); padding: 38px 24px; text-align: center; background: var(--color-bg); transition: all 0.2s; cursor: pointer; }
.dropzone:hover, .dropzone.dragging { border-color: var(--color-primary); background: var(--color-primary-soft); }
.dropzone-icon { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--color-primary); }
.dropzone h4 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.dropzone p { font-size: 12.5px; color: var(--color-text-muted); }
.file-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.file-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--color-primary-soft); color: var(--color-primary); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.file-meta { flex: 1; min-width: 0; }
.file-meta .name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta .size { font-size: 11.5px; color: var(--color-text-muted); }
.file-remove { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--color-text-faint); }
.file-remove:hover { color: var(--color-danger); background: var(--color-danger-soft); }

.app { display: none; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }
.app.active { display: grid; }
.sidebar { background: var(--color-card); border-left: 1px solid var(--color-border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-header { padding: 24px 20px 20px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 12px; }
.sidebar-section-label { padding: 18px 20px 8px; font-size: 11px; font-weight: 600; color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-nav { padding: 0 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--color-text-muted); font-size: 14px; font-weight: 500; width: 100%; text-align: right; transition: all 0.15s; margin-bottom: 2px; }
.nav-item:hover { background: var(--color-bg); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-soft); color: var(--color-primary-dark); font-weight: 700; }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--color-border); padding: 16px 20px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: 11.5px; color: var(--color-text-muted); }

.main { padding: 28px 36px 60px; max-width: 1400px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 22px; margin-bottom: 26px; border-bottom: 1px solid var(--color-border); flex-wrap: wrap; }
.page-title h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }
.breadcrumb { font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 6px; }
.breadcrumb .sep { color: var(--color-text-faint); margin: 0 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; }
.card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.card-header h3 { font-size: 16px; font-weight: 700; }
.card-header p { font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 20px 22px; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; right: 0; width: 4px; height: 100%; background: var(--color-primary); }
.stat-card.accent::before { background: var(--color-accent); }
.stat-card.warn::before { background: var(--color-warn); }
.stat-card.success::before { background: var(--color-success); }
.stat-label { font-size: 12.5px; color: var(--color-text-muted); font-weight: 500; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.stat-meta { margin-top: 8px; font-size: 12px; color: var(--color-text-muted); }

.table-wrap { border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; background: var(--color-card); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead { background: var(--color-bg); border-bottom: 1px solid var(--color-border); }
.table th { text-align: right; padding: 12px 16px; font-weight: 600; font-size: 12.5px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--color-bg); }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--color-border); gap: 12px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; max-width: 320px; }
.search-box .input { padding-right: 38px; }
.search-box svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--color-text-faint); pointer-events: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.success { background: var(--color-success-soft); color: #047857; }
.badge.warn { background: var(--color-warn-soft); color: #92400e; }
.badge.danger { background: var(--color-danger-soft); color: #b91c1c; }
.badge.neutral { background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge.primary { background: var(--color-primary-soft); color: var(--color-primary-dark); }
.badge.accent { background: var(--color-accent-soft); color: #8b6914; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.action-btn { width: 30px; height: 30px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-muted); transition: all 0.15s; }
.action-btn:hover { background: var(--color-bg); color: var(--color-text); }
.action-btn.danger:hover { background: var(--color-danger-soft); color: var(--color-danger); }
.actions-cell { display: flex; gap: 4px; }

.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); align-items: center; justify-content: center; padding: 20px; z-index: 100; backdrop-filter: blur(4px); }
.modal-overlay.active { display: flex; }
.modal { background: var(--color-card); border-radius: var(--radius-lg); width: 100%; max-width: 460px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3); position: relative; animation: modalIn 0.2s ease; max-height: 90vh; overflow: auto; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-header { padding: 22px 24px 18px; border-bottom: 1px solid var(--color-border); }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close-btn { position: absolute; top: 16px; left: 16px; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--color-text-faint); }
.modal-close-btn:hover { background: var(--color-bg); color: var(--color-text); }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-start; gap: 10px; }
.login-modal-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--color-primary-soft); color: var(--color-primary); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }

.toast-container { position: fixed; top: 24px; left: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--color-card); border: 1px solid var(--color-border); border-right: 4px solid var(--color-success); border-radius: var(--radius); padding: 12px 18px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; min-width: 280px; animation: toastIn 0.3s ease; display: flex; align-items: center; gap: 10px; }
.toast.error { border-right-color: var(--color-danger); }
.toast.warn { border-right-color: var(--color-warn); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: translateX(0); } }

.settings-grid { display: grid; grid-template-columns: 1fr 360px; gap: 24px; }
@media (max-width: 1100px) { .settings-grid { grid-template-columns: 1fr; } }
.color-input-row { display: flex; align-items: center; gap: 10px; }
.color-swatch { width: 44px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--color-border-strong); cursor: pointer; position: relative; overflow: hidden; flex-shrink: 0; }
.color-swatch input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; border: none; cursor: pointer; padding: 0; background: none; }
.color-hex { flex: 1; font-family: 'Courier New', monospace; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.theme-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 8px; }
.preset { border: 2px solid var(--color-border); border-radius: var(--radius); padding: 12px; cursor: pointer; transition: all 0.15s; background: var(--color-card); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.preset:hover { border-color: var(--color-border-strong); transform: translateY(-1px); }
.preset.active { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.preset-colors { display: flex; gap: 4px; }
.preset-color { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.08); }
.preset-name { font-size: 12.5px; font-weight: 600; }
.logo-preview { width: 96px; height: 96px; margin: 0 auto; border-radius: 12px; background: white; border: 1px solid var(--color-border); display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 10px; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview .placeholder { font-size: 32px; font-weight: 900; color: var(--color-primary); }

.public-footer { padding: 20px 24px; border-top: 1px solid var(--color-border); background: var(--color-card); text-align: center; font-size: 12px; color: var(--color-text-muted); }
.success-screen { display: none; text-align: center; padding: 50px 20px; }
.success-screen.active { display: block; animation: fadeIn 0.4s; }
.success-icon { width: 80px; height: 80px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success); display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; animation: scaleIn 0.4s ease; }
@keyframes scaleIn { from { transform: scale(0); } to { transform: scale(1); } }
.success-screen h3 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.success-screen p { font-size: 14px; color: var(--color-text-muted); margin-bottom: 24px; }
.upload-form.hidden { display: none; }
.loader { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { padding: 40px 20px; text-align: center; color: var(--color-text-muted); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 5px; }
@media (max-width: 900px) {
  .app.active { grid-template-columns: 1fr; }
  .sidebar { position: fixed; right: 0; width: var(--sidebar-width); z-index: 50; transform: translateX(100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .public-hero h2 { font-size: 24px; }
  .upload-card { padding: 22px; }
}
