:root {
    --ink: #14213d;
    --ink-soft: #455166;
    --muted: #5b6577;
    --paper: #f4efe6;
    --paper-strong: #fffdf8;
    --edge: rgba(20, 33, 61, 0.12);
    --accent: #d97706;
    --accent-2: #0f766e;
    --accent-3: #1d4ed8;
    --accent-4: #be123c;
    --shadow: 0 24px 60px rgba(20, 33, 61, 0.14);
    --page-gap: 28px;
    --card-gap: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(217, 119, 6, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(15, 118, 110, 0.14), transparent 24%),
        linear-gradient(180deg, #f8f4ec 0%, #efe7db 100%);
}

body.modal-open {
    overflow: hidden;
}

[hidden] {
    display: none !important;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 300px 1fr;
    align-items: start;
    transition: grid-template-columns 180ms ease;
}

body.sidebar-collapsed .app-shell {
    grid-template-columns: 76px 1fr;
}

body.sidebar-collapsed-preload .app-shell,
body.sidebar-collapsed-preload .sidebar {
    transition: none !important;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 32px 24px;
    background: linear-gradient(180deg, #10203a 0%, #1e3559 100%);
    color: #edf2f7;
    display: flex;
    flex-direction: column;
    gap: 28px;
    transition: padding 180ms ease;
}

.sidebar-toggle {
    width: 100%;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    color: #edf2f7;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-weight: 700;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.16);
}

.sidebar-toggle-icon {
    font-size: 1.3rem;
    line-height: 1;
}

body.sidebar-collapsed .sidebar {
    padding: 18px 12px;
    gap: 18px;
    overflow-x: hidden;
}

body.sidebar-collapsed .brand-block h1,
body.sidebar-collapsed .brand-block p,
body.sidebar-collapsed .brand-block .eyebrow,
body.sidebar-collapsed .sidebar-toggle-text,
body.sidebar-collapsed .user-chip span,
body.sidebar-collapsed .user-chip strong {
    display: none;
}

body.sidebar-collapsed .sidebar-toggle-icon {
    transform: rotate(180deg);
}

body.sidebar-collapsed .nav a,
body.sidebar-collapsed .logout-link {
    min-height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 8px;
}

body.sidebar-collapsed .nav-label {
    display: none;
}

body.sidebar-collapsed .nav-icon,
body.sidebar-collapsed .nav-icon svg {
    width: 22px;
    height: 22px;
}

body.sidebar-collapsed .user-chip {
    min-height: 44px;
    padding: 10px 8px;
}

body.sidebar-collapsed .user-chip::before {
    content: "U";
    display: grid;
    place-items: center;
    font-weight: 800;
}

.brand-block h1,
.topbar h2,
.login-card h1,
.hero-panel h3,
.panel h3,
.info-card h3 {
    font-family: "Source Serif 4", serif;
    margin: 0;
}

.brand-block p,
.login-card p {
    color: rgba(237, 242, 247, 0.82);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
    color: var(--ink-soft);
    font-weight: 800;
}

.sidebar .eyebrow,
.login-card .eyebrow {
    color: rgba(237, 242, 247, 0.76);
}

.panel .eyebrow,
.info-card .eyebrow,
.modal-card .eyebrow {
    color: #7c2d12;
}

.nav {
    display: grid;
    gap: 10px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(237, 242, 247, 0.92);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: currentColor;
}

.nav-label {
    min-width: 0;
}

.nav a.is-active,
.nav a:hover {
    background: linear-gradient(90deg, rgba(217, 119, 6, 0.35), rgba(255, 255, 255, 0.08));
}

.sidebar-foot {
    margin-top: auto;
    display: grid;
    gap: 14px;
}

.user-chip {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    display: grid;
    gap: 6px;
}

.logout-link {
    color: #ffd8a8;
}

.content {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar .eyebrow,
.topbar-note {
    color: var(--ink-soft);
}

.content > section + section {
    margin-top: var(--page-gap);
}

.grid {
    display: grid;
    gap: var(--card-gap);
    min-width: 0;
}

.metrics-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.dashboard-grid,
.detail-grid {
    grid-template-columns: 1.05fr 1fr;
    align-items: start;
    gap: var(--page-gap);
}

.metric-card,
.panel,
.info-card,
.login-card {
    background: rgba(255, 253, 248, 0.88);
    border: 1px solid var(--edge);
    border-radius: 24px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.metric-card {
    padding: 22px;
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: auto -24px -24px auto;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    opacity: 0.12;
}

.accent-amber::after { background: var(--accent); }
.accent-sky::after { background: var(--accent-3); }
.accent-mint::after { background: var(--accent-2); }
.accent-rose::after { background: var(--accent-4); }

.metric-card span {
    display: block;
    color: var(--ink-soft);
    margin-bottom: 14px;
}

.metric-card strong {
    font-size: 2rem;
}

.panel,
.info-card {
    padding: 24px;
}

.filter-panel {
    margin-bottom: 18px;
}

.page-trail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 0 0 18px;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    font-size: 0.92rem;
}

.breadcrumbs a {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(217, 119, 6, 0.12);
    color: #7c2d12;
    font-weight: 700;
}

.breadcrumbs span {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(20, 33, 61, 0.08);
    color: var(--ink-soft);
}

.breadcrumbs span::before {
    content: "›";
    margin-right: 10px;
    color: rgba(20, 33, 61, 0.42);
}

.back-link {
    gap: 10px;
    flex: 0 0 auto;
}

.back-link::before {
    content: "←";
    width: 20px;
    height: 20px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
}

.hero-panel p,
.detail-intro {
    color: #2f3a4d;
}

.tender-description {
    color: #2f3a4d;
    line-height: 1.65;
    max-height: 320px;
    overflow: auto;
    padding-right: 8px;
}

.stack-form {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.stack-form label {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.stack-form textarea {
    font: inherit;
    border-radius: 14px;
    border: 1px solid var(--edge);
    padding: 14px 16px;
    background: #fffdfa;
    resize: vertical;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.check-row input {
    width: 18px;
    height: 18px;
    padding: 0;
}

.split-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.section-help {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    margin-left: 10px;
    z-index: 20;
}

.section-help-icon {
    width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(20, 33, 61, 0.08);
    color: var(--ink-soft);
    border: 1px solid rgba(20, 33, 61, 0.12);
    font-size: 0.82rem;
    font-weight: 900;
    cursor: help;
}

.section-help-text {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(320px, 78vw);
    padding: 12px 14px;
    border-radius: 14px;
    background: #14213d;
    color: #fffdf8;
    box-shadow: 0 18px 42px rgba(20, 33, 61, 0.22);
    font-size: 0.82rem;
    line-height: 1.45;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 140ms ease, transform 140ms ease;
}

.section-help-text::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 10px;
    width: 12px;
    height: 12px;
    background: #14213d;
    transform: rotate(45deg);
}

.section-help:hover .section-help-icon,
.section-help:focus .section-help-icon,
.section-help:focus-within .section-help-icon {
    background: #0f766e;
    color: white;
}

.section-help:hover .section-help-text,
.section-help:focus .section-help-text,
.section-help:focus-within .section-help-text {
    opacity: 1;
    transform: translateY(0);
}

.panel-head a:not(.button-link) {
    color: #9a3412;
}

.panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-list,
.mini-stats {
    display: grid;
    gap: 12px;
}

.stat-list div,
.mini-stats div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px dashed var(--edge);
    padding-bottom: 8px;
}

dt {
    color: var(--ink-soft);
}

dd {
    margin: 0;
    text-align: right;
}

.stack-list {
    display: grid;
    gap: 12px;
}

.stack-item {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--edge);
    background: linear-gradient(135deg, rgba(255,255,255,0.7), rgba(250, 244, 233, 0.95));
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.stack-item:hover {
    border-color: rgba(15, 118, 110, 0.34);
    box-shadow: 0 14px 32px rgba(20, 33, 61, 0.1);
}

.stack-item-tight {
    align-items: center;
}

.stack-item p {
    margin: 6px 0 0;
    color: var(--ink-soft);
}

.tooltip-label {
    text-decoration: underline dotted rgba(20, 33, 61, 0.5);
    text-underline-offset: 4px;
    cursor: help;
}

.keyword-type-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: #0f4f4a;
    font-weight: 800;
    cursor: help;
}

.meta-cluster {
    text-align: right;
    color: var(--ink-soft);
    display: grid;
    align-content: center;
}

.open-cue {
    margin-top: 8px;
    color: #0f766e;
    font-weight: 700;
}

.open-cue::after {
    content: " →";
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(240px, 1.8fr) minmax(140px, 1fr) minmax(180px, 1.1fr) minmax(140px, 1fr);
    gap: 12px;
    align-items: center;
}

.filter-bar-archive {
    grid-template-columns: minmax(240px, 1.8fr) minmax(140px, 1fr) minmax(180px, 1.1fr);
}

.filter-bar button {
    white-space: nowrap;
}

.audit-filter-bar {
    align-items: end;
    grid-template-columns: repeat(2, minmax(145px, 0.8fr)) minmax(170px, 1fr) repeat(3, minmax(190px, 1.2fr)) auto;
    margin-top: 16px;
}

.error-filter-bar {
    align-items: end;
    grid-template-columns: repeat(2, minmax(145px, 0.75fr)) repeat(5, minmax(150px, 1fr)) repeat(3, minmax(170px, 1.2fr)) auto;
    margin-top: 16px;
}

.run-filter-bar {
    align-items: end;
    grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
    margin-top: 16px;
}

.error-filter-bar input[name="request_url"],
.error-filter-bar input[name="message"] {
    min-width: 220px;
}

.audit-filter-bar label {
    display: grid;
    gap: 6px;
}

.audit-filter-bar label span,
.error-filter-bar label span,
.run-filter-bar label span {
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.error-filter-bar label,
.run-filter-bar label {
    display: grid;
    gap: 6px;
}

input,
select,
button {
    font: inherit;
    border-radius: 14px;
    border: 1px solid var(--edge);
    padding: 14px 16px;
    background: #fffdfa;
}

input,
select,
textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.stack-form button {
    justify-self: start;
}

.form-section {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--edge);
    border-radius: 18px;
    background: rgba(255, 253, 248, 0.62);
    min-width: 0;
}

.form-section h4 {
    margin: 0;
    font-size: 1rem;
}

.lms-inject-form {
    margin-top: 12px;
}

.lms-inject-modal-card {
    width: min(1180px, 100%);
}

.lms-status-card {
    border-left: 5px solid #f59e0b;
}

.lms-status-card.is-synced {
    border-left-color: #0f766e;
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(255, 253, 248, 0.95));
}

.lms-status-card.is-pending {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(255, 253, 248, 0.95));
}

.lms-status-card h3 {
    color: var(--ink);
}

.lms-status-card p {
    margin: 6px 0 0;
    color: #25324b;
    font-weight: 500;
}

.lms-status-card strong {
    color: #0f172a;
    font-weight: 800;
}

.lms-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
}

