@font-face {
    font-family: 'Roboto';
    src: url('./assets/fonts/Roboto-Variable.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --fullscreen-top-offset: 0px;
    --tg-bg: var(--tg-theme-bg-color, #f9fafb);
    --tg-text: var(--tg-theme-text-color, #334155);
    --tg-hint: var(--tg-theme-hint-color, #94a3b8);
    --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #ffffff);
    --tg-button: var(--tg-theme-button-color, #718aef);
    --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
    --tg-separator: var(--tg-theme-section-separator-color, #e5e7eb);

    --bg: var(--tg-secondary-bg);
    --surface: var(--tg-bg);
    --text: var(--tg-text);
    --muted: var(--tg-hint);
    --line: var(--tg-separator);

    --green-bg: #dcfce3;
    --green-text: #15803d;

    --risk-red: #ef4444;
    --risk-yellow: #f59e0b;
    --risk-green: #22c55e;

    --alert-bg: #fee2e2;
    --alert-text: #b91c1c;

    --action: var(--tg-button);
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --border-color: var(--tg-separator);
    --brand-soft: rgba(113, 138, 239, 0.14);
    --btn-radius: 14px;
    --btn-border: var(--line);
    --btn-border-accent: rgba(113, 138, 239, 0.45);
    --btn-bg: var(--tg-bg);
    --btn-bg-hover: #f8fafc;
    --btn-bg-active: #eef2ff;
    --btn-text: var(--tg-text);
    --btn-muted: var(--tg-hint);
    --btn-accent: var(--tg-button);
    --btn-accent-hover: #5f78e6;
    --btn-accent-active: #4f69d8;
    --btn-focus: rgba(113, 138, 239, 0.28);
    --btn-danger: #e53935;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    min-height: 100%;
    width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    display: flex;
    justify-content: center;
    padding: 0;
    touch-action: pan-y;
}

.container {
    width: min(448px, 100%);
    max-width: 100%;
    margin: 0 auto;
    padding: calc(44px + var(--fullscreen-top-offset, 0px)) 16px 24px;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
p {
    margin: 0;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 8px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-5 {
    margin-top: 20px;
}

.mb-8 {
    margin-bottom: 32px;
}

.text-sm {
    font-size: 14px;
}

.text-hint {
    color: var(--tg-hint);
}

.text-error {
    color: var(--risk-red);
}

.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
}

.header-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-transform: none;
}

.subtitle {
    font-size: 14px;
    line-height: 1.5;
    color: var(--tg-hint);
    font-weight: 500;
}

.header-icon {
    width: 82px;
    height: 82px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--btn-accent);
    background: #ffffff;
    border: 1px solid rgba(113, 138, 239, 0.16);
    box-shadow: 0 14px 28px rgba(113, 138, 239, 0.17);
}

.search-panel {
    margin-bottom: 32px;
}

.section-eyebrow {
    color: #6b7280;
    font-size: 12px;
    text-transform: uppercase;
    padding: 4px 8px;
    margin: 0 0 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: center;
}

.input-hint {
    margin-top: 2px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

.auth-dashboard {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 14px;
}

.auth-dashboard-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.auth-dashboard-title {
    font-size: 16px;
    line-height: 1.2;
    font-weight: 700;
}

.auth-dashboard-subtitle {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--muted);
}

.auth-refresh-btn {
    flex: none;
    min-width: 104px;
    padding: 7px 10px;
    font-size: 13px;
}

.auth-dashboard-status-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-stat-card {
    border: 1px solid var(--line);
    background: var(--tg-secondary-bg);
    border-radius: 10px;
    padding: 8px 10px;
    min-height: 58px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}

.auth-stat-card--wide {
    grid-column: 1 / -1;
}

.auth-stat-label {
    font-size: 11px;
    line-height: 1.2;
    color: var(--muted);
}

.auth-stat-value {
    font-size: 13px;
    line-height: 1.3;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}

.auth-stat-value--muted {
    font-weight: 500;
    color: var(--muted);
}

.auth-stat-value--ok {
    color: var(--risk-green);
}

.auth-stat-value--warn {
    color: var(--risk-yellow);
}

.auth-stat-value--bad {
    color: var(--risk-red);
}

.auth-message {
    margin-top: 10px;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.35;
    border: 1px solid var(--line);
    background: var(--tg-secondary-bg);
    color: var(--text);
}

.auth-message--ok {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.14);
    color: #15803d;
}

.auth-message--error {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.auth-message--info {
    border-color: var(--line);
    background: var(--tg-secondary-bg);
    color: var(--text);
}

.auth-dashboard-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.auth-dashboard-actions--locked {
    opacity: 0.5;
}

.auth-access-gate {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--tg-secondary-bg);
    padding: 10px;
}

.auth-access-title {
    font-size: 12px;
    line-height: 1.35;
    color: var(--muted);
}

.auth-inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(154px, auto);
    align-items: stretch;
    gap: 8px;
}

.auth-inline-form--access {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(154px, auto);
    margin-top: 8px;
}

.auth-inline-form--profile {
    width: 100%;
}

.auth-inline-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.auth-inline-row--actions .btn {
    width: 100%;
}

.auth-input {
    min-height: 42px;
    padding-right: 12px;
    font-size: 14px;
}

.auth-select {
    appearance: none;
}

.auth-action-btn {
    width: 100%;
    min-height: 42px;
    min-width: 154px;
    padding: 8px 12px;
    font-size: 13px;
}

.auth-init-chat-btn {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    font-size: 13px;
}

.auth-profile-reset-btn {
    border-color: rgba(229, 57, 53, 0.45);
    background: rgba(229, 57, 53, 0.08);
    color: #b91c1c;
}

.auth-profile-reset-btn:hover {
    border-color: #e53935;
    background: rgba(229, 57, 53, 0.14);
}

.auth-profile-reset-btn:active {
    background: rgba(229, 57, 53, 0.22);
}

.auth-restart-stage-btn {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    font-size: 13px;
}

.input-wrapper {
    position: relative;
    width: 100%;
    margin-inline: 0;
}

.input-field {
    width: 100%;
    min-height: 58px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--tg-bg);
    color: var(--tg-text);
    padding: 15px 118px 15px 16px;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 0;
    outline: none;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-field::placeholder {
    color: var(--muted);
    opacity: 1;
    letter-spacing: normal;
}

.input-field:focus {
    border-color: var(--btn-border-accent);
    box-shadow: 0 0 0 3px rgba(113, 138, 239, 0.13);
    background: var(--btn-bg);
}

.input-field.error {
    border-color: var(--risk-red);
}

.input-field.error::placeholder {
    color: var(--risk-red);
    opacity: 1;
}

.input-actions {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--btn-border);
    border-radius: var(--btn-radius);
    background: var(--btn-bg);
    color: var(--btn-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.08s ease;
    position: relative;
    overflow: hidden;
}

.icon-btn:hover {
    border-color: var(--btn-border-accent);
    background: var(--btn-bg-hover);
}

.icon-btn:active {
    background: var(--btn-bg-active);
    color: var(--btn-accent);
    transform: translateY(1px);
}

.icon-btn.is-keyboard-open {
    color: var(--btn-accent);
    border-color: var(--btn-border-accent);
}

.icon-btn.is-keyboard-open::after {
    content: '';
    position: absolute;
    left: -3px;
    right: -3px;
    top: 50%;
    height: 2px;
    background: currentColor;
    transform: rotate(-26deg);
    opacity: 0.9;
    pointer-events: none;
}

.paste-btn {
    height: 34px;
    border: 1px solid var(--btn-border);
    border-radius: var(--btn-radius);
    background: var(--btn-bg);
    color: var(--btn-accent);
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.08s ease;
}

.paste-btn:hover {
    border-color: var(--btn-border-accent);
    background: var(--btn-bg-hover);
}

.paste-btn:active {
    background: var(--btn-bg-active);
    transform: translateY(1px);
}

.error-slot {
    display: none;
    line-height: 1.35;
    text-align: center;
    font-size: 13px;
    margin-top: 2px;
}

.error-slot.visible {
    display: block;
}

.btn-link {
    text-decoration: none;
}

.btn {
    width: 100%;
    min-height: 52px;
    border: 1px solid transparent;
    border-radius: var(--btn-radius);
    font-size: 15px;
    font-weight: 700;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.55;
    pointer-events: none;
}

.btn-primary {
    background: var(--btn-accent);
    color: var(--tg-button-text);
    border-color: var(--btn-accent);
    box-shadow: 0 10px 22px rgba(113, 138, 239, 0.28);
}

.btn-primary:hover {
    background: var(--btn-accent-hover);
    border-color: var(--btn-accent-hover);
}

.btn-primary:active {
    background: var(--btn-accent-active);
    border-color: var(--btn-accent-active);
}

.btn-secondary {
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--btn-border);
}

.btn-secondary:hover {
    border-color: var(--btn-border-accent);
    background: var(--btn-bg-hover);
}

.btn-secondary:active {
    background: var(--btn-bg-active);
}

.btn-collapsible {
    overflow: hidden;
    max-height: 52px;
    opacity: 1;
    transition: max-height 0.28s ease, opacity 0.24s ease, transform 0.24s ease, margin 0.24s ease, padding 0.24s ease, border-width 0.24s ease;
}

.btn-collapsible.is-hidden {
    max-height: 0;
    opacity: 0;
    transform: translateY(-4px);
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    pointer-events: none;
}

.btn-collapsible.is-gone {
    display: none !important;
}

#check-btn {
    width: 100%;
    margin-inline: 0;
}

.subscription-gate {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    margin: 0 auto;
    width: min(440px, calc(100% - 24px));
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    padding: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s ease, opacity 0.22s ease;
    z-index: 120;
}

.subscription-gate.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.subscription-gate-text {
    font-size: 13px;
    line-height: 1.35;
    font-weight: 600;
}

.subscription-gate-hint {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--muted);
}

