:root {
  color-scheme: light;
  --brand: #1a6bad;
  --brand-dark: #105084;
  --brand-soft: #eaf3fa;
  --ink: #17212b;
  --muted: #526170;
  --canvas: #f3f6f8;
  --surface: #ffffff;
  --border: #d8e0e7;
  --border-strong: #b9c7d3;
  --success: #18794e;
  --success-soft: #eaf6f0;
  --warning: #795500;
  --warning-soft: #fff5d6;
  --error: #b42318;
  --error-soft: #fdedec;
  --focus: #0b78d0;
  --radius: 6px;
  --transition: 180ms cubic-bezier(0.22, 1, 0.36, 1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  color: var(--ink);
  background: var(--canvas);
  font-size: 0.9375rem;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
textarea {
  max-width: 100%;
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 40%, transparent);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: 0;
  text-wrap: balance;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.button,
.header-button,
.quick-actions button,
.icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
}

.button {
  min-height: 42px;
  padding: 0.625rem 1rem;
  font-weight: 700;
}

.button--compact {
  min-height: 34px;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
}

.button--primary {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
}

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

.button--secondary {
  color: var(--brand-dark);
  background: var(--surface);
  border-color: var(--border-strong);
}

.button--secondary:hover:not(:disabled) {
  background: var(--brand-soft);
  border-color: var(--brand);
}

.button--full {
  width: 100%;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(18rem, 0.85fr) minmax(20rem, 1.15fr);
  min-height: 100dvh;
  background: var(--surface);
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding: 3rem;
  color: #ffffff;
  background: var(--brand);
}

.login-brand img {
  width: min(20rem, 100%);
  height: auto;
  object-fit: contain;
}

.login-brand p {
  margin: 0;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 700;
}

.login-workspace {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 2rem;
}

.login-form {
  width: min(25rem, 100%);
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.login-form__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.login-form__heading h1 {
  margin: 0;
  font-size: 1.5rem;
}

.login-form__heading span {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

label {
  display: block;
  margin-bottom: 0.375rem;
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

input {
  min-height: 44px;
  padding: 0.625rem 0.75rem;
  margin-bottom: 1rem;
}

textarea {
  min-height: 56px;
  max-height: 12rem;
  padding: 0.75rem;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #5f6d79;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
  outline: 0;
}

.form-message {
  min-height: 1.5rem;
  margin: 0.25rem 0 0.75rem;
  color: var(--error);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 64px;
  padding: 0.625rem max(1rem, calc((100% - 1180px) / 2));
  color: #ffffff;
  background: var(--brand);
  border-bottom: 1px solid var(--brand-dark);
}

.app-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  color: #ffffff;
  text-decoration: none;
}

.app-brand img {
  width: 9.75rem;
  height: auto;
  flex: 0 1 auto;
}

.app-brand span {
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 1px solid rgb(255 255 255 / 0.45);
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
}

.app-commands {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.375rem;
  min-width: 0;
}

.app-user {
  max-width: 10rem;
  margin-right: 0.5rem;
  overflow: hidden;
  color: #ffffff;
  font-size: 0.8125rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-button {
  min-height: 38px;
  padding: 0.5rem 0.75rem;
  color: #ffffff;
  background: transparent;
  border-color: rgb(255 255 255 / 0.42);
  font-size: 0.8125rem;
  font-weight: 700;
}

.header-button:hover:not(:disabled) {
  background: rgb(255 255 255 / 0.14);
  border-color: #ffffff;
}

.catalog-groups { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.catalog-group { min-width: 0; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.catalog-group h2 { margin-bottom: 0.625rem; font-size: 1rem; }
.catalog-group__buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; min-width: 0; }
.catalog-group__buttons button { max-width: 100%; padding: 0.5rem 0.75rem; color: var(--brand-dark); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); font-weight: 700; overflow-wrap: anywhere; }
.catalog-group__buttons button:hover:not(:disabled) { background: var(--brand-soft); border-color: var(--brand); }

.assistant-workspace {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: min(1180px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.quick-actions button {
  min-height: 36px;
  padding: 0.4375rem 0.75rem;
  color: var(--brand-dark);
  background: var(--surface);
  border-color: var(--border-strong);
  font-size: 0.8125rem;
  font-weight: 700;
}

.quick-actions button:hover:not(:disabled) {
  background: var(--brand-soft);
  border-color: var(--brand);
}

.chat-thread {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  min-width: 0;
  padding: 2rem 0 3rem;
}

.chat-empty {
  width: min(42rem, 100%);
  margin: auto;
  padding: 2rem 1rem;
  text-align: center;
}

.chat-empty h1 {
  margin-bottom: 0.5rem;
  color: var(--ink);
  font-size: 1.625rem;
}

.chat-empty p {
  margin: 0;
  color: var(--muted);
  text-wrap: pretty;
}

.chat-entry {
  width: 100%;
  min-width: 0;
}

.chat-entry--user {
  align-self: flex-end;
  width: fit-content;
  max-width: min(44rem, 88%);
  padding: 0.75rem 1rem;
  color: var(--ink);
  background: var(--brand-soft);
  border: 1px solid #bfd9ec;
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.chat-entry--user p {
  margin: 0;
}

.assistant-result {
  min-width: 0;
  padding: 0.25rem 0;
}

.assistant-result__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.assistant-result__heading h2,
.assistant-result--error h2 {
  margin: 0;
  font-size: 1.125rem;
}

.assistant-result__count {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.assistant-result__table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.assistant-result__table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

.assistant-result__table th,
.assistant-result__table td {
  padding: 0.625rem 0.75rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.assistant-result__table th {
  color: #394b5a;
  background: #edf2f5;
  font-size: 0.75rem;
  font-weight: 800;
}

.assistant-result__table td {
  font-size: 0.8125rem;
}

.assistant-result__table tbody tr:last-child td {
  border-bottom: 0;
}

.result-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 0.75rem;
}

.assistant-result__summary {
  margin-bottom: 0.75rem;
  padding: 0.75rem 0.875rem;
  color: var(--brand-dark);
  background: #edf6fd;
  border: 1px solid #bdd9ef;
  border-radius: var(--radius);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.result-card {
  display: grid;
  gap: 0.875rem;
  min-width: 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgb(23 33 43 / 0.05);
}

.result-card__main {
  min-width: 0;
}

.result-card__main h3 {
  margin: 0 0 0.1875rem;
  color: var(--ink);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.result-card__main p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.result-card__amount {
  color: var(--brand-dark);
  font-size: 1.125rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.result-card__meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.625rem;
  margin: 0;
}

.result-card__meta div {
  min-width: 0;
}

.result-card__meta dt {
  margin: 0 0 0.125rem;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-card__meta dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.result-card__meta a {
  color: var(--brand-dark);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.result-card__note {
  margin: 0;
  padding: 0.625rem 0.75rem;
  color: #394b5a;
  background: #edf2f5;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.result-card--service-proposal {
  border-color: color-mix(in srgb, var(--brand) 32%, var(--border));
  background: #fbfdff;
}

.service-proposal[data-state="confirmed"] .result-card--service-proposal {
  border-color: color-mix(in srgb, var(--success) 34%, var(--border));
  background: var(--success-soft);
}

.service-proposal__questions {
  padding: 0.75rem;
  color: var(--warning);
  background: var(--warning-soft);
  border: 1px solid color-mix(in srgb, var(--warning) 22%, var(--border));
  border-radius: var(--radius);
}

.service-proposal__questions strong {
  display: block;
  margin-bottom: 0.375rem;
}

.service-proposal__questions ul {
  margin: 0;
  padding-left: 1.125rem;
}

.service-proposal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.assistant-result--success {
  padding: 1rem;
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid color-mix(in srgb, var(--success) 32%, var(--border));
  border-radius: var(--radius);
}

.assistant-result__notice,
.assistant-result__empty {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.assistant-result--error {
  padding: 1rem;
  color: var(--error);
  background: var(--error-soft);
  border: 1px solid #f3b8b3;
  border-radius: var(--radius);
}

.assistant-result--error p {
  margin: 0.5rem 0 0;
}

.chat-loading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.125rem 0.75rem;
  align-items: center;
  width: min(28rem, 100%);
  padding: 0.875rem 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgb(23 33 43 / 0.05);
}

.chat-loading__icon {
  grid-row: span 2;
  font-size: 1.5rem;
  line-height: 1;
  animation: loading-hourglass 1.2s ease-in-out infinite;
}

.chat-loading strong {
  font-size: 0.9375rem;
}

.chat-loading small {
  color: var(--muted);
  font-size: 0.75rem;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  width: 100%;
  min-width: 0;
  padding: 1rem 0 max(1rem, env(safe-area-inset-bottom));
  background: var(--canvas);
  border-top: 1px solid var(--border);
}

.composer__submit {
  min-width: 7rem;
  min-height: 56px;
}

.settings-dialog {
  width: min(36rem, calc(100% - 2rem));
  max-width: 100%;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgb(23 33 43 / 0.2);
}

.settings-dialog::backdrop {
  background: rgb(23 33 43 / 0.46);
}

.settings-form {
  margin: 0;
}

.settings-form__header,
.settings-form__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.settings-form__header {
  border-bottom: 1px solid var(--border);
}

.settings-form__header h2 {
  margin: 0 0 0.125rem;
  font-size: 1.125rem;
}

.settings-form__header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.settings-form__body {
  padding: 1.25rem;
}

.quick-settings {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.quick-settings__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.quick-settings__header h3 {
  margin: 0 0 0.125rem;
  font-size: 0.9375rem;
}

.quick-settings__header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.quick-settings__list {
  display: grid;
  gap: 0.75rem;
}

.quick-action-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem;
  background: #f8fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.quick-action-row__enabled,
.quick-action-row__controls label {
  display: inline-flex;
  gap: 0.375rem;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.quick-action-row__fields {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.quick-action-row__fields textarea {
  min-height: 4.75rem;
  resize: vertical;
}

.quick-action-row__controls {
  display: grid;
  gap: 0.5rem;
  justify-items: end;
}

.settings-form__actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  font-size: 1.5rem;
  line-height: 1;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--canvas);
}

.connection-status {
  margin-top: 0.25rem;
  padding: 0.625rem 0.75rem;
  color: var(--warning);
  background: var(--warning-soft);
  border: 1px solid #ead796;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.connection-status[data-state="success"] {
  color: var(--success);
  background: var(--success-soft);
  border-color: #afd8c2;
}

.connection-status[data-state="error"] {
  color: var(--error);
  background: var(--error-soft);
  border-color: #f3b8b3;
}

.settings-form__note {
  margin: 0.625rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  width: min(22rem, calc(100% - 2rem));
  padding: 0.75rem 1rem;
  color: #ffffff;
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(23 33 43 / 0.2);
  overflow-wrap: anywhere;
}

.toast[data-state="error"] {
  background: var(--error);
}

.noscript-message,
.service-error {
  width: min(36rem, calc(100% - 2rem));
  margin: 2rem auto;
  padding: 1rem;
  background: var(--warning-soft);
  border: 1px solid #ead796;
  border-radius: var(--radius);
}

.service-error {
  margin-top: 15vh;
}

.service-error h1 {
  font-size: 1.5rem;
}

.service-error p {
  margin-bottom: 0;
}

@keyframes loading-pulse {
  from { opacity: 0.48; }
  to { opacity: 1; }
}

@keyframes loading-hourglass {
  0%, 100% {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(180deg);
  }
}

@media (max-width: 760px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 11rem;
    padding: 1.5rem;
  }

  .login-brand img {
    width: min(15rem, 80%);
  }

  .login-workspace {
    place-items: start center;
    padding: 1.25rem;
  }

  .login-form {
    padding: 1.25rem;
  }

  .app-header {
    align-items: flex-start;
    gap: 0.75rem;
    min-height: 58px;
    padding: 0.625rem 0.75rem;
  }

  .app-brand img {
    width: 7.5rem;
  }

  .app-brand span,
  .app-user {
    display: none;
  }

  .app-commands {
    flex-wrap: wrap;
  }

  .header-button {
    min-height: 36px;
    padding: 0.4375rem 0.625rem;
  }

  .assistant-workspace {
    padding: 0 0.75rem;
  }

  .chat-thread {
    padding-top: 1.25rem;
  }

  .chat-entry--user {
    max-width: 94%;
  }

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

  .assistant-result__table-wrap {
    border: 0;
    background: transparent;
  }

  .assistant-result__table,
  .assistant-result__table tbody,
  .assistant-result__table tr,
  .assistant-result__table td {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  .assistant-result__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .assistant-result__table tr {
    margin-bottom: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .assistant-result__table td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.5625rem 0.75rem;
  }

  .assistant-result__table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 800;
  }

  .assistant-result__table tbody tr:last-child td {
    border-bottom: 1px solid var(--border);
  }

  .assistant-result__table td:last-child {
    border-bottom: 0;
  }

  .composer {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .composer__submit {
    width: 100%;
    min-height: 44px;
  }

  .settings-form__actions .button {
    flex: 1 1 12rem;
  }

  .quick-settings__header,
  .quick-action-row {
    grid-template-columns: 1fr;
  }

  .quick-settings__header {
    display: grid;
  }

  .quick-action-row__controls {
    justify-items: stretch;
  }
}

@media (max-width: 440px) {
  .app-header {
    align-items: center;
  }

  .app-brand img {
    width: 6.25rem;
  }

  .header-button {
    padding-inline: 0.5rem;
    font-size: 0.75rem;
  }

  .quick-actions button {
    flex: 1 1 auto;
  }

  .assistant-result__heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }

  .assistant-result__table td {
    grid-template-columns: 1fr;
    gap: 0.125rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
