:root {
    color-scheme: light;
    --app-background: #f5f5f5;
    --app-surface: #ffffff;
    --app-hover: #f0f0f0;
    --app-border: #dedede;
    --app-text: #252525;
    --app-muted: #666666;
    --app-accent: #353535;
    --app-focus: #2563eb;
    --bs-body-bg: var(--app-background);
    --bs-body-color: var(--app-text);
    --bs-border-color: var(--app-border);
    --bs-secondary-color: var(--app-muted);
    --bs-secondary-bg: #eeeeee;
    --bs-tertiary-bg: #f7f7f7;
    --bs-link-color: #353535;
    --bs-link-hover-color: #111111;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-size: 14px;
}

body {
    margin: 0;
    background: var(--app-background);
    color: var(--app-text);
    font-family: "Segoe UI", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--bs-link-color);
    text-underline-offset: 3px;
}

    a:hover {
        color: var(--bs-link-hover-color);
    }

:focus-visible {
    outline: 2px solid var(--app-focus);
    outline-offset: 4px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
}

.app-navigation {
    display: flex;
    align-items: center;
    gap: 48px;
    width: 100%;
    max-width: 1600px;
    min-height: 64px;
    margin: 0 auto;
    padding: 0 36px;
}

.app-brand {
    flex-shrink: 0;
    color: var(--app-text);
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.3px;
    text-decoration: none;
}

    .app-brand:hover {
        color: #000000;
    }

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.app-brand-logo {
    display: block;
    height: 34px;
    width: auto;
    flex-shrink: 0;
}

.app-nav {
    display: flex;
    align-self: stretch;
    gap: 28px;
    margin: 0;
    padding: 0;
    list-style: none;
}

    .app-nav li {
        display: flex;
    }

