:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --accent-primary: #3b82f6;
    --accent-secondary: #10b981;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

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

.hidden {
    display: none !important;
}

#gpon-form.gpon-ural #gpon-csm-fields {
    display: none !important;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* Header */
.header {
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--accent-primary);
}

.header .tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Tabs */
.tech-tabs {
    display: flex;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 18px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom: 3px solid var(--accent-primary);
    background-color: rgba(59, 130, 246, 0.05);
}

/* Main Forms */
.main-content {
    padding: 30px;
}

.tech-form {
    display: none;
    animation: fadeIn 0.5s ease;
}

.tech-form.active {
    display: block;
}

.tech-form h2 {
    font-size: 1.8rem;
    margin-bottom: 25px;
    color: var(--accent-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.form-grid-single-row {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    grid-auto-flow: row;
}

.form-group, .form-group-full {
    display: flex;
    flex-direction: column;
}

.form-group-full {
    grid-column: 1 / -1;
}

.vlan-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vlan-input-group-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 15px;
    align-items: flex-end;
    width: 100%;
}

.vlan-field {
    display: flex;
    flex-direction: column;
    min-width: 150px;
    flex: 0 0 auto;
    max-width: 250px;
    width: auto;
}

label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    cursor: help;
    color: var(--accent-primary);
    font-size: 0.9rem;
    margin-left: 4px;
    transition: color 0.2s;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 50%;
}

.info-icon:hover {
    color: var(--accent-secondary);
}

.info-tooltip {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0;
    background-color: var(--bg-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 9999;
    min-width: 600px;
    max-width: 700px;
    max-height: 60vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.info-icon:hover > .info-tooltip {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(4px);
}

.info-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--accent-primary);
}

.tooltip-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    color: var(--text-primary);
    display: block;
    max-height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) var(--bg-tertiary);
}

.tooltip-table::-webkit-scrollbar {
    width: 8px;
}

.tooltip-table::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.tooltip-table::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

.tooltip-table::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

.tooltip-table thead {
    background-color: var(--bg-tertiary);
    display: table;
    width: 100%;
    table-layout: fixed;
    position: sticky;
    top: 0;
    z-index: 10;
}

.tooltip-table tbody {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.tooltip-table tbody tr {
    display: table-row;
}

.tooltip-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--accent-primary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.tooltip-table th:first-child {
    border-top-left-radius: 8px;
    width: 10%;
}

.tooltip-table th:nth-child(2) {
    width: 20%;
}

.tooltip-table th:nth-child(3),
.tooltip-table th:nth-child(4),
.tooltip-table th:nth-child(5) {
    width: 23.33%;
}

.tooltip-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
    color: var(--text-primary);
    font-size: 0.8rem;
    line-height: 1.4;
    vertical-align: top;
}

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

.tooltip-table tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.tooltip-table td:nth-child(3),
.tooltip-table td:nth-child(4),
.tooltip-table td:nth-child(5) {
    font-family: var(--font-mono);
    color: var(--accent-secondary);
    font-weight: 500;
}

/* Компактные таблицы для подсказок */
.tooltip-table.tooltip-table-compact {
    font-size: 0.75rem;
    max-height: 320px;
}

.tooltip-table.tooltip-table-compact th {
    padding: 6px 8px;
    font-size: 0.75rem;
}

.tooltip-table.tooltip-table-compact th:first-child {
    width: 35%;
}

.tooltip-table.tooltip-table-compact th:nth-child(2),
.tooltip-table.tooltip-table-compact th:nth-child(3) {
    width: 32.5%;
}

.tooltip-table.tooltip-table-compact td {
    padding: 5px 8px;
    font-size: 0.75rem;
    line-height: 1.3;
}

.tooltip-table.tooltip-table-compact td:nth-child(3),
.tooltip-table.tooltip-table-compact td:nth-child(4) {
    font-size: 0.7rem;
}

.tooltip-table.tooltip-table-compact td:nth-child(2),
.tooltip-table.tooltip-table-compact td:nth-child(3) {
    color: var(--accent-secondary);
}

.tooltip-table.tooltip-table-compact td:nth-child(2) {
    color: var(--accent-primary);
    font-weight: 600;
}

.tooltip-table .region-cell {
    background-color: var(--bg-tertiary);
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    padding: 12px 6px;
    border-right: 2px solid var(--accent-primary);
}

/* Горизонтальное расположение филиалов в подсказке VPI/VCI */
.tooltip-columns {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 10px 12px;
}

.tooltip-column {
    flex: 1 1 0;
    min-width: 0;
}

.tooltip-column-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent-primary);
    margin-bottom: 6px;
    text-align: center;
}

.tooltip-table .region-divider td {
    border-top: 2px dashed var(--border-color);
    height: 4px;
    padding: 0;
}

