:root {
    --page: #f8fafc;
    --surface: #ffffff;
    --surface-soft: rgba(255, 255, 255, 0.82);
    --fg: #0b1220;
    --muted: #52607a;
    --muted-2: #748097;
    --border: #e6e9f2;
    --border-strong: #cfd6e6;
    --brand-1: #6366f1;
    --brand-2: #818cf8;
    --brand-3: #4f46e5;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 18px 40px rgba(11, 18, 32, 0.10);
    --shadow-soft: 0 10px 26px rgba(11, 18, 32, 0.07);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-body {
    background:
        linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(248, 250, 252, 0) 280px),
        var(--page);
    color: var(--fg);
}

.auth-body {
    background:
        linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px) 0 0 / 28px 28px,
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px) 0 0 / 28px 28px,
        linear-gradient(135deg, #0b1220 0%, #1f2552 52%, #312e81 100%);
}

.auth-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(16px);
}

.app-header {
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
}

.brand-lockup {
    align-items: center;
    display: flex;
    gap: 1rem;
}

.brand-app {
    align-items: center;
    color: var(--fg);
    display: inline-flex;
    gap: 0.75rem;
    min-width: 0;
}

.brand-app strong {
    display: block;
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.1;
}

.brand-app small,
.tenant-name {
    color: var(--muted);
    display: block;
    font-size: 0.78rem;
    font-weight: 650;
}

.tenant-name {
    border-left: 1px solid var(--border);
    padding-left: 1rem;
}

.brand-icon {
    align-items: center;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.32);
    color: white;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 1rem;
    font-weight: 900;
    height: 2.5rem;
    justify-content: center;
    width: 2.5rem;
}

.nav-link {
    border-radius: 12px;
    color: rgba(11, 18, 32, 0.74);
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0.62rem 0.86rem;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.nav-link:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--fg);
}

.nav-link-active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--brand-3);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.18);
}

.btn-primary,
.btn-secondary,
.btn-ghost {
    align-items: center;
    border-radius: 12px;
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 800;
    justify-content: center;
    min-height: 2.55rem;
    padding: 0.62rem 1rem;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn-primary {
    background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
    box-shadow: 0 12px 26px rgba(99, 102, 241, 0.28);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(90deg, var(--brand-3), var(--brand-2));
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(99, 102, 241, 0.10);
    color: var(--brand-3);
}

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.16);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
}

.btn-ghost:hover {
    background: rgba(11, 18, 32, 0.06);
    color: var(--fg);
}

.section-kicker {
    background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.page-title {
    color: var(--fg);
    font-size: clamp(1.8rem, 4vw, 2.7rem);
    font-weight: 850;
    letter-spacing: 0;
    line-height: 1.05;
}

.panel,
.metric {
    background: var(--surface-soft);
    border: 1px solid rgba(230, 233, 242, 0.92);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.panel {
    padding: 1.25rem;
}

.panel-heading {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.panel-heading h2,
.panel-title {
    color: var(--fg);
    font-size: 1rem;
    font-weight: 800;
}

.label {
    color: var(--muted);
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 0.42rem;
}

.input {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    color: var(--fg);
    display: block;
    min-height: 2.8rem;
    padding: 0.7rem 0.82rem;
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
    width: 100%;
}

.input:focus {
    background: #fff;
    border-color: var(--brand-1);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
    outline: none;
}

.value {
    color: var(--fg);
    font-weight: 700;
}

.metric {
    overflow: hidden;
    padding: 1.2rem;
    position: relative;
}

.metric::after {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.18), rgba(129, 140, 248, 0));
    content: "";
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    width: 5px;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 0.82rem;
    font-weight: 800;
}

.metric strong {
    color: var(--fg);
    display: block;
    font-size: 2.2rem;
    font-weight: 850;
    line-height: 1.1;
    margin-top: 0.45rem;
}

.audit-row {
    align-items: center;
    border-bottom: 1px solid rgba(230, 233, 242, 0.9);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding-bottom: 0.75rem;
}

.empty {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 0.75rem 0;
}

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

.data-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 680px;
    width: 100%;
}

.data-table th {
    background: rgba(248, 250, 252, 0.9);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.73rem;
    font-weight: 900;
    padding: 0.8rem;
    text-align: left;
    text-transform: uppercase;
}

.data-table td {
    border-bottom: 1px solid rgba(230, 233, 242, 0.9);
    color: rgba(11, 18, 32, 0.78);
    font-size: 0.9rem;
    padding: 0.9rem 0.8rem;
    vertical-align: top;
}

.data-table tr:hover td {
    background: rgba(99, 102, 241, 0.035);
}

.data-table td span {
    color: var(--muted-2);
    display: block;
    font-size: 0.8rem;
    margin-top: 0.15rem;
    max-width: 32rem;
}

.link {
    color: var(--brand-3);
    font-weight: 800;
}

.link-danger {
    color: var(--danger);
    font-size: 0.84rem;
    font-weight: 800;
}

.suggestions {
    display: grid;
    gap: 0.5rem;
}

.suggestion {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    padding: 0.8rem;
    text-align: left;
    transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.suggestion:hover,
.suggestion.is-selected {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.08);
}

.suggestion strong {
    color: var(--fg);
    display: block;
}

.suggestion span {
    color: var(--muted);
    display: block;
    font-size: 0.82rem;
}

.document-shell {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    color: var(--fg);
    margin: 0 auto;
    max-width: 960px;
    padding: clamp(1rem, 3vw, 2rem);
}

.document-header {
    align-items: flex-start;
    border-bottom: 2px solid var(--brand-1);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding-bottom: 1rem;
}

.document-header h1 {
    font-size: 1.5rem;
    font-weight: 850;
    line-height: 1.15;
}

.document-header p,
.document-header span {
    color: var(--muted);
}

.document-section {
    margin-top: 1.5rem;
}

.document-section h2 {
    color: var(--fg);
    font-size: 1rem;
    font-weight: 850;
    margin-bottom: 0.75rem;
}

.document-section table {
    border-collapse: collapse;
    width: 100%;
}

.document-section th {
    background: rgba(99, 102, 241, 0.08);
}

.document-section th,
.document-section td {
    border: 1px solid var(--border-strong);
    font-size: 0.88rem;
    padding: 0.62rem;
    text-align: left;
}

.signature-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 3rem;
}

.signature-grid span {
    border-top: 1px solid var(--fg);
    display: block;
}

.signature-grid p {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: center;
}

@media (max-width: 640px) {
    .brand-lockup {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.5rem;
    }

    .tenant-name {
        border-left: 0;
        padding-left: 0;
    }

    .document-header,
    .signature-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    body {
        background: white;
    }

    .app-header {
        display: none;
    }

    .document-shell {
        border: 0;
        box-shadow: none;
        max-width: none;
        padding: 0;
    }
}
