:root {
    --ink: #223044;
    --muted: #728095;
    --line: #dce4ed;
    --blue: #2478d3;
    --blue-dark: #175da8;
    --navy: #10284c;
    --navy-soft: #18365f;
    --green: #17835f;
    --gold: #9a6a16;
    --red: #b33d49;
    --bg: #eef2f6;
    --white: #fff;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font: 14px/1.55 Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
}

.dashboard-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    padding: 22px 14px 14px;
    overflow: hidden;
    color: #dbe9ff;
    background: var(--navy);
}

.sidebar-account {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 55px;
    padding: 2px 9px 17px;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.sidebar-account > span:last-child {
    min-width: 0;
}

.sidebar-account strong,
.sidebar-account small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-account strong {
    color: #fff;
    font-size: 13px;
}

.sidebar-account small {
    margin-top: 3px;
    color: #8fa7c3;
    font-size: 10px;
}

.sidebar-nav {
    display: grid;
    gap: 3px;
    min-height: 0;
    padding: 14px 0;
    overflow-y: auto;
}

.sidebar-nav button,
.sidebar-footer button {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    border: 0;
    border-radius: 7px;
    color: #9eb3ce;
    background: transparent;
    text-align: left;
}

.sidebar-nav button:hover,
.sidebar-nav button.active,
.sidebar-footer button:hover {
    color: #fff;
    background: rgba(48, 139, 255, .2);
}

.sidebar-nav button.active {
    box-shadow: inset 3px 0 #5ea9f4;
}

.sidebar-nav i,
.sidebar-footer i {
    display: grid;
    place-items: center;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    color: #cde3ff;
    background: rgba(255, 255, 255, .08);
    font-size: 10px;
    font-style: normal;
    font-weight: 800;
}

.sidebar-nav span,
.sidebar-footer span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav b {
    margin-left: auto;
    padding: 2px 5px;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 5px;
    color: #91a7c2;
    font-size: 9px;
    font-weight: 600;
}

.sidebar-nav b.ready {
    color: #9fe0bf;
    border-color: rgba(91, 209, 149, .35);
}

.sidebar-nav b.partial {
    color: #f0ce87;
    border-color: rgba(236, 190, 91, .35);
}

.sidebar-footer {
    display: grid;
    gap: 2px;
    margin-top: auto;
    padding-top: 9px;
    border-top: 1px solid rgba(255, 255, 255, .09);
}

.sidebar-footer form {
    margin: 0;
}

.workbench {
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

.page-content {
    height: 100%;
    padding: 22px 26px 52px;
    overflow-y: auto;
}

.workspace-view {
    width: min(1360px, 100%);
    margin: 0 auto;
}

.view-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 70px;
    margin-bottom: 16px;
}

.view-heading > div:first-child > span,
.panel-head > div > span,
.dialog-head span {
    color: var(--blue);
    font-size: 10px;
    font-weight: 800;
}

.view-heading h1 {
    margin: 3px 0 0;
    font-size: 25px;
    line-height: 1.25;
}

.panel {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--white);
}

.panel + .panel,
.panel + .provider-panel {
    margin-top: 16px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.panel-head h2 {
    margin: 3px 0 0;
    font-size: 17px;
}

.narrow-panel {
    width: min(760px, 100%);
}

.state-badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 8px;
    border: 1px solid #d7e0ea;
    border-radius: 6px;
    color: #607086;
    background: #f5f7fa;
    font-size: 10px;
}

.state-badge.pending {
    color: var(--gold);
    border-color: #ead8ac;
    background: #fff9e9;
}

.state-badge.success {
    color: var(--green);
    border-color: #bfe3d3;
    background: #eef9f4;
}

.state-badge.partial {
    color: #745c18;
    border-color: #e2d28e;
    background: #fff9da;
}

.connection-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 310px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.connection-strip > div {
    flex: 1;
    min-width: 0;
}

.connection-strip strong,
.connection-strip small,
.settings-status strong,
.settings-status small {
    display: block;
}

.connection-strip small,
.settings-status small {
    color: var(--muted);
    font-size: 10px;
}

.status-dot,
.online-dot {
    display: inline-block;
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #aab4c1;
}

.online-dot,
.status-dot.on {
    background: #25b46e;
    box-shadow: 0 0 0 4px rgba(37, 180, 110, .12);
}

