:root {
    --ink: #18231f;
    --muted: #68736e;
    --surface: #ffffff;
    --canvas: #f4f6f1;
    --line: #dfe5de;
    --green: #166b4c;
    --green-dark: #0e5139;
    --mint: #dff3e7;
    --amber: #f2a93b;
    --red: #a63c3c;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: Inter, "Segoe UI", Arial, sans-serif; letter-spacing: -.035em; }
h1 { margin-bottom: .35rem; font-size: clamp(1.6rem, 3vw, 2.35rem); }
h2 { margin-bottom: 0; font-size: clamp(1.25rem, 2vw, 1.65rem); }

.app-shell { width: min(1440px, 100%); margin: auto; padding: 24px clamp(16px, 3vw, 44px) 64px; }
.topbar, .conversation-strip, .section-heading, .generate-row, .response-head, .top-actions {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar { margin-bottom: 22px; }
.ui-language { padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.conversation-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 10px; padding: 2px 1px 6px; }
.conversation-tab { display: grid; min-width: 150px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.conversation-tab span { font-weight: 700; }
.conversation-tab small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.conversation-tab.active { border-color: var(--green); background: var(--mint); color: var(--green-dark); }
.conversation-tab.add { display: flex; align-items: center; justify-content: center; min-width: 130px; color: var(--green); font-weight: 700; }
.resume-conversation { min-width: 260px; max-width: 390px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .15em; }
.muted { color: var(--muted); }

.conversation-strip, .workspace-card, .response-card, .history-section, .stats-grid article {
    background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 35px rgba(30, 50, 40, .055);
}
.conversation-strip { border-radius: 18px; padding: 16px 18px; margin-bottom: 18px; }
.conversation-id { min-width: 250px; }
.conversation-id span, .response-head span, .response-card footer, .stats-grid span { color: var(--muted); font-size: .78rem; }
.conversation-id strong { display: block; margin-top: 4px; font-size: .84rem; overflow-wrap: anywhere; }
.action-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.btn, .copy-button, .icon-button {
    border: 0; border-radius: 11px; cursor: pointer; font-weight: 700; transition: .18s ease;
}
.btn { min-height: 44px; padding: 10px 16px; }
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(.98); }
.btn:disabled { cursor: not-allowed; opacity: .45; }
.primary { color: #fff; background: var(--green); }
.primary:hover:not(:disabled) { background: var(--green-dark); }
.secondary { color: var(--green-dark); background: var(--mint); }
.danger { color: var(--red); background: #fbe9e7; }
.ghost { color: var(--ink); background: #edf0eb; }
.compact { min-height: 38px; padding: 7px 12px; }
.wide { width: 100%; margin-top: 12px; }

.license-pill, .active-dot { border-radius: 999px; padding: 8px 12px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.license-pill.ok, .active-dot { color: var(--green-dark); background: var(--mint); }
.license-pill.bad { color: var(--red); background: #fbe9e7; }
.active-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #2e9b6e; }

.workspace-card, .history-section { border-radius: 22px; padding: clamp(18px, 3vw, 28px); margin-bottom: 18px; }
.section-heading { margin-bottom: 16px; }
.message-input {
    display: block; width: 100%; min-height: 128px; resize: vertical; border: 1px solid var(--line); border-radius: 14px;
    padding: 15px 16px; color: var(--ink); background: #fbfcfa; outline: none;
}
.message-input:focus, .field:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 107, 76, .11); }
.generate-row { margin-top: 14px; }
.generate { min-width: 210px; }

.response-grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin-bottom: 18px; }
.response-grid.dual { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.response-card { border-radius: 22px; overflow: hidden; min-height: 250px; padding: clamp(18px, 3vw, 26px); display: flex; flex-direction: column; }
.response-card.accent { border-top: 4px solid var(--amber); }
.response-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.response-head strong { display: block; margin-top: 4px; }
.output-box {
    flex: 1; width: 100%; min-height: 170px; margin: 16px 0; padding: 14px; resize: vertical;
    border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fbfcfa;
    line-height: 1.6; white-space: pre-wrap;
}
.response-card.failed { border-color: #e7b6b2; }
.response-card.failed .output-box { color: #792d2d; background: #fff5f4; }
.response-card footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.copy-button { padding: 7px 11px; color: var(--green); background: var(--mint); }
.response-actions, .settings-block-head, .inline-actions {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.response-actions { min-height: 44px; margin: -5px 0 10px; }
.response-actions label { margin: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.stats-grid article { border-radius: 15px; padding: 15px; }
.stats-grid strong { display: block; margin-top: 6px; font-family: "Manrope"; }
.history-list { display: grid; gap: 10px; max-height: 480px; overflow: auto; }
.history-list article { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfa; }
.history-list article > div { display: flex; justify-content: space-between; }
.history-list time { color: var(--muted); font-size: .8rem; }
.history-list p { margin: 8px 0 0; line-height: 1.45; }
.history-list .client-line { color: var(--muted); font-size: .86rem; }

.auth-shell {
    min-height: 100vh; display: grid; place-items: center; padding: clamp(24px, 4vw, 64px);
    background:
        radial-gradient(circle at 10% 10%, rgba(22,107,76,.1), transparent 28%),
        radial-gradient(circle at 90% 90%, rgba(242,169,59,.09), transparent 25%),
        #edf1ec;
}
.auth-stage {
    width: min(1120px, 100%); min-height: min(720px, calc(100vh - 64px)); display: grid;
    grid-template-columns: minmax(420px, 1.08fr) minmax(400px, .92fr); overflow: hidden;
    border: 1px solid rgba(14,81,57,.1); border-radius: 30px; background: #fff;
    box-shadow: 0 32px 90px rgba(24,35,31,.16);
}
.auth-intro {
    position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
    padding: 46px 50px 42px; color: #fff;
    background: linear-gradient(145deg, #0b3d2d 0%, #126346 58%, #16805a 100%);
}
.auth-intro::before, .auth-intro::after {
    content: ""; position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%;
}
.auth-intro::before { width: 430px; height: 430px; right: -220px; top: -145px; }
.auth-intro::after { width: 330px; height: 330px; left: -190px; bottom: -180px; }
.brand-lockup { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup strong { font-size: 1.02rem; }
.brand-lockup span { margin-top: 3px; color: rgba(255,255,255,.62); font-size: .75rem; }
.brand-mark {
    display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 auto; border-radius: 14px;
    color: var(--green-dark); background: #fff; font-weight: 850; letter-spacing: -.05em;
}
.intro-copy { position: relative; z-index: 1; max-width: 500px; }
.intro-copy h1 { margin: 14px 0 18px; font-size: clamp(2.35rem, 4vw, 3.7rem); line-height: 1.05; letter-spacing: -.055em; }
.intro-copy > p:last-child { max-width: 440px; margin: 0; color: rgba(255,255,255,.72); font-size: 1.05rem; line-height: 1.65; }
.eyebrow.light { color: #a9e2c4; }
.trust-row { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 20px; color: rgba(255,255,255,.62); font-size: .76rem; }
.trust-row span:first-child { color: #bde8ce; }
.auth-card { align-self: center; width: 100%; padding: 54px clamp(44px, 5vw, 72px); background: #fff; }
.auth-language { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: 0 0 28px; color: var(--muted); font-size: .88rem; }
.auth-card h2 { margin: 0 0 8px; font-size: clamp(1.8rem, 3vw, 2.35rem); }
.auth-subtitle { margin-bottom: 30px; line-height: 1.55; }
.mobile-brand { display: none; }
label { display: block; margin: 13px 0 6px; font-size: .84rem; font-weight: 700; }
.field { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; outline: none; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.password-field { position: relative; }
.password-field .field { padding-right: 86px; }
.password-toggle { position: absolute; top: 50%; right: 7px; min-width: 68px; min-height: 34px; padding: 5px 9px; transform: translateY(-50%); border: 0; border-radius: 8px; color: var(--green-dark); background: var(--mint); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; }
.password-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.code-field { text-align: center; font-size: 1.3rem; letter-spacing: .28em; }
.notice, .error-box, .success-box { border-radius: 12px; padding: 12px 14px; }
.notice { background: #f0f3ee; }
.error-box { color: #792d2d; background: #fbe9e7; }
.success-box { color: var(--green-dark); background: var(--mint); }
.auth-card .error-box { margin-top: 14px; }
.auth-notice { margin-top: 14px; }
.auth-link {
    display: block; width: 100%; margin-top: 17px; padding: 7px; border: 0; color: var(--muted);
    background: transparent; cursor: pointer; font-weight: 500; text-align: center;
}
.auth-link strong { color: var(--green); }
.auth-link:hover { color: var(--green-dark); }
.auth-link:hover strong { text-decoration: underline; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(430px, calc(100vw - 40px)); box-shadow: 0 10px 30px rgba(0,0,0,.12); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: rgba(18, 30, 25, .58); backdrop-filter: blur(4px); }
.settings-modal { width: min(980px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: clamp(20px, 4vw, 30px); border-radius: 24px; background: var(--surface); box-shadow: 0 30px 100px rgba(0,0,0,.25); }
.profile-modal { width: min(720px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: clamp(20px, 4vw, 30px); border-radius: 24px; background: var(--surface); box-shadow: 0 30px 100px rgba(0,0,0,.3); }
.modal-backdrop.nested { z-index: 60; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 18px; }
.settings-block { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fbfcfa; }
.settings-block-head { margin-bottom: 12px; }
.settings-block-head strong, .settings-block-head span { display: block; }
.settings-block-head span { margin-top: 3px; color: var(--muted); font-size: .78rem; font-weight: 500; }
.compact-grid label { margin-top: 0; }
.manual-message-grid, .metadata-list { display: grid; gap: 9px; max-height: 280px; overflow: auto; padding-right: 3px; }
.manual-message-row { display: grid; grid-template-columns: 130px minmax(260px, 1fr) 38px; align-items: start; gap: 8px; }
.manual-message-row textarea { min-height: 70px; resize: vertical; }
.metadata-row { display: grid; grid-template-columns: minmax(140px, .7fr) minmax(220px, 1.3fr) 38px; gap: 8px; }
.icon-button.remove { color: var(--red); background: #fbe9e7; }
.empty-state { margin: 6px 0; color: var(--muted); font-size: .85rem; }
.profile-description { min-height: 110px; resize: vertical; }
.property-editor-list { display: grid; gap: 10px; max-height: 430px; overflow: auto; padding-right: 4px; }
.property-editor-row {
    display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(180px, 1.5fr) 145px 125px 105px;
    align-items: end; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.property-label span, .property-label strong, .property-label small { display: block; }
.property-label span { color: var(--green); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.property-label strong { margin-top: 3px; font-size: .86rem; }
.property-label small { margin-top: 3px; color: var(--muted); line-height: 1.3; }
.confidence-field { margin: 0; font-size: .72rem; color: var(--muted); }
.proposal-list { display: grid; gap: 10px; }
.proposal-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfa; }
.proposal-card.conflict { border-color: #e1b76f; background: #fffaf0; }
.proposal-copy span, .proposal-copy small { display: block; color: var(--muted); font-size: .76rem; }
.proposal-copy .field { margin: 7px 0; }
.proposal-actions { display: flex; gap: 8px; }
.conflict-note { display: block; margin-top: 7px; color: #8a5a08; font-size: .78rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.clone-wizard { width: min(680px, 100%); }
.wizard-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 24px; }
.wizard-steps span { padding: 10px; border-radius: 10px; background: var(--surface-muted); color: var(--muted); text-align: center; font-size: .88rem; }
.wizard-steps span.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.clone-category-list { display: grid; gap: 8px; max-height: 360px; overflow: auto; margin: 14px 0; padding-right: 4px; }
.clone-category { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.clone-category span { display: grid; gap: 3px; }
.clone-category small { color: var(--muted); }
.selection-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.review-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); }
.review-card p { margin: 5px 0; }
.conversation-messages-modal { width: min(820px, 100%); }
.category-content-modal { width: min(860px, 100%); }
.content-property-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.content-property-list span { padding: 7px 11px; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--border); font-size: .9rem; }
.clone-category-edit { display: block; }
.clone-category-edit > label { display: flex; align-items: center; gap: 10px; }
.clone-category-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 10px; }
.catalog-heading { position: sticky; top: -30px; z-index: 5; margin: -30px -30px 18px; padding: 24px 30px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.catalog-actions-card { align-self: start; padding: 20px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-soft); }
.catalog-actions-card .btn { width: 100%; margin-top: 10px; }
.definition-editor-modal { width: min(760px, 100%); }
.conversation-message-list { display: grid; gap: 10px; max-height: 65vh; overflow: auto; padding: 4px; }
.conversation-message { max-width: 86%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #f8faf7; }
.conversation-message.client { justify-self: start; border-bottom-left-radius: 4px; }
.conversation-message.assistant, .conversation-message.operator { justify-self: end; border-bottom-right-radius: 4px; background: var(--mint); }
.conversation-message header { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 6px; color: var(--muted); font-size: .82rem; }
.conversation-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.conversation-message small { display: block; margin-top: 7px; color: var(--muted); }
.empty-state { padding: 30px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }
.icon-button { width: 38px; height: 38px; font-size: 1.5rem; color: var(--muted); background: #edf0eb; }

@media (max-width: 850px) {
    .topbar, .conversation-strip { align-items: stretch; flex-direction: column; }
    .top-actions { justify-content: space-between; }
    .action-row { display: grid; grid-template-columns: repeat(2, 1fr); }
    .action-row .btn { width: 100%; }
    .response-grid.dual { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .auth-shell { padding: 18px; }
    .auth-stage { min-height: auto; grid-template-columns: 1fr; max-width: 520px; }
    .auth-intro { display: none; }
    .auth-card { padding: 42px; }
    .mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 38px; }
    .mobile-brand .brand-mark { width: 42px; height: 42px; color: #fff; background: var(--green); }
}

@media (max-width: 560px) {
    .app-shell { padding: 16px 12px 48px; }
    .topbar { margin-bottom: 14px; }
    .conversation-strip, .workspace-card, .history-section, .response-card { border-radius: 16px; }
    .action-row, .settings-grid { grid-template-columns: 1fr; }
    .generate-row { align-items: stretch; flex-direction: column; }
    .generate { width: 100%; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .section-heading { align-items: flex-start; }
    .response-actions, .settings-block-head { align-items: stretch; flex-direction: column; }
    .inline-actions { justify-content: flex-start; flex-wrap: wrap; }
    .manual-message-row, .metadata-row { grid-template-columns: 1fr 38px; }
    .property-editor-row { grid-template-columns: 1fr; }
    .proposal-card { grid-template-columns: 1fr; }
    .proposal-actions { justify-content: flex-end; }
    .manual-message-row select, .metadata-row > :first-child { grid-column: 1 / -1; }
    .active-dot { display: none; }
    .modal-backdrop { padding: 0; align-items: end; }
    .settings-modal { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; }
    .toast { right: 12px; bottom: 12px; max-width: calc(100vw - 24px); }
    .auth-card { padding: 30px 24px; }
    .mobile-brand { margin-bottom: 30px; }
}

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }
#blazor-error-ui { display: none; position: fixed; right: 16px; bottom: 16px; z-index: 2000; padding: 12px 16px; border-radius: 12px; color: #792d2d; background: #fbe9e7; box-shadow: var(--shadow); }
.app-loading { min-height: 100vh; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.property-selector { max-height: 230px; margin: 12px 0; padding: 12px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.property-selector .check-row { margin: 8px 0; }
.admin-grid { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.compact-field { width: 160px; min-height: 36px; padding: 6px 8px; }
.audit-list { max-height: 300px; overflow-y: auto; }
.audit-list .metadata-row { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
