/* Основной стиль для страницы */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

body[data-theme="light"] {
    background: radial-gradient(1000px 500px at 20% 0%, rgba(191, 219, 254, 0.8), transparent 60%),
                radial-gradient(900px 500px at 80% 0%, rgba(221, 214, 254, 0.8), transparent 55%),
                linear-gradient(180deg, #f7f7fb 0%, #fdfdff 45%, #f5f5ff 100%);
    color: #1f2933;
}

body[data-theme="dark"] {
    background-color: #020617;
    color: #e5e7eb;
}

body[data-theme="dark"]::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        linear-gradient(to bottom, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9)),
        url("темная тема.png") center/cover no-repeat;
    opacity: 1;
    z-index: -1;
}

header {
    position: relative;
    padding: 80px 16px 80px;
    color: #ffffff;
    overflow: hidden;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.25);
}

header::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to bottom, rgba(15, 23, 42, 0.85), rgba(37, 99, 235, 0.6)),
        url("шапка.png") center/cover no-repeat;
    filter: brightness(0.85);
    transform: scale(1.04);
    z-index: -1;
}

h1 {
    margin: 0;
    font-size: 2.4rem;
    letter-spacing: 0.2px;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

header p {
    margin-top: 18px; /* опускаем строку чуть ниже заголовка */
    margin-bottom: 0;
    color: rgba(255, 255, 255, 0.9);
}

.page {
    width: min(1100px, 92vw);
    margin: 26px auto 40px;
    flex: 1;
}

.auth-container {
    width: min(520px, 92vw);
    margin: 0;
    padding: 20px 22px 22px;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    position: relative;
    z-index: 1;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.auth-modal[hidden] {
    display: none;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(4px);
}

.auth-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.auth-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.auth-switch-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-switch-wrap span {
    font-size: 0.9rem;
    opacity: 0.9;
}

.auth-switch-wrap #authSwitchBtn {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
}

.auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.auth-status {
    min-height: 20px;
    margin: 10px 0 0;
    font-size: 0.9rem;
}

.toggle-password-btn {
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
}

/* Стилизация формы */
.form-container {
    width: 100%;
    margin: 0 auto 20px;
    padding: 20px 22px 22px;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
}

.form-group {
    margin-bottom: 15px;
}

.form-textarea {
    min-height: 96px;
}

.form-description {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

label {
    font-weight: bold;
    margin-bottom: 5px;
    display: inline-block;
}

input, select {
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(55, 65, 81, 0.9);
    border-radius: 10px;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
    outline: none;
}

input::placeholder {
    color: #9ca3af;
}

input:focus, select:focus {
    border-color: rgba(96, 165, 250, 1);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45);
}

button {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
}

button:hover {
    filter: brightness(1.05);
}

/* Стиль для вывода сценария */
.result-container {
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
}

textarea {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid rgba(55, 65, 81, 0.9);
    border-radius: 12px;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
    min-height: 96px;
    line-height: 1.5;
    resize: vertical;
}

.script-output {
    min-height: 52vh;
}

textarea:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.75);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.result-actions button {
    padding: 10px 14px;
}

.theme-toggle-container {
    width: 100%;
    margin: 22px auto 0;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}

.theme-toggle-container #themeToggleBtn {
    width: 74px;
    height: 74px;
    padding: 0;
    border-radius: 16px;
    background-repeat: no-repeat;
    background-size: 60px 60px;
    background-position: center;
}

.account-badge {
    font-size: 0.9rem;
    opacity: 0.9;
}

.nav-menu {
    width: 100%;
    margin: 18px auto 0;
    padding: 18px 22px 20px;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
}

.nav-menu-description {
    margin: 0 0 12px;
    font-size: 0.95rem;
}

.nav-menu-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.nav-menu-item {
    flex: 1 1 260px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.nav-menu-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.nav-menu-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

.nav-menu-hint {
    margin-top: 14px;
    margin-bottom: 0;
    font-size: 0.85rem;
    opacity: 0.9;
}

.tool-container {
    width: 100%;
    margin: 18px auto 0;
    padding: 18px 22px 20px;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
}

.tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tool-header h2 {
    margin: 0;
}

.tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tool-body {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.tool-visual {
    width: 100%;
    min-height: 120px;
    border-radius: 12px;
    border: 1px solid rgba(75, 85, 99, 0.5);
    background: rgba(15, 23, 42, 0.35);
    overflow: auto;
    padding: 10px;
}

.viz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.viz-card {
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.35);
}

.viz-card h3 {
    margin: 0 0 6px;
    font-size: 0.95rem;
}

.viz-card p {
    margin: 0 0 6px;
    font-size: 0.88rem;
    line-height: 1.4;
}

.viz-card ul {
    margin: 0;
    padding-left: 18px;
    font-size: 0.85rem;
}

.viz-legend {
    margin-top: 8px;
    font-size: 0.84rem;
    opacity: 0.9;
}

.graph-edge {
    transition: stroke 0.15s ease, stroke-width 0.15s ease, opacity 0.15s ease;
}

.graph-edge.is-dim {
    opacity: 0.2;
}

.graph-edge.is-active {
    stroke: rgba(250, 204, 21, 0.95);
    stroke-width: 3;
    opacity: 1;
}

.graph-node {
    cursor: grab;
}

.graph-node:active {
    cursor: grabbing;
}

.graph-node circle {
    transition: stroke 0.15s ease, stroke-width 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.graph-node.is-dim circle,
.graph-node.is-dim text {
    opacity: 0.35;
}

.graph-node.is-active circle {
    stroke: rgba(250, 204, 21, 0.98);
    stroke-width: 3;
    filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.45));
}