.lms-status-synced,
.lms-tag-good {
    background: rgba(15, 118, 110, 0.14);
    color: #0f4f4a;
}

.lms-tag-pending {
    background: rgba(245, 158, 11, 0.16);
    color: #92400e;
}

.lms-document-option {
    align-items: flex-start;
}

.lms-document-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin-top: 3px;
    padding: 0;
}

.lms-document-option span {
    min-width: 0;
}

.lms-document-option small {
    display: block;
    margin-top: 6px;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
}

.extra-documents {
    display: grid;
    gap: 10px;
}

.extra-document-row {
    display: grid;
    grid-template-columns: minmax(160px, 0.8fr) minmax(220px, 1.2fr) auto;
    gap: 10px;
    align-items: center;
}

.checkbox-dropdown {
    position: relative;
    display: grid;
    gap: 8px;
    min-width: 0;
}

.checkbox-dropdown-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--ink);
    background: #fffdfa;
    border: 1px solid var(--edge);
    text-align: left;
}

.checkbox-dropdown-toggle::after {
    content: "⌄";
    color: var(--ink-soft);
}

.checkbox-dropdown-menu {
    position: absolute;
    z-index: 1010;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--edge);
    border-radius: 14px;
    background: #fffdfa;
    box-shadow: 0 18px 42px rgba(20, 33, 61, 0.16);
}

