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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #273548;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #22c55e;
  --warning: #f97316;
  --danger: #ef4444;
  --radius: 8px;
}

body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

.hidden { display: none !important; }

/* Login */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.8rem; color: var(--primary); margin-bottom: .25rem; }
.login-card p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .9rem; }
.login-error { color: var(--danger); font-size: .85rem; margin-top: .5rem; min-height: 1.2em; }

/* Layout */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.5rem 0; position: fixed; top: 0; bottom: 0; left: 0;
}
.sidebar-logo { padding: 0 1.25rem 1.5rem; font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.sidebar-logo span { color: var(--text-muted); font-weight: 400; font-size: .75rem; display: block; }

.nav-link {
  display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem;
  color: var(--text-muted); text-decoration: none; font-size: .9rem; border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--primary); border-left-color: var(--primary); background: var(--surface2); }

.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; }

.main { margin-left: 220px; flex: 1; padding: 2rem; max-width: 1100px; }

/* Components */
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-title { font-size: 1.5rem; font-weight: 700; }
.section-title { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 .75rem; }
.section-header { display: flex; gap: .75rem; margin-bottom: 1rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; }

.input {
  display: block; width: 100%; padding: .55rem .75rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: .9rem; transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--primary); }
.input-lg { font-size: 1.1rem; padding: .75rem 1rem; }
label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: .25rem; }
label + .input, label .input { margin-top: .25rem; }
label { margin-bottom: .9rem; }
.input-color { height: 2.5rem; cursor: pointer; }
textarea.input { min-height: 80px; resize: vertical; }
select.input { cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }

.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge-draft { background: #334155; color: #94a3b8; }
.badge-active { background: #14532d; color: #4ade80; }
.badge-closed { background: #7c2d12; color: #fb923c; }
.badge-pending { background: #1e3a5f; color: #60a5fa; }
.badge-used { background: #14532d; color: #4ade80; }
.badge-cancelled { background: #7c2d12; color: #f87171; }
.badge-ok { background: #14532d; color: #4ade80; }
.badge-already_used { background: #7c2d12; color: #fb923c; }
.badge-not_found { background: #450a0a; color: #f87171; }
.badge-invalid { background: #450a0a; color: #f87171; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; padding: .6rem .75rem; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 500; white-space: nowrap; }
.table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: var(--surface2); }
.table a { color: var(--primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.actions { display: flex; gap: .4rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

.events-list { display: flex; flex-direction: column; gap: .75rem; }
.event-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem;
  transition: border-color .15s;
}
.event-card:hover { border-color: var(--primary); }
.event-info { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.event-stats { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; font-size: .8rem; color: var(--text-muted); }
.progress { width: 120px; height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); transition: width .3s; }

.event-meta { display: flex; gap: 1.25rem; flex-wrap: wrap; color: var(--text-muted); font-size: .875rem; margin-bottom: 1rem; }
.event-desc { color: var(--text-muted); margin-bottom: 1rem; font-size: .9rem; line-height: 1.6; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab {
  padding: .6rem 1.25rem; font-size: .875rem; font-weight: 500;
  border: none; background: none; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--text); }

.pagination { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; font-size: .85rem; color: var(--text-muted); }

/* Validate */
.validate-box { display: flex; gap: .75rem; margin-bottom: 1.5rem; align-items: center; }
.validate-result {
  border: 2px solid; border-radius: var(--radius); padding: 1.5rem; margin-top: 1rem;
  text-align: center; background: var(--surface);
}
.result-icon { font-size: 3rem; margin-bottom: .5rem; }
.result-msg { font-size: 1.5rem; font-weight: 700; margin-bottom: .75rem; }
.result-detail { background: var(--surface2); border-radius: var(--radius); padding: 1rem; margin-top: .75rem; text-align: left; font-size: .9rem; }
.result-detail p { margin-bottom: .25rem; }

.color-swatch { width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--border); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: center; justify-content: center; z-index: 1000; padding: 1rem;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.75rem; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 1.15rem; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: .5rem; }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--primary);
  color: #fff; padding: .75rem 1.25rem; border-radius: var(--radius);
  font-size: .875rem; z-index: 2000; animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.loading { color: var(--text-muted); padding: 2rem; text-align: center; }

code { background: var(--bg); padding: .15rem .4rem; border-radius: 4px; font-size: .85em; font-family: monospace; }

@media (max-width: 640px) {
  .sidebar { width: 60px; }
  .sidebar-logo, .nav-link span, .sidebar-footer { display: none; }
  .main { margin-left: 60px; padding: 1rem; }
}
