:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #667085;
    --line: #e4e8f0;
    --primary: #2856d7;
    --primary-dark: #1e45b5;
    --accent: #f07a2b;
    --danger: #c9363e;
    --success: #178754;
    --shadow: 0 8px 28px rgba(24, 39, 75, .07);
    --radius: 14px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }
.topbar { height: 70px; background: #111827; color: #fff; display: flex; align-items: center; padding: 0 30px; gap: 36px; position: sticky; top: 0; z-index: 50; box-shadow: 0 3px 16px rgba(0,0,0,.18); }
.brand { color: #fff; display: flex; align-items: center; gap: 11px; min-width: 215px; }
.brand-mark { width: 37px; height: 37px; border-radius: 10px; background: linear-gradient(135deg, #4778ff, #2447bf); display: inline-grid; place-items: center; color: #fff; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .04em; }
.brand small { color: #9aa6bc; font-size: 11px; margin-top: 2px; }
.topnav { display: flex; align-self: stretch; align-items: center; gap: 6px; flex: 1; }
.topnav a { color: #c6cfdd; padding: 10px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.topnav a:hover, .topnav a.active { color: #fff; background: rgba(255,255,255,.09); }
.user-menu { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.user-avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: #334155; font-weight: 700; }
.user-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-button { border: 0; background: transparent; color: #98a6bd; padding: 6px; }
.link-button:hover { color: #fff; }
.main-content { max-width: 1760px; margin: 0 auto; padding: 30px; }
.auth-content { max-width: none; padding: 0; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { font-size: 29px; margin: 4px 0 7px; letter-spacing: -.035em; }
.page-heading p { color: var(--muted); margin: 0; }
.compact-heading { align-items: center; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.back-link { display: inline-block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.heading-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.button { border: 1px solid transparent; border-radius: 9px; padding: 10px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 700; font-size: 13px; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(40,86,215,.22); }
.button-primary:hover { background: var(--primary-dark); color: #fff; }
.button-secondary { background: #fff; color: #344054; border-color: #d5dae4; }
.button-secondary:hover { background: #f7f8fb; color: #172033; }
.button-ghost { background: transparent; color: #475467; border-color: transparent; }
.button-accent { background: var(--accent); color: #fff; }
.button-danger { background: var(--danger); color: #fff; }
.button-danger-outline { color: var(--danger); border-color: #efc7ca; background: #fff; }
.button-full { width: 100%; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 17px 18px; min-height: 82px; box-shadow: 0 3px 14px rgba(24,39,75,.04); }
.metric-card span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 9px; }
.metric-card strong { font-size: 23px; letter-spacing: -.03em; }
.currency-metric-lines { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.currency-metric-lines strong { margin-top: 0; font-size: 16px; letter-spacing: 0; }
.currency-metric-lines small { color: var(--muted); font-size: 10px; font-weight: 700; margin-left: 3px; }

.metric-action { background: linear-gradient(135deg, #eff4ff, #fff); }
.metric-action a { font-weight: 700; }
.filter-panel { padding: 15px; margin-bottom: 16px; }
.search-row { display: flex; gap: 9px; align-items: center; }
.search-box { height: 42px; border: 1px solid #d7dce6; border-radius: 9px; display: flex; align-items: center; gap: 9px; padding: 0 12px; flex: 1; background: #fff; }
.search-box:focus-within { border-color: #7b9cf0; box-shadow: 0 0 0 3px rgba(40,86,215,.09); }
.search-box span { font-size: 22px; color: #7c8799; }
.search-box input { border: 0; outline: 0; width: 100%; color: var(--text); }
.advanced-filters { display: none; grid-template-columns: repeat(5,minmax(150px,1fr)); gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); margin-top: 15px; }
.advanced-filters.open { display: grid; }
.field label, .calculated-field label { display: block; color: #344054; font-weight: 650; font-size: 12px; margin-bottom: 7px; }
.required { color: var(--danger); margin-left: 3px; }
.form-control, .login-card input { width: 100%; border: 1px solid #d4dae5; border-radius: 8px; background: #fff; color: var(--text); padding: 10px 11px; min-height: 41px; outline: none; }
textarea.form-control { resize: vertical; line-height: 1.45; }
.form-control:focus, .login-card input:focus { border-color: #7798eb; box-shadow: 0 0 0 3px rgba(40,86,215,.1); }
.field-error .form-control { border-color: #dc7d83; }
.help-text, .error-text { display: block; margin-top: 5px; font-size: 11px; }
.help-text { color: var(--muted); }
.error-text { color: var(--danger); font-weight: 600; }
.registry-panel { overflow: hidden; }
.table-toolbar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); font-size: 12px; }
.muted { color: var(--muted); }
.table-scroll { overflow: auto; max-width: 100%; }
.registry-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.registry-table th { position: sticky; top: 0; z-index: 4; background: #f7f8fb; color: #596579; text-align: left; font-size: 10px; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--line); padding: 12px 11px; }
.registry-table th a { color: inherit; }
.registry-table td { padding: 11px; border-bottom: 1px solid #edf0f4; vertical-align: top; max-width: 230px; line-height: 1.35; background: #fff; }
.registry-table tbody tr { cursor: pointer; }
.registry-table tbody tr:hover td { background: #f6f9ff; }
.registry-table .sticky-number { position: sticky; left: 0; z-index: 2; min-width: 98px; box-shadow: 5px 0 9px rgba(26,43,77,.03); }
.registry-table th:nth-child(2) { left: 0; z-index: 6; }
.document-link { font-weight: 800; white-space: nowrap; }
.sticky-number small { display: block; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.wide-cell { min-width: 210px; }
.memo-cell { min-width: 180px; white-space: normal; }
.money-cell { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.company-pill { display: inline-block; border-radius: 6px; background: #edf2ff; color: #3153aa; padding: 4px 7px; min-width: 140px; }
.participants-compact { display: flex; flex-direction: column; gap: 4px; }
.participants-compact span { border-left: 2px solid #cdd8f6; padding-left: 6px; }
.participants-compact em { color: var(--muted); font-style: normal; font-size: 10px; white-space: nowrap; }
.status-badge { display: inline-block; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; background: #edf0f5; color: #485467; }
.status-paid { background: #e8f7ef; color: #147346; }
.status-unpaid { background: #fff0f0; color: #ac3036; }
.status-partially-paid { background: #fff6e6; color: #9b6409; }
.actions-column { min-width: 78px; }
.row-actions { display: flex; align-items: center; justify-content: center; gap: 5px; }
.row-actions form { margin: 0; }
.row-actions a { width: 28px; height: 28px; border-radius: 7px; display: inline-grid; place-items: center; background: #eef3ff; }
.generate-mini { width: 28px; height: 28px; border-radius: 7px; border: 0; display: grid; place-items: center; background: #fff0e7; color: #b85516; font-weight: 800; }
.sort-icon { color: var(--primary); margin-left: 4px; font-size: 13px; }
.empty-state { text-align: center; padding: 55px !important; cursor: default; }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { font-size: 16px; margin-bottom: 6px; }
.empty-state span { color: var(--muted); }
.pagination { display: flex; justify-content: center; gap: 5px; padding: 15px; }
.pagination a, .pagination span { min-width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; border: 1px solid var(--line); background: #fff; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.messages { margin-bottom: 15px; }
.message { padding: 12px 15px; border-radius: 9px; border: 1px solid; background: #fff; }
.message-success { color: #166c45; border-color: #b9dfcb; background: #effaf4; }
.message-warning { color: #815608; border-color: #edd59d; background: #fff9e9; }
.message-info { color: #2451a3; border-color: #bdd0f4; background: #f0f5ff; }
.message-error { color: #9d2d34; border-color: #e7babc; background: #fff1f1; }
.form-section { padding: 22px; margin-bottom: 16px; }
.section-heading { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.section-heading > span { width: 29px; height: 29px; flex: 0 0 auto; border-radius: 8px; background: #edf2ff; color: var(--primary); display: grid; place-items: center; font-weight: 800; }
.section-heading h2 { margin: 0 0 3px; font-size: 17px; }
.section-heading p { margin: 0; font-size: 12px; color: var(--muted); }
.form-grid { display: grid; gap: 16px; }
.cols-1 { grid-template-columns: 1fr; }
.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
.related-document-box { display: none; margin-top: 18px; padding: 16px; border: 1px solid #dbe3f4; border-radius: 10px; background: #f7f9fe; }
.related-document-box.visible { display: block; }
.hidden { display: none !important; }
.context-note { font-size: 12px; line-height: 1.5; color: #526075; border-left: 3px solid #99afea; padding: 8px 11px; background: #f5f8ff; margin: 13px 0 0; }
.document-number-chip { background: #111827; color: #fff; border-radius: 10px; padding: 11px 16px; font-weight: 800; font-size: 17px; min-width: 140px; text-align: center; }
.document-number-chip.preview { background: #e9eef9; color: #3e506d; }
.participant-table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.participant-header, .participant-row { display: grid; grid-template-columns: minmax(260px,2fr) minmax(150px,1fr) 100px; gap: 10px; align-items: center; }
.participant-header { background: #f7f8fb; color: #667085; text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 10px 12px; }
.participant-row { padding: 10px 12px; border-top: 1px solid var(--line); }
.participant-row:first-of-type { border-top: 0; }
.participant-remove { text-align: center; font-size: 11px; color: var(--muted); }
.icon-button { width: 32px; height: 32px; border-radius: 7px; border: 0; font-size: 20px; }
.icon-button.danger { color: #ae343b; background: #fff0f1; }
.memo-top { margin-top: 17px; }
.calculated-field { align-self: start; }
.calculated-value { min-height: 41px; display: flex; align-items: center; padding: 10px 11px; background: #eef3fc; border: 1px solid #dbe4f6; border-radius: 8px; font-weight: 800; }
.calculated-field small { color: var(--muted); display: block; margin-top: 5px; }
.form-alert { background: #fff1f1; border: 1px solid #e7babc; color: #9d2d34; padding: 12px 14px; border-radius: 8px; margin-bottom: 15px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; }
.sticky-actions { position: sticky; bottom: 12px; z-index: 20; padding: 12px; background: rgba(255,255,255,.93); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 35px rgba(20,35,65,.14); backdrop-filter: blur(8px); }
.detail-title-line { display: flex; align-items: center; gap: 12px; }
.detail-layout { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 16px; align-items: start; }
.detail-main { padding: 24px; }
.detail-section + .detail-section { border-top: 1px solid var(--line); margin-top: 25px; padding-top: 25px; }
.detail-section h2 { font-size: 17px; margin: 0 0 17px; }
.details-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px 24px; margin: 0; }
.details-grid div { min-width: 0; }
.details-grid dt { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.details-grid dd { margin: 0; line-height: 1.45; word-break: break-word; }
.missing-reference { color: #b06312; background: #fff6e8; border-radius: 6px; padding: 6px 8px; display: inline-block; }
.participant-detail-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.participant-detail-list > div { border: 1px solid var(--line); padding: 10px; border-radius: 9px; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; }
.person-icon { width: 27px; height: 27px; border-radius: 50%; background: #edf2ff; color: var(--primary); display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.participant-detail-list em { font-style: normal; color: var(--muted); font-size: 11px; }
.memo-block { margin-top: 13px; padding: 13px; border-radius: 9px; background: #f8fafc; border-left: 3px solid #9baccc; }
.memo-block span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.memo-block p { margin: 0; }
.detail-sidebar { display: flex; flex-direction: column; gap: 14px; }
.detail-sidebar .panel { padding: 19px; }
.payment-card { background: linear-gradient(150deg, #172033, #293952); color: #fff; border: 0; }
.payment-card .eyebrow { color: #96b3ff; }
.payment-total { font-size: 33px; font-weight: 850; letter-spacing: -.04em; margin-top: 12px; }
.payment-total small { font-size: 19px; }
.payment-code { color: #b7c2d4; margin: 4px 0 20px; font-size: 12px; }
.payment-breakdown { border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; margin-top: 12px; display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.payment-breakdown span { color: #b7c2d4; }
.metadata-card h3, .related-list-card h3 { margin: 0 0 14px; font-size: 14px; }
.metadata-card div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 11px; }
.metadata-card span { color: var(--muted); }
.related-list-card a { display: block; padding: 9px 0; border-top: 1px solid var(--line); }
.related-list-card span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.import-layout { display: grid; grid-template-columns: minmax(0,1fr) 360px; gap: 16px; align-items: start; }
.import-card, .import-help { padding: 22px; }
.stack-form { display: flex; flex-direction: column; gap: 15px; }
.checkbox-input { width: 17px; height: 17px; }
.import-help h2 { margin-top: 0; font-size: 17px; }
.import-help ol { padding-left: 21px; color: #475467; line-height: 1.6; }
.import-help code { background: #eef1f6; padding: 2px 5px; border-radius: 4px; }
.import-result { margin-top: 16px; padding: 20px; }
.result-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.result-heading h2 { margin: 5px 0 0; }
.result-metrics { display: flex; gap: 13px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.result-metrics strong { color: var(--text); font-size: 15px; margin-left: 3px; }
.result-metrics .danger strong { color: var(--danger); }
.result-metrics .success strong { color: var(--success); }
.result-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.result-table th, .result-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
.import-status { padding: 3px 7px; border-radius: 999px; background: #edf0f5; }
.import-error { background: #ffeded; color: #a72c33; }
.import-created, .import-updated { background: #e9f8ef; color: #167347; }
.import-preview { background: #edf3ff; color: #2855af; }
.confirm-card { max-width: 550px; margin: 80px auto; padding: 30px; text-align: center; }
.confirm-card h1 { font-size: 23px; }
.confirm-card p { color: var(--muted); }
.danger-icon { width: 50px; height: 50px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: #ffeded; color: var(--danger); font-size: 24px; font-weight: 900; }
.confirm-summary { padding: 14px; border-radius: 9px; background: #f7f8fb; margin: 20px 0; }
.confirm-summary strong, .confirm-summary span { display: block; }
.confirm-summary span { color: var(--muted); margin-top: 4px; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1.25fr) minmax(420px,.75fr); background: #101827; }
.login-intro { color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 9vw; background: radial-gradient(circle at 15% 20%, rgba(54,101,230,.34), transparent 35%), linear-gradient(135deg,#111b30,#17233b); }
.brand-large { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .05em; }
.login-intro h1 { max-width: 720px; font-size: clamp(36px,4vw,62px); letter-spacing: -.055em; line-height: 1.04; margin: 50px 0 22px; }
.login-intro > p { color: #b6c2d5; max-width: 620px; font-size: 17px; line-height: 1.55; }
.login-feature-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 50px; max-width: 650px; }
.login-feature-grid div { border-top: 1px solid rgba(255,255,255,.17); padding-top: 15px; }
.login-feature-grid strong, .login-feature-grid span { display: block; }
.login-feature-grid strong { font-size: 21px; }
.login-feature-grid span { color: #95a4ba; margin-top: 4px; font-size: 12px; }
.login-card { background: #fff; align-self: center; margin: 45px; border-radius: 18px; padding: 45px; box-shadow: 0 20px 70px rgba(0,0,0,.3); }
.login-card h2 { font-size: 26px; margin: 0 0 8px; }
.login-card .muted { margin-bottom: 27px; }
@media (max-width: 1100px) {
    .main-content { padding: 20px; }
    .topbar { padding: 0 18px; gap: 14px; }
    .brand { min-width: auto; }
    .brand > span:last-child, .user-name { display: none; }
    .metric-grid { grid-template-columns: repeat(2,1fr); }
    .advanced-filters { grid-template-columns: repeat(3,1fr); }
    .detail-layout, .import-layout { grid-template-columns: 1fr; }
    .detail-sidebar { display: grid; grid-template-columns: repeat(2,1fr); }
    .login-intro { padding: 6vw; }
}
@media (max-width: 760px) {
    html { font-size: 14px; }
    .topbar { height: auto; min-height: 62px; flex-wrap: wrap; padding: 10px 12px; }
    .topnav { order: 3; width: 100%; overflow-x: auto; }
    .topnav a { white-space: nowrap; padding: 8px 10px; }
    .user-menu { margin-left: auto; }
    .main-content { padding: 16px 10px; }
    .page-heading, .result-heading { align-items: flex-start; flex-direction: column; }
    .heading-actions { width: 100%; }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .search-row { flex-wrap: wrap; }
    .search-box { flex-basis: 100%; }
    .advanced-filters { grid-template-columns: 1fr 1fr; }
    .cols-2, .cols-3, .cols-4, .details-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .participant-header { display: none; }
    .participant-row { grid-template-columns: 1fr 120px 45px; }
    .participant-detail-list { grid-template-columns: 1fr; }
    .detail-sidebar { display: flex; }
    .sticky-actions { bottom: 5px; }
    .login-layout { grid-template-columns: 1fr; }
    .login-intro { display: none; }
    .login-card { margin: 18px; padding: 30px 24px; }
}
@media (max-width: 480px) {
    .metric-grid, .advanced-filters { grid-template-columns: 1fr; }
    .participant-row { grid-template-columns: 1fr; }
    .participant-remove { text-align: right; }
    .button { padding: 10px 12px; }
}
