/* === Reset & Base (Dark theme) === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f1117;
    color: #e2e4e9;
    line-height: 1.6;
}
a { color: #7c9eff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Layout === */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.header {
    background: #161b22;
    color: #e2e4e9;
    padding: 20px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid #21262d;
}
.header .container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.header h1 { font-size: 1.5rem; font-weight: 600; flex-shrink: 0; }
.header .nav-wrap {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 4px;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
}
.header .nav-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.header .nav-links a {
    color: #8b949e;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.header .nav-links a:hover {
    color: #e2e4e9;
    background: #21262d;
    text-decoration: none;
}
.header .nav-links a.nav-active {
    color: #e2e4e9;
    background: #21262d;
}
.header .nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding-left: 12px;
    border-left: 1px solid #21262d;
}
.header .nav-user {
    color: #8b949e;
    font-size: 0.8rem;
    white-space: nowrap;
    padding: 0 4px;
}
.header .nav-actions form { display: inline-flex; }
.header .nav-action-btn {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    background: #21262d;
    color: #8b949e;
    white-space: nowrap;
}
.header .nav-action-btn:hover {
    background: #30363d;
    color: #e2e4e9;
}
.header .nav-action-btn.nav-pause { background: #e63946; color: white; }
.header .nav-action-btn.nav-pause:hover { opacity: 0.9; }
.header .nav-action-btn.nav-resume { background: #2ec4b6; color: white; }
.header .nav-action-btn.nav-resume:hover { opacity: 0.9; }
.header .nav-actions .nav-logout {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #8b949e;
    white-space: nowrap;
}
.header .nav-actions .nav-logout:hover {
    background: #21262d;
    color: #e2e4e9;
}

/* === Page Layout === */
.page-title { font-size: 1.4rem; font-weight: 600; color: #e2e4e9; margin-bottom: 24px; }
.page-desc { color: #8b949e; font-size: 0.95rem; margin-bottom: 24px; line-height: 1.5; }
.settings-card {
    background: #161b22;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid #21262d;
    max-width: 600px;
}
.settings-card-full { max-width: none; }
.settings-card h3 { font-size: 1rem; font-weight: 600; color: #e2e4e9; margin-bottom: 12px; }
.settings-card .sub { font-size: 0.85rem; color: #8b949e; margin-bottom: 14px; }
.settings-status {
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 0.95rem;
}
.settings-status.enabled { background: rgba(63,185,80,0.12); border: 1px solid rgba(63,185,80,0.35); color: #3fb950; }
.settings-status.disabled { background: rgba(210,153,34,0.12); border: 1px solid rgba(210,153,34,0.35); color: #d29922; }
.settings-status .sub { font-size: 0.85rem; opacity: 0.9; margin-top: 6px; }
.settings-hint { font-size: 0.8rem; color: #8b949e; margin-top: 6px; }
.settings-hint code { background: #21262d; padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; }
.recommendations-card {
    margin-top: 30px;
    background: #161b22;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #21262d;
}
.recommendations-card h3 { font-size: 1rem; color: #e2e4e9; margin-bottom: 16px; }
.recommendations-card table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.recommendations-card th { text-align: left; padding: 10px 12px; border-bottom: 1px solid #21262d; color: #8b949e; }
.recommendations-card td { padding: 10px 12px; border-bottom: 1px solid #21262d; color: #e2e4e9; }
.recommendations-card .info-box { margin-top: 16px; padding: 14px; background: rgba(124,158,255,0.1); border: 1px solid rgba(124,158,255,0.25); border-radius: 8px; font-size: 0.85rem; color: #7c9eff; }

/* === Stats Cards === */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}
.stat-card {
    background: #161b22;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #21262d;
}
.stat-card .number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .label {
    font-size: 0.85rem;
    color: #8b949e;
    margin-top: 4px;
}
.stat-card.total .number { color: #7c9eff; }
.stat-card.healthy .number { color: #3fb950; }
.stat-card.down .number { color: #f85149; }
.stat-card.changed .number { color: #d29922; }

/* === Actions Bar === */
.actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}
.actions-search {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.actions-card {
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 12px;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.actions-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.actions-group:not(:last-child) { border-bottom: 1px solid #21262d; padding-bottom: 20px; margin-bottom: -4px; }
.actions-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8b949e;
}
.actions-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.actions-btns .btn { white-space: nowrap; }
.actions-status {
    font-size: 0.85rem;
    color: #8b949e;
    margin-left: 4px;
}
.actions-btn-form { display: inline-flex; }

.search-box {
    padding: 10px 16px;
    border: 1px solid #21262d;
    border-radius: 8px;
    font-size: 0.95rem;
    width: 300px;
    outline: none;
    background: #161b22;
    color: #e2e4e9;
}
.search-box:focus { border-color: #7c9eff; box-shadow: 0 0 0 2px rgba(124,158,255,0.2); }
.search-box::placeholder { color: #6e7681; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary { background: #238636; color: white; }
.btn-primary:hover { background: #2ea043; text-decoration: none; }
.btn-danger { background: #da3633; color: white; }
.btn-danger:hover { background: #b62324; }
.btn-secondary { background: #21262d; color: #e2e4e9; border: 1px solid #30363d; }
.btn-secondary:hover { background: #30363d; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-outline {
    background: transparent;
    border: 1px solid #30363d;
    color: #8b949e;
}
.btn-outline:hover { background: #21262d; color: #e2e4e9; }

/* === Table === */
.table-wrapper {
    background: #161b22;
    border-radius: 12px;
    border: 1px solid #21262d;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
}
.table-wrapper thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #161b22;
    box-shadow: 0 1px 0 0 #21262d;
}
.details-cell {
    max-width: 320px;
    word-break: break-word;
    font-size: 0.85rem;
    color: #8b949e;
}
table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}
.table-wrapper th:last-child,
.table-wrapper td:last-child {
    white-space: nowrap;
    position: sticky;
    right: 0;
    background: #161b22;
    box-shadow: -4px 0 8px rgba(0,0,0,0.3);
}
.table-wrapper tr:hover td:last-child { background: #1c2128; }
.table-wrapper thead th:last-child { background: #161b22; z-index: 3; }
.table-wrapper td:last-child { z-index: 0; }
th {
    background: #161b22;
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #8b949e;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #21262d;
}
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
th.sortable:hover {
    color: #7c9eff;
    background: #1c2128;
}
th .sort-arrow {
    margin-left: 4px;
    font-size: 0.65rem;
    color: #6e7681;
}
th .sort-arrow.active {
    color: #7c9eff;
}
td {
    padding: 14px 16px;
    border-top: 1px solid #21262d;
    font-size: 0.9rem;
    color: #e2e4e9;
}
tr:hover td { background: #1c2128; }

/* === Status Badges === */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-up { background: rgba(63,185,80,0.2); color: #3fb950; }
.badge-down { background: rgba(248,81,73,0.2); color: #f85149; }
.badge-changed { background: rgba(210,153,34,0.2); color: #d29922; }
.badge-ok { background: rgba(63,185,80,0.2); color: #3fb950; }
.badge-pending { background: rgba(110,118,129,0.25); color: #8b949e; }

/* === Flash Messages === */
.flash {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.flash-success { background: rgba(63,185,80,0.15); color: #3fb950; border: 1px solid rgba(63,185,80,0.3); }
.flash-error { background: rgba(248,81,73,0.15); color: #f85149; border: 1px solid rgba(248,81,73,0.3); }

/* === Forms === */
.form-card {
    background: #161b22;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    border: 1px solid #21262d;
}
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #e2e4e9;
}
.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #21262d;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #0f1117;
    color: #e2e4e9;
}
.form-group input:focus { border-color: #7c9eff; outline: none; box-shadow: 0 0 0 2px rgba(124,158,255,0.2); }
.form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #21262d;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #0f1117;
    color: #e2e4e9;
    font-family: inherit;
}
.form-group select:focus, .form-group textarea:focus { border-color: #7c9eff; outline: none; box-shadow: 0 0 0 2px rgba(124,158,255,0.2); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* === Screenshots Side by Side === */
.screenshot-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}
.screenshot-panel {
    background: #161b22;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #21262d;
}
.screenshot-panel h3 {
    font-size: 0.9rem;
    color: #8b949e;
    margin-bottom: 10px;
}
.screenshot-panel img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #21262d;
}

/* === Login === */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #0f1117;
}
.login-card {
    background: #161b22;
    border-radius: 16px;
    padding: 40px;
    width: 380px;
    border: 1px solid #21262d;
}
.login-card h1 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: #e2e4e9;
}
.login-card p {
    color: #8b949e;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

/* === Client Detail === */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 16px;
}
.detail-header h2 { font-size: 1.5rem; color: #e2e4e9; }
.detail-header .url { color: #8b949e; font-size: 0.9rem; }
.detail-actions { display: flex; gap: 8px; }

/* === History Table === */
.history-section {
    margin-top: 30px;
}
.history-section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #e2e4e9;
}

/* === Delete Confirmation === */
.confirm-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    justify-content: center;
    align-items: center;
}
.confirm-overlay.active { display: flex; }
.confirm-box {
    background: #161b22;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    text-align: center;
    border: 1px solid #21262d;
}
.confirm-box h3 { margin-bottom: 10px; color: #e2e4e9; }
.confirm-box p { color: #8b949e; margin-bottom: 20px; font-size: 0.9rem; }
.confirm-box .btn-group { display: flex; gap: 10px; justify-content: center; }

/* === Insights: white cards === */
.insight-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.06);
}
.insight-card-attention {
    margin-bottom: 24px;
    border-left-width: 4px;
    border-left-style: solid;
}
.insight-card-attention .insight-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.insight-card-attention .insight-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2328;
}
.insight-card-attention .insight-empty {
    text-align: center;
    padding: 32px 24px;
    color: #2da44e;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.insight-recheck-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.insight-recheck-hint {
    font-size: 0.85rem;
    color: #8b949e;
}
.insight-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.insight-card-chart {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.insight-card-chart h3 {
    margin: 0 0 18px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2328;
}
.insight-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.insight-bar-row:last-child { margin-bottom: 0; }
.insight-bar-label {
    width: 88px;
    flex-shrink: 0;
    text-align: right;
    font-size: 0.875rem;
    color: #57606a;
}
.insight-bar-track {
    flex: 1;
    min-width: 0;
    background: #eaeef2;
    border-radius: 6px;
    height: 24px;
    overflow: hidden;
}
.insight-bar-fill {
    height: 100%;
    border-radius: 6px;
    min-width: 2px;
}
.insight-bar-value {
    width: 40px;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2328;
    text-align: right;
}
.insight-card-chart .insight-sub {
    font-size: 0.8rem;
    color: #8b949e;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #eaeef2;
}

/* === Responsive === */
@media (max-width: 768px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .screenshot-compare { grid-template-columns: 1fr; }
    .actions { flex-direction: column; align-items: stretch; }
    .search-box { width: 100%; }
    .insight-cards-grid { grid-template-columns: 1fr; }
}