.subscription-gate-actions {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.subscription-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 12, 0.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 110;
}

.subscription-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.subscription-check-loader {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
    border-radius: 50%;
    background: rgba(16, 18, 24, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 130;
}

.subscription-check-loader.is-active {
    opacity: 1;
    transform: scale(1);
}

.subscription-check-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#check-subscription-btn.is-loading {
    position: relative;
    color: transparent;
}

#check-subscription-btn.is-loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.cta-stack {
    position: static;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 18px;
    box-shadow: var(--shadow);
    z-index: auto;
}

.loader-block {
    padding: 44px 0;
}

.loader-icon {
    color: var(--action);
    margin-bottom: 14px;
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.canvas {
    width: 100%;
    margin: 0 auto;
    position: relative;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    padding: 20px 0 22px;
}

.content-346 {
    width: calc(100% - 36px);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 18px;
    min-height: 22px;
    width: fit-content;
    min-width: 0;
    padding: 3px 10px;
    gap: 6px;
    border-radius: 999px;
    background: var(--line);
    color: var(--muted);
    font-size: 11px;
    line-height: 1.1;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pill--green {
    background: var(--green-bg);
    color: #186e18;
}

.status-pill--yellow {
    background: rgba(234, 179, 8, 0.2);
    color: #a16207;
}

.status-pill--red {
    background: rgba(239, 68, 68, 0.2);
    color: #b91c1c;
}

.status-pill--neutral,
.status-pill--loading {
    background: var(--line);
    color: var(--muted);
}

.status-pill-logo {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Crect width='24' height='24' rx='12' fill='%231f2937'/%3E%3Ctext x='12' y='15' font-size='9' text-anchor='middle' fill='white' font-family='Arial'%3ERP%3C/text%3E%3C/svg%3E");
}

.status-pill-text {
    display: inline-block;
    max-width: 100%;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: inherit;
    font-size: 10px;
    line-height: 1.2;
    font-weight: 500;
    letter-spacing: 0.15px;
    color: inherit;
}

.company-name {
    margin: 16px 18px 0;
    font-size: 24px;
    line-height: 1.3;
    font-weight: 800;
    color: #1e293b;
}

.meta {
    margin-left: 18px;
    width: calc(100% - 36px);
    font-size: 13px;
    line-height: 1.6;
    font-weight: 500;
    color: #64748b;
}

.meta.light {
    font-weight: 500;
}

.result-card {
    width: calc(100% - 36px);
    max-width: 400px;
    margin: 20px auto 0;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: 0 6px 22px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.risk-head {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 14px 14px 14px 10px;
    background: #f8fafc;
}

.risk-mark {
    width: 10px;
    height: 34px;
    border-radius: 999px;
    background: var(--risk-red);
}

.risk-head h2 {
    font-size: 14px;
    line-height: 1.4;
    font-weight: 700;
    color: #334155;
}

#risk-level-text {
    text-transform: lowercase;
    color: var(--text);
}

.risk-head small {
    font-size: 11px;
    line-height: 1;
    font-weight: 600;
    color: var(--muted);
}

.result-card.green .risk-head {
    background: rgba(34, 197, 94, 0.1);
}

.result-card.yellow .risk-head {
    background: rgba(245, 158, 11, 0.12);
}

.result-card.red .risk-head {
    background: rgba(239, 68, 68, 0.12);
}

.risk-summary-block {
    padding: 16px 18px 0;
    margin-bottom: 14px;
}

.summary-title {
    font-size: 11px;
    line-height: 1.4;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.risk-details {
    list-style: none;
    margin: 0;
    padding: 0;
}

#risk-details li.risk-entry-title {
    margin-top: 14px;
    font-size: 15px;
    line-height: 1.34;
    font-weight: 700;
    color: #334155;
}

#risk-details li.risk-entry-title strong {
    font-weight: 700;
}

#risk-details li.risk-entry-title:first-child {
    margin-top: 0;
}