.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
}

.checkbox-option:hover {
    background: rgba(15, 118, 110, 0.08);
}

.checkbox-option input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin-top: 2px;
    padding: 0;
}

.checkbox-option span {
    min-width: 0;
    overflow-wrap: anywhere;
}

button {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
    border: none;
    cursor: pointer;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid rgba(20, 33, 61, 0.08);
    vertical-align: top;
}

th {
    color: var(--ink-soft);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sortable-heading {
    padding: 8px 10px;
}

.sort-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--ink-soft);
    font-size: inherit;
    font-weight: 700;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.sort-button::after {
    content: "↕";
    opacity: 0.45;
    font-size: 0.78rem;
}

.server-sort.is-sorted-asc::after {
    content: "↑";
    opacity: 1;
}

.server-sort.is-sorted-desc::after {
    content: "↓";
    opacity: 1;
}

.sortable-heading[aria-sort="ascending"] .sort-button,
.sortable-heading[aria-sort="descending"] .sort-button,
.server-sort[class*="is-sorted-"],
.sort-button:hover {
    border-color: rgba(15, 118, 110, 0.18);
    background: rgba(15, 118, 110, 0.08);
    color: #0f766e;
}

.sortable-heading[aria-sort="ascending"] .sort-button::after {
    content: "↑";
    opacity: 1;
}

