:root {
  --ink: #162238;
  --muted: #657188;
  --line: #dfe5ee;
  --paper: #ffffff;
  --soft: #f4f7fb;
  --navy: #10233f;
  --navy-2: #173a66;
  --accent: #ef6c2f;
  --accent-dark: #d9551b;
  --success: #16775b;
  --warning: #a86412;
  --danger: #a83737;
  --shadow: 0 18px 45px rgba(16, 35, 63, 0.09);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--soft); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 95% 0%, rgba(239, 108, 47, 0.08), transparent 32rem),
    var(--soft);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: var(--navy-2); text-decoration: none; }
a:hover { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; }

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 34px;
  padding: 12px max(24px, calc((100vw - 1180px) / 2));
  color: #fff;
  background: rgba(16, 35, 63, 0.97);
  box-shadow: 0 8px 26px rgba(7, 20, 39, 0.16);
  backdrop-filter: blur(12px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; }
.brand:hover { color: #fff; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 0.98rem; }
.brand small { margin-top: 1px; color: #bbc8d8; font-size: 0.76rem; }

.topnav { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.topnav a { padding: 9px 12px; color: #d8e1ec; border-radius: 9px; font-size: 0.91rem; }
.topnav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.account-menu { display: flex; align-items: center; gap: 13px; color: #d8e1ec; font-size: 0.86rem; }
.account-menu form { margin: 0; }
.link-button { padding: 0; border: 0; color: #fff; background: none; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.notification-link { display: inline-flex !important; align-items: center; gap: 7px; }
.notification-badge { min-width: 20px; height: 20px; display: inline-grid; place-items: center; padding: 0 5px; border-radius: 999px; color: #fff; background: var(--accent); font-size: 0.68rem; font-weight: 850; }

.demo-banner { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 8px 18px; color: #6d3a08; background: #fff1dc; border-bottom: 1px solid #f3d4a7; font-size: 0.8rem; }
.demo-banner form { margin: 0; }
.demo-banner button { padding: 4px 9px; color: #6d3a08; border: 1px solid #e4ba7b; border-radius: 7px; background: #fff; cursor: pointer; font-weight: 750; }

.page-shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 46px 0 58px; }
.page-shell.login-page { width: 100%; padding: 0; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-header h1 { margin: 4px 0 6px; font-size: clamp(2rem, 4vw, 3.15rem); line-height: 1.04; letter-spacing: -0.045em; }
.page-header p { max-width: 670px; margin: 0; color: var(--muted); }
.eyebrow { display: block; color: var(--accent-dark); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.header-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.button {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
  transition: 160ms ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 9px 22px rgba(239, 108, 47, 0.24); }
.button-primary:hover { color: #fff; background: var(--accent-dark); }
.button-secondary { color: var(--navy); border-color: #cbd5e2; background: #fff; }
.button-secondary:hover { color: var(--navy); border-color: #aebdce; background: #fafdff; }
.button-ghost { color: var(--navy-2); background: #edf2f8; }
.button-full { width: 100%; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card, .panel, .form-card, .summary-card {
  border: 1px solid rgba(207, 216, 228, 0.88);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.stat-card { min-height: 158px; display: flex; flex-direction: column; padding: 24px; }
.stat-card > span { color: var(--muted); font-size: 0.83rem; font-weight: 700; }
.stat-card > strong { margin: 7px 0 auto; color: var(--navy); font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.1; letter-spacing: -0.04em; }
.stat-card small, .stat-card a { margin-top: 15px; color: var(--muted); font-size: 0.78rem; }
.stat-card a { color: var(--navy-2); font-weight: 750; }
.stat-card.featured { color: #fff; border-color: transparent; background: linear-gradient(140deg, var(--navy), #1a477a); }
.stat-card.featured > span, .stat-card.featured small, .stat-card.featured a { color: #c7d5e6; }
.stat-card.featured > strong { color: #fff; }

.two-column { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr); gap: 22px; }
.panel { overflow: hidden; }
.panel-header { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 3px 0 0; font-size: 1.2rem; }
.panel-header > a { font-size: 0.85rem; font-weight: 750; }

.compact-list, .activity-list, .document-list { display: flex; flex-direction: column; }
.compact-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 15px 22px; border-bottom: 1px solid #edf0f4; color: var(--ink); }
.compact-row:last-child, .document-row:last-child { border-bottom: 0; }
.compact-row:hover { color: var(--ink); background: #fafcff; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--navy); background: #e8eff7; font-size: 0.78rem; font-weight: 850; }
.compact-main { min-width: 0; }
.compact-main strong, .compact-main small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compact-main strong { font-size: 0.9rem; }
.compact-main small { margin-top: 2px; color: var(--muted); font-size: 0.75rem; }

.status { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 0.68rem; font-weight: 800; white-space: nowrap; }
.status.viewed { color: var(--success); background: #e4f4ee; }
.status.signed { color: var(--success); background: #dcf5eb; }
.status.pending { color: var(--warning); background: #fff0d9; }
.status.new { margin-left: 5px; color: #fff; background: var(--accent); vertical-align: middle; }
.status.muted { color: var(--muted); background: #edf0f4; }
.status.large { min-height: 34px; padding: 7px 12px; font-size: 0.76rem; }

.activity-row { display: grid; grid-template-columns: auto 1fr; gap: 13px; padding: 16px 22px; border-bottom: 1px solid #edf0f4; }
.activity-row > span { width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px #ffede4; }
.activity-row.signature-activity > span { background: var(--success); box-shadow: 0 0 0 5px #e4f4ee; }
.activity-row strong { font-size: 0.87rem; }
.activity-row p { margin: 2px 0; color: var(--muted); font-size: 0.8rem; }
.activity-row small { color: #8a94a6; font-size: 0.7rem; }

.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty-state > span { width: 50px; height: 50px; display: grid; place-items: center; margin: 0 auto 13px; border-radius: 50%; color: var(--success); background: #e4f4ee; font-weight: 850; }
.empty-state h3 { margin: 0 0 5px; color: var(--ink); }
.empty-state p { margin: 0; }

.employee-chip { min-width: 140px; padding: 14px 17px; border-left: 3px solid var(--accent); border-radius: 3px 12px 12px 3px; background: #fff; box-shadow: var(--shadow); }
.employee-chip span, .employee-chip strong { display: block; }
.employee-chip span { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.employee-chip strong { margin-top: 3px; }

.filter-form, .search-form { display: flex; align-items: center; gap: 9px; }
.filter-form label { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.filter-form select { min-width: 105px; }
.document-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 18px; padding: 19px 22px; border-bottom: 1px solid #edf0f4; }
.document-icon { width: 46px; height: 52px; display: grid; place-items: center; border-radius: 8px; color: var(--danger); background: #fce9e9; font-size: 0.67rem; font-weight: 900; }
.document-info h3 { margin: 0 0 3px; font-size: 0.96rem; }
.document-info p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.document-amount { min-width: 118px; text-align: right; }
.document-amount span, .document-amount strong { display: block; }
.document-amount span { color: var(--muted); font-size: 0.7rem; }
.document-amount strong { font-size: 0.94rem; }

.login-layout { min-height: calc(100svh - 78px); display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(480px, .92fr); overflow: clip; }
.demo-mode.login-view .login-layout { min-height: calc(100svh - 120px); }
.login-intro { min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: clamp(52px, 7vw, 112px); color: #fff; background: linear-gradient(145deg, rgba(16, 35, 63, 0.98), rgba(19, 61, 103, 0.95)), repeating-linear-gradient(-35deg, transparent 0 26px, rgba(255,255,255,.03) 26px 27px); }
.login-intro .eyebrow { color: #ff9a6b; }
.login-intro h1 { max-width: 730px; margin: 13px 0 20px; font-size: clamp(3rem, 5.7vw, 5.8rem); line-height: 0.94; letter-spacing: -0.06em; }
.login-intro > p { max-width: 530px; margin: 0; color: #c6d2e2; font-size: 1.08rem; }
.security-note { max-width: 430px; display: flex; align-items: center; gap: 13px; margin-top: 48px; padding: 16px; border: 1px solid rgba(255, 255, 255, 0.11); border-radius: 14px; background: rgba(255, 255, 255, 0.06); }
.security-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--accent); font-weight: 900; }
.security-note strong, .security-note span { display: block; }
.security-note div > span { color: #bfccdc; font-size: 0.78rem; }
.login-card { width: min(540px, calc(100% - 48px)); align-self: center; justify-self: center; margin: 38px 0; padding: clamp(30px, 3vw, 42px); border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.login-card h2 { margin: 7px 0 5px; font-size: 1.7rem; }
.login-card > p { margin: 0 0 26px; color: var(--muted); }
.help-copy { display: block; margin-top: 18px; color: var(--muted); text-align: center; }
.demo-login { margin-top: 24px; }
.demo-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 0.72rem; text-align: center; }
.demo-divider::before, .demo-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.demo-role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.demo-role-grid form { margin: 0; }
.demo-role-grid .button { min-height: 104px; flex-direction: column; gap: 1px; padding: 11px 7px; font-size: .8rem; }
.demo-role-grid .button small { color: var(--muted); font-size: 0.65rem; font-weight: 600; }
.demo-profile-avatar { width: 31px; height: 31px; display: grid; place-items: center; margin-bottom: 4px; border-radius: 10px; color: var(--navy); background: #e8eff7; font-size: .66rem; font-weight: 900; }
.demo-reset-form { margin: 15px 0 0; text-align: center; }
.demo-reset { color: var(--muted); font-size: 0.72rem; }

.installer-body { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.installer-card { width: min(520px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.installer-card h1 { margin: 7px 0 8px; font-size: 2rem; letter-spacing: -0.035em; }
.installer-card > p { margin: 0 0 24px; color: var(--muted); }
.installer-card .form-alert { margin-bottom: 18px; }

.stack-form { display: flex; flex-direction: column; gap: 17px; }
.form-card { padding: 25px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 22px; align-items: start; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; }
.two-fields > h2, .two-fields > p, .two-fields > .full { grid-column: 1 / -1; }
.form-card h2 { margin: 0; font-size: 1.25rem; }
.form-card > p { margin: -9px 0 4px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { color: #344057; font-size: 0.79rem; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid #cbd5e2;
  border-radius: 10px;
  outline: none;
  background: #fff;
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #6288b0; box-shadow: 0 0 0 4px rgba(66, 117, 167, 0.12); }
input[type="file"] { padding: 8px; background: #f8fafc; }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; padding: 0; accent-color: var(--accent); }
.form-actions { padding-top: 5px; }
.summary-card { padding: 24px; }
.summary-card h3 { margin: 0 0 12px; }
.summary-card p { color: var(--muted); font-size: 0.84rem; }
.check-list { margin: 16px 0 0; padding: 0; list-style: none; }
.check-list li { position: relative; margin: 10px 0; padding-left: 23px; color: #465269; font-size: 0.82rem; }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--success); font-weight: 900; }

.publish-layout { grid-template-columns: minmax(240px, .55fr) minmax(0, 1.45fr); gap: 34px; }
.publish-intro { position: sticky; top: 102px; }
.publish-intro h1 { margin: 10px 0 12px; font-size: clamp(2.1rem, 4vw, 3.6rem); line-height: .98; letter-spacing: -.05em; }
.publish-intro > p { max-width: 410px; color: var(--muted); }
.publish-form { gap: 19px; }
.source-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; padding: 0; border: 0; }
.source-selector legend { grid-column: 1 / -1; margin-bottom: 3px; color: #344057; font-size: .79rem; font-weight: 750; }
.source-option { min-height: 91px; display: flex; align-items: flex-start; gap: 11px; padding: 15px; border: 1px solid #cbd5e2; border-radius: 13px; background: #fff; cursor: pointer; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.source-option:has(input:checked) { border-color: #6288b0; background: #f4f8fc; box-shadow: 0 0 0 3px rgba(66, 117, 167, .1); }
.source-option.disabled { color: #8b95a5; background: #f5f6f8; cursor: not-allowed; }
.source-option input[type="radio"] { width: 18px; min-height: 18px; height: 18px; flex: 0 0 auto; margin: 2px 0 0; padding: 0; accent-color: var(--accent); }
.source-option strong, .source-option small { display: block; }
.source-option strong { color: var(--ink); font-size: .84rem; }
.source-option small { margin-top: 4px; color: var(--muted); font-size: .71rem; line-height: 1.4; }
.source-option.disabled strong { color: #727d8e; }
.source-note { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .72rem; }
.source-panel { display: flex; flex-direction: column; gap: 16px; padding: 19px; border: 1px solid var(--line); border-radius: 14px; background: #f9fbfd; }
.source-panel[hidden] { display: none !important; }
.source-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.source-panel-heading span { color: var(--ink); font-size: .86rem; font-weight: 800; }
.source-panel-heading small { color: var(--muted); font-size: .7rem; }
.amount-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.calculated-net { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2px 16px; padding: 15px 17px; color: #fff; border-radius: 12px; background: var(--navy); }
.calculated-net span { color: #c8d5e3; font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.calculated-net strong { grid-row: 1 / 3; grid-column: 2; font-size: 1.3rem; }
.calculated-net small { color: #aebdcd; font-size: .68rem; }

.form-alert, .form-success, .message { padding: 12px 14px; border-radius: 10px; font-size: 0.84rem; }
.form-alert { color: #8d2e2e; border: 1px solid #efc7c7; background: #fff0f0; }
.form-success { color: #116347; border: 1px solid #b8dfd2; background: #eaf8f3; }
.message { width: min(1160px, calc(100% - 36px)); margin: 18px auto -14px; }
.message.success { color: #116347; border: 1px solid #b8dfd2; background: #eaf8f3; }
.message.error { color: #8d2e2e; border: 1px solid #efc7c7; background: #fff0f0; }
.login-view .message { position: relative; z-index: 2; margin: 18px auto; }

.search-form { margin-left: auto; }
.search-form input { width: min(290px, 46vw); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid #edf0f4; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f9fbfd; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
td { font-size: 0.82rem; }
tbody tr:hover { background: #fafcff; }

.breadcrumb { margin-bottom: 19px; font-size: 0.8rem; }
.breadcrumb span { margin-left: 8px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .6fr); gap: 22px; }
.pdf-panel { min-height: 660px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #e4e8ed; box-shadow: var(--shadow); }
.pdf-panel header { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 16px; color: #415069; background: #fff; border-bottom: 1px solid var(--line); font-size: 0.78rem; font-weight: 700; }
.pdf-panel iframe { width: 100%; height: 700px; display: block; border: 0; }
.summary-card dl, .evidence-list { margin: 18px 0; }
.summary-card dl > div, .evidence-list > div { padding: 11px 0; border-bottom: 1px solid #edf0f4; }
.summary-card dt, .evidence-list dt { color: var(--muted); font-size: 0.7rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.05em; }
.summary-card dd, .evidence-list dd { margin: 3px 0 0; color: var(--ink); font-size: 0.86rem; overflow-wrap: anywhere; }
code { padding: 3px 6px; border-radius: 6px; color: #465269; background: #eef2f7; font-size: 0.75em; }

.notification-preview { margin-bottom: 22px; }
.notification-list { display: flex; flex-direction: column; }
.notification-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 15px 22px; color: var(--ink); border-bottom: 1px solid #edf0f4; }
.notification-row:last-child { border-bottom: 0; }
.notification-row:hover { color: var(--ink); background: #fafcff; }
.notification-row.unread { background: #fff9f4; }
.notification-row.unread:hover { background: #fff5ed; }
.notification-row > span:nth-child(2) { min-width: 0; }
.notification-row strong, .notification-row small { display: block; }
.notification-row strong { font-size: 0.88rem; }
.notification-row small { margin-top: 3px; color: var(--muted); font-size: 0.76rem; }
.notification-row time { color: #8a94a6; font-size: 0.7rem; white-space: nowrap; }
.notification-dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e2; }
.notification-row.unread .notification-dot { background: var(--accent); box-shadow: 0 0 0 5px #ffede4; }
.notification-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 11px; color: var(--navy); background: #e8eff7; font-size: 0.68rem; font-weight: 900; }
.notification-row.unread .notification-icon { color: #fff; background: var(--accent); }

.chat-page-header { align-items: center; margin-bottom: 22px; }
.chat-page-meta { display: flex; align-items: center; gap: 8px; }
.chat-page-meta span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; color: #526079; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.78); font-size: .7rem; font-weight: 750; }
.chat-page-meta i, .chat-private-label i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(22,119,91,.11); }
.chat-shell { height: min(720px, calc(100svh - 250px)); min-height: 590px; display: grid; grid-template-columns: minmax(300px, 350px) minmax(0, 1fr); border-radius: 24px; box-shadow: 0 22px 60px rgba(16, 35, 63, .12); }
.chat-sidebar { min-width: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); border-right: 1px solid var(--line); background: #fbfcfe; }
.chat-sidebar > header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 17px 19px 13px; }
.chat-sidebar > header > span, .chat-sidebar > header strong, .chat-sidebar > header small { display: block; }
.chat-sidebar > header strong { font-size: .95rem; }
.chat-sidebar > header small { margin-top: 1px; color: var(--muted); font-size: .69rem; }
.chat-sidebar > header b { min-width: 29px; height: 29px; display: grid; place-items: center; padding: 0 7px; color: var(--navy); border-radius: 9px; background: #e8eff7; font-size: .7rem; }
.chat-search { position: relative; display: block; margin: 0 14px 12px; }
.chat-search > span { position: absolute; z-index: 1; left: 12px; top: 50%; color: #7d899b; font-size: 1.05rem; transform: translateY(-53%); }
.chat-search input { min-height: 40px; padding: 8px 12px 8px 34px; border-color: #e1e7ef; border-radius: 12px; background: #f2f5f9; font-size: .74rem; }
.chat-contact-list { min-height: 0; display: flex; flex-direction: column; overflow-y: auto; border-top: 1px solid #edf0f4; }
.chat-contact { position: relative; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; margin: 5px 8px 0; padding: 12px 11px; color: var(--ink); border-radius: 13px; }
.chat-contact:hover { color: var(--ink); background: #f0f4f9; }
.chat-contact.selected { background: #eaf1f9; box-shadow: inset 3px 0 0 var(--accent); }
.chat-avatar { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid #d4deea; border-radius: 14px; color: var(--navy); background: linear-gradient(145deg, #edf3f9, #dfe9f4); font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.chat-avatar.large { width: 46px; height: 46px; border-radius: 15px; }
.chat-contact-copy { min-width: 0; }
.chat-contact-copy > span { display: flex; align-items: baseline; justify-content: space-between; gap: 7px; }
.chat-contact-copy strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
.chat-contact-copy small { flex: 0 0 auto; color: #8792a3; font-size: .58rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.chat-contact-copy em { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: .68rem; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.chat-unread { min-width: 21px; height: 21px; display: grid; place-items: center; padding: 0 5px; border-radius: 999px; color: #fff; background: var(--accent); box-shadow: 0 5px 12px rgba(239,108,47,.22); font-size: .62rem; font-weight: 850; }
.chat-empty-contact, .chat-search-empty { padding: 30px 18px; color: var(--muted); font-size: .76rem; text-align: center; }
.chat-conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-conversation-header { min-height: 76px; display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.chat-conversation-person { min-width: 0; margin-right: auto; }
.chat-conversation-header strong, .chat-conversation-header small { display: block; }
.chat-conversation-header strong { overflow: hidden; font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-conversation-header small { margin-top: 2px; color: var(--muted); font-size: .69rem; }
.chat-private-label { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; color: #526079; border: 1px solid #e1e7ef; border-radius: 999px; font-size: .65rem; font-weight: 750; }
.chat-messages { min-height: 0; display: flex; flex-direction: column; gap: 11px; padding: 24px; overflow-y: auto; background-color: #f3f6fa; background-image: radial-gradient(rgba(16,35,63,.045) .75px, transparent .75px); background-size: 17px 17px; }
.chat-message { width: fit-content; max-width: min(72%, 620px); padding: 11px 14px 8px; border: 1px solid #dfe5ee; border-radius: 16px 16px 16px 5px; background: #fff; box-shadow: 0 6px 18px rgba(16, 35, 63, .055); }
.chat-message.mine { align-self: flex-end; color: #fff; border-color: transparent; border-radius: 16px 16px 5px 16px; background: linear-gradient(145deg, #173a66, var(--navy)); box-shadow: 0 8px 20px rgba(16,35,63,.16); }
.chat-message-sender { display: block; margin-bottom: 3px; color: var(--accent-dark); font-size: .63rem; font-weight: 850; }
.chat-message.mine .chat-message-sender { color: #ffb18d; }
.chat-message p { margin: 0; font-size: .82rem; line-height: 1.48; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message time { display: block; margin-top: 5px; color: #8994a5; font-size: .59rem; text-align: right; }
.chat-message.mine time { color: #b8c7d8; }
.chat-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 13px 17px; border-top: 1px solid var(--line); background: #fff; }
.chat-compose-field { min-width: 0; }
.chat-composer textarea { min-height: 46px; max-height: 132px; padding: 11px 13px; border-radius: 13px; resize: none; }
.chat-compose-field small { display: block; margin: 5px 2px 0; color: #909bad; font-size: .58rem; }
.chat-send-button { min-height: 46px; gap: 12px; padding-inline: 18px; }
.chat-send-button b { font-size: 1rem; }
.chat-conversation-empty { margin: auto; padding: 26px; color: var(--muted); text-align: center; }
.chat-conversation-empty > span, .chat-no-conversation > span { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 50%; color: var(--navy); background: #e2eaf4; font-size: .7rem; font-weight: 850; }
.chat-conversation-empty h3, .chat-no-conversation h2 { margin: 0 0 4px; color: var(--ink); }
.chat-conversation-empty p, .chat-no-conversation p { margin: 0; font-size: .78rem; }
.chat-no-conversation { display: grid; place-content: center; padding: 40px; color: var(--muted); text-align: center; }

.signature-request, .signature-evidence, .signature-waiting { margin-top: 22px; }
.signature-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .55fr); gap: 20px 24px; padding: 24px; }
.signature-copy, .signature-field, .acceptance-check, .signature-form .form-actions, .signature-disclaimer, .signature-form .form-alert { grid-column: 1 / -1; }
.signature-copy h3 { margin: 0 0 5px; }
.signature-copy p { margin: 0; color: var(--muted); }
.signature-label { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.clear-signature { color: var(--navy-2); }
#signature-pad { width: 100%; height: auto; display: block; border: 1px dashed #9eacbf; border-radius: 12px; background: #fff; cursor: crosshair; touch-action: none; }
#signature-pad:focus { outline: none; border-color: #6288b0; box-shadow: 0 0 0 4px rgba(66, 117, 167, 0.12); }
#signature-pad.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(168, 55, 55, 0.1); }
.signature-field small { color: var(--muted); font-size: 0.72rem; }
.acceptance-check { display: flex; align-items: flex-start; gap: 11px; padding: 15px; border: 1px solid #f0d0b9; border-radius: 12px; background: #fff9f4; color: #3f4c62; font-size: 0.84rem; }
.acceptance-check input { flex: 0 0 auto; margin-top: 2px; }
.signature-disclaimer { margin: 0; color: var(--muted); font-size: 0.72rem; }
.signature-evidence-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr); gap: 24px; padding: 24px; }
.signature-preview { min-height: 220px; display: grid; place-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.signature-preview img { max-width: 100%; max-height: 220px; }
.evidence-list { margin: 0; }
.error-page { min-height: 55vh; display: grid; place-content: center; justify-items: center; padding: 40px; text-align: center; }
.error-page h1 { margin: 5px 0 8px; font-size: 2.5rem; }
.error-page p { margin: 0 0 22px; color: var(--muted); }

.footer { width: min(1180px, calc(100% - 36px)); display: flex; justify-content: space-between; margin: 0 auto; padding: 20px 0 30px; color: #7b879a; border-top: 1px solid var(--line); font-size: 0.72rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px 20px; }
  .topnav { order: 3; width: 100%; overflow-x: auto; }
  .account-menu { margin-left: auto; }
  .login-layout { min-height: 0; grid-template-columns: 1fr; }
  .login-intro { min-height: 440px; padding: 60px 34px; }
  .login-card { margin: 46px auto; }
  .two-column, .form-layout, .detail-grid { grid-template-columns: 1fr; }
  .publish-intro { position: static; }
  .signature-evidence-grid { grid-template-columns: 1fr; }
  .chat-shell { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); }
  .pdf-panel, .pdf-panel iframe { min-height: 560px; height: 560px; }
}

@media (max-width: 680px) {
  .page-shell { width: min(100% - 24px, 1180px); padding-top: 30px; }
  .topbar { position: static; padding: 12px; }
  .brand { margin-right: auto; }
  .account-menu > span { display: none; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-header h1 { font-size: 2.15rem; }
  .demo-banner { align-items: flex-start; flex-direction: column; gap: 6px; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 136px; }
  .document-row { grid-template-columns: auto minmax(0, 1fr); }
  .document-row .document-amount { text-align: left; }
  .document-row .button { grid-column: 1 / -1; }
  .notification-row { grid-template-columns: auto minmax(0, 1fr); padding: 15px; }
  .notification-row time { grid-column: 2; }
  .signature-form { grid-template-columns: 1fr; padding: 18px; }
  .signature-form > * { grid-column: 1; }
  .two-fields { grid-template-columns: 1fr; }
  .two-fields > * { grid-column: 1 / -1; }
  .source-selector, .amount-grid { grid-template-columns: 1fr; }
  .source-selector legend, .source-note { grid-column: 1; }
  .source-panel-heading { align-items: flex-start; flex-direction: column; }
  .chat-page-meta { width: 100%; flex-wrap: wrap; }
  .chat-shell { height: auto; min-height: 0; grid-template-columns: 1fr; }
  .chat-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-contact-list { max-height: 245px; }
  .chat-conversation { min-height: 560px; }
  .chat-messages { height: 440px; min-height: 440px; padding: 15px; }
  .chat-message { max-width: 88%; }
  .chat-composer { grid-template-columns: 1fr; }
  .chat-composer .button { width: 100%; }
  .chat-compose-field small { display: none; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .search-form { width: 100%; margin-left: 0; }
  .search-form input { width: 100%; }
  .login-intro { min-height: 390px; padding: 48px 24px; }
  .login-intro h1 { font-size: 3rem; }
  .login-card { width: calc(100% - 24px); padding: 27px 22px; }
  .demo-role-grid { grid-template-columns: 1fr 1fr; }
  .demo-role-grid form:last-child { grid-column: 1 / -1; }
  .footer { width: calc(100% - 24px); }
}
