:root {
  --navy: #0a2c74;
  --navy-dark: #071d4d;
  --cyan: #18a0dd;
  --ink: #12181f;
  --muted: #5c6b7a;
  --border: #dfe4e9;
  --accent: var(--cyan);
  --bg: #f2f5f9;
  --danger: #c0392b;
  --ok: #1a7f37;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  -webkit-font-smoothing: antialiased;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(10, 20, 40, 0.04), 0 12px 32px rgba(10, 20, 40, 0.06);
  padding: 36px 32px;
  max-width: 420px;
  width: 100%;
}
.card.wide { max-width: 640px; }

.brand-logo { display: block; height: 40px; width: auto; margin: 0 0 20px; }
.brand-logo.small { height: 30px; margin: 0; }
.brand-row { display: flex; align-items: center; gap: 12px; min-width: 0; }

h1 { font-size: 21px; margin: 0 0 8px; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 22px; line-height: 1.5; }

form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 14px;
}
input {
  width: 100%;
  margin-top: 6px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(24, 160, 221, 0.15);
}

button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 55%, var(--cyan) 150%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity 0.15s, transform 0.05s;
}
button:hover { opacity: 0.92; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; }

.btn-ghost {
  width: auto;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
  font-weight: 500;
  padding: 9px 16px;
  font-size: 13px;
  flex-shrink: 0;
}
.btn-ghost:hover { opacity: 1; border-color: var(--muted); background: var(--bg); }

.status { font-size: 13px; margin-top: 16px; line-height: 1.5; }
.status.error { color: var(--danger); }
.status.ok { color: var(--ok); }

.alt-action { margin-top: 22px; text-align: center; }
.alt-action .link-btn { display: inline; font-size: 13px; color: var(--muted); }
.alt-action .link-btn:hover { color: var(--cyan); }

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

.brand-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.brand-header .brand-logo { height: 52px; margin: 0; flex-shrink: 0; }
.brand-header-text { min-width: 0; }
.brand-line-legal {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.brand-line-name {
  margin: 2px 0 8px;
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand-summary {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 62ch;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.small { font-size: 12px; color: var(--muted); margin: 0; }
#who { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 2px; }

.tier-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(24, 160, 221, 0.12);
  color: var(--navy);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.section { margin-top: 24px; }
.section h2 { font-size: 15px; margin: 0 0 6px; color: var(--ink); }

.breadcrumb { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.breadcrumb .link-btn { font-size: 12px; color: var(--cyan); font-weight: 600; }
.breadcrumb span.sep { color: var(--muted); font-size: 12px; }
.breadcrumb span.current { font-size: 12px; color: var(--muted); }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  width: auto;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.link-btn:hover { color: var(--cyan); opacity: 1; }

.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.doc-row:last-child { border-bottom: none; }
.doc-row.empty { color: var(--muted); font-size: 13px; padding: 16px 0; }

.doc-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
button.doc-main {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  width: auto;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
button.doc-main:hover .doc-name { color: var(--cyan); }
button.doc-main:hover { opacity: 1; }

.doc-icon { font-size: 20px; flex-shrink: 0; width: 24px; text-align: center; }
.doc-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
}
.doc-meta { font-size: 12px; color: var(--muted); }

.doc-action {
  flex-shrink: 0;
  color: #fff;
  background: var(--navy);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.doc-action:hover { background: var(--navy-dark); }

.chat-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.chat-header h2 { font-size: 15px; margin: 0 0 4px; }
.chat-header .muted-sm { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; line-height: 1.4; }

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 2px;
  margin-bottom: 10px;
}
.chat-messages:empty { display: none; }

.chat-msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.assistant { align-self: flex-start; background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-msg.assistant.pending { color: var(--muted); font-style: italic; }
.chat-msg.error { align-self: flex-start; background: #fdecea; color: var(--danger); border: 1px solid #f3c9c2; }

.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1;
  margin-top: 0;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.chat-form input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(24, 160, 221, 0.15); }
.chat-form button { width: auto; margin-top: 0; padding: 10px 18px; flex-shrink: 0; }

.chat-status { font-size: 12px; color: var(--muted); margin: 8px 0 0; min-height: 14px; }
.chat-status.error { color: var(--danger); }

@media (max-width: 480px) {
  .chat-messages { max-height: 280px; }
  .chat-msg { max-width: 94%; font-size: 13px; }
}

@media (max-width: 480px) {
  body { padding: 20px 12px; align-items: stretch; }
  .card { padding: 24px 18px; border-radius: 10px; }
  h1 { font-size: 18px; }
  .brand-logo { height: 32px; }
  .doc-action { padding: 7px 10px; font-size: 11px; }
  .doc-icon { font-size: 18px; width: 20px; }
  .brand-header { flex-direction: column; gap: 10px; padding-bottom: 16px; margin-bottom: 16px; }
  .brand-header .brand-logo { height: 40px; }
  .brand-line-name { font-size: 18px; }
}