.status-dot.warn {
    background: #d28b32;
}

.button {
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--ink);
    background: #edf2f7;
    font-weight: 700;
}

.button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.button.primary {
    color: #fff;
    background: var(--blue);
    border-color: var(--blue);
}

.button.primary:hover:not(:disabled) {
    background: var(--blue-dark);
}

.button.secondary {
    color: var(--blue);
    background: #f3f8fe;
    border-color: #c9dcf2;
}

.button.danger {
    color: var(--red);
    background: #fff4f5;
    border-color: #edc9ce;
}

.button.danger:hover:not(:disabled) {
    color: #fff;
    background: var(--red);
}

.button.small {
    min-height: 31px;
    padding: 5px 9px;
    font-size: 11px;
}

.button.mini {
    min-height: 29px;
    margin-top: 5px;
    padding: 5px 8px;
    font-size: 10px;
}

.segmented-control {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 3px;
    margin-bottom: 14px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #e7edf4;
}

.segmented-control button {
    min-width: 104px;
    padding: 7px 11px;
    border: 0;
    border-radius: 5px;
    color: #637288;
    background: transparent;
    font-size: 12px;
}

.segmented-control button.active {
    color: var(--ink);
    background: #fff;
    box-shadow: 0 1px 4px rgba(25, 44, 68, .12);
    font-weight: 700;
}

.opening-pane {
    min-width: 0;
}

.opening-form,
.stack-form {
    display: grid;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.form-grid label,
.stack-form label,
.textarea-field {
    display: grid;
    gap: 6px;
    min-width: 0;
    color: #536174;
    font-size: 11px;
}

.form-grid input,
.form-grid select,
.stack-form input,
.inline-form input,
.textarea-field textarea {
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid #d5dee8;
    border-radius: 6px;
    outline: none;
    color: var(--ink);
    background: #fff;
}

.form-grid input:focus,
.form-grid select:focus,
.stack-form input:focus,
.inline-form input:focus,
.textarea-field textarea:focus {
    border-color: #6da8e7;
    box-shadow: 0 0 0 3px rgba(36, 120, 211, .1);
}

.opening-provider-field,
.opening-choice-field {
    position: relative;
    z-index: 4;
}

.opening-provider-field.is-open,
.opening-choice-field.is-open {
    z-index: 20;
}

.opening-provider-picker,
.opening-choice-picker {
    position: relative;
    display: block;
}

.opening-provider-picker > input,
.opening-choice-picker > input {
    padding-right: 34px;
}

.opening-provider-picker::after,
.opening-choice-picker::after {
    position: absolute;
    top: 50%;
    right: 12px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid #708095;
    border-bottom: 1.5px solid #708095;
    content: "";
    pointer-events: none;
    transform: translateY(-65%) rotate(45deg);
}

.opening-provider-hint,
.opening-choice-hint {
    color: var(--muted);
    font-size: 10px;
}

.opening-provider-results,
.opening-choice-results {
    position: absolute;
    z-index: 20;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    display: grid;
    max-height: 280px;
    overflow: auto;
    border: 1px solid #cbd7e4;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(25, 44, 68, .16);
}

.opening-provider-results[hidden],
.opening-choice-results[hidden] {
    display: none;
}

.opening-provider-results button,
.opening-choice-results button {
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 9px 11px;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    color: var(--ink);
    text-align: left;
    background: #fff;
}

.opening-provider-results button:last-child,
.opening-choice-results button:last-child {
    border-bottom: 0;
}

.opening-provider-results button:hover,
.opening-provider-results button.active,
.opening-choice-results button:hover,
.opening-choice-results button.active {
    background: #eef6ff;
}

.opening-provider-results strong,
.opening-provider-results small,
.opening-choice-results strong,
.opening-choice-results small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opening-provider-results strong,
.opening-choice-results strong {
    font-size: 11px;
}

.opening-provider-results small,
.opening-provider-results p,
.opening-choice-results small,
.opening-choice-results p {
    color: var(--muted);
    font-size: 10px;
}

.opening-provider-results p,
.opening-choice-results p {
    margin: 0;
    padding: 12px;
}

.opening-registration-field {
    grid-column: span 2;
}

.opening-choice-results button > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opening-sales-results button {
    gap: 2px;
}

.check-row {
    display: flex !important;
    align-items: center;
    gap: 8px !important;
}

.check-row input {
    width: auto;
}

.catalog-preview {
    max-height: 150px;
    padding: 11px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: #617086;
    background: #f8fafc;
    font-size: 11px;
    white-space: pre-wrap;
}

.opening-assist {
    display: grid;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcfe;
}

.opening-assist .result-console {
    margin-top: 0;
}

.opening-flow-section {
    display: grid;
    gap: 12px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcfe;
}

.opening-flow-section > header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.opening-flow-section > header > span {
    display: grid;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 6px;
    color: #176fc8;
    background: #eaf4ff;
    font-weight: 700;
}

.opening-flow-section > header > div {
    display: grid;
    gap: 3px;
}

.opening-flow-section > header strong {
    color: var(--ink);
    font-size: 12px;
}

.opening-flow-section > header small,
.opening-flow-content > p,
.opening-contact-choice > small,
.opening-qualification-item > small,
.opening-qualification-status {
    margin: 0;
    color: var(--muted);
    font-size: 10px;
}

.opening-flow-content,
.opening-business-ranges,
.opening-qualification-groups,
.opening-qualification-item,
.opening-contact-choice {
    display: grid;
    gap: 9px;
}

.opening-business-ranges {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 11px;
    border: 1px solid #dce5ee;
    border-radius: 6px;
    background: #fff;
}

.opening-business-ranges > strong {
    grid-column: 1 / -1;
    font-size: 11px;
}

.opening-business-ranges label,
.opening-contact-choice label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #536174;
    font-size: 10px;
}