#risk-details li.risk-entry-text {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.6;
    font-weight: 500;
    color: #475569;
}

#risk-details li.risk-entry-text + li.risk-entry-title {
    margin-top: 16px;
}

.risk-last-updated {
    margin-top: 12px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--muted);
}

.result-subsection {
    margin-top: 14px;
    padding: 14px 18px 0;
    border-top: 1px solid var(--line);
}

#result-history-details li.history-entry-title {
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 700;
    color: #334155;
}

#result-history-details {
    margin: 0 0 16px;
    padding: 0;
}

#result-history-details li.history-entry-title:first-child {
    margin-top: 0;
}

#result-history-details li.history-entry-date {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--muted);
}

.result-card-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: calc(100% - 36px);
    max-width: 400px;
    margin: 20px auto 0;
    padding: 0;
}

.result-actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.save-btn {
    flex: 1;
    min-height: 50px;
    border: 1px solid var(--btn-border);
    border-radius: var(--btn-radius);
    background: var(--btn-bg);
    color: var(--btn-text);
    font: 700 14px/1.2 Inter, Roboto, sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.08s ease;
}

.save-btn:hover {
    border-color: var(--btn-border-accent);
    background: var(--btn-bg-hover);
}

.save-btn:active {
    background: var(--btn-bg-active);
    transform: translateY(1px);
}

