:root {
    --bg-deep: #292621;
    --bg-panel: #353334;
    --bg-card: #424041;
    --bg-hover: #4d4a4b;
    --border: #5a5758;
    --border-accent: #6e6b6c;
    --text-primary: #efecec;
    --text-secondary: #bdc4c3;
    --text-muted: #9ea4ab;
    --accent: rgb(42, 142, 130);
    --accent-dim: rgba(42, 142, 130, 0.18);
    --accent-glow: rgba(42, 142, 130, 0.10);
    --accent-light: rgb(98, 132, 132);
    --green: #4ade80;
    --green-dim: rgba(74, 222, 128, 0.12);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.12);
    --yellow: #facc15;
    --yellow-dim: rgba(250, 204, 21, 0.12);
    --blue: #60a5fa;
    --blue-dim: rgba(96, 165, 250, 0.12);
    --purple: #a78bfa;
    --purple-dim: rgba(167, 139, 250, 0.12);
    --stone: rgb(113, 106, 86);
    --stone-dim: rgba(113, 106, 86, 0.2);
    --radius: 8px;
    --radius-lg: 12px;
    --font-heading: 'Fraunces', serif;
    --font-body: 'Quattrocento Sans', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-heading); }

/* ===== NAV ===== */
nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(41, 38, 33, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-brand img {
    height: 28px;
    width: auto;
}

.nav-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
}

.nav-title span {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 6px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 6px;
    transition: all 0.15s;
}

.nav-links a:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-links a.active { color: var(--accent); background: var(--accent-dim); }

.nav-links .logout {
    margin-left: 12px;
    padding-left: 14px;
    border-left: 1px solid var(--border);
}

/* ===== LAYOUT ===== */
main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 2rem 4rem;
}

.page-header { margin-bottom: 28px; }

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ===== STATUS CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.stat-card.accent::before { background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-card.red::before { background: var(--red); }

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-family: var(--font-heading);
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.red .stat-value { color: var(--red); }

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-sub a { color: var(--yellow); text-decoration: none; }
.stat-sub a:hover { text-decoration: underline; }

/* ===== BOT STATUS BADGE ===== */
.bot-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--green-dim);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: 20px;
    padding: 5px 14px 5px 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--green);
    margin-top: 8px;
}

.bot-status .dot {
    width: 7px; height: 7px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.bot-status.error {
    background: var(--red-dim);
    border-color: rgba(248,113,113,0.2);
    color: var(--red);
}
.bot-status.error .dot { background: var(--red); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input[type="text"] {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.15s;
}

.filter-bar select:focus,
.filter-bar input:focus { border-color: var(--accent); }

.filter-bar input[type="text"] { width: 220px; }

.filter-bar button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    padding: 8px 18px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.filter-bar button:hover { opacity: 0.85; }

/* ===== SECTION ===== */
.section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
}

.section-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ===== TABLE ===== */
.log-table {
    width: 100%;
    border-collapse: collapse;
}

.log-table thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.log-table tbody tr {
    border-bottom: 1px solid rgba(90, 87, 88, 0.5);
    transition: background 0.1s;
}

.log-table tbody tr:hover { background: var(--bg-hover); }
.log-table tbody tr:last-child { border-bottom: none; }

.log-table td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    vertical-align: middle;
}

.log-table td:first-child {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ===== ACTION BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-card_created { background: var(--green-dim); color: var(--green); }
.badge-card_updated { background: var(--blue-dim); color: var(--blue); }
.badge-needs_review { background: var(--yellow-dim); color: var(--yellow); }
.badge-error { background: var(--red-dim); color: var(--red); }
.badge-non_client { background: var(--purple-dim); color: var(--purple); }
.badge-ignored { background: var(--stone-dim); color: var(--text-muted); }

.td-client { color: var(--text-primary) !important; font-weight: 700; }

/* ===== REVIEW CARDS ===== */
.review-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.review-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
}

.review-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.review-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.review-meta {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.review-meta span { display: flex; align-items: center; gap: 4px; }

.confidence-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.confidence-bar .bar-track {
    width: 60px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.confidence-bar .bar-fill {
    height: 100%;
    border-radius: 2px;
}

.confidence-bar .bar-fill.low { background: var(--red); }
.confidence-bar .bar-fill.med { background: var(--yellow); }
.confidence-bar .bar-fill.high { background: var(--green); }

.confidence-bar .bar-label {
    font-size: 12px;
    font-weight: 700;
}

.review-card-body { padding: 16px 20px; }

.review-summary {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-style: italic;
}

.review-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.review-field label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 5px;
}

.review-field input,
.review-field select {
    width: 100%;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.15s;
}

.review-field input:focus,
.review-field select:focus { border-color: var(--accent); }

.review-field.full { grid-column: 1 / -1; }

.review-actions {
    display: flex;
    gap: 10px;
    padding-top: 4px;
}

.btn {
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    padding: 9px 20px;
    cursor: pointer;
    transition: all 0.15s;
}

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

.btn-primary:hover { opacity: 0.85; }

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

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ===== LOGIN ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -40%; right: -20%;
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
}

.login-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 380px;
    position: relative;
}

.login-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.login-logo img {
    height: 48px;
    width: auto;
}

.login-box h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    text-align: center;
}

.login-box .subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
    text-align: center;
}

.login-box label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.login-box input[type="password"] {
    width: 100%;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    padding: 11px 14px;
    outline: none;
    transition: border-color 0.15s;
    margin-bottom: 20px;
}

.login-box input[type="password"]:focus { border-color: var(--accent); }

.login-box .btn-primary {
    width: 100%;
    padding: 11px;
    font-size: 14px;
}

.login-error {
    background: var(--red-dim);
    border: 1px solid rgba(248,113,113,0.2);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--red);
    margin-bottom: 16px;
}

/* ===== FLASH MESSAGES ===== */
.flash-messages { list-style: none; margin-bottom: 20px; }

.flash-messages li {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 8px;
}

.flash-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }
.flash-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(74,222,128,0.2); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .review-fields { grid-template-columns: 1fr; }
    main { padding: 20px 1rem; }
    nav { padding: 0 1rem; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar input[type="text"] { width: 100%; }
}

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