.app-nav-link {
    display: flex;
    align-items: center;
    padding: 2px 0 0;
    border-bottom: 2px solid transparent;
    color: var(--app-muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

    .app-nav-link:hover {
        color: var(--app-text);
    }

    .app-nav-link.is-active {
        border-bottom-color: var(--app-accent);
        color: var(--app-text);
    }

.app-content {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 36px;
}

.app-navigation {
    max-width: none;
}

.app-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    color: var(--app-muted);
    font-size: 13px;
}

h1,
h2,
h3,
.app-brand,
.app-nav-link {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

h1 {
    margin: 0 0 28px;
    font-size: 28px;
    line-height: 1.2;
}

h2 {
    font-size: 21px;
}

h3 {
    font-size: 17px;
}

.text-muted {
    color: var(--app-muted) !important;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

    .page-header h1 {
        margin: 0;
    }

.table {
    --bs-table-color: var(--app-text);
    --bs-table-bg: var(--app-surface);
    --bs-table-border-color: var(--app-border);
    --bs-table-striped-bg: #fafafa;
    --bs-table-striped-color: var(--app-text);
    --bs-table-hover-bg: var(--app-hover);
    --bs-table-hover-color: var(--app-text);
    width: 100%;
    margin-bottom: 24px;
    font-size: 13px;
}

    .table > :not(caption) > * > * {
        padding: 13px 16px;
        vertical-align: middle;
    }

    .table thead th {
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }

    .table thead th {
        background: #ededed;
        color: #555555;
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
    }

    .table tbody tr:hover > * {
        background-color: var(--app-hover);
    }

.table-responsive {
    border: 1px solid var(--app-border);
    border-radius: 3px;
    background: var(--app-surface);
}

    .table-responsive .table {
        margin-bottom: 0;
    }

    .table-responsive tbody tr:last-child > * {
        border-bottom: 0;
    }

body.documents-index {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.documents-index .app-header {
    flex-shrink: 0;
}

.documents-index .app-content {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 28rem;
}

.documents-index .page-header,
.documents-index .alert {
    flex-shrink: 0;
}

.documents-table {
    flex: 0 1 auto;
    min-height: 0;
    overflow: auto;
}

.documents-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.documents-table tbody tr {
    position: relative;
}

.form-label {
    margin-bottom: 7px;
    color: var(--app-text);
    font-size: 13px;
    font-weight: 600;
}

.form-control,
.form-select {
    min-height: 40px;
    border: 1px solid #bcbcbc;
    border-radius: 3px;
    background-color: var(--app-surface);
    color: var(--app-text);
    font-size: 14px;
}

    .form-control::placeholder {
        color: #737373;
        opacity: 1;
    }

    .form-control:focus,
    .form-select:focus {
        border-color: var(--app-focus);
        background-color: var(--app-surface);
        color: var(--app-text);
        box-shadow: 0 0 0 3px rgb(37 99 235 / 12%);
    }

    .form-control:disabled,
    .form-select:disabled {
        background-color: #eeeeee;
        color: var(--app-muted);
        opacity: 1;
    }

.form-text {
    color: var(--app-muted);
}

.form-check-input {
    border-color: #888888;
    background-color: var(--app-surface);
}

    .form-check-input:checked {
        border-color: #2563eb;
        background-color: #2563eb;
    }

.btn {
    padding: 9px 15px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
}

.btn-primary {
    --bs-btn-color: #ffffff;
    --bs-btn-bg: #2563eb;
    --bs-btn-border-color: #2563eb;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: #1d4ed8;
    --bs-btn-hover-border-color: #1d4ed8;
    --bs-btn-active-color: #ffffff;
    --bs-btn-active-bg: #1e40af;
    --bs-btn-active-border-color: #1e40af;
    --bs-btn-disabled-color: #ffffff;
    --bs-btn-disabled-bg: #2563eb;
    --bs-btn-disabled-border-color: #2563eb;
}

.btn-secondary,
.btn-outline-secondary {
    --bs-btn-color: #353535;
    --bs-btn-bg: #ffffff;
    --bs-btn-border-color: #bcbcbc;
    --bs-btn-hover-color: #111111;
    --bs-btn-hover-bg: #eeeeee;
    --bs-btn-hover-border-color: #888888;
    --bs-btn-active-color: #111111;
    --bs-btn-active-bg: #dedede;
    --bs-btn-active-border-color: #888888;
    --bs-btn-disabled-color: #666666;
    --bs-btn-disabled-bg: #eeeeee;
    --bs-btn-disabled-border-color: #cccccc;
}

.text-danger,
.field-validation-error,
.validation-summary-errors {
    color: #b42318 !important;
}

.input-validation-error {
    border-color: #b42318;
}

@media (max-width: 640px) {
    .app-navigation {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 16px 20px 0;
    }

    .app-nav {
        gap: 24px;
    }

    .app-nav-link {
        min-height: 44px;
    }

    .app-content {
        padding: 28px 20px;
    }

    h1 {
        font-size: 24px;
    }
}

.document-form {
    max-width: 640px;
}

.revision-preview {
    width: 100%;
    height: 85vh;
    min-height: 640px;
    border: 1px solid var(--app-border);
}

.revision-table tbody tr.is-live > *,
.revision-table tbody tr.is-live:hover > * {
    background-color: #d1e7dd;
}

.revision-file-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .revision-file-actions .btn {
        white-space: nowrap;
    }

.link-guidance {
    max-width: 760px;
    margin-bottom: 24px;
    padding-left: 16px;
    border-left: 3px solid var(--app-border);
}

    .link-guidance p {
        margin-bottom: 10px;
    }

.app-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    color: var(--app-muted);
    font-size: 13px;
}

@media (max-width: 640px) {
    .app-user {
        margin-left: 0;
        padding-bottom: 16px;
    }
}

.product-link-grid {
    margin-bottom: 24px;
}

.product-link-card {
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
    box-shadow: 0 2px 8px rgb(0 0 0 / 4%);
}

.product-link-card--empty {
    border-color: #dc7a7a;
    box-shadow: 0 2px 8px rgb(180 35 24 / 8%);
}

.product-link-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 92px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--app-border);
    background: linear-gradient(135deg, #ffffff, #f3f5f6);
}

.product-link-card--empty .product-link-card__header {
    border-bottom-color: #f0caca;
    background: linear-gradient(135deg, #fffafa, #fcecec);
}

.product-link-card--empty .product-link-count {
    background: #f8d7da;
    color: #842029;
}

    .product-link-card__header h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 650;
    }

.product-link-card__eyebrow {
    margin: 0 0 4px;
    color: var(--app-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.product-link-count,
.product-link-placeholder-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #e8ecef;
    color: var(--app-text);
    font-size: 13px;
    font-weight: 700;
}

.product-link-card__body {
    display: grid;
    gap: 20px;
    min-height: 112px;
    padding: 20px;
}

.product-link-group__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.product-link-group h4 {
    margin: 0;
    color: var(--app-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.product-link-count--small {
    width: 26px;
    height: 26px;
    font-size: 11px;
}

.product-link-empty {
    margin: 0;
    color: var(--app-muted);
    font-size: 13px;
}

.relationship-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

    .relationship-list li {
        display: inline-flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 10px;
        border: 1px solid var(--app-border);
        border-radius: 6px;
        background: var(--app-background);
        font-size: 12px;
        font-weight: 600;
        overflow-wrap: anywhere;
    }

.product-link-hidden {
    color: var(--app-muted);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.product-link-card--placeholder {
    border-style: dashed;
    box-shadow: none;
}

    .product-link-card--placeholder .product-link-card__header {
        background: #fafafa;
    }

.product-link-placeholder-icon {
    background: transparent;
    color: #858585;
    font-size: 24px;
    font-weight: 400;
}