.sortable-heading[aria-sort="descending"] .sort-button::after {
    content: "↓";
    opacity: 1;
}

.table-detail-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.1);
    color: #0f766e;
    font-weight: 700;
    text-decoration: none;
}

.table-detail-link::after {
    content: "Open";
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.14);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.table-detail-link:hover {
    background: #0f766e;
    color: white;
}

.table-detail-link:hover::after {
    background: rgba(255, 255, 255, 0.18);
}

.table-open-link {
    display: inline-flex;
    align-items: center;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.1);
    color: #0f766e;
    font-weight: 800;
}

.table-open-link:hover {
    background: #0f766e;
    color: white;
}

.table-wrap {
    overflow-x: auto;
}

.tender-list-panel {
    padding: 16px;
    border-radius: 18px;
}

.tender-list-panel .panel-head {
    margin-bottom: 12px;
}

.tender-list-panel .panel-head h3 {
    font-size: 1.15rem;
}

.tender-list-panel .filter-bar {
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 8px;
}

.tender-list-panel .filter-bar-archive {
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.tender-list-panel input,
.tender-list-panel select {
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 11px;
    font-size: 0.88rem;
}

.tender-results-panel table {
    table-layout: fixed;
    min-width: 1180px;
    font-size: 0.82rem;
}

.tender-results-panel tbody tr.tender-row-lms-synced {
    background: linear-gradient(90deg, rgba(186, 230, 253, 0.48), rgba(240, 249, 255, 0.3));
}

.tender-results-panel tbody tr.tender-row-lms-synced td {
    border-bottom-color: rgba(14, 165, 233, 0.18);
}

.tender-results-panel tbody tr.tender-row-viewed {
    background: linear-gradient(90deg, rgba(254, 240, 138, 0.52), rgba(255, 251, 235, 0.34));
}

.tender-results-panel tbody tr.tender-row-viewed td {
    border-bottom-color: rgba(202, 138, 4, 0.18);
}

.saved-filter-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.saved-filter-form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.saved-filter-form input {
    min-width: 210px;
}

.saved-filter-list {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.saved-filter-list a,
.saved-filter-list button {
    background: rgba(15, 118, 110, 0.1);
    border: 1px solid rgba(15, 118, 110, 0.2);
    border-radius: 999px;
    color: #0f766e;
    font-weight: 800;
    padding: 7px 10px;
    text-decoration: none;
}

.saved-filter-list form {
    display: inline;
}

.saved-filter-list button {
    cursor: pointer;
    padding: 6px 9px;
}

.crm-state-panel {
    border-color: rgba(15, 118, 110, 0.22);
}

.inline-state-form,
.comment-form {
    align-items: end;
    display: flex;
    gap: 10px;
}

.inline-state-form label,
.comment-form {
    flex: 1;
}

.comment-form {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 14px;
}

.comment-form textarea {
    min-height: 86px;
    resize: vertical;
}

.audit-list {
    display: grid;
    gap: 10px;
}

.audit-item {
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    padding: 11px 12px;
}

.audit-item strong {
    color: #0f172a;
    display: block;
}

.audit-item span,
.muted-small {
    color: #64748b;
    display: block;
    font-size: 0.8rem;
    margin-top: 2px;
}

.audit-item p {
    color: #334155;
    margin: 8px 0 0;
}

.template-tabs,
.decision-actions,
.bulk-review-bar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.template-tabs a {
    background: rgba(15, 118, 110, 0.1);
    border: 1px solid rgba(15, 118, 110, 0.2);
    border-radius: 999px;
    color: #0f766e;
    font-weight: 800;
    padding: 9px 12px;
    text-decoration: none;
}

.template-tabs a.is-active {
    background: #0f766e;
    color: white;
}

.template-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
    gap: 18px;
}

.token-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.token-grid code {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    color: #0f172a;
    font-weight: 800;
    padding: 7px 10px;
}

.email-preview-frame {
    background: white;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 18px;
    height: 620px;
    width: 100%;
}

.template-text-preview pre {
    white-space: pre-wrap;
}

.template-fallback-preview {
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    margin-top: 14px;
    padding: 12px 14px;
}

.template-fallback-preview summary {
    color: #0f766e;
    cursor: pointer;
    font-weight: 800;
}

.field-hint {
    color: #64748b;
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 4px 0 8px;
}

.is-preview-updated {
    animation: previewPulse 1400ms cubic-bezier(0.2, 0.9, 0.2, 1);
    position: relative;
}

@keyframes previewPulse {
    0% {
        background-color: rgba(250, 204, 21, 0.42);
        box-shadow:
            0 0 0 0 rgba(245, 158, 11, 0.95),
            0 0 0 8px rgba(15, 118, 110, 0.34),
            0 24px 70px rgba(245, 158, 11, 0.42);
        filter: saturate(1.45) brightness(1.04);
        outline: 6px solid rgba(245, 158, 11, 1);
        transform: translateX(0) scale(1.018);
    }
    12% {
        transform: translateX(-4px) scale(1.024);
    }
    24% {
        transform: translateX(4px) scale(1.024);
    }
    35% {
        background-color: rgba(45, 212, 191, 0.24);
        box-shadow:
            0 0 0 12px rgba(245, 158, 11, 0.3),
            0 0 0 18px rgba(15, 118, 110, 0.18),
            0 22px 58px rgba(15, 23, 42, 0.28);
        outline: 6px solid rgba(15, 118, 110, 0.95);
        transform: translateX(0) scale(1.018);
    }
    62% {
        background-color: rgba(250, 204, 21, 0.16);
        box-shadow:
            0 0 0 20px rgba(245, 158, 11, 0.12),
            0 14px 38px rgba(15, 23, 42, 0.22);
        outline: 5px solid rgba(245, 158, 11, 0.62);
        transform: scale(1.008);
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0 30px rgba(15, 118, 110, 0);
        filter: saturate(1);
        outline: 6px solid rgba(15, 118, 110, 0);
        transform: scale(1);
    }
}

.toggle-control {
    align-items: center;
    cursor: pointer;
    display: flex;
    gap: 12px;
}

.toggle-control input {
    inline-size: 1px;
    opacity: 0;
    position: absolute;
}

.toggle-track {
    background: #cbd5e1;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 999px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.12);
    display: inline-flex;
    height: 30px;
    padding: 3px;
    transition: background 0.16s ease, border-color 0.16s ease;
    width: 58px;
}

.toggle-knob {
    background: white;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.22);
    height: 22px;
    transform: translateX(0);
    transition: transform 0.16s ease;
    width: 22px;
}

