:root {
  --brand: #3366cc;
  --brand-dark: #2952a3;
  --brand-soft: #e8f0ff;
  --page: #eef3f8;
  --frame: #f8fafc;
  --ink: #091f44;
  --muted: #64748b;
  --line: #d9e2ef;
  --card: #ffffff;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 18px 42px rgba(15, 45, 90, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

a {
  color: var(--brand);
}

.app {
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.shell {
  position: relative;
  width: min(100%, 1280px);
  margin: 0 auto;
}

.topbar {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 150px;
  padding: 10px 58px 22px;
}

.brand {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.logo {
  width: min(52vw, 260px);
  height: auto;
  object-fit: contain;
  display: block;
}

.workspace {
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card,
.disclosure-card {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 28px;
}

.stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
}

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

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(51, 102, 204, 0.18);
}

.password-field {
  position: relative;
}

.password-field .input {
  padding-right: 56px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--brand);
  font-size: 1rem;
  line-height: 1;
}

.password-toggle:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.button:hover {
  background: var(--brand-dark);
}

.button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
}

.button.secondary:hover {
  background: #f7fbff;
}

.button.icon-only {
  width: 48px;
  padding: 0;
  flex: 0 0 auto;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.error {
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 800;
}

.success {
  color: var(--success);
  font-size: 0.92rem;
  font-weight: 800;
}

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

.small {
  font-size: 0.84rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(15, 45, 90, 0.07);
}

.tab {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #52627a;
  font-weight: 850;
}

.tab:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(51, 102, 204, 0.24);
}

.panel {
  min-height: calc(100vh - 285px);
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--frame);
}

.panel-title h2 {
  margin: 0;
  font-size: 1.15rem;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 360px;
  max-height: 56vh;
  overflow-y: auto;
  padding: 22px;
  background: #fff;
}

.message {
  max-width: min(86%, 760px);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: pre-wrap;
  line-height: 1.48;
  font-size: 0.96rem;
}

.message.user {
  justify-self: end;
  background: var(--brand);
  color: #fff;
}

.message.assistant {
  justify-self: start;
  background: #f3f6fa;
  border: 1px solid var(--line);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  background: var(--frame);
}

.document-tools {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.doc-list {
  display: grid;
  gap: 8px;
  max-height: 40vh;
  overflow-y: auto;
}

.doc-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.doc-item:hover {
  border-color: #bfd1ea;
  background: #f8fbff;
}

.doc-item.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(51, 102, 204, 0.12);
}

.doc-title {
  display: block;
  font-weight: 800;
}

.doc-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.viewer {
  width: 100%;
  height: 60vh;
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.settings {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.app-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 4px 4px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.footer-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px 14px;
  min-width: 0;
}

.footer-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 800;
  padding: 2px 0;
}

.footer-button:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.settings-button {
  justify-self: end;
}

.disclosure-text {
  display: grid;
  gap: 12px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
  line-height: 1.43;
}

.disclosure-text h3 {
  margin: 6px 0 0;
  font-size: 1rem;
}

.disclosure-text ul {
  margin: 0;
  padding-left: 21px;
}

.check-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
}

.check-row input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.hidden {
  display: none !important;
}

@media (min-width: 780px) {
  .app {
    padding-inline: 32px;
  }

  .login-card,
  .disclosure-card {
    padding: 34px;
  }

  .filter-row {
    grid-template-columns: 1.4fr 0.9fr 0.9fr;
  }

  .document-tools {
    grid-template-columns: 340px 1fr;
    align-items: start;
  }

  .viewer {
    height: 68vh;
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 128px;
    padding: 8px 52px 18px;
  }

  .logo {
    width: min(68vw, 200px);
  }

  .tabs {
    gap: 6px;
  }

  .tab {
    min-height: 44px;
    font-size: 0.9rem;
  }

  .panel-title,
  .chat-log,
  .composer {
    padding-inline: 14px;
  }

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