/* ── Variables ──────────────────────────────────────────────── */
:root {
    --bg-primary: #F5F7FA;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #EDF0F5;
    --text-primary: #1A2332;
    --text-secondary: #4A5568;
    --text-muted: #8896A6;
    --accent: #0066CC;
    --accent-hover: #004FA3;
    --accent-light: rgba(0, 102, 204, 0.08);
    --green: #16a34a;
    --yellow: #ca8a04;
    --red: #dc2626;
    --orange: #ea580c;
    --border: #DEE3EB;
    --sidebar-width: 220px;
    --sidebar-bg: #001B41;
    --sidebar-bg2: #0B2A63;
    --sidebar-border: #1A3F73;
    --sidebar-text: #8BA4C4;
    --sidebar-text-bright: #FFFFFF;
    --sidebar-muted: #465A75;
    --font: 'Open Sans', -apple-system, sans-serif;
    --font-heading: 'Overpass', -apple-system, sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
}

/* ── Reset & Base ──────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Sidebar (stays dark IONOS navy) ──────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.sidebar-logo svg { flex-shrink: 0; }

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--sidebar-text-bright);
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--sidebar-muted);
    letter-spacing: 0.3px;
}

.sidebar-accent-line {
    height: 2px;
    background: linear-gradient(90deg, #11C7E6, transparent);
    margin-top: 12px;
}

.nav-links { list-style: none; padding: 10px 0; }

.nav-links li a {
    display: block;
    padding: 8px 20px;
    color: var(--sidebar-text);
    font-size: 13px;
    transition: all 0.15s;
}

.nav-links li a:hover {
    background: rgba(17, 199, 230, 0.08);
    color: var(--sidebar-text-bright);
    text-decoration: none;
}

.nav-links li a.active {
    background: rgba(17, 199, 230, 0.15);
    color: #11C7E6;
    font-weight: 600;
    border-left: 3px solid #11C7E6;
    padding-left: 17px;
}

.nav-section {
    padding: 15px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ── Main Content ──────────────────────────────────────────── */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
}

.top-bar {
    padding: 15px 25px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.top-bar h1 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.top-bar-info {
    color: var(--text-muted);
    font-size: 12px;
}

.page-content { padding: 20px 25px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.card h3 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

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

.card-header h3 { margin-bottom: 0; }

.cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    text-align: center;
    padding: 20px 15px;
    border-top: 3px solid var(--accent);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
    text-transform: uppercase;
}

/* ── Grid Layouts ──────────────────────────────────────────── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ── Market Grid ───────────────────────────────────────────── */
.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.market-card {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    transition: transform 0.15s, box-shadow 0.15s;
    display: block;
    border: 1px solid var(--border);
}

.market-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.market-code {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.market-stats {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 5px 0;
}

.market-rate {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Progress Bar ──────────────────────────────────────────── */
.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin: 6px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s;
}

/* ── Tables ────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    background: var(--bg-tertiary);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.data-table tbody tr:hover {
    background: var(--accent-light);
}

.row-highlight {
    background: rgba(22, 163, 74, 0.06) !important;
}

.row-critical { border-left: 3px solid var(--red); }
.row-warning { border-left: 3px solid var(--yellow); }
.row-info { border-left: 3px solid var(--accent); }

.info-table { width: 100%; }

.info-table td {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.info-table td:first-child {
    color: var(--text-muted);
    width: 40%;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-critical { background: rgba(220, 38, 38, 0.1); color: var(--red); }
.badge-warning { background: rgba(202, 138, 4, 0.1); color: var(--yellow); }
.badge-info { background: rgba(0, 102, 204, 0.1); color: var(--accent); }
.badge-success { background: rgba(22, 163, 74, 0.1); color: var(--green); }
.badge-sea { background: rgba(234, 88, 12, 0.1); color: var(--orange); }
.badge-seo { background: rgba(0, 102, 204, 0.1); color: var(--accent); }
.badge-failed { background: rgba(220, 38, 38, 0.1); color: var(--red); }
.badge-blocked { background: rgba(202, 138, 4, 0.1); color: var(--yellow); }
.badge-parse_error { background: rgba(234, 88, 12, 0.1); color: var(--orange); }

.badge-impact-critical { background: rgba(220, 38, 38, 0.1); color: var(--red); }
.badge-impact-warning_down { background: rgba(202, 138, 4, 0.1); color: var(--yellow); }
.badge-impact-warning_lost { background: rgba(220, 38, 38, 0.08); color: var(--red); }
.badge-impact-positive_up { background: rgba(22, 163, 74, 0.1); color: var(--green); }
.badge-impact-positive_new { background: rgba(22, 163, 74, 0.08); color: var(--green); }
.badge-impact-neutral { background: rgba(137, 150, 166, 0.12); color: var(--text-muted); }

/* ── Rank Badges ───────────────────────────────────────────── */
.rank-badge {
    display: inline-block;
    padding: 2px 6px;
    margin: 1px 2px;
    border-radius: 3px;
    font-size: 11px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.rank-ours {
    background: rgba(22, 163, 74, 0.1);
    color: var(--green);
    font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    font-family: var(--font);
}

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

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

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

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

.btn-small {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-small:hover { background: var(--border); text-decoration: none; }

/* ── Filters ───────────────────────────────────────────────── */
.filters {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font);
}

/* ── Change Log ────────────────────────────────────────────── */
.change-log {
    max-height: 400px;
    overflow-y: auto;
}

.change-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 13px;
}

.change-date {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

/* ── Heatmap Cells ─────────────────────────────────────────── */
.heatmap-cell {
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    padding: 6px 8px;
}

.heatmap-1 { background: rgba(22, 163, 74, 0.18); color: var(--green); }
.heatmap-2 { background: rgba(22, 163, 74, 0.12); color: var(--green); }
.heatmap-3 { background: rgba(22, 163, 74, 0.07); color: var(--green); }
.heatmap-4 { background: rgba(202, 138, 4, 0.12); color: var(--yellow); }
.heatmap-5 { background: rgba(202, 138, 4, 0.08); color: var(--yellow); }
.heatmap-6 { background: rgba(234, 88, 12, 0.1); color: var(--orange); }
.heatmap-7 { background: rgba(234, 88, 12, 0.07); color: var(--orange); }
.heatmap-8 { background: rgba(220, 38, 38, 0.1); color: var(--red); }
.heatmap-9 { background: rgba(220, 38, 38, 0.07); color: var(--red); }
.heatmap-10 { background: rgba(220, 38, 38, 0.05); color: var(--red); }
.heatmap-none { color: var(--text-muted); text-align: center; }

/* ── Forms & Inputs ───────────────────────────────────────── */
.input-field {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font);
    min-width: 200px;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.15);
}

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

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

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 25px;
    width: 500px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

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

.modal-header h3 { margin-bottom: 0; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

/* ── Action Buttons ───────────────────────────────────────── */
.action-buttons { display: flex; gap: 4px; }

.btn-danger {
    background: rgba(220, 38, 38, 0.1);
    color: var(--red);
    border: none;
    cursor: pointer;
}

.btn-danger:hover { background: rgba(220, 38, 38, 0.18); }

/* ── Inactive Rows ────────────────────────────────────────── */
.row-inactive { opacity: 0.5; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.pagination a.active {
    background: var(--accent);
    color: white;
}

/* ── Utility ───────────────────────────────────────────────── */
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.bg-green { background: var(--green); }
.bg-yellow { background: var(--yellow); }
.bg-red { background: var(--red); }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
    font-size: 14px;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { margin-left: 0; }
    .cards-row { grid-template-columns: 1fr 1fr; }
}