.opening-business-ranges input,
.opening-contact-choice input {
    width: auto;
}

.opening-qualification-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.opening-qualification-item {
    align-content: start;
    padding: 12px;
    border: 1px solid #dce5ee;
    border-radius: 6px;
    background: #fff;
}

.opening-qualification-item > strong {
    color: #34465b;
    font-size: 11px;
}

.opening-qualification-item select,
.opening-contact-choice select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #d5dee8;
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
}

.opening-qualification-drop {
    display: grid;
    min-height: 86px;
    padding: 12px;
    place-content: center;
    border: 1px dashed #9cbddd;
    border-radius: 6px;
    color: #55718e;
    background: #f5faff;
    text-align: center;
    cursor: pointer;
}

.opening-qualification-drop.is-dragging {
    border-color: #2378d1;
    background: #eaf4ff;
}

.opening-qualification-drop input {
    width: 100%;
    max-width: 280px;
    margin-bottom: 7px;
    font-size: 10px;
}

.opening-qualification-drop span {
    font-size: 10px;
}

.opening-qualification-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.opening-qualification-files span {
    max-width: 100%;
    padding: 5px 7px;
    overflow: hidden;
    border-radius: 4px;
    color: #526075;
    background: #eef2f7;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opening-contact-choice {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.opening-contact-choice select,
.opening-contact-choice > small {
    grid-column: 1 / -1;
}

.opening-confirm-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 24px 64px rgba(18, 36, 60, .26);
}

.opening-confirm-dialog::backdrop {
    background: rgba(19, 32, 49, .54);
}

.opening-confirm-panel {
    display: grid;
    max-height: calc(100vh - 48px);
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.opening-confirm-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 19px;
    border-bottom: 1px solid var(--line);
}

.opening-confirm-head > div {
    display: grid;
    gap: 4px;
}

.opening-confirm-head strong {
    color: var(--ink);
    font-size: 14px;
}

.opening-confirm-head small {
    color: var(--muted);
    font-size: 10px;
}

.opening-confirm-list {
    display: grid;
    overflow: auto;
    padding: 8px 19px;
}

.opening-confirm-list > div {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid #edf1f5;
}

.opening-confirm-list > div:last-child {
    border-bottom: 0;
}

.opening-confirm-list strong {
    color: #536174;
    font-size: 10px;
}

.opening-confirm-list span {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 11px;
}

.opening-confirm-panel > .dialog-actions {
    padding: 14px 19px;
    border-top: 1px solid var(--line);
}

.opening-template-hint {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 10px;
}

.opening-template-list {
    display: grid;
    gap: 8px;
}

