:root {
    --ink: #17252f;
    --muted: #6d7a80;
    --line: #dfe5e4;
    --surface: #ffffff;
    --canvas: #f4f6f3;
    --teal: #0f766e;
    --teal-dark: #0b5f59;
    --teal-soft: #e7f3f0;
    --amber: #b36a16;
    --amber-soft: #fbf0df;
    --green: #32734c;
    --green-soft: #e8f3eb;
    --red: #b44646;
    --cherry: #c9384f;
    --cherry-dark: #a8223a;
    --cherry-soft: #fff0f2;
    --shadow: 0 18px 50px rgba(29, 48, 55, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(15, 118, 110, .22);
    outline-offset: 2px;
}

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 244px;
    display: flex;
    flex-direction: column;
    padding: 26px 20px 20px;
    color: #dfe9e7;
    background: #18323a;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 28px; }
.brand-mark {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
    flex: 0 0 auto; overflow: hidden; background: var(--cherry-soft);
    box-shadow: inset 0 0 0 1px rgba(201,56,79,.08), 0 7px 18px rgba(10,28,34,.12);
}
.brand-mark img { display: block; width: 28px; height: 28px; }
.brand strong, .brand span { display: block; }
.brand strong { color: white; font-size: 17px; letter-spacing: .2px; }
.brand span { color: #9cb0b3; font-size: 11px; margin-top: 1px; }
.nav-list { display: grid; gap: 5px; }
.nav-item {
    width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 11px;
    padding: 11px 12px; text-align: left; background: transparent; color: #b9c9c9; cursor: pointer;
}
.nav-item:hover:not(:disabled) { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: rgba(255,255,255,.1); color: white; font-weight: 650; }
.nav-item:disabled { opacity: .48; cursor: default; }
.nav-item em { margin-left: auto; font-size: 9px; font-style: normal; color: #f2c14e; }
.nav-dot { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; }
.active .nav-dot { border: 0; background: #f2c14e; box-shadow: 0 0 0 4px rgba(242,193,78,.12); }
.sidebar-note { margin-top: auto; padding: 15px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: rgba(255,255,255,.035); }
.sidebar-note strong, .sidebar-note p { display: block; }
.sidebar-note strong { margin-top: 5px; color: white; font-size: 12px; }
.sidebar-note p { margin: 4px 0 0; color: #9cb0b3; font-size: 11px; }
.sidebar-note small { display: block; margin-top: 8px; color: #6f898d; font-size: 9px; }
.operator { display: grid; grid-template-columns: 34px 1fr auto; gap: 9px; align-items: center; margin-top: 17px; padding: 12px 5px 0; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #31525a; color: white; font-weight: 700; }
.operator strong, .operator span { display: block; }
.operator strong { color: #eef5f4; font-size: 12px; }
.operator span { color: #8fa4a7; font-size: 10px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #6cc08b; }
.logout-button { border: 0; padding: 2px; color: #91a7aa; background: transparent; font-size: 9px; cursor: pointer; }
.logout-button:hover { color: white; }
.operator-actions { display: flex; align-items: center; gap: 3px; }
.operator-actions form { margin: 0; }

.main-content { margin-left: 244px; padding: 34px 38px 60px; max-width: 1580px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 26px; }
.topbar h1 { margin: 4px 0 2px; font-family: Georgia, "STSong", serif; font-size: 29px; letter-spacing: -.5px; }
.topbar p, .panel-header p { margin: 0; color: var(--muted); }
.eyebrow { display: block; color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: 1.4px; }
.topbar-actions { display: flex; gap: 9px; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 10px; padding: 9px 15px; color: inherit; font-weight: 700; text-decoration: none; cursor: pointer; transition: .16s ease; }
.button.primary { background: var(--teal); color: white; box-shadow: 0 7px 18px rgba(15,118,110,.16); }
.button.primary:hover { background: var(--teal-dark); transform: translateY(-1px); }
.button.secondary { background: white; border-color: var(--line); }
.button.secondary:hover { border-color: #bac8c5; background: #fbfcfb; }
.button.danger { color: var(--red); background: #fff5f5; border-color: #f0d0d0; }
.button.small { padding: 6px 10px; font-size: 12px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 16px; }
.metric-card { position: relative; overflow: hidden; padding: 17px 18px 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.metric-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #aebcba; }
.metric-card.accent::before { background: var(--teal); }
.metric-card.warning::before { background: var(--amber); }
.metric-card.success::before { background: var(--green); }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { font-size: 12px; font-weight: 650; }
.metric-card strong { display: block; margin: 5px 0 0; font-family: Georgia, serif; font-size: 28px; line-height: 1; }
.metric-card small { margin-top: 8px; font-size: 10px; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 0 rgba(18,45,54,.02); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(290px, .8fr); gap: 16px; align-items: stretch; }
.chat-panel { min-height: 590px; display: flex; flex-direction: column; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.panel-header.compact { padding: 20px; }
.panel-header h2 { margin: 2px 0 0; font-size: 16px; }
.assistant-identity { display: flex; align-items: center; gap: 11px; }
.assistant-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--teal-soft); color: var(--teal); font-size: 11px; font-weight: 900; letter-spacing: .5px; }
.assistant-identity h2 { margin: 0; }
.assistant-identity p { font-size: 11px; }
.assistant-status { display: grid; justify-items: end; gap: 5px; }
.assistant-status-line { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.assistant-status small { max-width: 310px; color: #8a9899; font-size: 8px; line-height: 1.35; text-align: right; }
.new-chat-button { border: 1px solid #cddbd8; border-radius: 99px; padding: 5px 9px; color: #53676b; background: white; font-size: 9px; font-weight: 750; cursor: pointer; }
.new-chat-button:hover { border-color: #91b8b2; color: var(--teal); }
.new-chat-button:disabled { opacity: .5; cursor: default; }
.safe-badge, .count-badge { border-radius: 99px; padding: 5px 9px; font-size: 10px; font-weight: 750; }
.safe-badge { color: var(--green); background: var(--green-soft); }
.count-badge { min-width: 27px; text-align: center; color: var(--teal); background: var(--teal-soft); }
.chat-feed { flex: 1; min-height: 300px; max-height: 390px; overflow-y: auto; padding: 22px; background: #fbfcfa; }
.message { max-width: 80%; margin-bottom: 17px; }
.user-message { margin-left: auto; }
.message-label { margin: 0 0 5px 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
.user-message .message-label { text-align: right; margin-right: 4px; }
.message-bubble { padding: 12px 14px; border: 1px solid #dce6e3; border-radius: 5px 15px 15px 15px; background: white; box-shadow: 0 4px 16px rgba(20,51,57,.04); }
.user-message .message-bubble { color: white; background: var(--teal); border-color: var(--teal); border-radius: 15px 5px 15px 15px; }
.message-bubble p { margin: 0; }
.message-bubble p + p { margin-top: 7px; }
.message-note { color: var(--muted); font-size: 11px; }
.user-message .message-note { color: rgba(255,255,255,.8); }
.typing .message-bubble { color: var(--muted); }
.processing-progress { display: grid; gap: 7px; min-width: min(430px, 62vw); margin-top: 12px; padding: 11px 12px; border: 1px solid #c9dfda; border-radius: 10px; background: #f4faf8; }
.processing-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--teal-dark); font-size: 9px; }
.processing-progress-head strong { font-size: 10px; }
.processing-progress-track { height: 7px; overflow: hidden; border-radius: 99px; background: #dce9e5; }
.processing-progress-track > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #167f72, #55aa94); transition: width .35s ease; box-shadow: 0 0 10px rgba(22,127,114,.22); }
.processing-progress small { color: var(--muted); font-size: 8px; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 20px 0; border-top: 1px solid var(--line); }
.quick-prompts button { border: 1px solid var(--line); border-radius: 99px; padding: 6px 10px; background: #fafbf9; color: #4e6267; font-size: 11px; cursor: pointer; }
.quick-prompts button:hover { border-color: #9db9b4; color: var(--teal); }
.composer { margin: 12px 20px 18px; border: 1px solid #cbd8d5; border-radius: 13px; background: white; transition: .16s; }
.composer:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,.08); }
.composer.dragging { border-color: var(--teal); background: #f4fbf9; box-shadow: 0 0 0 4px rgba(15,118,110,.1); }
.composer textarea { display: block; width: 100%; min-height: 58px; max-height: 140px; resize: vertical; border: 0; outline: 0; padding: 12px 13px 5px; color: var(--ink); background: transparent; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; padding: 5px 7px 7px 12px; color: #8a9699; font-size: 9px; }
.composer-tools { display: flex; align-items: center; gap: 9px; min-width: 0; }
.attach-button { border: 0; border-radius: 7px; padding: 5px 7px; color: var(--teal); background: var(--teal-soft); font-size: 10px; font-weight: 750; cursor: pointer; }
.attach-button:hover { background: #d8eee9; }
.attachment-preview { margin: 9px 10px 0; padding: 8px 9px; border: 1px solid #d9e5e2; border-radius: 10px; background: #f7faf8; }
.attachment-preview[hidden] { display: none; }
.attachment-summary { display: grid; grid-template-columns: 36px minmax(0, 1fr) 26px; align-items: center; gap: 9px; }
.attachment-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--teal); background: var(--teal-soft); font-size: 7px; font-weight: 900; }
.attachment-meta { min-width: 0; }
.attachment-meta strong, .attachment-meta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-meta strong { color: var(--ink); font-size: 10px; }
.attachment-meta small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.attachment-preview button { border: 0; background: transparent; color: var(--muted); font-size: 17px; cursor: pointer; }
.attachment-list { display: grid; gap: 4px; max-height: 94px; margin-top: 7px; overflow-y: auto; }
.attachment-list:empty { display: none; }
.attachment-list-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 5px 7px; border-radius: 7px; background: white; color: var(--muted); font-size: 9px; }
.attachment-list-item strong { overflow: hidden; color: var(--ink); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.attach-button.secondary { color: #52696d; background: #edf2f1; }
.send-button { border: 0; border-radius: 8px; padding: 7px 14px; background: var(--teal); color: white; font-weight: 750; cursor: pointer; }
.send-button:disabled { opacity: .55; cursor: wait; }

.action-panel { position: sticky; top: 18px; display: flex; flex-direction: column; height: min(720px, calc(100vh - 36px)); min-height: 520px; overflow: hidden; }
.candidate-panel { flex: 1; min-height: 0; padding: 14px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.candidate-card { width: 100%; display: block; margin-bottom: 9px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; text-align: left; background: white; cursor: pointer; }
.candidate-card:hover { border-color: #93bbb5; box-shadow: 0 6px 18px rgba(15,118,110,.07); }
.candidate-top { display: flex; justify-content: space-between; gap: 10px; }
.candidate-top strong { font-size: 13px; }
.candidate-card p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.match-reason { display: inline-block; margin-top: 9px; color: var(--teal); font-size: 10px; font-weight: 700; }
.material-result { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding: 11px 12px; border: 1px solid #d7e5e2; border-radius: 11px; background: #f7fbfa; }
.material-result strong, .material-result span { display: block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-result strong { font-size: 10px; }
.material-result span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.material-result a { flex: 0 0 auto; color: var(--teal); font-size: 9px; font-weight: 750; text-decoration: none; }
.batch-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.batch-stat { padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: #f8fbfa; text-align: center; }
.batch-stat strong, .batch-stat span { display: block; }
.batch-stat strong { color: var(--ink); font-size: 15px; }
.batch-stat span { margin-top: 2px; color: var(--muted); font-size: 8px; }
.batch-stat.confirmed strong { color: var(--green); }
.batch-item { margin-bottom: 9px; border: 1px solid #c9ddd8; border-radius: 11px; background: #f5faf8; box-shadow: inset 4px 0 0 #aacbc3, 0 3px 10px rgba(22,65,60,.04); overflow: hidden; }
.batch-item.file-error { border-color: #efcfd3; background: #fffafb; }
.batch-item.confirmed { border-color: #9fcec0; background: #edf7f2; box-shadow: inset 4px 0 0 #4f9b87, 0 5px 14px rgba(22,93,76,.08); }
.batch-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 10px 11px; background: rgba(255,255,255,.46); }
.batch-item-title { min-width: 0; }
.batch-item-title strong, .batch-item-title span { display: block; }
.batch-item-title strong { overflow: hidden; color: var(--ink); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.batch-item-title span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.batch-status { flex: 0 0 auto; padding: 4px 6px; border-radius: 99px; color: var(--green); background: var(--green-soft); font-size: 8px; font-weight: 800; }
.file-error .batch-status { color: var(--red); background: var(--red-soft); }
.confirmed .batch-status { color: var(--green); background: var(--green-soft); }
.batch-issue { margin: 0 10px 10px; padding: 8px; border-radius: 8px; color: #9b3342; background: var(--red-soft); font-size: 9px; line-height: 1.5; }
.batch-fields { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 9px; }
.batch-field { padding: 4px 6px; border-radius: 6px; color: #456064; background: #eef4f2; font-size: 8px; }
.batch-candidates { display: grid; gap: 5px; padding: 0 10px 10px; }
.batch-candidate { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px; border: 1px solid #d7e5e2; border-radius: 8px; color: var(--ink); background: #f7fbfa; font-size: 9px; cursor: pointer; }
.batch-candidate span { color: var(--teal); font-weight: 750; }
.batch-confirm-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) auto; gap: 7px; align-items: end; margin: 0 10px 10px; padding: 9px; border: 1px solid #cfe1dd; border-radius: 9px; background: #f7fbfa; }
.batch-confirm-form label { display: grid; min-width: 0; gap: 4px; }
.batch-confirm-form label > span { color: var(--muted); font-size: 8px; font-weight: 750; }
.batch-confirm-form input, .batch-confirm-form select { width: 100%; min-width: 0; height: 31px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; color: var(--ink); background: white; font-size: 9px; outline: 0; }
.batch-confirm-form input:focus, .batch-confirm-form select:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(15,118,110,.08); }
.batch-confirm-form p { align-self: center; margin: 0; color: var(--muted); font-size: 8px; line-height: 1.45; }
.batch-confirm-form button { height: 31px; border: 0; border-radius: 7px; padding: 0 10px; color: white; background: var(--teal); font-size: 8px; font-weight: 800; cursor: pointer; white-space: nowrap; }
.batch-confirm-form button:disabled { opacity: .6; cursor: wait; }
.batch-confirmed { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 9px; align-items: center; margin: 0 10px 10px; padding: 10px; border: 1px solid #badccb; border-radius: 9px; color: #155f4d; background: #dceee5; }
.person-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: white; background: #367f6b; font-size: 14px; font-weight: 800; }
.confirmed-person-info { min-width: 0; }
.confirmed-person-info small, .confirmed-person-info strong, .confirmed-person-info code, .confirmed-person-info span { display: block; }
.confirmed-person-info small { color: #5c8679; font-size: 7px; font-weight: 800; letter-spacing: .7px; }
.confirmed-person-info strong { margin-top: 1px; color: #124e41; font-size: 11px; }
.confirmed-person-info code { margin-top: 1px; color: #367363; font-size: 7px; }
.confirmed-person-info span { margin-top: 4px; color: #4d746a; font-size: 8px; }
.agent-rules { margin: 0 14px 14px; padding: 13px; border-radius: 12px; background: #f5f7f4; }
.agent-rules strong { font-size: 11px; }
.query-safety-note { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.agent-rules ul { margin: 7px 0 0; padding-left: 17px; color: var(--muted); font-size: 10px; }
.agent-rules li + li { margin-top: 4px; }
.empty-state { text-align: center; color: var(--muted); }
.compact-empty { padding: 56px 22px; }
.empty-symbol { width: 38px; height: 38px; display: grid; place-items: center; margin: 0 auto 10px; border-radius: 50%; background: #eff3f1; color: #91a09d; }
.empty-state strong { display: block; color: var(--ink); font-size: 12px; }
.empty-state p { margin: 5px auto 0; max-width: 200px; font-size: 10px; }

.profiles-panel { margin-top: 16px; overflow: hidden; }
.profiles-header { align-items: flex-end; }
.profiles-header p { margin-top: 3px; font-size: 11px; }
.profile-filters { display: flex; gap: 8px; }
.profile-filters input, .profile-filters select { height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 11px; background: white; color: var(--ink); }
.profile-filters input { width: 220px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; color: #879397; background: #fafbf9; font-size: 9px; letter-spacing: .6px; text-transform: uppercase; }
td { padding: 13px 16px; border-top: 1px solid #edf0ef; vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fbfdfc; }
.client-cell strong, .client-cell span { display: block; }
.client-cell strong { font-size: 12px; }
.client-cell span, .contact-cell { color: var(--muted); font-size: 10px; }
.contact-cell span { display: block; }
.progress { width: 110px; height: 5px; border-radius: 99px; background: #e8ecea; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.progress-label { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.status-pill { display: inline-block; border-radius: 99px; padding: 4px 8px; color: #576669; background: #edf1f0; font-size: 9px; font-weight: 750; }
.status-COLLECTING { color: var(--amber); background: var(--amber-soft); }
.status-PENDING_CONFIRMATION { color: #8757a5; background: #f2ebf7; }
.status-COMPLETE { color: var(--green); background: var(--green-soft); }
.row-action { color: var(--teal); font-size: 11px; font-weight: 700; }
.loading-row { padding: 26px; text-align: center; color: var(--muted); }
.table-footer { display: flex; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.table-footer button { border: 0; background: transparent; color: var(--teal); font-weight: 700; cursor: pointer; }

dialog { border: 0; padding: 0; }
dialog::backdrop { background: rgba(14,30,35,.48); backdrop-filter: blur(3px); }
.profile-dialog { width: min(720px, calc(100vw - 28px)); max-height: calc(100vh - 36px); border-radius: 18px; box-shadow: var(--shadow); }
.password-dialog { width: min(480px, calc(100vw - 28px)); border-radius: 18px; box-shadow: var(--shadow); }
.change-review-dialog { width: min(900px, calc(100vw - 28px)); max-height: calc(100vh - 34px); border-radius: 18px; box-shadow: var(--shadow); }
.change-review-dialog form { max-height: calc(100vh - 34px); overflow-y: auto; background: white; }
.review-summary { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 8px; padding: 13px 24px; border-bottom: 1px solid var(--line); background: #fafbf9; }
.review-summary span, .review-summary small { color: var(--muted); font-size: 10px; }
.review-summary strong { font-size: 13px; }
.change-review-list { display: grid; gap: 10px; padding: 16px 24px 8px; }
.change-row { display: grid; grid-template-columns: 26px minmax(110px, .55fr) minmax(0, 1fr) 34px minmax(0, 1fr); gap: 10px; align-items: stretch; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.change-row.selected { border-color: #9fcac3; background: #fbfefd; }
.change-row.unchanged { opacity: .72; }
.change-check { display: flex; align-items: center; justify-content: center; }
.change-check input { width: 16px; height: 16px; accent-color: var(--teal); }
.change-field { align-self: center; }
.change-field strong, .change-field span { display: block; }
.change-field strong { font-size: 11px; }
.change-field span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.change-value { min-width: 0; padding: 9px 10px; border-radius: 9px; background: #f5f7f6; }
.change-value.proposed { color: #0c655e; background: #eaf7f3; }
.change-value small, .change-value strong { display: block; }
.change-value small { margin-bottom: 4px; color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: .5px; }
.change-value strong { overflow-wrap: anywhere; font-size: 10px; font-weight: 600; }
.change-arrow { display: grid; place-items: center; color: #92a09e; }
.change-evidence { grid-column: 3 / 6; margin: -1px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.confidence { display: inline-block; margin-right: 6px; padding: 2px 5px; border-radius: 99px; color: var(--teal); background: var(--teal-soft); font-weight: 750; }
.review-footer { align-items: center; justify-content: space-between; }
.review-footer > span { color: var(--muted); font-size: 10px; }
.review-footer > div { display: flex; gap: 8px; }
.profile-dialog form { max-height: calc(100vh - 36px); overflow-y: auto; background: white; }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 20px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); background: white; }
.dialog-header h2 { margin: 3px 0; font-size: 19px; }
.dialog-header p { margin: 0; color: var(--muted); font-size: 11px; }
.icon-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 9px; background: white; font-size: 20px; cursor: pointer; }
.form-section { padding: 18px 24px 0; }
.form-section h3 { margin: 0 0 11px; font-size: 11px; letter-spacing: .3px; }
.form-section h3 small { margin-left: 6px; color: var(--muted); font-size: 9px; font-weight: 400; }
.conditional-fields { margin-top: 14px; padding: 13px; border: 1px solid #d9e7e3; border-radius: 12px; background: #f7fbfa; }
.conditional-fields > p { margin: 0 0 11px; color: var(--teal-dark); font-size: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 5px; }
.field.span-2 { grid-column: span 2; }
.field > span { color: #516166; font-size: 10px; font-weight: 700; }
.field em { color: var(--red); font-style: normal; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; outline: 0; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); }
.field textarea { resize: vertical; }
.dialog-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding: 14px 24px; border-top: 1px solid var(--line); background: white; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(18,36,42,.3); }
.profile-drawer { position: fixed; z-index: 30; top: 0; right: 0; width: min(520px, 100vw); height: 100vh; overflow-y: auto; background: white; box-shadow: -20px 0 50px rgba(18,36,42,.16); transform: translateX(102%); transition: transform .22s ease; }
.profile-drawer.open { transform: translateX(0); }
.drawer-header { position: sticky; top: 0; z-index: 2; padding: 22px; border-bottom: 1px solid var(--line); background: white; }
.drawer-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-header h2 { margin: 3px 0 0; font-size: 22px; font-family: Georgia, "STSong", serif; }
.client-code { display: block; margin-top: 4px; color: var(--teal-dark); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; font-weight: 800; letter-spacing: .5px; }
.drawer-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.drawer-actions { display: flex; gap: 7px; margin-top: 14px; }
.drawer-body { padding: 19px 22px 34px; }
.completeness-card { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; padding: 14px; border-radius: 13px; background: #f4f7f5; }
.completion-ring { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--teal) var(--completion), #dfe7e4 0); position: relative; }
.completion-ring::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #f4f7f5; }
.completion-ring strong { position: relative; z-index: 1; font-size: 12px; }
.completeness-card h3 { margin: 0; font-size: 12px; }
.completeness-card p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.detail-section { padding: 19px 0; border-bottom: 1px solid var(--line); }
.detail-section:last-child { border-bottom: 0; }
.detail-section > h3 { margin: 0 0 12px; font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.detail-item span, .detail-item strong { display: block; }
.detail-item span { color: var(--muted); font-size: 9px; }
.detail-item strong { margin-top: 2px; font-size: 11px; font-weight: 600; word-break: break-word; }
.missing-list { display: flex; flex-wrap: wrap; gap: 6px; }
.missing-chip { padding: 5px 8px; border-radius: 99px; color: var(--amber); background: var(--amber-soft); font-size: 9px; font-weight: 700; }
.document-upload { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 7px; margin-bottom: 12px; }
.document-upload select, .document-upload input { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px; font-size: 10px; }
.document-list { display: grid; gap: 7px; }
.document-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.document-row strong, .document-row span { display: block; }
.document-row strong { font-size: 10px; }
.document-row span { color: var(--muted); font-size: 9px; }
.document-actions { display: flex; align-items: center; gap: 5px; }
.document-actions a, .document-download { border: 0; padding: 0; color: var(--teal); background: transparent; font-size: 9px; font-weight: 700; text-decoration: none; cursor: pointer; }
.document-download:disabled { opacity: .55; cursor: wait; }
.danger-text { color: var(--red); }
.delete-confirmation-body { display: grid; gap: 15px; padding: 20px 24px 4px; }
.delete-target { display: grid; gap: 3px; padding: 13px; border: 1px solid #f0cbd0; border-radius: 11px; background: #fff8f9; }
.delete-target span { color: var(--muted); font-size: 9px; }
.delete-target strong { font-size: 15px; }
.delete-target code { color: var(--red); font-size: 10px; }
.delete-confirmation-hint { margin: -5px 0 0; color: var(--muted); font-size: 9px; }
.delete-confirmation-hint.matched { color: var(--green); font-weight: 700; }

.toast-region { position: fixed; z-index: 50; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { min-width: 250px; max-width: 360px; padding: 11px 13px; border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 10px; background: white; box-shadow: var(--shadow); font-size: 11px; animation: toast-in .2s ease; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.login-page { min-height: 100vh; background: #eef2ef; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 1.1fr) minmax(420px, .9fr); }
.login-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(48px, 8vw, 110px); color: white; background: #18323a; }
.login-brand::after { content: ""; position: absolute; right: -130px; bottom: -160px; width: 430px; height: 430px; border: 1px solid rgba(242,193,78,.22); border-radius: 50%; box-shadow: 0 0 0 70px rgba(242,193,78,.04), 0 0 0 140px rgba(242,193,78,.025); }
.login-brand .brand-mark { width: 48px; height: 48px; margin-bottom: 54px; border-radius: 15px; }
.login-brand .brand-mark img { width: 34px; height: 34px; }
.login-brand .eyebrow { color: #7fc4bb; }
.login-brand h1 { position: relative; z-index: 1; margin: 14px 0 18px; font-family: Georgia, "STSong", serif; font-size: clamp(36px, 4.4vw, 62px); font-weight: 500; line-height: 1.12; letter-spacing: -1.8px; }
.login-brand > p { position: relative; z-index: 1; max-width: 560px; margin: 0; color: #b7c8c8; font-size: 15px; line-height: 1.8; }
.login-principles { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 38px; }
.login-principles span { padding: 7px 10px; border: 1px solid rgba(255,255,255,.13); border-radius: 99px; color: #d8e4e3; font-size: 10px; }
.login-card { display: flex; flex-direction: column; justify-content: center; width: min(430px, calc(100% - 48px)); margin: auto; padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.login-card h2 { margin: 7px 0 5px; font-size: 26px; }
.login-card > div > p { margin: 0 0 26px; color: var(--muted); }
.login-form { display: grid; gap: 16px; }
.login-form .field input { padding: 12px; }
.login-submit { width: 100%; margin-top: 3px; padding: 12px; }
.login-alert { margin-bottom: 16px; padding: 10px 12px; border-radius: 9px; color: var(--green); background: var(--green-soft); font-size: 11px; }
.login-alert.error { color: var(--red); background: #fff0f0; }
.login-help { margin: 22px 0 0; color: var(--muted); font-size: 10px; }
.login-help code { color: var(--ink); }

.download-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 20% 10%, #e0efea 0, transparent 34%), #edf3f0; }
.download-shell { width: min(560px, 100%); }
.download-brand { display: inline-flex; align-items: center; gap: 9px; margin: 0 0 14px 6px; color: var(--ink); text-decoration: none; }
.download-brand .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.download-brand .brand-mark img { width: 24px; height: 24px; }
.download-card { padding: 34px; border: 1px solid #cedbd7; border-radius: 22px; background: white; box-shadow: 0 24px 70px rgba(22,54,48,.12); }
.download-ready-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 19px; border-radius: 15px; color: white; background: var(--teal); font-size: 22px; font-weight: 800; box-shadow: 0 10px 24px rgba(15,118,110,.2); }
.download-card h1 { margin: 7px 0 7px; font-size: 27px; }
.download-card > p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.download-file-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; margin: 22px 0 16px; padding: 15px; border: 1px solid #d4e2de; border-radius: 13px; background: #f4f8f6; }
.download-file-card div span, .download-file-card div strong, .download-file-card div code { display: block; }
.download-file-card div span { color: var(--muted); font-size: 8px; }
.download-file-card div strong { margin-top: 3px; font-size: 12px; }
.download-file-card div code { margin-top: 3px; color: var(--teal-dark); font-size: 9px; }
.download-file-card small { grid-column: 1 / -1; overflow-wrap: anywhere; color: var(--muted); font-size: 9px; }
.download-generation-progress { display: grid; gap: 7px; margin-bottom: 14px; padding: 12px; border-radius: 10px; background: #eff7f4; }
.download-generation-progress[hidden] { display: none; }
.download-generation-progress > div:first-child { display: flex; justify-content: space-between; color: var(--teal-dark); font-size: 9px; }
.download-primary { width: 100%; display: flex; justify-content: center; padding: 12px; text-decoration: none; }
.download-primary[aria-disabled="true"] { pointer-events: none; opacity: .68; cursor: wait; }
.processing-progress-track > span.failed { background: linear-gradient(90deg, #c2413a, #e46b62); }
.download-back { display: block; margin-top: 13px; color: var(--teal); text-align: center; font-size: 10px; font-weight: 700; text-decoration: none; }
.download-help { margin-top: 18px !important; padding-top: 14px; border-top: 1px solid var(--line); font-size: 9px !important; }

@media (max-width: 1050px) {
    .sidebar { width: 78px; padding-inline: 14px; }
    .brand > div:last-child, .nav-item:not(.active), .nav-item em, .sidebar-note, .operator > div:nth-child(2), .operator .online-dot { display: none; }
    .brand { justify-content: center; padding-inline: 0; }
    .nav-item.active { justify-content: center; font-size: 0; padding: 15px; }
    .nav-dot { width: 9px; height: 9px; }
    .operator { grid-template-columns: 1fr; justify-items: center; }
    .main-content { margin-left: 78px; padding-inline: 24px; }
}
@media (max-width: 780px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { min-height: 38vh; padding: 38px 28px; }
    .login-brand .brand-mark { margin-bottom: 28px; }
    .login-brand h1 { font-size: 34px; }
    .login-card { width: calc(100% - 30px); margin-block: 24px; padding: 28px; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 22px 15px 40px; }
    .topbar { align-items: flex-start; }
    .topbar-actions .secondary { display: none; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .workspace-grid { grid-template-columns: 1fr; }
    .action-panel { position: static; height: auto; min-height: auto; max-height: none; }
    .candidate-panel { max-height: 68vh; }
    .batch-confirm-form { grid-template-columns: 1fr; }
    .profiles-header { align-items: flex-start; flex-direction: column; }
    .profile-filters { width: 100%; }
    .profile-filters label:first-child, .profile-filters input { width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .field.span-2 { grid-column: span 1; }
    .document-upload { grid-template-columns: 1fr; }
    .change-row { grid-template-columns: 24px 1fr; }
    .change-field { grid-column: 2; }
    .change-value { grid-column: 2; }
    .change-arrow { display: none; }
    .change-evidence { grid-column: 2; }
}
@media (max-width: 480px) {
    .topbar { flex-direction: column; }
    .topbar-actions { width: 100%; }
    .topbar-actions .primary { width: 100%; }
    .metrics { gap: 8px; }
    .metric-card { padding: 14px; }
    .safe-badge { display: none; }
    .message { max-width: 92%; }
    th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3) { display: none; }
    .detail-grid { grid-template-columns: 1fr; }
}
