:root {
    --background: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #eef1f5;
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --nav: #212529;
    --nav-hover: #343a40;
    --text: #17202a;
    --muted: #5f6b7a;
    --border: #d8dee8;
    --header-text: #ffffff;
    --shadow: 0 8px 28px rgba(23, 32, 42, 0.06);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}

a {
    color: var(--primary-dark);
}

button,
input,
select,
textarea {
    font: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav);
    color: var(--header-text);
    box-shadow: none;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1100px;
    min-height: 62px;
    margin: 0 auto;
    padding: 0 22px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--header-text);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.menu-toggle {
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 6px;
    background: transparent;
    color: var(--header-text);
    cursor: pointer;
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
    background: var(--nav-hover);
}

.menu-icon,
.menu-icon::before,
.menu-icon::after {
    display: block;
    width: 21px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.menu-icon {
    position: relative;
}

.menu-icon::before,
.menu-icon::after {
    position: absolute;
    left: 0;
    content: '';
}

.menu-icon::before { top: -7px; }
.menu-icon::after { top: 7px; }

.main-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: max(20px, calc((100% - 1100px) / 2 + 22px));
    width: min(330px, calc(100vw - 32px));
    max-height: calc(100vh - 88px);
    overflow-y: auto;
    border: 1px solid #343a40;
    border-top: 0;
    border-radius: 0 0 8px 8px;
    background: var(--nav);
    box-shadow: var(--shadow);
}

.main-menu.active {
    display: block;
}

.main-menu ul {
    margin: 0;
    padding: 8px;
    list-style: none;
}

.main-menu a,
.submenu-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--header-text);
    cursor: pointer;
    font: inherit;
    text-align: left;
    text-decoration: none;
}

.submenu-chevron,
.tool-chevron {
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 160ms ease;
}

.menu-group.open > .submenu-toggle .submenu-chevron {
    transform: rotate(225deg);
}

.main-menu a:hover,
.main-menu a:focus-visible,
.submenu-toggle:hover,
.submenu-toggle:focus-visible {
    background: var(--nav-hover);
    outline: none;
}

.submenu {
    display: none;
    margin: 0 0 5px 12px !important;
    padding: 3px 0 3px 10px !important;
    border-left: 2px solid rgba(255, 255, 255, 0.28);
}

.menu-group.open .submenu {
    display: block;
}

.submenu a {
    font-size: 0.94rem;
}

.menu-label {
    margin: 8px 12px 3px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

main {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0;
}

main h1,
main h2,
main h3 {
    margin-top: 0;
    color: var(--text);
    line-height: 1.2;
}

.welcome {
    max-width: 760px;
    margin: 0 auto 32px;
    text-align: center;
}

.welcome h1 {
    margin-bottom: 10px;
    font-size: clamp(2.2rem, 6vw, 4rem);
    font-weight: 800;
    letter-spacing: -0.035em;
}

.welcome p {
    margin: 0;
    color: var(--muted);
    font-size: 1.08rem;
}

.btn,
button[type='submit'] {
    display: inline-block;
    padding: 11px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.btn:hover,
button[type='submit']:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.tools-section {
    padding-top: 0;
}

.tools-section h2 {
    margin-bottom: 18px;
    font-size: 1.5rem;
}

.tool-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.tool-item {
    display: grid;
    grid-template-columns: 52px 1fr 14px;
    gap: 15px;
    align-items: center;
    min-height: 112px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: border-color 140ms ease, transform 140ms ease;
}

.tool-item:hover,
.tool-item:focus-visible {
    border-color: #adb8c7;
    outline: none;
    transform: translateY(-2px);
}

.tool-item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.tool-badge {
    display: grid;
    width: 52px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--primary-dark);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.tool-content {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.tool-content strong {
    color: var(--text);
    font-size: 1.05rem;
}

.tool-content span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.89rem;
    line-height: 1.4;
}

.tool-chevron {
    width: 9px;
    height: 9px;
    color: var(--primary);
    transform: rotate(-45deg);
}

form {
    max-width: 720px;
    margin: 20px auto;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: left;
}

label {
    display: block;
    margin: 12px 0 5px;
    font-weight: 700;
}

input,
select,
textarea {
    max-width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
}

table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
    overflow-x: auto;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    background: var(--surface-muted);
}

.admin-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.btn-edit,
.btn-delete,
.btn-password {
    display: inline-block;
    margin: 2px;
    padding: 6px 9px;
    border-radius: 5px;
    color: #fff;
    text-decoration: none;
}

.btn-edit { background: #2878c7; }
.btn-delete { background: #c43d3d; }
.btn-password { background: #268247; }

.site-footer {
    padding: 24px 20px 34px;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

.footer-content {
    display: flex;
    max-width: 1100px;
    margin: 0 auto;
    justify-content: space-between;
    gap: 15px;
}

.footer-content p {
    margin: 0;
}

@media (max-width: 700px) {
    main {
        width: calc(100% - 20px);
        padding: 32px 0;
    }

    .tool-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tool-item:last-child:nth-child(odd) {
        grid-column: auto;
    }

    .tool-item {
        grid-template-columns: 45px 1fr 12px;
        gap: 12px;
        min-height: 96px;
        padding: 16px;
    }

    .tool-badge {
        width: 45px;
        height: 36px;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    table {
        display: block;
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .tool-item,
    .submenu-chevron { transition: none; }
}