.opening-template-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.opening-template-item > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.opening-template-item > div:first-child {
    display: grid;
    min-width: 0;
    gap: 4px;
}

.opening-template-item strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opening-template-item small {
    color: var(--muted);
    font-size: 10px;
}

.submit-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    padding-top: 14px;
    border-top: 1px solid #e9eef3;
}

.form-message {
    min-height: 19px;
    margin: 11px 0 0;
    color: var(--green);
    font-size: 11px;
}

.form-message.error {
    color: var(--red);
}

.opening-result {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid #bfe3d3;
    border-radius: 7px;
    background: #eef9f4;
}

.opening-result img {
    width: 150px;
    height: 150px;
    object-fit: contain;
    background: #fff;
}

.opening-result > div {
    display: grid;
    gap: 8px;
}

.opening-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.opening-result-warning {
    color: var(--red);
    line-height: 1.6;
}

.opening-record-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.opening-record-toolbar input {
    width: min(260px, 40vw);
    min-height: 34px;
}

.opening-record-qr {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.opening-record-qr img {
    width: 132px;
    height: 132px;
    object-fit: contain;
}

.file-drop-zone {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
    place-items: center;
    min-height: 82px;
    padding: 12px;
    border: 1px dashed #9fb5cc;
    border-radius: 6px;
    color: #52667d;
    background: #f8fafc;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.file-drop-zone.large {
    min-height: 108px;
}

.file-drop-zone:hover,
.file-drop-zone.is-dragging,
.file-drop-zone:focus-visible {
    border-color: var(--blue);
    background: #edf6ff;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(36, 120, 211, .12);
}

.file-drop-zone.has-files {
    border-style: solid;
    border-color: #75b493;
    background: #f0faf5;
}

.file-drop-zone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.file-drop-zone strong {
    font-size: 12px;
}

.file-drop-zone small {
    margin-top: 4px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 10px;
}

.file-drop-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    width: 100%;
    margin-top: 3px;
}

.file-drop-item {
    max-width: 100%;
    padding: 2px 6px;
    overflow: hidden;
    border: 1px solid #c9dfd2;
    border-radius: 4px;
    color: #3b6f56;
    background: #fff;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-console {
    min-height: 96px;
    max-height: 360px;
    margin: 14px 0 0;
    padding: 12px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: #405268;
    background: #f8fafc;
    font: 11px/1.65 Consolas, "Courier New", monospace;
    white-space: pre-wrap;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.module-grid .panel + .panel {
    margin-top: 0;
}

.module-grid .wide-panel {
    grid-column: 1 / -1;
}

.customer-picker:empty {
    display: none;
}

.customer-picker .operation-result-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
}

.customer-picker .operation-result-row input {
    width: 16px;
    height: 16px;
}

.separated-form {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.compact-actions {
    margin-top: 0;
}

.operation-results {
    display: grid;
    gap: 7px;
    max-height: 460px;
    margin-top: 12px;
    overflow: auto;
}

.operation-result-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 1fr);
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fafcfe;
}

.operation-result-row input {
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
    border: 1px solid #d5dee8;
    border-radius: 5px;
}

.record-table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    padding: 11px 10px;
    border-bottom: 1px solid #e7edf3;
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    color: #728095;
    background: #f8fafc;
    font-size: 10px;
}

.record-status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 5px;
    color: #6f7d90;
    background: #edf1f5;
    font-size: 10px;
}

.record-status.success {
    color: var(--green);
    background: #eaf7f1;
}

.record-status.failed {
    color: var(--red);
    background: #fff0f2;
}

.module-empty {
    display: grid;
    justify-items: center;
    min-height: 330px;
    padding: 70px 24px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: #fff;
    text-align: center;
}

.module-empty.prominent {
    min-height: 230px;
}

.module-empty strong {
    margin-top: 14px;
    color: #3f4e62;
    font-size: 15px;
}

.module-empty p {
    max-width: 560px;
    margin: 6px 0 0;
    font-size: 11px;
}

.ai-source-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-source-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.ai-source-switch select {
    width: min(150px, 34vw);
    min-height: 32px;
    padding: 4px 26px 4px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    outline: none;
    color: var(--ink);
    background: #fff;
}

.ai-source-switch select:focus {
    border-color: #74a9dc;
    box-shadow: 0 0 0 3px rgba(36, 120, 211, .1);
}

