:root {
  --ink: #435053;
  --muted: #707070;
  --line: #dce5ec;
  --bg: #f4f8f6;
  --panel: #ffffff;
  --green: #D68F00;
  --green-dark: #b77800;
  --chat-green: #36aa6a;
  --chat-green-dark: #2f925c;
  --chat-blue: #36aa6a;
  --chat-blue-dark: #2e925b;
  --chat-soft: #eef4fb;
  --blue: #265d8f;
  --danger: #b3261e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--muted);
}

a {
  color: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 30px 24px 22px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

.site-logo {
  display: block;
  width: clamp(126px, 12vw, 168px);
  height: auto;
  flex: 0 0 auto;
}

.brand-title {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

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

h1 {
  color: var(--ink);
  margin-bottom: 0;
  font-size: clamp(34px, 4.2vw, 48px);
  line-height: 1.05;
}

h2 {
  color: var(--ink);
  margin-bottom: 10px;
  font-size: clamp(27px, 4vw, 42px);
  line-height: 1.08;
}

h3,
.field,
.dropzone,
.panel-head h2,
.history-row strong,
.file-row strong,
.chat-head strong,
.audio-panel strong {
  color: var(--ink);
}

nav {
  display: flex;
  gap: 8px;
}

nav a,
.button,
button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

nav a {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

nav a[aria-current="page"],
button:hover,
.button:hover {
  background: var(--green-dark);
  color: #fff;
}

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

.home-layout,
.admin-layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 54px;
}

.hero,
.upload-panel,
.history-panel,
.status-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 52px rgba(18, 36, 58, 0.08);
}

.hero {
  padding: clamp(28px, 6vw, 64px);
}

.hero p {
  max-width: 780px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.status-grid article {
  padding: 20px;
}

.status-grid span {
  display: block;
  margin-bottom: 20px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.status-grid h3 {
  margin-bottom: 8px;
}

.status-grid p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 22px;
}

.upload-panel,
.history-panel {
  padding: clamp(22px, 4vw, 34px);
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-weight: 900;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid #c8d4df;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
}

.field textarea {
  resize: vertical;
}

.dropzone {
  display: grid;
  gap: 12px;
  min-height: 172px;
  margin-bottom: 16px;
  place-items: center;
  border: 1px dashed #9cb0bf;
  border-radius: 8px;
  padding: 22px;
  background: #fbfdfc;
  text-align: center;
  font-weight: 900;
}

.dropzone span {
  max-width: 520px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.file-list,
.history-list {
  display: grid;
  gap: 10px;
}

.file-row,
.history-row {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.file-row strong,
.history-row strong {
  overflow-wrap: anywhere;
}

.file-row span,
.history-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.document-list {
  display: grid;
  gap: 8px;
}

.document-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
}

.small-action {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 12px;
  font-size: 13px;
}

.small-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  padding: 0;
  background: var(--chat-green);
  border: 3px solid #fff;
  box-shadow: 0 16px 42px rgba(18, 36, 58, 0.2);
  overflow: hidden;
}

.chat-launcher:hover {
  background: var(--chat-green-dark);
  transform: translateY(-1px);
}

.chat-launcher img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-widget {
  position: fixed;
  right: 22px;
  bottom: 92px;
  display: none;
  width: min(420px, calc(100vw - 28px));
  height: min(720px, calc(100vh - 118px));
  overflow: hidden;
  border: 1px solid #b8d0eb;
  border-radius: 8px;
  background: #fbfdff;
  box-shadow: 0 22px 70px rgba(18, 36, 58, 0.22);
}

.chat-widget.is-open {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 28px 30px;
  background: var(--chat-blue);
  color: #fff;
}

.chat-head strong {
  display: block;
  color: #fff;
  font-size: 28px;
  line-height: 1.05;
}

.chat-head span {
  display: block;
  margin-top: 6px;
  color: rgba(255,255,255,0.78);
  font-size: 18px;
  font-weight: 700;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-close,
.chat-refresh {
  min-height: 44px;
  width: 44px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
}

.chat-close:hover,
.chat-refresh:hover {
  background: rgba(255,255,255,0.12);
}

.chat-close svg,
.chat-refresh svg,
.chat-tool-button svg,
.chat-send-button svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.chat-body {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 34px 26px;
  background: #fbfdff;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.bot-row {
  justify-self: start;
}

.bot-avatar {
  display: block;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(18, 36, 58, 0.12);
}

.chat-body p {
  width: fit-content;
  max-width: 86%;
  margin: 0;
  border-radius: 8px;
  padding: 16px 18px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.chat-body .bot {
  max-width: min(330px, calc(100vw - 132px));
  background: var(--chat-soft);
  color: #1f2933;
  font-size: 18px;
  line-height: 1.45;
}

.chat-body .user {
  justify-self: end;
  max-width: min(310px, calc(100vw - 82px));
  background: #dcecff;
  color: var(--ink);
}

.audio-panel {
  display: none;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.audio-panel.is-visible {
  display: block;
}

.audio-panel strong,
.audio-panel span {
  display: block;
}

.audio-panel span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.audio-panel audio {
  margin-top: 8px;
  width: 100%;
  height: 34px;
}

.chat-input {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.chat-input input {
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-weight: 500;
}

.chat-input input:focus {
  outline: 3px solid rgba(24, 93, 166, 0.18);
  border-color: var(--chat-blue);
}

.chat-tool-button,
.chat-send-button {
  min-height: 48px;
  width: 48px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--chat-blue);
}

.chat-tool-button:hover {
  background: #eef4fb;
}

.chat-tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.chat-send-button {
  background: var(--chat-blue);
  color: #fff;
}

.chat-send-button:hover {
  background: var(--chat-blue-dark);
}

.chat-tool-button.is-recording {
  background: var(--danger);
  color: #fff;
}

@media (max-width: 920px) {
  .app-header,
  .panel-head {
    display: grid;
    gap: 18px;
  }

  .brand-lockup {
    align-items: center;
  }

  .status-grid,
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-header,
  .home-layout,
  .admin-layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  nav,
  .hero-actions,
  .actions {
    display: grid;
  }

  .brand-lockup {
    gap: 14px;
  }

  .site-logo {
    width: 118px;
  }

  h1 {
    font-size: clamp(28px, 9vw, 38px);
  }

  .chat-input {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }
}
