/* Modern Minimal Design System */
:root {
    --bg: #f8f9fc;
    --card: #ffffff;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-lighter: #eef2ff;
    --muted: #64748b;
    --dark: #0f172a;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.6;
    font-size: 15px;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--dark);
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.25rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: all 0.2s;
}

a:hover {
    color: var(--accent-light);
}

/* Layout */
.container {
    max-width: 720px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.container.wide {
    max-width: 1200px;
}

/* Header */
header {
    margin-bottom: 2.5rem;
}

body.admin header {
    text-align: left;
}

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

header .tag {
    color: var(--bg);
    font-size: 0.925rem;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    color: var(--dark);
}

/* Compact card variant for auth */
.card.compact,
.auth-card {
    max-width: 420px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Centered auth container */
.auth-container {
    min-height: calc(100vh - 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-hero {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    align-items: center;
}

.auth-hero .brand-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-hero .brand-block h1 {
    font-size: 2rem;
    margin-bottom: 0;
}

.auth-hero .brand-block p {
    color: var(--muted);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.06);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.12);
}

/* Header row for card titles (controls/meta) */
.header-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: space-between;
}

.meta-count {
    background: var(--bg);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
}

/* small helpers */
.muted {
    color: var(--muted);
}


/* Forms */
.field {
    margin-bottom: 1.25rem;
}

.label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.925rem;
    color: var(--dark);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 0.925rem;
    transition: all 0.2s;
    font-family: inherit;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

select {
    cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-lighter);
}

/* Buttons */
.actions {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.925rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn.primary {
    background: var(--accent);
    color: #fff;
}

.btn.primary:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn.secondary {
    background: var(--accent-lighter);
    color: var(--accent);
    border: 1px solid transparent;
}

.btn.secondary:hover {
    border-color: var(--accent);
}

.btn.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
}

.btn.ghost:hover {
    background: var(--bg);
    color: var(--dark);
}

.btn.danger {
    background: #fff;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.btn.danger:hover {
    background: rgba(239, 68, 68, 0.05);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Status & Tags */
.status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--accent-lighter);
    border-radius: 8px;
    color: var(--accent);
    font-size: 0.925rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--success);
    color: #fff;
}

/* compact badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.825rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
}

.badge.ok {
    border-color: rgba(16, 185, 129, .18);
    color: var(--success);
    background: rgba(16, 185, 129, .04);
}

.badge.off {
    border-color: rgba(107, 114, 128, .12);
    color: var(--muted);
    background: rgba(107, 114, 128, .03);
}

.small {
    color: var(--muted);
    font-size: 0.875rem;
}

/* Navigation */
.topnav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    padding: 0.5rem;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.topnav a {
    padding: 0.625rem 1rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.925rem;
    font-weight: 500;
    transition: all 0.2s;
}

.topnav a:hover {
    background: var(--bg);
    color: var(--dark);
}

.topnav a.active {
    background: var(--accent);
    color: #fff;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table thead th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr {
    transition: background 0.2s;
}

.table tbody tr:hover {
    background: var(--bg);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table td form {
    display: inline-block;
    margin-right: 0.5rem;
}

/* Services Grid */
.services {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.25rem;
}

.services label {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    cursor: pointer;
    transition: all 0.2s;
}

.services label:hover {
    border-color: var(--accent);
    background: var(--accent-lighter);
}

.services input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Stars Rating */
.stars {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 0.375rem;
}

.stars input {
    display: none;
}

.stars label {
    font-size: 1.75rem;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s;
}

.stars input:checked~label,
.stars label:hover,
.stars label:hover~label {
    color: var(--warning);
    transform: scale(1.1);
}

/* Admin layout (sidebar + topbar + main) */
.admin-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.sidebar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    height: calc(100vh - 48px);
    position: sticky;
    top: 16px;
    overflow: auto;
}

.brand {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.brand .logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.brand .brand-name {
    font-weight: 700;
    color: var(--dark);
}

.sidebar nav a {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 0.5rem;
    color: var(--muted);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sidebar nav a.active {
    background: var(--accent);
    color: #fff;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    flex: 1 1 480px;
}

.search input {
    border: none;
    outline: none;
    width: 100%;
    background: transparent;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd166, #f97316);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat-card {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
}

.stat-card .icon {
    font-size: 1.6rem;
}

.stat-card .value {
    font-size: 1.3rem;
    font-weight: 700;
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.875rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1rem;
}

.chart-placeholder {
    height: 260px;
    border-radius: 8px;
    background: linear-gradient(180deg, #fff, #fbfdff);
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.right-panel h3 {
    margin-top: 0;
}

.exclusions {
    list-style: none;
    padding: 0;
    margin: 0;
}

.exclusions li {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.exclusions .dot {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

.exclusions .dot.blue {
    background: #60a5fa;
}

.exclusions .dot.teal {
    background: #34d399;
}

.exclusions .title {
    font-weight: 600;
}

.exclusions .muted {
    color: var(--muted);
    font-size: 0.9rem;
}

.exclusions .count {
    margin-left: auto;
    font-weight: 700;
    color: var(--danger);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.875rem;
}

/* Utilities */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* AI test response */
.response-block {
    background: #0f172a;
    color: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, 'Roboto Mono', monospace;
}

/* Responsive */
@media (max-width: 1024px) {
    .admin-layout {
        grid-template-columns: 220px 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-2 {
        grid-template-columns: 1fr 280px;
    }
}

@media (max-width: 768px) {
    .container {
        margin: 1rem auto;
        padding: 0 1rem;
    }

    .auth-hero {
        grid-template-columns: 1fr;
    }

    .auth-card {
        margin: auto;
    }


    header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.25rem;
    }

    .topnav {
        gap: 0.375rem;
    }

    .topnav a {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }

    .services {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }
}