.ai-chat-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    height: calc(100vh - 140px);
    min-height: 540px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.ai-session-rail {
    min-width: 0;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: #f7f9fc;
}

.ai-session-rail > header,
.ai-conversation-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 58px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--line);
}

.ai-session-list {
    display: grid;
    gap: 3px;
    padding: 8px;
}

.ai-session-item {
    display: grid;
    gap: 3px;
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #405169;
    background: transparent;
    text-align: left;
}

.ai-session-item:hover,
.ai-session-item.active {
    border-color: #cbdced;
    background: #fff;
}

.ai-session-item strong,
.ai-session-item small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-session-item strong {
    font-size: 12px;
}

.ai-session-item small,
.ai-conversation-head small {
    color: var(--muted);
    font-size: 9px;
}

.ai-conversation {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
}

.ai-conversation-head > div {
    display: grid;
    min-width: 0;
}

.ai-message-list {
    min-height: 0;
    padding: 22px;
    overflow-y: auto;
    background: #fff;
}

.ai-chat-empty {
    display: grid;
    justify-items: center;
    align-content: center;
    min-height: 100%;
    color: var(--muted);
    text-align: center;
}

.ai-chat-empty > span {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    border: 1px solid #c9d9ea;
    border-radius: 7px;
    color: var(--blue);
    background: #f0f6fc;
    font-weight: 800;
}

.ai-chat-empty small {
    margin-top: 5px;
}

.ai-message {
    display: grid;
    gap: 5px;
    max-width: min(760px, 88%);
    margin-bottom: 18px;
}

.ai-message.user {
    justify-items: end;
    margin-left: auto;
}

.ai-message > small {
    color: var(--muted);
    font-size: 9px;
}

.ai-message > div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: #35465d;
    background: #f7f9fc;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.ai-message.user > div,
.ai-message.pending > div {
    white-space: pre-wrap;
}

.ai-message.user > div {
    color: #fff;
    border-color: var(--blue);
    background: var(--blue);
}

.ai-message.pending > div {
    color: var(--muted);
    background: #fff;
}

.ai-message-content > :first-child {
    margin-top: 0;
}

.ai-message-content > :last-child {
    margin-bottom: 0;
}

.ai-message-content p,
.ai-message-content ul,
.ai-message-content ol,
.ai-message-content blockquote,
.ai-message-content pre,
.ai-message-content table {
    margin: 0 0 10px;
}

.ai-message-content h1,
.ai-message-content h2,
.ai-message-content h3,
.ai-message-content h4,
.ai-message-content h5,
.ai-message-content h6 {
    margin: 15px 0 7px;
    color: #263a52;
    font-size: 15px;
    line-height: 1.45;
}

.ai-message-content h1,
.ai-message-content h2 {
    padding-bottom: 5px;
    border-bottom: 1px solid #dce4ed;
}

.ai-message-content ul,
.ai-message-content ol {
    padding-left: 22px;
}

.ai-message-content blockquote {
    padding: 6px 10px;
    border-left: 3px solid #9fc5e8;
    color: #5e6f83;
    background: #eef5fb;
}

.ai-message-content code {
    padding: 1px 4px;
    border-radius: 4px;
    color: #9b2c3f;
    background: #e9eef4;
    font: 12px/1.6 Consolas, "Courier New", monospace;
}

.ai-message-content pre {
    max-width: 100%;
    padding: 11px 12px;
    overflow: auto;
    border-radius: 6px;
    color: #e6edf5;
    background: #1e2937;
}

.ai-message-content pre code {
    padding: 0;
    color: inherit;
    background: transparent;
    white-space: pre;
}

.ai-message-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.ai-message-content th,
.ai-message-content td {
    min-width: 90px;
    padding: 6px 8px;
    border: 1px solid #ccd7e3;
    text-align: left;
}

.ai-message-content th {
    background: #eaf1f8;
}

.ai-message-content a {
    color: var(--blue-dark);
    text-decoration: underline;
}

.markdown-image-placeholder {
    color: var(--muted);
    font-size: 11px;
}

.ai-composer {
    padding: 13px;
    border-top: 1px solid var(--line);
    background: #fafcfe;
}