.form-select, .form-input {
    padding: 12px 15px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    transition: border 0.3s, box-shadow 0.3s;
}

.form-select:focus, .form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-input.error {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.form-input.error:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.form-input.valid {
    border-color: var(--accent-secondary);
}

.error-message {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 20px;
}

.error-message i {
    font-size: 0.75rem;
}

.form-group {
    position: relative;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    border: none;
}

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

.btn-primary:hover {
    background-color: #2563eb;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Output Section */
.output-section {
    margin-top: 40px;
    background-color: var(--bg-primary);
    border-radius: 12px;
    padding: 25px;
    border: 1px solid var(--border-color);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.output-header h3 {
    color: var(--accent-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.config-output, .diagnostics-output {
    background-color: #1a2332;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: #b9c8e0;
    white-space: pre-wrap;
    overflow-x: auto;
    line-height: 1.5;
    margin-bottom: 25px;
    min-height: 150px;
}

.diagnostics-section h4 {
    color: var(--text-secondary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Диагностика с группами и пояснениями */
.diagnostics-output {
    background-color: #1a2332;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: #b9c8e0;
    white-space: normal;
    overflow-x: auto;
    line-height: 1.5;
    margin-bottom: 25px;
    min-height: 150px;
}

.diag-group {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
}

.diag-group:last-child {
    border-bottom: none;
}

.diag-group-header {
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05));
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid var(--accent-primary);
}

.diag-group-header:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
    padding-left: 22px;
}

.diag-group-header i {
    font-size: 0.85rem;
}

.diag-group-content {
    padding: 0;
}

.diag-command {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
    transition: background-color 0.2s;
}

.diag-command:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

.diag-command:last-child {
    border-bottom: none;
}

.diag-command-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.diag-command-text {
    color: #b9c8e0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    margin-bottom: 6px;
    word-break: break-all;
    white-space: pre-wrap;
    padding: 10px 14px;
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    border-left: 3px solid var(--accent-secondary);
    transition: all 0.2s;
    cursor: pointer;
    flex: 1;
}

.diag-command-text:hover {
    background-color: rgba(0, 0, 0, 0.35);
    border-left-color: var(--accent-primary);
}

.diag-copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
}

.diag-copy-btn:hover {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    transform: scale(1.05);
}

.diag-command-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding-left: 14px;
    margin-top: 6px;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    user-select: none;
    cursor: default;
    max-width: 45%;
    margin-top: 0;
    padding-left: 0;
}

.diag-command-desc::before {
    content: "";
}

.diag-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 500;
    box-shadow: var(--shadow);
    z-index: 1000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 350px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--accent-secondary);
}

/* GPON VLAN поля - компактные */
.gpon-vlan-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 4px 0;
}

.gpon-vlan-field {
    min-width: 0;
}

.form-input-sm {
    padding: 8px 12px;
    font-size: 0.9rem;
    text-align: center;
}

/* GPON действия - компактные чекбоксы */
.gpon-actions-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 4px 0;
}

.gpon-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
}

.gpon-checkbox:hover {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-primary);
}

.gpon-checkbox-sm {
    padding: 8px 12px;
    justify-content: center;
}

.gpon-checkbox input[type="checkbox"] {
    display: none;
}

.gpon-checkbox .checkbox-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 5px;
    transition: all 0.25s ease;
    position: relative;
}

.gpon-checkbox-sm .checkbox-mark {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 4px;
}

.gpon-checkbox input[type="checkbox"]:checked + .checkbox-mark {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.gpon-checkbox input[type="checkbox"]:checked + .checkbox-mark::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    top: 2px;
}

.gpon-checkbox-sm input[type="checkbox"]:checked + .checkbox-mark::after {
    width: 4px;
    height: 7px;
    top: 1px;
}

.gpon-checkbox input[type="checkbox"]:checked ~ .checkbox-text .checkbox-title {
    color: var(--accent-primary);
}

.gpon-checkbox .checkbox-text {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.gpon-checkbox .checkbox-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: color 0.2s;
}

.gpon-checkbox-sm .checkbox-title {
    font-size: 0.85rem;
}

.gpon-checkbox .checkbox-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* GPON CSM поля (cvid/svid) */
#gpon-csm-fields {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

#gpon-csm-fields {
    display: contents;
}

#gpon-form.gpon-sib #gpon-ploam-field {
    display: none !important;
}

/* Выпадающий список профилей для Alcatel 7330 */
.diag-profile-select {
    padding: 8px 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border 0.2s, box-shadow 0.2s;
    min-width: 120px;
}

.diag-profile-select:hover {
    border-color: var(--accent-primary);
}

.diag-profile-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.diag-profile-select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px 12px;
}