.toggle-control input:checked + .toggle-track {
    background: #0f766e;
    border-color: #0f766e;
}

.toggle-control input:checked + .toggle-track .toggle-knob {
    transform: translateX(28px);
}

.toggle-control strong,
.toggle-control small {
    display: block;
}

.toggle-control small {
    color: #64748b;
    font-size: 0.78rem;
    margin-top: 2px;
}

.decision-action-form {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.button-danger {
    background: #be123c;
    border: 0;
    border-radius: 999px;
    color: white;
    cursor: pointer;
    font-weight: 800;
    padding: 10px 14px;
}

.score-reason-box {
    background: rgba(15, 118, 110, 0.08);
    border: 1px solid rgba(15, 118, 110, 0.18);
    border-radius: 16px;
    margin-top: 14px;
    padding: 12px 14px;
}

.score-reason-box ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.document-error {
    color: #9f1239;
    font-weight: 700;
}

.tender-results-panel th,
.tender-results-panel td {
    padding: 8px 7px;
    line-height: 1.25;
}

.tender-results-panel th {
    font-size: 0.68rem;
    letter-spacing: 0.045em;
}

.tender-results-panel .sortable-heading {
    padding: 4px;
}

.tender-results-panel .sort-button {
    padding: 5px 6px;
    border-radius: 9px;
    gap: 4px;
}

.tender-results-panel th:nth-child(1),
.tender-results-panel td:nth-child(1) {
    width: 132px;
}

.tender-results-panel th:nth-child(2),
.tender-results-panel td:nth-child(2) {
    width: 260px;
}

.tender-results-panel th:nth-child(3),
.tender-results-panel td:nth-child(3) {
    width: 150px;
}

.tender-results-panel th:nth-child(4),
.tender-results-panel td:nth-child(4) {
    width: 125px;
}

.tender-results-panel th:nth-child(5),
.tender-results-panel td:nth-child(5) {
    width: 120px;
}

.tender-results-panel th:nth-child(6),
.tender-results-panel td:nth-child(6) {
    width: 105px;
}

.tender-results-panel th:nth-child(7),
.tender-results-panel td:nth-child(7) {
    width: 170px;
}

.tender-results-panel th:nth-child(8),
.tender-results-panel td:nth-child(8) {
    width: 95px;
}

.tender-results-panel th:nth-child(9),
.tender-results-panel td:nth-child(9),
.tender-results-panel th:nth-child(10),
.tender-results-panel td:nth-child(10) {
    width: 110px;
}

.tender-results-panel td:nth-child(2),
.tender-results-panel td:nth-child(3),
.tender-results-panel td:nth-child(4),
.tender-results-panel td:nth-child(5),
.tender-results-panel td:nth-child(7) {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tender-results-panel td:nth-child(2),
.tender-results-panel td:nth-child(3),
.tender-results-panel td:nth-child(4),
.tender-results-panel td:nth-child(5) {
    white-space: nowrap;
}

.tender-results-panel .table-detail-link {
    max-width: 100%;
    padding: 5px 7px;
    gap: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tender-results-panel tbody tr[data-row-url] {
    cursor: pointer;
}

.tender-results-panel tbody tr[data-row-url]:hover {
    box-shadow: inset 4px 0 0 rgba(15, 118, 110, 0.55);
}

.tender-results-panel tbody tr[data-row-url]:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.36);
    outline-offset: -3px;
}

.reference-copy-button {
    border: 0;
    cursor: copy;
    font: inherit;
}

.reference-copy-button::after,
.tender-results-panel .reference-copy-button::after {
    content: "Copy";
}

.reference-copy-button:hover,
.reference-copy-button:focus-visible {
    background: #0f766e;
    color: #fff;
}

.toast-message {
    background: linear-gradient(135deg, #052e2b, #0f766e);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 18px;
    bottom: 28px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.34), 0 0 0 8px rgba(15, 118, 110, 0.1);
    color: #f8fafc;
    font-weight: 800;
    left: 50%;
    max-width: min(520px, calc(100vw - 32px));
    opacity: 0;
    padding: 14px 18px;
    pointer-events: none;
    position: fixed;
    text-align: center;
    transform: translate(-50%, 18px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 1000;
}

.toast-message.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.tender-results-panel table.tender-table-active {
    min-width: 1420px;
}

.tender-results-panel .tender-table-active th:nth-child(1),
.tender-results-panel .tender-table-active td:nth-child(1) {
    width: 36px;
}

.tender-results-panel .tender-table-active th:nth-child(2),
.tender-results-panel .tender-table-active td:nth-child(2) {
    width: 132px;
}

.tender-results-panel .tender-table-active th:nth-child(3),
.tender-results-panel .tender-table-active td:nth-child(3) {
    width: auto;
    min-width: 320px;
    white-space: normal;
}

.tender-results-panel .tender-table-active th:nth-child(4),
.tender-results-panel .tender-table-active td:nth-child(4) {
    width: 150px;
}

.tender-results-panel .tender-table-active th:nth-child(5),
.tender-results-panel .tender-table-active td:nth-child(5) {
    width: 125px;
}

.tender-results-panel .tender-table-active th:nth-child(6),
.tender-results-panel .tender-table-active td:nth-child(6) {
    width: 120px;
}

.tender-results-panel .tender-table-active th:nth-child(7),
.tender-results-panel .tender-table-active td:nth-child(7) {
    width: 105px;
}

.tender-results-panel .tender-table-active th:nth-child(8),
.tender-results-panel .tender-table-active td:nth-child(8) {
    width: 170px;
}

.tender-results-panel .tender-table-active th:nth-child(9),
.tender-results-panel .tender-table-active td:nth-child(9) {
    width: 95px;
}

.tender-results-panel .tender-table-active th:nth-child(10),
.tender-results-panel .tender-table-active td:nth-child(10),
.tender-results-panel .tender-table-active th:nth-child(11),
.tender-results-panel .tender-table-active td:nth-child(11) {
    width: 110px;
}

.tender-results-panel .tender-table-active td:nth-child(3),
.tender-results-panel .tender-table-active td:nth-child(4),
.tender-results-panel .tender-table-active td:nth-child(5),
.tender-results-panel .tender-table-active td:nth-child(6),
.tender-results-panel .tender-table-active td:nth-child(8) {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tender-results-panel .tender-table-active td:nth-child(4),
.tender-results-panel .tender-table-active td:nth-child(5),
.tender-results-panel .tender-table-active td:nth-child(6) {
    white-space: nowrap;
}

.tender-results-panel .table-detail-link::after {
    content: "↗";
    padding: 1px 5px;
    font-size: 0.66rem;
}

.tender-results-panel .reference-copy-button::after {
    content: "Copy";
}

.tender-results-panel .status-pill,
.tender-results-panel .tag {
    padding: 5px 7px;
    border-radius: 10px;
}

.tender-results-panel .department-badges {
    gap: 4px;
}

.tender-results-panel .department-badge {
    padding: 4px 6px;
    border-radius: 9px;
    font-size: 0.68rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.intel-tag-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 7px;
}

.intel-tag,
.decision-pill,
.checklist-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.1;
    background: rgba(15, 118, 110, 0.1);
    color: #0f766e;
}

.decision-good,
.checklist-pill.is-found {
    background: rgba(15, 118, 110, 0.14);
    color: #0f4f4a;
}

.decision-review {
    background: rgba(245, 158, 11, 0.16);
    color: #92400e;
}

.decision-bad {
    background: rgba(190, 18, 60, 0.13);
    color: #9f1239;
}

.score-tooltip {
    border-bottom: 1px dotted currentColor;
    cursor: help;
    display: inline-flex;
    position: relative;
}

.score-tooltip-value {
    font-variant-numeric: tabular-nums;
}

.score-tooltip-text {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    bottom: calc(100% + 10px);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
    color: #f8fafc;
    font-size: 0.78rem;
    font-weight: 600;
    left: 50%;
    line-height: 1.35;
    max-width: min(320px, 80vw);
    min-width: 260px;
    opacity: 0;
    padding: 10px 12px;
    pointer-events: none;
    position: absolute;
    text-align: left;
    transform: translateX(-50%) translateY(4px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    visibility: hidden;
    white-space: normal;
    z-index: 30;
}

.score-tooltip:hover .score-tooltip-text,
.score-tooltip:focus .score-tooltip-text,
.score-tooltip:focus-within .score-tooltip-text {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    visibility: visible;
}

.distance-good {
    background: rgba(22, 163, 74, 0.16);
    color: #166534;
    font-weight: 900;
}

.distance-warning {
    background: rgba(234, 179, 8, 0.22);
    color: #854d0e;
    font-weight: 900;
}

.distance-bad {
    background: rgba(220, 38, 38, 0.14);
    color: #991b1b;
    font-weight: 900;
}

.distance-bold {
    font-weight: 950;
}

.distance-inline {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    line-height: 1.35;
}

.checklist-pill.is-missing {
    background: rgba(148, 163, 184, 0.14);
    color: #475569;
}

.decision-panel {
    border-left: 5px solid rgba(15, 118, 110, 0.55);
}

.decision-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.decision-card {
    padding: 14px;
    border: 1px solid var(--edge);
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.72);
    min-width: 0;
}

.decision-card strong {
    display: block;
    color: var(--ink);
    margin-bottom: 6px;
}

.decision-card p {
    margin: 0 0 6px;
    color: #25324b;
    font-weight: 700;
}

.decision-card small {
    color: var(--ink-soft);
    overflow-wrap: anywhere;
}

.checklist-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.pagination a,
.pagination-disabled,
.pagination-ellipsis {
    min-width: 38px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--edge);
    background: white;
    text-align: center;
    font-weight: 700;
}

.pagination a.is-current {
    background: var(--ink);
    color: white;
}

.pagination-disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.pagination-ellipsis {
    background: transparent;
    border-color: transparent;
    min-width: auto;
    padding-inline: 4px;
    color: var(--ink-soft);
}

.pagination-jump {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.pagination-jump label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-soft);
    font-weight: 700;
}