.ai-composer textarea {
    display: block;
    width: 100%;
    min-height: 72px;
    max-height: 180px;
    resize: vertical;
    padding: 10px 11px;
    border: 1px solid #ccd8e5;
    border-radius: 6px;
    outline: none;
    color: var(--ink);
    background: #fff;
}

.ai-composer textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(36, 120, 211, .1);
}

.ai-composer > div {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-height: 34px;
    margin-top: 8px;
}

.ai-composer .form-message {
    margin-right: auto;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid #c9d9ea;
    border-radius: 7px;
    color: var(--blue);
    background: #f0f6fc;
    font-size: 14px;
    font-weight: 800;
}

.empty {
    padding: 20px 0;
    color: var(--muted);
    text-align: center;
}

.settings-band {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    width: min(680px, 100%);
}

.settings-status {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    margin-bottom: 14px;
}

.provider-panel {
    margin-top: 16px;
}

.provider-list {
    display: grid;
    gap: 7px;
    min-height: 60px;
    margin-bottom: 14px;
}

.provider-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fafcfe;
}

.provider-item strong,
.provider-item small {
    display: block;
}

.provider-item small {
    color: var(--muted);
    font-size: 10px;
}

.provider-item button {
    border: 0;
    color: var(--red);
    background: transparent;
    font-size: 10px;
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1.3fr 1.1fr auto;
    gap: 8px;
}

.settings-tabs {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.settings-pane {
    min-width: 0;
}

.ai-provider-panel {
    width: min(900px, 100%);
}

.ai-skill-panel {
    width: min(900px, 100%);
    margin-top: 16px;
}

.ai-skill-form {
    display: grid;
    gap: 10px;
}

.ai-skill-form label {
    color: #536174;
    font-size: 11px;
    font-weight: 700;
}

.ai-skill-form textarea {
    width: 100%;
    min-height: 260px;
    resize: vertical;
    padding: 11px 12px;
    border: 1px solid #d5dee8;
    border-radius: 6px;
    outline: none;
    color: var(--ink);
    background: #fff;
}

.ai-skill-form textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(36, 120, 211, .1);
}

.ai-skill-form textarea:disabled {
    color: var(--muted);
    background: #f5f7fa;
}

.ai-skill-form small {
    color: var(--muted);
    font-size: 10px;
}

.ai-provider-list {
    display: grid;
    gap: 8px;
}

.ai-provider-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fafcfe;
}

.ai-provider-item.selected {
    border-color: #9fc5e8;
    background: #f1f8ff;
}

.ai-provider-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    color: #325a7d;
    background: #e7f1fa;
    font-weight: 800;
}

.ai-provider-content {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.ai-provider-content small {
    color: var(--muted);
    font-size: 10px;
    overflow-wrap: anywhere;
}

.ai-provider-actions {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
}

.ai-qr-stage iframe {
    width: 360px;
    max-width: 100%;
    height: 460px;
    border: 0;
    background: #fff;
}

.company-source-panel,
.company-search-panel {
    width: min(860px, 100%);
}

.company-source-list,
.company-search-results {
    display: grid;
    gap: 8px;
}

.company-source-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fafcfe;
}

.company-source-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--blue-dark);
    background: #eaf4ff;
    font-weight: 800;
}

.company-source-content {
    min-width: 0;
}

.company-source-content strong,
.company-source-content small {
    display: block;
}

.company-source-content small {
    margin-top: 3px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 10px;
}

.company-source-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.company-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.company-search-form input {
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid #d5dee8;
    border-radius: 6px;
    outline: none;
    color: var(--ink);
    background: #fff;
}

.company-search-form input:focus {
    border-color: #6da8e7;
    box-shadow: 0 0 0 3px rgba(36, 120, 211, .1);
}

.company-search-result {
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--blue);
    border-radius: 6px;
    background: #fafcfe;
}

.company-search-result strong,
.company-search-result small {
    display: block;
}

.company-search-result small,
.company-search-result p {
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 10px;
}

.company-search-result p {
    margin: 5px 0 0;
}

.tool-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.tool-actions > span {
    margin-right: auto;
    color: var(--muted);
    font-size: 10px;
}

.textarea-field textarea {
    min-height: 230px;
    resize: vertical;
}

.mobile-bar {
    display: none;
}