.btn-icon {
    width: 50px;
    height: 50px;
    border: 1px solid var(--btn-border);
    border-radius: var(--btn-radius);
    background: var(--btn-bg);
    color: var(--btn-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.08s ease;
}

.btn-icon:hover {
    border-color: var(--btn-border-accent);
    background: var(--btn-bg-hover);
}

.btn-icon:active {
    background: var(--btn-bg-active);
    transform: translateY(1px);
}

.btn-share-accent {
    color: var(--btn-accent);
}

.btn-fav-wide {
    flex: 1;
    width: auto;
    padding: 0 14px;
    gap: 8px;
    justify-content: center;
    color: var(--btn-text);
}

.btn-fav-label {
    font: 700 14px/1.2 Inter, Roboto, sans-serif;
    color: var(--btn-text);
    white-space: nowrap;
}

.summary-report-btn {
    width: 100%;
    min-height: 50px;
    border: 1px solid var(--btn-border);
    border-radius: var(--btn-radius);
    background: var(--btn-bg);
    color: var(--btn-text);
    font: 700 14px/1.2 Inter, Roboto, sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.08s ease;
}

.summary-report-btn:hover {
    border-color: var(--btn-border-accent);
    background: var(--btn-bg-hover);
}

.summary-report-btn:active {
    background: var(--btn-bg-active);
    transform: translateY(1px);
}

.summary-report-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    border-color: var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-muted);
}

