:root {
    --nav-height: 84px;
    --z-base: 0;
    --z-dropdown: 200;
    --z-sticky: 400;
    --z-backdrop: 500;
    --z-drawer: 600;
    --z-modal: 700;
    --z-modal-content: 710;
    --z-toast: 800;

    /* Brand colors */
    --clr-primary:       #1d4ed8;
    --clr-primary-hover: #1e40af;
    --clr-primary-light: #eff6ff;
    --clr-primary-50:    rgba(29,78,216,0.07);
    --clr-accent:        #f97316;   /* orange for secondary accents */
    --clr-surface:       #ffffff;
    --clr-bg:            #f1f5f9;
    --clr-border:        #e2e8f0;
    --clr-text:          #1e293b;
    --clr-text-muted:    #64748b;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background: #f0f2f5;
}

.main-nav {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f172a 100%);
    color: #f1f5f9;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    min-height: var(--nav-height);
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 4px 24px rgba(0,0,0,0.35);
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.nav-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.nav-title a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-links > a {
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    transition: background 0.18s, color 0.18s;
    letter-spacing: 0.01em;
}

.nav-links > a:hover {
    background: rgba(255,255,255,0.09);
    color: #f1f5f9;
}

/* Стили для выпадающего меню */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.18s, color 0.18s;
}

.nav-dropdown:hover .nav-dropdown-toggle {
    background: rgba(255,255,255,0.09);
    color: #f1f5f9;
}

.nav-dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
    opacity: 0.7;
}

.nav-dropdown:hover .nav-dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 210px;
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.97);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 1000;
}

.nav-dropdown:hover .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 400;
    font-size: 0.88rem;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.nav-dropdown-menu a:hover {
    background: rgba(59,130,246,0.18);
    color: #93c5fd;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0.25rem;
    margin-left: auto;
    color: inherit;
}

.nav-toggle-line {
    width: 1.75rem;
    height: 3px;
    background-color: currentColor;
    border-radius: 999px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

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

.nav-links:focus-within {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: 4px;
    border-radius: 8px;
}

.main-nav:focus-within .nav-toggle {
    outline: 2px solid rgba(255, 255, 255, 0.45);
    outline-offset: 4px;
    border-radius: 10px;
}

.user-info span {
    margin-right: 1rem;
}

.user-info a {
    color: #3498db;
    text-decoration: none;
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    min-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 2rem;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dddddd;
    border-radius: 4px;
}

button {
    background: #3498db;
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background: #2980b9;
}

.add-form {
    background: #ffffff;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

.add-form input,
.add-form select {
    padding: 0.5rem;
    border: 1px solid #dddddd;
    border-radius: 4px;
    min-width: 200px;
}

.add-form textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dddddd;
    border-radius: 4px;
    min-height: 100px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-field label {
    font-weight: bold;
}

.table-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

table {
    background: #ffffff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eeeeee;
}

th {
    background: #34495e;
    color: #ffffff;
}

tr:hover {
    background: #f8f9fa;
}

.flash {
    padding: 1rem;
    margin: 1rem 0;
    background: #e74c3c;
    color: #ffffff;
    border-radius: 4px;
}

.search-filter {
    margin: 1rem 0;
    display: flex;
    gap: 1rem;
}

.search-filter input,
.search-filter select {
    padding: 0.5rem;
    border: 1px solid #dddddd;
    border-radius: 4px;
}

.search-filter button {
    padding: 0.5rem 1rem;
}

.pagination {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.pagination a {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #3498db;
    border: 1px solid #dddddd;
    border-radius: 4px;
}

.pagination a.active {
    background: #3498db;
    color: #ffffff;
}

.pagination a:hover:not(.active) {
    background: #f8f9fa;
}

.system-title {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.system-title:hover {
    color: #007bff;
}

.nav-links a:focus-visible,
.system-title:focus-visible,
button:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
    border-radius: 6px;
}

@media (max-width: 1024px) {
    :root {
        --nav-height: 64px;
    }

    .main-nav {
        flex-wrap: wrap;
        padding: 0.9rem 1.25rem;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .nav-links {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-top: 0;
        padding-top: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
        transition: max-height 0.35s ease, opacity 0.3s ease;
    }

    .nav-links.open {
        max-height: 400px;
        opacity: 1;
        margin-top: 0.75rem;
        padding-top: 0.25rem;
        pointer-events: auto;
    }

    body.nav-open {
        overflow: hidden;
    }

    .container {
        padding: 0 1.25rem;
    }
}

@media (max-width: 600px) {
    :root {
        --nav-height: 58px;
    }

    .main-nav {
        padding: 0.75rem 1rem;
    }

    .nav-toggle-line {
        width: 1.5rem;
    }

    .nav-title {
        font-size: 1.1rem;
    }

    .container {
        padding: 0 1rem;
    }
}

/* Optimizations for Thin Phones (Folded Z Fold, iPhone SE, etc) */
@media (max-width: 360px) {
    :root {
        --nav-height: 52px;
    }

    .main-nav {
        padding: 0.5rem 0.5rem;
    }

    .nav-title {
        font-size: 0.95rem;
        line-height: 1.2;
    }
    
    .nav-links a {
        font-size: 0.9rem;
    }

    .container {
        padding: 0 0.5rem;
    }
    
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .button {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
}