.qr-dialog {
    width: min(560px, calc(100vw - 32px));
    padding: 22px;
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(8, 25, 50, .26);
}

.qr-dialog::backdrop {
    background: rgba(12, 24, 40, .56);
}

.opening-template-dialog {
    width: min(460px, calc(100vw - 32px));
}

.opening-template-dialog .stack-form {
    margin-top: 20px;
}

.opening-template-dialog .dialog-actions {
    margin-top: 2px;
}

.panel-head-actions,
.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.opening-ai-dialog {
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow: auto;
}

.opening-ai-dialog .stack-form {
    margin-top: 20px;
}

.opening-ai-consent {
    align-items: flex-start;
    line-height: 1.5;
}

.opening-ai-progress {
    display: grid;
    gap: 7px;
    min-height: 92px;
    max-height: 190px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: #f8fafc;
    font-size: 11px;
}

.opening-ai-progress p {
    margin: 0;
}

.opening-ai-progress span {
    overflow-wrap: anywhere;
}

.opening-ai-progress .success {
    color: #208354;
}

.opening-ai-progress .warning {
    color: #946413;
}

.opening-ai-progress .error {
    color: var(--red);
}

.dialog-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.dialog-head h2 {
    margin: 3px 0 0;
    font-size: 18px;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    color: #6f7f93;
    background: transparent;
    font-size: 22px;
}

.global-notice {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1200;
    display: grid;
    grid-template-columns: 30px minmax(180px, 1fr) auto 34px;
    align-items: center;
    gap: 10px;
    width: min(560px, calc(100vw - 36px));
    min-height: 58px;
    padding: 11px 12px;
    border: 1px solid #ecc6ca;
    border-radius: 7px;
    color: #7d2731;
    background: #fff7f8;
    box-shadow: 0 12px 30px rgba(31, 48, 70, .18);
}

.global-notice-mark {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--red);
    font-weight: 700;
}

.global-notice strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 13px;
}

.global-notice .icon-button {
    color: #7d2731;
}

.qr-stage {
    padding: 26px 0;
    text-align: center;
}

.qr-refreshable {
    position: relative;
    display: grid;
    min-height: 250px;
    place-items: center;
}

.qr-refresh-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-content: center;
    gap: 6px;
    width: 250px;
    height: 250px;
    padding: 18px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: rgba(17, 29, 47, .88);
    cursor: pointer;
    transform: translate(-50%, -50%);
}

.qr-refresh-overlay[hidden] {
    display: none;
}

.qr-refresh-overlay:hover,
.qr-refresh-overlay:focus-visible {
    background: rgba(20, 55, 92, .94);
    outline: 2px solid #8fc2f8;
    outline-offset: 2px;
}

.qr-refresh-overlay .qr-refresh-icon {
    font-size: 34px;
    line-height: 1;
}

.qr-refresh-overlay strong {
    font-size: 13px;
}

.qr-refresh-overlay small {
    color: #d8e8f7;
    font-size: 10px;
}

.ai-qr-stage .qr-refresh-overlay {
    width: min(360px, 100%);
    height: 460px;
}

.qr-stage img {
    width: 250px;
    height: 250px;
    object-fit: contain;
}

.account-stage {
    display: grid;
    gap: 8px;
}

.account-search-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.account-search {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
}

.account-search:focus {
    border-color: var(--blue);
    outline: 2px solid rgba(36, 120, 211, .14);
}

.account-result-count {
    min-width: 48px;
    color: var(--muted);
    font-size: 11px;
    text-align: right;
}

.account-choice-list {
    display: grid;
    gap: 8px;
    max-height: min(420px, 52vh);
    padding-right: 3px;
    overflow-y: auto;
}

.account-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fafcfe;
}

.account-choice > div {
    min-width: 0;
}

.account-choice strong,
.account-provider-id {
    display: block;
    overflow-wrap: anywhere;
}

.account-provider-id {
    margin: 3px 0 1px;
    color: var(--blue-dark);
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    font-weight: 700;
}

.account-choice small {
    display: block;
    color: var(--muted);
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(340px, 1.05fr) minmax(380px, .95fr);
    min-height: 100vh;
    background: #fff;
}

.login-art {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 9vw;
    color: #fff;
    background: var(--navy);
}

