:root {
    --brand-900: #111827;
    --brand-700: #1f2937;
    --brand-600: #374151;
    --brand-500: #4b5563;
    --accent-500: #64748b;
    --surface: #ffffff;
    --surface-soft: #f5f5f5;
    --ink: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --page-bg: #ffffff;
}

body {
    font-family: "Work Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--page-bg);
}

body[data-theme="light"] {
    background: var(--page-bg);
    color: var(--ink);
}

h1,
h2,
h3,
h4,
h5,
h6,
.brand-title {
    font-family: "Playfair Display", "Times New Roman", serif;
    letter-spacing: 0.2px;
}

.score-badge {
    font-weight: bold;
    font-size: 0.9em;
}

.bg-gradient-primary {
    background: linear-gradient(120deg, var(--brand-700), var(--brand-600));
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: #ffffff;
    color: #111827;
    height: 100vh;
    position: sticky;
    top: 0;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
}

.sidebar svg {
    stroke: currentColor;
}

body[data-theme="dark"] .sidebar {
    background: #151a21;
    color: #e5e7eb;
    border-right-color: #2b3441;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.sidebar-footer {
    margin-top: auto;
    background: #ffffff;
}

body[data-theme="dark"] .sidebar-footer {
    background: #151a21;
}

.sidebar-footer .btn-outline-light {
    color: #111827;
    border-color: #111827;
}

.sidebar-footer .btn-outline-light:hover {
    background: #111827;
    color: #ffffff;
}

body[data-theme="dark"] .sidebar-footer .btn-outline-light {
    color: #e5e7eb;
    border-color: #e5e7eb;
}

body[data-theme="dark"] .sidebar-footer .btn-outline-light:hover {
    background: #e5e7eb;
    color: #151a21;
}

.sidebar-footer .dropdown-menu {
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.sidebar-footer .dropdown-item {
    color: #111827;
}

.sidebar-footer .dropdown-item:hover {
    background: #f5f5f5;
    color: #111827;
}

.sidebar-footer .dropdown-divider {
    border-color: #e5e7eb;
}

body[data-theme="dark"] .sidebar-footer .dropdown-menu {
    background: #151a21;
    color: #e5e7eb;
    border: 1px solid #2b3441;
}

body[data-theme="dark"] .sidebar-footer .dropdown-item {
    color: #e5e7eb;
}

body[data-theme="dark"] .sidebar-footer .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e5e7eb;
}

body[data-theme="dark"] .sidebar-footer .dropdown-divider {
    border-color: #2b3441;
}

.sidebar a {
    color: #111827;
    text-decoration: none;
}

.sidebar a:hover {
    color: #1f2937;
}

body[data-theme="dark"] .sidebar a {
    color: #e5e7eb;
}

body[data-theme="dark"] .sidebar a:hover {
    color: #ffffff;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.nav-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.92;
}

.nav-link-label {
    display: inline-flex;
    align-items: center;
}

.sidebar .nav-link.active {
    background: rgba(17, 24, 39, 0.08);
}

.content-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.navbar-brand {
    letter-spacing: 0.4px;
}

.dropdown-menu {
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.dropdown-menu .dropdown-item {
    color: #111827;
}

.dropdown-menu .dropdown-item:hover {
    background: #f5f5f5;
    color: #111827;
}

.dropdown-divider {
    border-color: #e5e7eb;
}

body[data-theme="dark"] .dropdown-menu {
    background: #151a21;
    color: #e5e7eb;
    border: 1px solid #2b3441;
}

body[data-theme="dark"] .dropdown-menu .dropdown-item {
    color: #e5e7eb;
}

body[data-theme="dark"] .dropdown-menu .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e5e7eb;
}

body[data-theme="dark"] .dropdown-divider {
    border-color: #2b3441;
}

.card {
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size: 1.6rem;
    margin-bottom: 0.35rem;
}

