:root {
    --transition-fast: 0.2s ease-in-out;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.top-bar h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.top-bar-right label {
    font-size: 0.9rem;
}

.container {
    padding: 1.5rem;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.card {
    border-radius: 16px;
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.card-header h2 {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th, td {
    padding: 0.6rem 0.5rem;
    text-align: left;
}

th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

tr:nth-child(even) {
    opacity: 0.95;
}

.btn {
    border-radius: 999px;
    border: none;
    padding: 0.45rem 0.9rem;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    text-decoration: none;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn.primary {
    font-weight: 600;
}

.btn.secondary {
    font-weight: 500;
}

.btn:active {
    transform: scale(0.97);
}

select {
    padding: 0.3rem 0.5rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: transparent;
    color: inherit;
    font-size: 0.85rem;
    outline: none;
}

.link {
    text-decoration: none;
    font-weight: 500;
}

.flash-container {
    margin-bottom: 1rem;
}

.flash {
    border-radius: 999px;
    padding: 0.5rem 0.9rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

/* Modal */

.modal-backdrop {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.modal-content {
    width: 100%;
    max-width: 420px;
    border-radius: 20px;
    padding: 1rem 1.25rem 1.25rem 1.25rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.7rem;
    gap: 0.25rem;
}

input[type="text"],
input[type="number"],
input[type="file"] {
    padding: 0.4rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    color: inherit;
    font-size: 0.9rem;
    outline: none;
}

input[type="file"] {
    padding: 0.3rem 0.6rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

.modal.visible,
.modal-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Theme: dark (default) */

body.theme-dark {
    background: radial-gradient(circle at top left, #1e293b, #020617 55%);
    color: #e5e7eb;
}

body.theme-dark .top-bar {
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.7));
    border-bottom-color: rgba(148, 163, 184, 0.3);
}

body.theme-dark .card {
    background: radial-gradient(circle at top left, #0f172a, #020617);
    border-color: rgba(148, 163, 184, 0.35);
}

body.theme-dark table {
    color: #e5e7eb;
}

body.theme-dark th {
    color: #94a3b8;
}

body.theme-dark tr:nth-child(even) {
    background-color: rgba(15, 23, 42, 0.7);
}

body.theme-dark tr:nth-child(odd) {
    background-color: rgba(15, 23, 42, 0.3);
}

body.theme-dark .btn.primary {
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    color: #0b1120;
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.35);
}

body.theme-dark .btn.secondary {
    background: transparent;
    color: #e5e7eb;
    border: 1px solid rgba(148, 163, 184, 0.8);
}

body.theme-dark .btn.secondary:hover {
    background-color: rgba(148, 163, 184, 0.15);
}

body.theme-dark select {
    border-color: rgba(148, 163, 184, 0.8);
    background-color: rgba(15, 23, 42, 0.7);
}

body.theme-dark .link {
    color: #38bdf8;
}

body.theme-dark .link:hover {
    text-decoration: underline;
}

body.theme-dark .flash.success {
    background-color: rgba(22, 163, 74, 0.2);
    color: #bbf7d0;
    border: 1px solid rgba(34, 197, 94, 0.7);
}

body.theme-dark .flash.error {
    background-color: rgba(185, 28, 28, 0.18);
    color: #fecaca;
    border: 1px solid rgba(248, 113, 113, 0.7);
}

body.theme-dark .modal-content {
    background: radial-gradient(circle at top left, #0f172a, #020617);
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.9);
}

body.theme-dark .modal-close {
    color: #94a3b8;
}

/* Theme: pastel */

body.theme-pastel {
    background: radial-gradient(circle at top left, #f9a8d4, #bfdbfe 40%, #bbf7d0 80%);
    color: #1f2933;
}

body.theme-pastel .top-bar {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    border-bottom-color: rgba(148, 163, 184, 0.4);
}

body.theme-pastel .card {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: 0 18px 40px rgba(148, 163, 184, 0.45);
}

body.theme-pastel table {
    color: #111827;
}

body.theme-pastel th {
    color: #6b7280;
}

body.theme-pastel tr:nth-child(even) {
    background-color: rgba(239, 246, 255, 0.9);
}

body.theme-pastel tr:nth-child(odd) {
    background-color: rgba(240, 253, 250, 0.9);
}

body.theme-pastel .btn.primary {
    background: linear-gradient(135deg, #fb7185, #f97316);
    color: #fff7ed;
    box-shadow: 0 14px 30px rgba(248, 113, 113, 0.4);
}

body.theme-pastel .btn.secondary {
    background: rgba(255, 255, 255, 0.85);
    color: #1f2933;
    border: 1px solid rgba(148, 163, 184, 0.8);
}

body.theme-pastel .btn.secondary:hover {
    background-color: rgba(249, 250, 251, 0.9);
}

body.theme-pastel select {
    border-color: rgba(148, 163, 184, 0.8);
    background-color: rgba(255, 255, 255, 0.9);
    color: #1f2933;
}

body.theme-pastel .link {
    color: #db2777;
}

body.theme-pastel .link:hover {
    text-decoration: underline;
}

body.theme-pastel .flash.success {
    background-color: rgba(22, 163, 74, 0.15);
    color: #166534;
    border: 1px solid rgba(22, 163, 74, 0.7);
}

body.theme-pastel .flash.error {
    background-color: rgba(185, 28, 28, 0.12);
    color: #b91c1c;
    border: 1px solid rgba(185, 28, 28, 0.7);
}

body.theme-pastel .modal-content {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.65);
    box-shadow: 0 20px 50px rgba(148, 163, 184, 0.8);
}

body.theme-pastel .modal-close {
    color: #6b7280;
}

/* Theme: cubist */

body.theme-cubist {
    background: linear-gradient(135deg, #111827 0%, #111827 35%, #1d4ed8 35%, #1d4ed8 70%, #b91c1c 70%, #b91c1c 100%);
    color: #f9fafb;
}

body.theme-cubist .top-bar {
    background: #020617;
    border-bottom-color: #facc15;
    box-shadow: 0 6px 0 #facc15;
}

body.theme-cubist .top-bar h1 {
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

body.theme-cubist .card {
    background: #020617;
    border-radius: 0;
    border: 3px solid #facc15;
    box-shadow: 10px 10px 0 #0f172a;
}

body.theme-cubist table {
    color: #f9fafb;
    border-collapse: separate;
    border-spacing: 0;
}

body.theme-cubist th {
    background-color: #0f172a;
    color: #facc15;
    text-transform: uppercase;
    border-bottom: 3px solid #b91c1c;
}

body.theme-cubist td {
    border-bottom: 1px solid #1f2937;
}

body.theme-cubist tr:nth-child(even) {
    background-color: rgba(15, 23, 42, 0.9);
}

body.theme-cubist tr:nth-child(odd) {
    background-color: rgba(15, 23, 42, 0.7);
}

body.theme-cubist .btn.primary {
    background: #facc15;
    color: #020617;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: 6px 6px 0 #b91c1c;
    border-radius: 0;
}

body.theme-cubist .btn.secondary {
    background: #e5e7eb;
    color: #020617;
    text-transform: uppercase;
    font-weight: 700;
    border-radius: 0;
    box-shadow: 4px 4px 0 #1d4ed8;
}

body.theme-cubist .btn.secondary:hover {
    background-color: #f9fafb;
}

body.theme-cubist select {
    border-radius: 0;
    border: 2px solid #facc15;
    background-color: #020617;
    color: #facc15;
}

body.theme-cubist .link {
    color: #facc15;
    font-weight: 700;
    text-transform: uppercase;
}

body.theme-cubist .link:hover {
    text-decoration: underline;
}

body.theme-cubist .flash.success {
    background-color: #16a34a;
    color: #f9fafb;
    border-radius: 0;
    border: 2px solid #bbf7d0;
}

body.theme-cubist .flash.error {
    background-color: #b91c1c;
    color: #fee2e2;
    border-radius: 0;
    border: 2px solid #fecaca;
}

body.theme-cubist .modal-content {
    background: #020617;
    border-radius: 0;
    border: 3px solid #facc15;
    box-shadow: 12px 12px 0 #0f172a;
}

body.theme-cubist .modal-close {
    color: #facc15;
}

body.theme-cubist input[type="text"],
body.theme-cubist input[type="number"],
body.theme-cubist input[type="file"] {
    border-radius: 0;
    border: 2px solid #1d4ed8;
    background-color: #020617;
    color: #f9fafb;
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .top-bar-right {
        flex-wrap: wrap;
    }

    .card {
        padding: 0.9rem;
    }

    .modal-content {
        margin: 0 1rem;
    }
}