.pagination-jump input {
    width: 86px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 11px;
}

.pagination-jump button {
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 11px;
}

.status-pill,
.tag {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(20, 33, 61, 0.08);
}

.department-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.department-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: #0f4f4a;
    font-size: 0.82rem;
    font-weight: 800;
}

.department-badge-unassigned {
    background: rgba(148, 163, 184, 0.18);
    color: #475569;
}

.multi-department-note {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.empty-filter-state {
    position: relative;
    overflow: hidden;
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 12px;
    padding: 54px 24px;
    border: 1px dashed rgba(15, 118, 110, 0.28);
    border-radius: 24px;
    background:
        radial-gradient(circle at 50% 0%, rgba(15, 118, 110, 0.14), transparent 34%),
        linear-gradient(135deg, rgba(255, 253, 248, 0.94), rgba(244, 239, 230, 0.82));
}

.empty-filter-state h3 {
    margin: 4px 0 0;
    font-size: 1.45rem;
}

.empty-filter-state p {
    max-width: 620px;
    margin: 0;
    color: var(--ink-soft);
}

.empty-filter-graphic {
    width: 112px;
    height: 82px;
    position: relative;
    border-radius: 26px;
    background:
        linear-gradient(135deg, rgba(217, 119, 6, 0.18), rgba(15, 118, 110, 0.2)),
        #fffdfa;
    box-shadow: inset 0 0 0 1px rgba(20, 33, 61, 0.08), 0 18px 42px rgba(20, 33, 61, 0.12);
}

.empty-filter-graphic::before {
    content: "";
    position: absolute;
    width: 42px;
    height: 42px;
    right: -12px;
    bottom: -10px;
    border: 8px solid #0f766e;
    border-radius: 50%;
    background: transparent;
}

.empty-filter-graphic::after {
    content: "";
    position: absolute;
    width: 34px;
    height: 8px;
    right: -32px;
    bottom: -16px;
    border-radius: 999px;
    background: #0f766e;
    transform: rotate(42deg);
}

.empty-filter-graphic span {
    position: absolute;
    left: 18px;
    right: 22px;
    height: 8px;
    border-radius: 999px;
    background: rgba(20, 33, 61, 0.18);
}

.empty-filter-graphic span:nth-child(1) {
    top: 20px;
}

.empty-filter-graphic span:nth-child(2) {
    top: 38px;
    right: 38px;
}

.empty-filter-graphic span:nth-child(3) {
    top: 56px;
    right: 52px;
}

.hero-panel {
    margin-bottom: 0;
}

.tag-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--card-gap);
}

