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

:root {
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-border: #e2e5e9;
    --color-text: #1a1d21;
    --color-text-secondary: #6b7280;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-paused: #6b7280;
    --color-pending: #d97706;
    --color-approved: #16a34a;
    --color-rejected: #dc2626;
    --sidebar-width: 220px;
    --font-mono: 'SFMono-Regular', 'Menlo', 'Consolas', monospace;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: var(--font-mono);
    font-size: 0.87em;
    background: #f1f3f5;
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

/* Layout */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 1.25rem 0;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 1.25rem 1.25rem;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li a {
    display: block;
    padding: 0.5rem 1.25rem;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.sidebar-nav li a:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}

.sidebar-nav li a.active {
    color: var(--color-primary);
    background: #eff6ff;
    font-weight: 600;
}

.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.content-header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.content-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.content-body {
    padding: 1.5rem 2rem;
    /* max-width: 1200px; */
}

/* Stats grid */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1.25rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

.stat-paused .stat-value { color: var(--color-paused); }
.stat-pending .stat-value { color: var(--color-pending); }
.stat-approved .stat-value { color: var(--color-approved); }
.stat-rejected .stat-value { color: var(--color-rejected); }

/* Panels */

.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.panel-body {
    padding: 1.25rem;
}

/* Tables */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: #f9fafb;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Status row highlights */

.status-row-pending {
    border-left: 3px solid var(--color-pending);
}

.status-row-rejected {
    border-left: 3px solid var(--color-rejected);
}

/* Badges */

.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-paused {
    background: #f3f4f6;
    color: var(--color-paused);
}

.badge-pending {
    background: #fef3c7;
    color: var(--color-pending);
}

.badge-approved {
    background: #dcfce7;
    color: var(--color-approved);
}

.badge-rejected {
    background: #fee2e2;
    color: var(--color-rejected);
}

.badge-neutral {
    background: #f1f3f5;
    color: var(--color-text-secondary);
}

/* Buttons */

.btn {
    display: inline-block;
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    color: #fff;
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
}

.btn-outline:hover {
    background: #eff6ff;
}

.btn-active {
    background: var(--color-primary);
    color: #fff;
}

.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
}

.btn-danger:hover {
    background: var(--color-danger-hover);
    border-color: var(--color-danger-hover);
}

.btn-approve {
    background: var(--color-success);
    border-color: var(--color-success);
}

.btn-approve:hover {
    background: #15803d;
    border-color: #15803d;
}

.btn-reject {
    background: var(--color-danger);
    border-color: var(--color-danger);
}

.btn-reject:hover {
    background: var(--color-danger-hover);
    border-color: var(--color-danger-hover);
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

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

/* Bulk add */

.bulk-hint {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.bulk-result {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

/* Forms */

input[type="text"],
input[type="search"],
textarea,
select {
    padding: 0.45rem 0.7rem;
    font-size: 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: inherit;
    line-height: 1.4;
}

input[type="text"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

textarea {
    width: 100%;
    resize: vertical;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input[type="text"] {
    min-width: 200px;
}

/* Filters */

.filters {
    margin-bottom: 1rem;
}

.filter-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-form select,
.filter-form input[type="text"] {
    min-width: 140px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
}

/* Pagination */

.pagination {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.review-summary {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
}

/* Creative detail */

.creative-nav {
    margin-bottom: 1rem;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem 2rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.meta-item-full {
    grid-column: 1 / -1;
}

.meta-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
}

.rejection-reason {
    color: var(--color-danger);
}

/* Creative content display */

.creative-field {
    margin-bottom: 1rem;
}

.creative-field-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
}

.creative-field-value {
    font-size: 0.9rem;
}

.creative-field-value img {
    max-width: 400px;
    max-height: 300px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
}

.creative-field-value a {
    word-break: break-all;
}

.asset-feed-item {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.asset-feed-item h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.json-raw {
    background: #f8f9fa;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 500px;
    overflow-y: auto;
}

/* Review actions */

.review-actions {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.reject-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 280px;
}

.review-result {
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

/* Alerts */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-warning {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-success {
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* Scan status */

.scan-status {
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

/* Scan progress overlay */

.scan-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-overlay-box {
    background: var(--color-surface);
    border-radius: 8px;
    padding: 2rem 2.5rem;
    width: 440px;
    max-width: 92vw;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

.scan-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.scan-overlay-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.scan-overlay-status {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2em 0.6em;
    border-radius: 3px;
    background: #f3f4f6;
    color: var(--color-text-secondary);
}

.scan-status-running {
    background: #dbeafe;
    color: var(--color-primary);
}

.scan-status-done {
    background: #dcfce7;
    color: var(--color-success);
}

.scan-status-fail {
    background: #fee2e2;
    color: var(--color-danger);
}

.scan-overlay-account-row {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.25rem;
}

.scan-bar-track {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 0.6rem;
}

.scan-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--color-primary);
    border-radius: 5px;
    transition: width 0.4s ease;
}

.scan-bar-fill.scan-bar-done {
    background: var(--color-success);
}

.scan-bar-fill.scan-bar-fail {
    background: var(--color-danger);
}

.scan-bar-fill.scan-bar-indeterminate {
    width: 100% !important;
    background: linear-gradient(
        90deg,
        #e5e7eb 0%,
        var(--color-primary) 30%,
        var(--color-primary) 50%,
        #e5e7eb 80%,
        #e5e7eb 100%
    );
    background-size: 200% 100%;
    animation: scan-indeterminate 1.5s linear infinite;
}

@keyframes scan-indeterminate {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.scan-overlay-details {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.scan-pct {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    min-width: 3.2em;
}

.scan-count {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.scan-stats {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.25rem;
    min-height: 1.2em;
}

.scan-overlay-box .btn {
    width: 100%;
    text-align: center;
}

/* Text helpers */

.text-muted {
    color: var(--color-text-secondary);
}

/* Responsive */

@media (max-width: 768px) {
    .sidebar {
        position: static;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        padding: 0.75rem 0;
    }

    .sidebar-brand {
        padding: 0 1rem 0.75rem;
    }

    .sidebar-nav {
        display: flex;
        gap: 0;
        overflow-x: auto;
    }

    .sidebar-nav li a {
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }

    .content {
        margin-left: 0;
    }

    .content-body {
        padding: 1rem;
    }

    .layout {
        flex-direction: column;
    }
}
