:root {
    --color-bg: #f3f4f6;
    --color-bg-accent: #e5ecff;
    --color-primary: #4f46e5;
    --color-primary-dark: #3730a3;
    --color-primary-soft: rgba(79, 70, 229, 0.12);
    --color-danger: #dc2626;
    --color-text: #0f172a;
    --color-muted: #6b7280;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-soft: 0 12px 24px rgba(15, 23, 42, 0.08);
}

html {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at top left, #e0e7ff, #f9fafb);
    color: var(--color-text);
}

/* ---------- Лейаут ---------- */

header {
    position: sticky;
    top: 0;
    z-index: 10;
    /* width: 100%; не надо, горизонтальный скролл появляется */
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
}

main {
    max-width: 1200px;
    margin: 32px auto 80px;
    padding: 0 20px 40px;
}

/* ---------- Главное меню ---------- */

header a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: #e5e7eb;
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease,
        box-shadow 0.2s ease, border-color 0.2s ease;
    font-size: 0.95rem;
}

header a:hover {
    background: rgba(148, 163, 184, 0.22);
    border-color: rgba(148, 163, 184, 0.6);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.45);
    transform: translateY(-1px);
}

/* активный пункт меню */
header a.select {
    background: linear-gradient(135deg, var(--color-primary), #ec4899);
    color: #f9fafb;
    border-color: rgba(248, 250, 252, 0.6);
    box-shadow: 0 10px 24px rgba(79, 70, 229, 0.55);
}

/* ---------- Подменю сортировки ---------- */

.submenu {
    max-width: 1200px;
    margin: 12px auto 0;
    padding: 4px 24px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    font-size: 0.85rem;
}

.submenu a {
    padding: 6px 12px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--color-muted);
    border: 1px solid transparent;
    background: rgba(248, 250, 252, 0.6);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
        transform 0.1s ease;
}

.submenu a:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    border-color: rgba(129, 140, 248, 0.6);
    transform: translateY(-1px);
}

.submenu .select {
    background: var(--color-primary);
    color: #f9fafb;
    border-color: transparent;
}

/* ---------- Сообщения об ошибке / успехе ---------- */

.success,
.error {
    max-width: 600px;
    margin: 16px auto;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.success {
    color: #14532d;
    background-color: #dcfce7;
    border-color: #22c55e;
}

.error {
    color: #991b1b;
    background-color: #fee2e2;
    border-color: #f97373;
}

/* ---------- Таблица записной книжки ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 24px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    font-size: 0.88rem;
}

th,
td {
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #eef2ff;
    color: #4b5563;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

tr:nth-child(even) {
    background: #f9fafb;
}

tr:hover {
    background: #e5ecff;
}

/* ---------- Пагинация ---------- */

.pagination {
    margin-top: 18px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.9rem;
}

.pagination a {
    padding: 5px 10px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--color-muted);
    border: 1px solid transparent;
    background: #ffffff;
    transition: border-color 0.15s ease, transform 0.1s ease,
        box-shadow 0.15s ease, background 0.15s ease;
}

.pagination a:hover {
    border: 2px solid var(--color-primary);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
    transform: translateY(-1px);
}

.pagination span {
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--color-primary);
    color: #f9fafb;
    font-weight: 600;
}

/* ---------- Форма добавления / редактирования ---------- */

.add {
    width: 100%;
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}

.column {
    flex: 1 1 320px;
    max-width: 520px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 18px 20px 20px;
}

label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.9rem;
    color: var(--color-muted);
}

label span,
label b {
    font-weight: 500;
    color: var(--color-text);
}

input[type="text"],
input[type="email"],
input[type="date"],
select,
textarea {
    width: 100%;
    box-sizing: border-box;
    margin-top: 4px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    background-color: #f9fafb;
    transition: border-color 0.15s ease, box-shadow 0.15s ease,
        background-color 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
    background-color: #ffffff;
}

textarea {
    resize: vertical;
    min-height: 90px;
}

/* ---------- Кнопка формы ---------- */

.form-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 6px;
    padding: 10px 18px;
    min-width: 180px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--color-primary), #6366f1);
    color: #f9fafb;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease,
        box-shadow 0.2s ease;
}

.form-btn:hover {
    background: linear-gradient(135deg, var(--color-primary-dark), #4f46e5);
    box-shadow: 0 10px 24px rgba(79, 70, 229, 0.5);
    transform: translateY(-1px);
}

.form-btn:active {
    transform: translateY(1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

/* ---------- Боковой список для редактирования ---------- */

.div-edit {
    flex: 0 0 220px;
    max-height: 480px;
    overflow-y: auto;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 14px 12px;
    font-size: 0.9rem;
}

.div-edit p {
    margin-top: 0;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--color-muted);
}

.div-edit a {
    display: block;
    padding: 6px 10px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease,
        transform 0.1s ease;
}

.div-edit a:hover {
    background: var(--color-bg-accent);
    transform: translateX(2px);
}

.div-edit .currentRow {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-weight: 600;
}

/* ---------- Подвал ---------- */

footer {
    width: 100%;
    height: 48px;
    background: #0f172a;
    position: fixed;
    bottom: 0;
    left: 0;
}

/* Чтобы контент не прятался за подвалом */
body {
    padding-bottom: 60px;
}

/* ---------- Адаптив ---------- */

@media (max-width: 768px) {
    header {
        flex-wrap: wrap;
        padding-bottom: 10px;
    }

    header a {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    table {
        font-size: 0.8rem;
    }

    main {
        margin-top: 20px;
        padding: 0 12px 80px;
    }
}
