:root {
    --ai-primary: #0f4c81;
    --ai-primary-dark: #0b3559;
    --ai-accent: #ffb703;
    --ai-bg: #f4f7fb;
    --ai-surface: #ffffff;
    --ai-text: #1f2937;
    --ai-muted: #6b7280;
    --ai-border: #d8e1ec;
}

body {
    background: linear-gradient(180deg, #eef4fb 0%, #f8fbff 100%);
    color: var(--ai-text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

.ai-header {
    background: linear-gradient(135deg, var(--ai-primary-dark), var(--ai-primary));
    box-shadow: 0 10px 30px rgba(15, 76, 129, 0.18);
}

.ai-brand {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.ai-nav-link {
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
}

.ai-nav-link:hover,
.ai-nav-link:focus {
    color: #fff;
}

.ai-main {
    padding: 2rem 0 4rem;
}

.ai-card {
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(15, 76, 129, 0.08);
}

.ai-card-header {
    border-bottom: 1px solid var(--ai-border);
    padding: 1rem 1.25rem;
    font-weight: 700;
}

.ai-card-body {
    padding: 1.25rem;
}

.ai-footer {
    background: #fff;
    border-top: 1px solid var(--ai-border);
    color: var(--ai-muted);
}

.ai-stat {
    border: 1px solid var(--ai-border);
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    padding: 1.2rem;
}

.ai-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.ai-login-wrap {
    min-height: 100vh;
}

.table > :not(caption) > * > * {
    vertical-align: middle;
}

.table tbody tr:nth-child(odd) > * {
    background-color: #FFFFE0;
}

.table tbody tr:nth-child(even) > * {
    background-color: #F0FFFF;
}

.table-hover tbody tr {
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.table-hover tbody tr:hover > * {
    background-color: #eef7ff;
}

.form-label {
    font-weight: 600;
}

.text-muted-small {
    color: var(--ai-muted);
    font-size: 0.9rem;
}

.badge-soft {
    background: rgba(15, 76, 129, 0.1);
    color: var(--ai-primary-dark);
}

.alert {
    border-radius: 14px;
}

.ai-status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.22rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #eef2f7;
    color: #334155;
}

.ai-status-inline {
    text-transform: none;
    letter-spacing: normal;
}

.ai-status-badge.is-draft {
    background: #e5e7eb;
    color: #374151;
}

.ai-status-badge.is-issued {
    background: #dbeafe;
    color: #1d4ed8;
}

.ai-status-badge.is-partial {
    background: #fef3c7;
    color: #b45309;
}

.ai-status-badge.is-paid {
    background: #dcfce7;
    color: #15803d;
}

.ai-status-badge.is-cancelled {
    background: #fee2e2;
    color: #b91c1c;
}

.ai-info-box {
    border: 1px solid var(--ai-border);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    padding: 0.85rem 1rem;
}

.ai-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.ai-table-note {
    color: var(--ai-muted);
    font-size: 0.86rem;
}

.ai-link-muted {
    color: var(--ai-primary-dark);
    text-decoration: none;
}

.ai-link-muted:hover,
.ai-link-muted:focus {
    color: var(--ai-primary);
    text-decoration: underline;
}

.ai-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    background: #eef5fc;
    color: var(--ai-primary-dark);
    font-size: 0.82rem;
    font-weight: 600;
}

.ai-metric-list {
    display: grid;
    gap: 0.75rem;
}

.ai-metric-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px dashed var(--ai-border);
}

.ai-metric-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.cursor-pointer {
    cursor: pointer;
}

.ai-modal-open {
    overflow: hidden;
}

.ai-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
}

.ai-modal-card {
    width: min(1100px, 100%);
    max-height: calc(100vh - 3rem);
    overflow: auto;
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    background: var(--ai-surface);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.ai-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--ai-border);
}

.ai-modal-body {
    padding: 1.25rem;
}

.ai-audit-json {
    max-height: 60vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.83rem;
    line-height: 1.45;
    padding: 0.9rem;
    border-radius: 14px;
    background: #f8fbff;
    border: 1px solid var(--ai-border);
}

.ai-diff-line {
    display: block;
    margin: 0 -0.35rem;
    padding: 0 0.35rem;
    border-radius: 6px;
}

.ai-diff-line.is-added {
    background: #dcfce7;
    color: #166534;
}

.ai-diff-line.is-removed {
    background: #fee2e2;
    color: #991b1b;
}

@media (max-width: 767px) {
    .ai-modal-backdrop {
        padding: 0.75rem;
    }

    .ai-modal-card {
        max-height: calc(100vh - 1.5rem);
    }

    .ai-audit-json {
        max-height: 32vh;
    }
}