.pdf-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 20px;
    padding: 0 6px;
    border-radius: 4px;
    background: #e53935;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.risk-icon {
    display: none;
}

.director-block {
    margin-top: 18px;
}

.alert-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 18px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--alert-bg);
    color: var(--alert-text);
    font-size: 9px;
    line-height: 1.2;
    text-align: right;
}

.details-block {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}


.flat-section {
    padding: 0 0 14px;
    border-bottom: 1px solid var(--line);
}

.flat-section--director {
    padding-bottom: 0;
    border-bottom: 0;
}

.flat-section-title {
    margin: 0 0 8px;
    font-size: 12px;
    line-height: 1.45;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.flat-section-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

 .flat-expandable {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--tg-secondary-bg);
    overflow: hidden;
}

.flat-expandable-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    -webkit-user-select: none;
    user-select: none;
}

.flat-expandable-summary::-webkit-details-marker {
    display: none;
}

.flat-expandable-summary-text {
    font-size: 12px;
    line-height: 1.4;
    color: var(--btn-accent);
    font-weight: 500;
}

.flat-expandable-summary-icon {
    font-size: 12px;
    line-height: 1;
    color: var(--muted);
    transition: transform 0.2s ease;
}

.flat-expandable[open] .flat-expandable-summary-icon {
    transform: rotate(180deg);
}

.flat-expandable-list {
    list-style: none;
    margin: 0;
    padding: 0 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flat-expandable-item {
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
    word-break: break-word;
}

.flat-line {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: #334155;
    font-weight: 600;
    word-break: break-word;
}

.flat-line--receipt,
.structured-meta--receipt {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 10px;
    white-space: nowrap;
}

.flat-line-receipt-key,
.structured-meta-receipt-key {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: inherit;
}

.flat-line-receipt-key::after,
.structured-meta-receipt-key::after {
    content: " ................................................";
    color: currentColor;
    opacity: 0.35;
    margin-left: 6px;
}

.flat-line-receipt-value,
.structured-meta-receipt-value {
    justify-self: end;
    text-align: right;
    color: var(--receipt-ink, var(--text));
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flat-line--label {
    margin-top: 4px;
    font-weight: 600;
}

.flat-line--muted {
    color: var(--muted);
}

.flat-line--alert {
    color: var(--alert-text);
}

.flat-line--link {
    color: var(--btn-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.flat-line--loading {
    display: flex;
    width: 100%;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    text-align: right;
}

.flat-line-loading-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    flex: none;
    animation: spin 0.9s linear infinite;
}

.flat-line-loading-text {
    animation: loadingPulse 1.1s ease-in-out infinite;
}

.flat-group-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.row {
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
    display: grid;
    gap: 6px;
}

.compact {
    line-height: 1.45;
}

.structured-block {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.structured-pending {
    border-style: dashed;
}

.structured-pending-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--muted);
}

.loading-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    display: inline-block;
    animation: spin 1s linear infinite;
}

.structured-title {
    font-size: 13px;
    line-height: 1.4;
    font-weight: 600;
    margin-bottom: 8px;
}

.structured-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.structured-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    background: #f8fafc;
}