body[data-theme="light"] .tool-container {
    background: #ffffff;
}

body[data-theme="dark"] .tool-container {
    background: rgba(15, 23, 42, 0.9);
}

body[data-theme="light"] .viz-card {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.history-container {
    width: 100%;
    margin: 18px auto 0;
    padding: 18px 22px 20px;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
}

.history-container h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

.history-empty {
    margin: 0 0 6px;
    font-size: 0.9rem;
    color: #9ca3af;
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.9rem;
}

.history-item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item-title {
    font-weight: 600;
}

.history-item-meta {
    font-size: 0.8rem;
}

.history-item-actions {
    display: flex;
    gap: 6px;
}

.history-item-actions button {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.admin-container {
    width: 100%;
    margin: 18px auto 0;
    padding: 18px 22px 20px;
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-dashboard {
    margin: 12px 0 18px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
}

.admin-stat-card {
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-stat-card strong {
    font-size: 1.35rem;
}

.admin-table-wrap {
    overflow: auto;
    margin-bottom: 16px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    padding: 8px;
    font-size: 0.88rem;
    text-align: left;
}

.admin-row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.admin-row-actions button {
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* Светлая тема */
body[data-theme="light"] .form-container {
    background: #ffffff;
}

body[data-theme="light"] .auth-container {
    background: #ffffff;
}

body[data-theme="light"] .form-description {
    color: #4b5563;
}

body[data-theme="light"] label {
    color: #111827;
}

body[data-theme="light"] input,
body[data-theme="light"] select {
    border-color: #d1d5db;
    background: #ffffff;
    color: #111827;
}

body[data-theme="light"] textarea {
    border-color: #d1d5db;
    background: #f9fafb;
    color: #111827;
}

body[data-theme="light"] .result-container {
    background: #ffffff;
}

body[data-theme="light"] .history-container {
    background: #ffffff;
}

body[data-theme="light"] .nav-menu {
    background: #ffffff;
}

body[data-theme="light"] .admin-container {
    background: #ffffff;
}

body[data-theme="light"] .admin-stat-card {
    background: #f8fafc;
    border-color: #e2e8f0;
}

body[data-theme="light"] .history-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

body[data-theme="light"] .history-item-title {
    color: #111827;
}

body[data-theme="light"] .history-item-meta {
    color: #6b7280;
}

body[data-theme="light"] .auth-status {
    color: #4b5563;
}

body[data-theme="light"] footer {
    background: #f3f4f6;
    border-top: 1px solid #e5e7eb;
    color: #4b5563;
}

/* Тёмная тема */
body[data-theme="dark"] .form-container {
    background: rgba(15, 23, 42, 0.9);
}

body[data-theme="dark"] .auth-container {
    background: rgba(15, 23, 42, 0.9);
}

body[data-theme="dark"] .form-description {
    color: #cbd5f5;
}

body[data-theme="dark"] label {
    color: #e5e7eb;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select {
    border-color: rgba(55, 65, 81, 0.9);
    background: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
}

body[data-theme="dark"] textarea {
    border-color: rgba(55, 65, 81, 0.9);
    background: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
}

body[data-theme="dark"] .result-container {
    background: rgba(15, 23, 42, 0.9);
}

body[data-theme="dark"] .history-container {
    background: rgba(15, 23, 42, 0.9);
}

body[data-theme="dark"] .nav-menu {
    background: rgba(15, 23, 42, 0.9);
}

body[data-theme="dark"] .admin-container {
    background: rgba(15, 23, 42, 0.9);
}

body[data-theme="dark"] .admin-stat-card {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(75, 85, 99, 0.9);
}

body[data-theme="dark"] .history-item {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(75, 85, 99, 0.9);
}

body[data-theme="dark"] .history-item-title {
    color: #e5e7eb;
}

body[data-theme="dark"] .history-item-meta {
    color: #9ca3af;
}

body[data-theme="dark"] .auth-status {
    color: #cbd5f5;
}

body[data-theme="dark"] footer {
    background: rgba(15, 23, 42, 0.98);
    border-top: 1px solid rgba(55, 65, 81, 0.9);
    color: #9ca3af;
}

footer {
    text-align: center;
    padding: 10px;
    width: 100%;
    margin-top: auto;
}

@media print {
    body {
        background: #ffffff !important;
    }

    header,
    .form-container,
    .result-actions,
    footer {
        display: none !important;
    }

    .result-container {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    textarea {
        border: none;
        background: #ffffff;
        min-height: auto;
    }
}