.login-art h1 {
    margin: 16px 0;
    font-size: 58px;
    line-height: 1.08;
}

.login-art p {
    max-width: 370px;
    color: rgba(255, 255, 255, .74);
    font-size: 15px;
}

.login-art-footer {
    margin-top: auto;
    color: rgba(255, 255, 255, .55);
    font-size: 11px;
}

.eyebrow,
.panel-kicker {
    color: #8ec5ff;
    font-size: 10px;
    font-weight: 800;
}

.login-panel {
    align-self: center;
    max-width: 440px;
    padding: 50px 70px;
}

.login-panel h2 {
    margin: 8px 0;
    font-size: 28px;
}

.login-panel .muted {
    margin-bottom: 28px;
}

.muted {
    color: var(--muted);
}

.alert {
    margin: 14px 0;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
}

.alert.error {
    color: var(--red);
    background: #fff2f3;
}

@media (max-width: 820px) {
    .global-notice {
        top: 10px;
        right: 10px;
        grid-template-columns: 28px minmax(0, 1fr) 34px;
        width: calc(100vw - 20px);
    }

    .global-notice .button {
        grid-column: 2 / 4;
        width: 100%;
    }

    .dashboard-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 100;
        top: 0;
        bottom: 0;
        left: 0;
        width: 232px;
        transform: translateX(-100%);
        transition: transform .18s ease;
    }

    .dashboard-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .mobile-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 56px;
        padding: 0 14px;
        border-bottom: 1px solid var(--line);
        background: #fff;
    }

    .mobile-bar strong {
        font-size: 13px;
    }

    .page-content {
        height: calc(100% - 56px);
        padding: 16px 14px 42px;
    }

    .view-heading.with-status {
        align-items: flex-start;
    }

    .connection-strip {
        min-width: 280px;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inline-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inline-form button {
        grid-column: 1 / -1;
    }

    .module-grid {
        grid-template-columns: 1fr;
    }

    .ai-chat-shell {
        grid-template-columns: 210px minmax(0, 1fr);
        height: calc(100vh - 190px);
    }
}

@media (max-width: 680px) {
    .view-heading,
    .view-heading.with-status {
        display: grid;
        align-items: start;
    }

    .connection-strip {
        width: 100%;
        min-width: 0;
    }

    .segmented-control {
        display: grid;
        grid-auto-flow: row;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .segmented-control button {
        min-width: 0;
    }

    .settings-tabs {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .form-grid,
    .settings-band,
    .inline-form {
        grid-template-columns: 1fr;
    }

    .opening-registration-field {
        grid-column: auto;
    }

    .opening-business-ranges,
    .opening-qualification-groups,
    .opening-contact-choice {
        grid-template-columns: 1fr;
    }

    .opening-confirm-list > div {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .opening-template-item {
        align-items: stretch;
        flex-direction: column;
    }

    .submit-bar,
    .tool-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .tool-actions > span {
        margin-right: 0;
    }

    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-art {
        min-height: 260px;
        padding: 32px;
    }

    .login-art h1 {
        font-size: 40px;
    }

    .login-art-footer {
        margin-top: 28px;
    }

    .login-panel {
        padding: 36px 24px;
    }

    .account-choice {
        align-items: flex-start;
    }

    .company-source-item {
        grid-template-columns: 36px minmax(0, 1fr);
    }

    .ai-provider-item {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .ai-provider-actions {
        grid-column: 1 / -1;
        justify-content: stretch;
    }

    .ai-provider-actions .button {
        flex: 1;
    }

    .company-source-actions {
        grid-column: 1 / -1;
        flex-wrap: wrap;
    }

    .company-search-form {
        grid-template-columns: 1fr;
    }

    .operation-result-row {
        grid-template-columns: 1fr;
    }

    .ai-source-controls {
        flex-wrap: wrap;
    }

    .ai-source-switch {
        width: 100%;
    }

    .ai-source-switch select {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    .panel-head-actions,
    .dialog-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .panel-head-actions .button,
    .dialog-actions .button {
        width: 100%;
    }

    .ai-chat-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 170px minmax(0, 1fr);
        height: calc(100vh - 230px);
        min-height: 620px;
    }

    .ai-session-rail {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .ai-message-list {
        padding: 15px;
    }

    .ai-message {
        max-width: 94%;
    }
}