.structured-item-title {
    font-size: 11px;
    line-height: 1.3;
    font-weight: 600;
    color: var(--muted);
}

.structured-item-main {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.45;
    font-weight: 500;
}

.structured-meta {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--muted);
    word-break: break-word;
}

.structured-alert {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--alert-text);
}

.structured-list {
    margin: 6px 0 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text);
}

.list-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.lists-container {
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.list-item {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    padding: 14px 14px 14px 18px;
    min-height: 66px;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.list-item:hover {
    border-color: rgba(113, 138, 239, 0.35);
    box-shadow: 0 6px 20px rgba(113, 138, 239, 0.12);
}

.list-item:active {
    transform: scale(0.98);
}

.list-indicator {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 36px;
    border-radius: 999px;
}

.list-content {
    padding-left: 12px;
    overflow: hidden;
    width: 100%;
}

.list-title {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.list-delete-btn {
    flex-shrink: 0;
    margin-left: 10px;
    border: 1px solid rgba(229, 57, 53, 0.45);
    background: var(--btn-bg);
    color: var(--btn-danger);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.08s ease;
}

.list-delete-btn:hover {
    border-color: var(--btn-danger);
    background: rgba(229, 57, 53, 0.12);
}

.list-delete-btn:active {
    background: rgba(229, 57, 53, 0.2);
    transform: translateY(1px);
}

.btn-action {
    flex: 1;
    padding: 10px 12px;
    border-radius: var(--btn-radius);
    font-size: 14px;
    font-weight: 700;
    border: 1px solid var(--btn-border);
    cursor: pointer;
    background: var(--btn-bg);
    color: var(--btn-text);
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.08s ease;
}

.btn-action:hover {
    border-color: var(--btn-border-accent);
    background: var(--btn-bg-hover);
}

.btn-action:active {
    background: var(--btn-bg-active);
    transform: translateY(1px);
}

.btn-clear-history {
    flex: none;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--btn-accent);
    border-color: var(--btn-accent);
}

.btn-clear-history:hover,
.btn-edit-favs:hover {
    border-color: var(--btn-accent-hover);
    background: var(--btn-bg-hover);
}

.btn-clear-history:active,
.btn-edit-favs:active {
    border-color: var(--btn-accent-active);
    background: var(--btn-bg-active);
}

.btn-edit-favs {
    flex: none;
    min-width: 88px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--btn-accent);
    border-color: var(--btn-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-edit-favs.is-active {
    background: var(--btn-bg-active);
    border-color: var(--btn-accent);
}

button:focus-visible {
    outline: 2px solid var(--btn-focus);
    outline-offset: 2px;
}

.empty-state {
    text-align: center;
    padding: 24px;
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--line);
    color: var(--tg-hint);
    font-size: 14px;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quiet-toast {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    transform: translateX(-50%) translateY(8px);
    background: rgba(17, 24, 39, 0.88);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 80;
}

.quiet-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.quiet-toast.is-success {
    background: rgba(22, 101, 52, 0.9);
}

.quiet-toast.is-warn {
    background: rgba(146, 64, 14, 0.9);
}

.quiet-toast.is-error {
    background: rgba(153, 27, 27, 0.9);
}

@keyframes loadingPulse {
    0%,
    100% {
        opacity: 0.45;
    }
    50% {
        opacity: 1;
    }
}

.fullscreen-toggle-btn {
    position: fixed;
    right: max(8px, calc(env(safe-area-inset-right, 0px) + 8px));
    top: max(10px, calc(env(safe-area-inset-top, 0px) + 10px + var(--fullscreen-top-offset, 0px)));
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    opacity: 0.22;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    z-index: 90;
    transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.08s ease;
}

.fullscreen-toggle-btn.is-active {
    top: max(18px, calc(env(safe-area-inset-top, 0px) + 46px + var(--fullscreen-top-offset, 0px)));
}

.fullscreen-toggle-btn:hover,
.fullscreen-toggle-btn:focus-visible,
.fullscreen-toggle-btn.is-active {
    opacity: 0.62;
    color: var(--text);
    border-color: var(--btn-border-accent);
}

.fullscreen-toggle-btn:active {
    transform: translateY(1px);
    opacity: 0.78;
}

.fullscreen-toggle-btn svg {
    display: block;
    pointer-events: none;
    width: 12px;
    height: 12px;
}

.fullscreen-toggle-btn__text {
    display: inline-block;
}

/* Receipt theme override */
:root {
    --receipt-paper: #fffdf6;
    --receipt-ink: #1f2328;
    --receipt-muted: #606871;
    --receipt-line: #d8d3c5;
    --receipt-accent: #111111;
    --receipt-danger: #b91c1c;
}

body {
    background:
        radial-gradient(circle at 8% 5%, rgba(160, 149, 116, 0.12), transparent 34%),
        radial-gradient(circle at 92% 12%, rgba(136, 124, 89, 0.1), transparent 30%),
        #efe9da;
    color: var(--receipt-ink);
    font-family: "Courier New", "Lucida Console", Monaco, monospace;
}

.container {
    width: min(472px, 100%);
    padding-top: calc(20px + var(--fullscreen-top-offset, 0px));
}

.header {
    position: relative;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    background: var(--receipt-paper);
    border: 1px dashed var(--receipt-line);
    border-radius: 0;
    padding: 16px 14px 14px;
    box-shadow: 0 10px 24px rgba(50, 46, 34, 0.14);
}

.header::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: -9px;
    height: 10px;
    background: repeating-linear-gradient(90deg, transparent 0 8px, rgba(78, 70, 49, 0.26) 8px 16px);
    opacity: 0.35;
    pointer-events: none;
}

.header-icon {
    width: 58px;
    height: 58px;
    border-radius: 0;
    background: #fff;
    border: none;
    box-shadow: none;
}

.title {
    font-size: 30px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
}

.subtitle {
    font-size: 13px;
    color: var(--receipt-muted);
}

.section-eyebrow {
    font-size: 11px;
    letter-spacing: 0.16em;
    color: var(--receipt-muted);
}

.cta-stack,
.canvas,
.result-card,
.subscription-gate,
.list-item,
.empty-state {
    background: var(--receipt-paper);
    border-radius: 0;
    border: 1px dashed var(--receipt-line);
    box-shadow: 0 8px 22px rgba(50, 46, 34, 0.1);
}

.cta-stack {
    position: relative;
}

.cta-stack::before,
.canvas::before {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    top: 10px;
    border-top: 1px dotted rgba(89, 80, 58, 0.35);
    pointer-events: none;
}

.input-field {
    min-height: 54px;
    border-radius: 0;
    border: 1px dashed var(--receipt-line);
    background: #fffef9;
    box-shadow: none;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 0.07em;
}

.btn,
.btn-action,
.save-btn,
.summary-report-btn,
.btn-icon,
.icon-btn,
.paste-btn,
.list-delete-btn {
    border-radius: 0;
    border-style: dashed;
    font-family: inherit;
    letter-spacing: 0.05em;
}

.btn-primary {
    background: var(--receipt-accent);
    border-color: var(--receipt-accent);
    box-shadow: none;
}

.btn-primary:hover {
    background: #2a2a2a;
    border-color: #2a2a2a;
}

.btn-secondary {
    background: #fffef9;
}

.canvas {
    border-style: solid;
    border-width: 1px;
    padding-top: 16px;
    overflow: visible;
}

.company-name {
    color: var(--receipt-ink);
    font-size: 21px;
    line-height: 1.35;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.meta,
.flat-line {
    color: var(--receipt-muted);
    font-family: inherit;
}

.result-card {
    border-style: solid;
    box-shadow: none;
}

.risk-head {
    background: transparent;
    border-bottom: 1px dotted var(--receipt-line);
}

.summary-title,
.flat-section-title,
.list-section-header {
    color: var(--receipt-muted);
    letter-spacing: 0.14em;
}

.flat-group-item,
.structured-block,
.structured-item,
.flat-expandable {
    border-radius: 0;
    border-style: dashed;
    background: #fffef9;
    box-shadow: none;
}

.list-item {
    min-height: 62px;
    border: 1px dashed var(--receipt-line);
    transition: border-color 0.2s ease, transform 0.1s ease;
}

.list-item:hover {
    border-color: #999080;
    box-shadow: 0 6px 14px rgba(50, 46, 34, 0.08);
}

.list-indicator {
    width: 3px;
    border-radius: 0;
}

.quiet-toast {
    border-radius: 0;
    border: 1px dashed rgba(255, 255, 255, 0.35);
}

@media (prefers-color-scheme: dark) {
    :root {
        --receipt-paper: #1f1d18;
        --receipt-ink: #f5f0df;
        --receipt-muted: #b9b3a6;
        --receipt-line: #5f594b;
        --receipt-accent: #e6dfcd;
        --receipt-danger: #f87171;
    }

    body {
        background:
            radial-gradient(circle at 8% 5%, rgba(255, 239, 194, 0.08), transparent 34%),
            radial-gradient(circle at 92% 12%, rgba(245, 224, 171, 0.06), transparent 30%),
            #131210;
        color: var(--receipt-ink);
    }

    .btn-primary {
        color: #161411;
        background: var(--receipt-accent);
        border-color: var(--receipt-accent);
    }

    .btn-primary:hover {
        background: #f3ecd9;
        border-color: #f3ecd9;
    }

    .header-icon,
    .input-field,
    .btn-secondary,
    .flat-group-item,
    .structured-block,
    .structured-item,
    .flat-expandable {
        background: #24211a;
    }

    .risk-head {
        background: rgba(255, 255, 255, 0.02);
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --tg-bg: #1e1f24;
        --tg-text: #f4f6fb;
        --tg-hint: #a8afc0;
        --tg-secondary-bg: #16181d;
        --tg-button: #8e63ff;
        --tg-button-text: #ffffff;
        --tg-separator: rgba(168, 175, 192, 0.28);
        --btn-border-accent: #7d64bd;
        --btn-accent-hover: #9b74ff;
        --btn-accent-active: #7f54ef;
        --btn-focus: rgba(142, 99, 255, 0.36);
        --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    }

    .quiet-toast {
        background: rgba(12, 14, 18, 0.92);
        color: #f4f6fb;
    }

    .quiet-toast.is-success {
        background: rgba(20, 83, 45, 0.94);
    }

    .quiet-toast.is-warn {
        background: rgba(120, 53, 15, 0.94);
    }

    .quiet-toast.is-error {
        background: rgba(127, 29, 29, 0.94);
    }

    .fullscreen-toggle-btn {
        border-color: var(--line);
        background: var(--surface);
    }
}

@media (max-width: 393px) {
    .auth-dashboard-head {
        flex-direction: column;
        align-items: stretch;
    }

    .auth-refresh-btn {
        width: 100%;
    }

    .auth-inline-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-inline-form {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .auth-action-btn,
    .auth-init-chat-btn,
    .auth-restart-stage-btn {
        width: 100%;
    }

    .canvas {
        width: calc(100vw - 24px);
    }

    .content-346,
    .result-card {
        width: calc(100vw - 48px);
    }

    .meta {
        width: calc(100vw - 74px);
    }

    .result-card-actions {
        width: calc(100vw - 48px);
    }

    .alert-pill {
        white-space: normal;
    }
}