.page-subtitle {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.app-footer {
    background: var(--surface);
    backdrop-filter: blur(6px);
}

.app-footer-links a {
    text-decoration: none;
}

.app-footer-links a:hover,
.app-footer-links a:focus {
    text-decoration: none;
}

body[data-theme="light"] .app-footer,
body[data-theme="system"] .app-footer {
    color: var(--ink);
    border-top-color: var(--border);
}

body[data-theme="light"] .app-footer .text-muted,
body[data-theme="system"] .app-footer .text-muted {
    color: var(--ink) !important;
}

body[data-theme="light"] .app-footer a,
body[data-theme="system"] .app-footer a {
    color: var(--ink);
}

body[data-theme="light"] .app-footer a:hover,
body[data-theme="system"] .app-footer a:hover {
    color: var(--brand-900);
}

.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.keyword-zone {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 14px;
}

.keyword-zone__title {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.keyword-zone__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.keyword-chip {
    align-items: center;
    background: var(--surface);
    border: 1px solid rgba(44, 127, 184, 0.35);
    border-radius: 999px;
    color: var(--brand-700);
    display: inline-flex;
    font-size: 0.85rem;
    font-weight: 600;
    gap: 6px;
    padding: 6px 10px 6px 12px;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.keyword-chip__label {
    cursor: pointer;
}

.keyword-chip__remove {
    background: rgba(28, 93, 153, 0.12);
    border: 0;
    border-radius: 50%;
    color: var(--brand-700);
    font-size: 1rem;
    height: 20px;
    line-height: 1;
    padding: 0;
    width: 20px;
}

.keyword-chip__remove:hover {
    background: rgba(28, 93, 153, 0.2);
}

.keyword-zone__editor {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto auto;
    margin-top: 12px;
}

.keyword-input {
    background: var(--surface);
    border-radius: 12px;
}

.keyword-hidden {
    display: none;
}

.keyword-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 16px rgba(15, 23, 42, 0.14);
}

.keyword-zone__empty {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.btn-brand {
    background: linear-gradient(120deg, var(--brand-600), var(--brand-500));
    border: 0;
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.btn-brand:hover {
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(28, 93, 153, 0.25);
    transform: translateY(-1px);
}

.fade-up {
    animation: fadeUp 0.6s ease both;
}

.toast-container {
    z-index: 1080;
}

.toast {
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.15);
}

.toast-header {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.form-control,
.form-select {
    border-radius: 0.375rem;
    border: 1px solid #e0e0e0;
    padding: 0.625rem 0.875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.icon-inline {
    display: inline-block;
    vertical-align: middle;
}

.icon-inline-sm {
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
}

.icon-inline-md {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.icon-inline-lg {
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.match-score-high {
    background: linear-gradient(135deg, #1c9c7a 0%, #158f70 100%);
}

.match-score-medium {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.match-score-low {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body[data-theme="dark"] {
    --surface: #151a21;
    --surface-soft: #0f1115;
    --ink: #e5e7eb;
    --muted: #9ca3af;
    --border: #2b3441;
    --page-bg: #0b0f14;
    background: var(--page-bg);
    color: var(--ink);
}

body[data-theme="dark"] .sidebar {
    background: #151a21;
    color: #e5e7eb;
    border-right-color: #2b3441;
}

body[data-theme="dark"] .sidebar-footer {
    background: #151a21;
}

body[data-theme="dark"] .sidebar-footer .btn-outline-light {
    color: var(--ink);
    border-color: var(--ink);
}

body[data-theme="dark"] .sidebar-footer .btn-outline-light:hover {
    background: var(--ink);
    color: #0f1115;
}

body[data-theme="dark"] .sidebar-footer .dropdown-menu {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
}

body[data-theme="dark"] .sidebar-footer .dropdown-item {
    color: var(--ink);
}

body[data-theme="dark"] .sidebar-footer .dropdown-item:hover {
    background: var(--surface-soft);
    color: var(--ink);
}

body[data-theme="dark"] .sidebar-footer .dropdown-divider {
    border-color: var(--border);
}

body[data-theme="dark"] .sidebar a {
    color: #e5e7eb;
}

body[data-theme="dark"] .sidebar a:hover {
    color: #ffffff;
}

body[data-theme="dark"] .sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.12);
}

body[data-theme="dark"] .card,
body[data-theme="dark"] .table,
body[data-theme="dark"] .app-footer {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--border);
}

body[data-theme="dark"] .app-footer {
    border-top-color: rgba(148, 163, 184, 0.2);
}

body[data-theme="dark"] .app-footer .text-muted,
body[data-theme="dark"] .app-footer a {
    color: var(--ink) !important;
}

body[data-theme="dark"] .app-footer a:hover {
    color: #ffffff;
}

body[data-theme="dark"] .keyword-zone,
body[data-theme="system"] .keyword-zone {
    background: var(--surface-soft);
    border-color: var(--border);
}

body[data-theme="dark"] .keyword-chip,
body[data-theme="system"] .keyword-chip {
    background: var(--surface);
    border-color: rgba(100, 116, 139, 0.6);
    color: var(--ink);
}

body[data-theme="dark"] .keyword-chip__remove,
body[data-theme="system"] .keyword-chip__remove {
    background: rgba(100, 116, 139, 0.24);
    color: var(--ink);
}

body[data-theme="dark"] .keyword-input,
body[data-theme="system"] .keyword-input {
    background: var(--surface);
    border-color: var(--border);
    color: var(--ink);
}

body[data-theme="dark"] .toast,
body[data-theme="system"] .toast {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--border);
}

body[data-theme="dark"] .toast-header,
body[data-theme="system"] .toast-header {
    background: var(--surface-soft);
    color: var(--ink);
    border-color: var(--border);
}

body[data-theme="dark"] .text-muted,
body[data-theme="system"] .text-muted {
    color: var(--muted) !important;
}

body[data-theme="dark"] .text-dark,
body[data-theme="system"] .text-dark {
    color: var(--ink) !important;
}

body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select,
body[data-theme="system"] .form-control,
body[data-theme="system"] .form-select {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--border);
}

@media (prefers-color-scheme: dark) {
    body[data-theme="system"] {
        background: #0b0f14;
        color: #ffffff;
    }

    body[data-theme="system"] .sidebar {
        background: #151a21;
        color: #e5e7eb;
        border-right-color: #2b3441;
    }

    body[data-theme="system"] .sidebar-footer {
        background: #151a21;
    }

    body[data-theme="system"] .sidebar a {
        color: #e5e7eb;
    }

    body[data-theme="system"] .sidebar a:hover {
        color: #ffffff;
    }

    body[data-theme="system"] .sidebar .nav-link.active {
        background: rgba(255, 255, 255, 0.12);
    }

    body[data-theme="system"] .sidebar-footer .btn-outline-light {
        color: #e5e7eb;
        border-color: #e5e7eb;
    }

    body[data-theme="system"] .sidebar-footer .btn-outline-light:hover {
        background: #e5e7eb;
        color: #151a21;
    }

    body[data-theme="system"] .sidebar-footer .dropdown-menu {
        background: #151a21;
        color: #e5e7eb;
        border: 1px solid #2b3441;
    }

    body[data-theme="system"] .sidebar-footer .dropdown-item {
        color: #e5e7eb;
    }

    body[data-theme="system"] .sidebar-footer .dropdown-item:hover {
        background: rgba(255, 255, 255, 0.12);
        color: #e5e7eb;
    }

    body[data-theme="system"] .sidebar-footer .dropdown-divider {
        border-color: #2b3441;
    }

    body[data-theme="system"] .card,
    body[data-theme="system"] .table,
    body[data-theme="system"] .app-footer {
        background: #111827;
        color: #ffffff;
        border-color: rgba(148, 163, 184, 0.2);
    }

    body[data-theme="system"] .app-footer {
        border-top-color: rgba(148, 163, 184, 0.2);
    }

    body[data-theme="system"] .app-footer .text-muted,
    body[data-theme="system"] .app-footer a {
        color: var(--ink) !important;
    }

    body[data-theme="system"] .app-footer a:hover {
        color: #ffffff;
    }
}

body[data-theme-resolved="light"] {
    --page-bg: #ffffff;
    --surface: #f3f4f6;
    --surface-soft: #e5e7eb;
    --ink: #000000;
    --muted: #4b5563;
    --border: #d1d5db;
    --bs-body-bg: #ffffff;
    --bs-body-color: #000000;
    --bs-secondary-color: #4b5563;
    --bs-border-color: #d1d5db;
    --bs-card-bg: #f3f4f6;
    --bs-card-color: #000000;
    --bs-tertiary-bg: #f3f4f6;
    --bs-dropdown-bg: #ffffff;
    --bs-dropdown-color: #000000;
    --bs-dropdown-border-color: #d1d5db;
}

body[data-theme-resolved="dark"] {
    --page-bg: #0b0f14;
    --surface: #151a21;
    --surface-soft: #1f2630;
    --ink: #ffffff;
    --muted: #d1d5db;
    --border: #2b3441;
    --bs-body-bg: #0b0f14;
    --bs-body-color: #ffffff;
    --bs-secondary-color: #d1d5db;
    --bs-border-color: #2b3441;
    --bs-card-bg: #151a21;
    --bs-card-color: #ffffff;
    --bs-tertiary-bg: #151a21;
    --bs-dropdown-bg: #151a21;
    --bs-dropdown-color: #ffffff;
    --bs-dropdown-border-color: #2b3441;
}

body[data-theme-resolved] {
    background: var(--page-bg) !important;
    color: var(--ink) !important;
}

body[data-theme-resolved] .sidebar {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border-right-color: var(--border) !important;
}

body[data-theme-resolved] .sidebar-footer {
    background: var(--surface) !important;
}

body[data-theme-resolved] .sidebar,
body[data-theme-resolved] .sidebar a,
body[data-theme-resolved] .sidebar .nav-link,
body[data-theme-resolved] .sidebar .navbar-brand,
body[data-theme-resolved] .sidebar svg {
    color: var(--ink) !important;
    stroke: currentColor;
}

body[data-theme-resolved="light"] .sidebar .nav-link.active {
    background: rgba(0, 0, 0, 0.08) !important;
}

body[data-theme-resolved="dark"] .sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.14) !important;
}

body[data-theme-resolved] .card,
body[data-theme-resolved] .panel-card,
body[data-theme-resolved] .table,
body[data-theme-resolved] .app-footer,
body[data-theme-resolved] .bg-light {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border-color: var(--border) !important;
}

body[data-theme-resolved] .card-header,
body[data-theme-resolved] .card-footer,
body[data-theme-resolved] .table thead,
body[data-theme-resolved] .table tbody {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border-color: var(--border) !important;
}

body[data-theme-resolved] .dropdown-menu,
body[data-theme-resolved] .dropdown-menu.show,
body[data-theme-resolved] ul.dropdown-menu.dropdown-menu-end,
body[data-theme-resolved] ul.dropdown-menu.dropdown-menu-end.show {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border-color: var(--border) !important;
}

body[data-theme-resolved] .dropdown-item {
    color: var(--ink) !important;
}

body[data-theme-resolved="light"] .dropdown-item:hover,
body[data-theme-resolved="light"] .dropdown-item:focus {
    background: var(--surface-soft) !important;
    color: #000000 !important;
}

body[data-theme-resolved="dark"] .dropdown-item:hover,
body[data-theme-resolved="dark"] .dropdown-item:focus {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
}

body[data-theme-resolved] .dropdown-divider {
    border-color: var(--border) !important;
}

body[data-theme-resolved] .offcanvas,
body[data-theme-resolved] .offcanvas-header,
body[data-theme-resolved] .offcanvas-body {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border-color: var(--border) !important;
}

body[data-theme-resolved="dark"] .offcanvas .btn-close {
    filter: invert(1) grayscale(1);
}

body[data-theme-resolved] .form-control,
body[data-theme-resolved] .form-select,
body[data-theme-resolved] .input-group-text {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border-color: var(--border) !important;
}

body[data-theme-resolved] .text-muted {
    color: var(--muted) !important;
}

body[data-theme-resolved="light"] .app-footer .text-muted,
body[data-theme-resolved="light"] .app-footer a {
    color: #000000 !important;
}

body[data-theme-resolved="dark"] .app-footer .text-muted,
body[data-theme-resolved="dark"] .app-footer a {
    color: #ffffff !important;
}

body[data-theme-resolved] .btn-outline-light {
    color: var(--ink) !important;
    border-color: var(--ink) !important;
}

body[data-theme-resolved="light"] .btn-outline-light:hover {
    background: #000000 !important;
    color: #ffffff !important;
}

body[data-theme-resolved="dark"] .btn-outline-light:hover {
    background: #ffffff !important;
    color: #000000 !important;
}

body[data-theme="dark"] .card,
body[data-theme="dark"] .card-header,
body[data-theme="dark"] .card-body,
body[data-theme="dark"] .card-footer,
body[data-theme="dark"] .card .list-group-item,
body[data-theme="dark"] .card .table,
body[data-theme="dark"] .card .table th,
body[data-theme="dark"] .card .table td {
    background: #151a21 !important;
    color: #ffffff !important;
    border-color: #2b3441 !important;
}

@media (prefers-color-scheme: dark) {

    body[data-theme="system"] .card,
    body[data-theme="system"] .card-header,
    body[data-theme="system"] .card-body,
    body[data-theme="system"] .card-footer,
    body[data-theme="system"] .card .list-group-item,
    body[data-theme="system"] .card .table,
    body[data-theme="system"] .card .table th,
    body[data-theme="system"] .card .table td {
        background: #151a21 !important;
        color: #ffffff !important;
        border-color: #2b3441 !important;
    }
}