.card-actions {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.inline-form {
    margin: 0;
}

.department-create-form {
    gap: 16px;
}

.department-create-card {
    width: min(640px, 100%);
}

.confirm-card {
    width: min(520px, 100%);
}

.confirm-message {
    margin: 0 0 22px;
    color: var(--ink-soft);
}

.confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button-link,
.button-danger,
.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font: inherit;
}

.button-small {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.button-link {
    background: linear-gradient(135deg, #0f766e, #155e75);
    color: white;
}

.button-danger {
    background: linear-gradient(135deg, #be123c, #881337);
    color: white;
}

.button-secondary {
    background: rgba(20, 33, 61, 0.08);
    color: var(--ink);
}

.info-card p,
.empty-state {
    color: var(--ink-soft);
}

.source-note {
    margin-top: 14px;
    font-size: 0.92rem;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(520px, 100%);
    padding: 32px;
    background:
        linear-gradient(180deg, rgba(20,33,61,0.96), rgba(35,56,92,0.96)),
        linear-gradient(135deg, rgba(217,119,6,0.14), rgba(15,118,110,0.18));
    color: #edf2f7;
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.login-form label {
    display: grid;
    gap: 8px;
}

.flash {
    padding: 14px 16px;
    border-radius: 14px;
    margin-top: 18px;
}

.flash-error {
    background: rgba(190, 24, 60, 0.22);
    border: 1px solid rgba(190, 24, 60, 0.28);
}

.flash-success {
    background: rgba(15, 118, 110, 0.18);
    border: 1px solid rgba(15, 118, 110, 0.28);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 32, 58, 0.56);
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 1000;
}

.modal-card {
    width: min(980px, 100%);
    max-height: 85vh;
    overflow: auto;
    border-radius: 24px;
    border: 1px solid var(--edge);
    box-shadow: var(--shadow);
    background: rgba(255, 253, 248, 0.98);
    padding: 24px;
}

@media (max-width: 1100px) {
    .app-shell,
    .metrics-grid,
    .dashboard-grid,
    .detail-grid,
    .card-grid,
    .department-create-form,
    .filter-bar,
    .extra-document-row {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        overflow: visible;
        padding-bottom: 18px;
    }

    body.sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    body.sidebar-collapsed .sidebar {
        display: none;
    }
}

@media (max-width: 1200px) {
    .decision-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1400px) and (min-width: 1101px) {
    .app-shell {
        grid-template-columns: 248px 1fr;
    }

    .sidebar {
        padding: 22px 16px;
        gap: 20px;
    }

    .nav a {
        padding: 11px 12px;
        border-radius: 12px;
    }

    .content {
        padding: 18px;
    }

    .topbar {
        margin-bottom: 14px;
    }

    .panel,
    .info-card {
        padding: 18px;
    }

    .content > section + section {
        margin-top: 16px;
    }
}

@media (max-height: 820px) and (min-width: 1101px) {
    .sidebar {
        padding-top: 18px;
        padding-bottom: 18px;
        gap: 16px;
    }

    .brand-block p {
        display: none;
    }

    .nav {
        gap: 7px;
    }

    .user-chip {
        padding: 10px 12px;
    }
}

.source-health {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    display: grid;
    gap: 4px;
    font-size: 0.86rem;
}

.source-health strong,
.source-health span,
.source-health p {
    color: inherit;
}

.source-health p {
    margin: 0;
    opacity: 0.86;
}

.source-health-warning {
    background: rgba(185, 28, 28, 0.12);
    border: 1px solid rgba(185, 28, 28, 0.28);
    color: #7f1d1d;
}

.source-health-ok {
    background: rgba(22, 101, 52, 0.10);
    border: 1px solid rgba(22, 101, 52, 0.22);
    color: #14532d;
}
