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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a2e;
    background: #f4f6f9;
    min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ───────────────────────────────────────────────────────── */
.navbar {
    background: #1e293b;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.navbar-brand a {
    color: #f1f5f9;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: -.2px;
}

.navbar-links a {
    color: #94a3b8;
    margin-left: 20px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: color .15s;
}

.navbar-links a:hover,
.navbar-links a.active { color: #f1f5f9; }

/* ── Layout ───────────────────────────────────────────────────────── */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 24px 48px;
}

/* ── Page Header ──────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.breadcrumb {
    display: inline-block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 4px;
}

.breadcrumb:hover { color: #2563eb; text-decoration: none; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0 12px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; text-decoration: none; color: #fff; }

.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; text-decoration: none; }

.btn-ghost { background: transparent; color: #6b7280; border-color: transparent; }
.btn-ghost:hover { background: #f1f5f9; text-decoration: none; color: #374151; }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; color: #fff; }

/* Inline text action links */
.btn-link {
    background: none;
    border: none;
    padding: 2px 4px;
    font-size: 13px;
    color: #2563eb;
    cursor: pointer;
    text-decoration: none;
}

.btn-link:hover { text-decoration: underline; }
.btn-link-muted { color: #6b7280; }
.btn-link-muted:hover { color: #374151; }
.btn-link-danger { color: #ef4444; }
.btn-link-danger:hover { color: #dc2626; }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.alert ul { list-style: none; }
.alert ul li::before { content: "• "; }

/* ── Stats Grid ───────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6b7280;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
}

.stat-value.stat-meta {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    padding-top: 4px;
}

.stat-working { border-top: 3px solid #22c55e; }
.stat-working .stat-value { color: #15803d; }

.stat-broken { border-top: 3px solid #ef4444; }
.stat-broken .stat-value { color: #b91c1c; }

.stat-warning { border-top: 3px solid #f59e0b; }
.stat-warning .stat-value { color: #b45309; }

.stat-redirected { border-top: 3px solid #3b82f6; }
.stat-redirected .stat-value { color: #1d4ed8; }

/* ── Filter Bar ───────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 14px;
}

.filter-bar select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    background: #fff;
    cursor: pointer;
}

.filter-bar select:focus { outline: 2px solid #2563eb; border-color: transparent; }

/* ── Tables ───────────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6b7280;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background .1s;
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody td { padding: 9px 12px; vertical-align: middle; color: #374151; }

.row-inactive td { color: #9ca3af; }
.row-inactive .badge { opacity: .65; }

.url-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-cell { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { white-space: nowrap; }
.nowrap { white-space: nowrap; }

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

.badge-working   { background: #dcfce7; color: #15803d; }
.badge-broken    { background: #fee2e2; color: #b91c1c; }
.badge-warning   { background: #fef9c3; color: #92400e; }
.badge-redirected{ background: #dbeafe; color: #1e40af; }
.badge-unchecked { background: #f1f5f9; color: #64748b; }
.badge-inactive  { background: #f1f5f9; color: #9ca3af; }
.badge-active    { background: #dcfce7; color: #15803d; }

/* ── Empty State ──────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

/* ── Detail Page ──────────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

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

.detail-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

.detail-card h2 {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.detail-list {
    display: grid;
    grid-template-columns: 130px 1fr;
    row-gap: 8px;
    column-gap: 12px;
    font-size: 13px;
}

.detail-list dt {
    font-weight: 600;
    color: #6b7280;
    padding-top: 1px;
}

.detail-list dd {
    color: #374151;
    word-break: break-word;
}

/* ── Form ─────────────────────────────────────────────────────────── */
.form-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    max-width: 640px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    background: #fff;
    transition: border-color .15s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.form-group textarea { resize: vertical; }

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

.form-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    margin-bottom: 0;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #2563eb;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 8px;
}

.required { color: #ef4444; }

/* ── Admin ────────────────────────────────────────────────────────── */
.admin-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.admin-section h2 {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.admin-description {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 16px;
    line-height: 1.6;
}

.admin-description code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    color: #374151;
}

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

.confirm-delete .confirm-prompt { display: none; gap: 4px; align-items: center; }
.confirm-delete.confirming > button { display: none; }
.confirm-delete.confirming .confirm-prompt { display: inline-flex; }

/* ── CSV Import ───────────────────────────────────────────────────── */
.import-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.import-stat {
    flex: 1;
    min-width: 120px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.import-stat-num {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
}

.import-stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #6b7280;
}

.import-stat-ok  { border-top: 3px solid #22c55e; }
.import-stat-ok  .import-stat-num { color: #15803d; }

.import-stat-dup { border-top: 3px solid #f59e0b; }
.import-stat-dup .import-stat-num { color: #b45309; }

.import-stat-err { border-top: 3px solid #ef4444; }
.import-stat-err .import-stat-num { color: #b91c1c; }

.results-heading {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    margin: 20px 0 10px;
}
