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

:root {
    --bg-primary: #1a1d29;
    --bg-secondary: #242837;
    --bg-tertiary: #2d3142;
    --bg-hover: #353a4f;
    --text-primary: #e0e4eb;
    --text-secondary: #9ca3b8;
    --border-color: #3a3f54;
    --blue: #4a90e2;
    --green: #2ecc71;
    --yellow: #f39c12;
    --red: #e74c3c;
    --orange: #e67e22;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Main Container */
.main-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== HEADER ========== */
.header {
    background: var(--bg-secondary);
    padding: 15px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    margin-right: auto;
}

.panel-selector {
    position: relative;
}

.panel-selector select,
.panel-selector button {
    background: var(--blue);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.panel-selector select:hover,
.panel-selector button:hover {
    opacity: 0.9;
}

.btn {
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn-blue { background: #3498db; color: white; }
.btn-green { background: #27ae60; color: white; }
.btn-yellow { background: #f39c12; color: white; }
.btn-orange { background: #e67e22; color: white; }
.btn-red { background: #e74c3c; color: white; }

/* ========== CONFIG BLOCK ========== */
.config-section {
    background: var(--bg-secondary);
    margin: 20px 30px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.config-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.config-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.config-content {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

.config-content.collapsed {
    display: none;
}

.config-group {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 6px;
}

.config-group h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.config-group .btn {
    padding: 5px 10px;
    font-size: 12px;
}

.config-item {
    background: var(--bg-secondary);
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.config-item-info {
    flex: 1;
    overflow: hidden;
}

.config-item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.config-item-details {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.config-item-actions {
    display: flex;
    gap: 5px;
}

.icon-btn {
    padding: 5px 8px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    background: var(--bg-hover);
    color: var(--text-primary);
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--blue);
}

.icon-btn.delete:hover {
    background: var(--red);
}

.icon-btn-mini {
    padding: 2px 6px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    background: var(--bg-hover);
    color: var(--text-primary);
    transition: all 0.2s;
    font-size: 11px;
    margin-left: 5px;
}

.icon-btn-mini:hover {
    background: var(--blue);
}

.text-muted {
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
}

/* ========== CONTROLS ========== */
.controls {
    padding: 20px 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.filter-input {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    width: 200px;
}

.filter-input:focus {
    outline: none;
    border-color: var(--blue);
}

/* ========== PROJECTS TABLE ========== */
.projects-container {
    padding: 20px 30px;
}

.project-row {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 15px;
    display: grid;
    grid-template-columns: 150px 300px 200px 220px 180px 220px 200px;
    gap: 12px;
    align-items: start;
}

.project-row.parent {
    border-left: 3px solid var(--blue);
}

.project-row.child {
    margin-left: 30px;
    border-left: 3px solid var(--green);
}

/* Project columns */
.project-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-col-code {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-col strong {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.expand-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    width: 20px;
    padding: 0;
}

.project-code {
    font-weight: 600;
    font-size: 14px;
    color: var(--blue);
    word-break: break-word;
}

.project-code.parent {
    color: var(--green);
}

.project-code-input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--blue);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
}

.project-code-input.parent {
    color: var(--green);
}

.project-code-input:focus {
    outline: none;
    border-color: var(--blue);
}

/* Domain column */
.domain-registrar select {
    font-size: 12px;
    padding: 4px 8px;
}

.domain-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.domain-link {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
}

.domain-link:hover {
    color: var(--blue);
}

.domain-actions {
    display: flex;
    gap: 4px;
}

.domain-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.domain-token {
    font-size: 12px;
    color: var(--text-secondary);
}

/* IP column */
.ip-editor, .ns-info {
    font-size: 12px;
}

.ip-input-group {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
}

.ip-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

.ip-input:focus {
    outline: none;
    border-color: var(--blue);
}

.ip-confirm-btn {
    background: var(--green);
    color: white;
    border: none;
    padding: 5px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

.ip-confirm-btn:hover {
    opacity: 0.85;
}

.ns-records {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.ns-record {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 2px 0;
}

.ns-record span {
    flex: 1;
}

/* SSL column */
.ssl-compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.ssl-badge {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ssl-mode-badge {
    background: var(--orange);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.ssl-details {
    font-size: 11px;
    color: var(--text-secondary);
}

.ssl-settings.collapsed {
    display: none;
}

.page-rules {
    margin-top: 8px;
    font-size: 11px;
}

.rules-count {
    color: var(--text-secondary);
    font-size: 10px;
}

/* GSC column */
.gsc-block, .google-account {
    font-size: 12px;
}

.gsc-code, .google-email {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Comments column */
.comments-textarea {
    width: 100%;
    min-height: 60px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 12px;
    resize: vertical;
}

.comments-textarea:focus {
    outline: none;
    border-color: var(--blue);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 3px;
}

/* Actions column */
.project-col-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    align-items: start;
}

.action-btn {
    position: relative;
    width: 100%;
    height: 50px;
    border: none;
    border-radius: 6px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-weight: 600;
    line-height: 1;
}

.action-btn .icon {
    font-size: 16px;
    display: block;
}

.action-btn .label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.action-btn:active {
    transform: translateY(0);
}

/* Gradient backgrounds for action buttons */
.action-btn.btn-cache {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.action-btn.btn-sync {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.action-btn.btn-dev {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
}

.action-btn.btn-security {
    background: linear-gradient(135deg, #16a085 0%, #1abc9c 100%);
}

.action-btn.btn-delete {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    grid-column: 1 / -1;
    height: 36px;
    flex-direction: row;
    gap: 6px;
}

.compact {
    font-size: 12px;
    padding: 4px 6px;
}

/* EasyMDE Dark Theme Overrides */
.EasyMDEContainer {
    background: var(--bg-secondary);
}

.EasyMDEContainer .CodeMirror {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.EasyMDEContainer .CodeMirror-cursor {
    border-left-color: var(--text-primary);
}

.EasyMDEContainer .editor-toolbar {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px 6px 0 0;
}

.EasyMDEContainer .editor-toolbar button {
    color: var(--text-secondary) !important;
}

.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
    background: var(--bg-hover);
    border-color: var(--blue);
}

.EasyMDEContainer .editor-toolbar i.separator {
    border-left-color: var(--border-color);
}

.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.EasyMDEContainer .editor-preview pre,
.EasyMDEContainer .editor-preview-side pre {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.EasyMDEContainer .editor-preview code,
.EasyMDEContainer .editor-preview-side code {
    background: var(--bg-primary);
    color: var(--green);
}

.EasyMDEContainer .editor-statusbar {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
}

.scroll-to-top:active {
    transform: translateY(-2px);
}

/* Security Level Modal */
.security-level-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
}

.security-level-btn:hover {
    background: var(--bg-hover);
    border-color: var(--blue);
    transform: translateX(5px);
}

.security-level-btn.active {
    background: var(--bg-hover);
    border-color: var(--green);
}

.security-level-btn .level-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.security-level-btn .level-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.project-field {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 6px;
}

.project-field label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

.project-field-content {
    font-size: 14px;
    color: var(--text-primary);
}

.domain-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.domain-name {
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.domain-actions {
    display: flex;
    gap: 5px;
}

.domain-actions .icon-btn {
    padding: 4px 8px;
    font-size: 12px;
}

.status-code {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
}

.status-200 {
    background: var(--green);
    color: white;
}

.status-301 {
    background: var(--yellow);
    color: white;
}

.status-error {
    background: var(--red);
    color: white;
}

.redirect-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.token-info {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========== SSL/TLS SETTINGS ========== */
.ssl-settings {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 6px;
    margin-top: 10px;
}

.ssl-settings h4 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

select.setting-value {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-primary);
}

/* ========== PAGE RULES ========== */
.page-rules {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
}

.page-rules h4 {
    font-size: 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-rule-item {
    background: var(--bg-secondary);
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

/* ========== COMMENTS ========== */
.comments {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 6px;
}

.comments textarea {
    width: 100%;
    min-height: 60px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}

.comments textarea:focus {
    outline: none;
    border-color: var(--blue);
}

/* ========== PROJECT ACTIONS ========== */
.project-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.project-actions .btn {
    padding: 6px 12px;
    font-size: 13px;
}

/* ========== MODAL ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 25px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ========== LOADING ========== */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--blue);
}
