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

:root {
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-success-bg: #dcfce7;
    --color-success-text: #166534;
    --color-error-bg: #fee2e2;
    --color-error-text: #991b1b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --header-height: 64px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

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

/* Header */
.header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    gap: 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
}

.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle.is-open span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem;
    gap: 0.5rem;
    box-shadow: var(--shadow-lg);
}

.nav.is-open {
    display: flex;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius);
    min-height: 44px;
    line-height: 1.75;
}

.nav-link:hover,
.nav-link.active {
    background: #eff6ff;
    color: var(--color-primary);
}

.nav-user {
    padding: 0.75rem 1rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.logout-form {
    padding: 0 1rem;
}

/* Main */
.main {
    padding: 1.5rem 0 3rem;
}

.main-guest {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 2rem);
    padding: 2rem 0;
}

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

/* Filters */
.filters {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 1rem;
}

.filters-grid .form-group {
    margin-bottom: 1rem;
}

.filters-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .filters-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Page header */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.625rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--color-text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--color-danger-hover);
}

.btn-outline {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover {
    background: var(--color-bg);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 36px;
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
}

/* Forms */
.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    max-width: 640px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row .form-group {
    margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.375rem;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    min-height: 44px;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-input {
    min-height: 120px;
    resize: vertical;
}

.form-textarea-large {
    min-height: 240px;
}

.form-input.is-invalid {
    border-color: var(--color-danger);
}

.form-error {
    display: block;
    color: var(--color-danger);
    font-size: 0.85rem;
    margin-top: 0.375rem;
}

.form-hint {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 0.375rem;
}

.form-check {
    margin-bottom: 1.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
    min-height: 44px;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.inline-form {
    display: inline;
}

/* Login */
.login-wrapper {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-lg);
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
}

.login-subtitle {
    text-align: center;
    color: var(--color-text-muted);
    margin: 0.5rem 0 1.5rem;
}

/* Cards (mobile list) */
.cards-mobile {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.card-row {
    font-size: 0.9rem;
    margin-bottom: 0.375rem;
    color: var(--color-text-muted);
}

.card-row strong {
    color: var(--color-text);
}

.card-note {
    font-style: italic;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.card-hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

/* Table (desktop) */
.table-desktop {
    display: none;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.table tr:last-child td {
    border-bottom: none;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-admin {
    background: #fef3c7;
    color: #92400e;
}

.badge-user {
    background: #e0e7ff;
    color: #3730a3;
}

.text-muted {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
}

.empty-state p {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

/* Desktop */
@media (min-width: 768px) {
    .nav-toggle {
        display: none;
    }

    .nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        position: static;
        border: none;
        box-shadow: none;
        padding: 0;
        gap: 0.25rem;
    }

    .nav-link {
        padding: 0.5rem 0.875rem;
        min-height: auto;
    }

    .logout-form {
        padding: 0;
        margin-left: 0.5rem;
    }

    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .cards-mobile {
        display: none;
    }

    .table-desktop {
        display: block;
    }
}
