/* Interim palette sampled from the supplied P3A seal. Replace these tokens
   with the official brand pack values when it is delivered. */
:root {
  color-scheme: light;
  --brand: #007a46;
  --brand-dark: #005a35;
  --brand-deep: #063d2b;
  --gold: #f6c431;
  --gold-dark: #d9a91d;
  --bg: #f4f6f1;
  --panel: #ffffff;
  --text: #0f1b18;
  --muted: #5f6f6a;
  --line: #dde5e2;
  --accent: #007a46;
  --accent-dark: #005a35;
  --danger: #a53333;
  --warn: #8a6011;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  accent-color: var(--brand);
}

::selection { background: var(--gold); color: var(--brand-deep); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

p {
  color: var(--muted);
}

.link-button,
button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 11px 16px;
  text-decoration: none;
}

button:hover,
.link-button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
  padding: 12px 14px;
}

.chat-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chat-panel {
  display: grid;
  grid-template-rows: minmax(420px, 60vh) auto;
  overflow: hidden;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 20px;
}

.message {
  max-width: 780px;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.45;
}

.message.user {
  align-self: flex-end;
  background: var(--brand);
  color: #ffffff;
}

.message.bot {
  align-self: flex-start;
  background: #eef1ef;
}

.chat-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-brand img {
  display: block;
  width: 150px;
  height: auto;
}

.chat-brand-divider {
  align-self: stretch;
  width: 1px;
  background: var(--line);
}

.message.typing {
  color: var(--muted);
  font-style: italic;
}

.message.error {
  background: #fbe9e9;
  color: var(--danger);
}

.contact-form {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.contact-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.contact-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.contact-row input {
  background: var(--panel);
}

.contact-row button {
  padding: 10px 16px;
}

.contact-status {
  margin: 8px 0 0;
  min-height: 18px;
  font-size: 13px;
}

.contact-status.error {
  color: var(--danger);
}

.contact-status.success {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.panel {
  padding: 22px;
}

/* Must beat the later display rules on .banner, .stat-grid and friends, which
   otherwise win on source order at equal specificity. */
.hidden {
  display: none !important;
}

.stack {
  display: grid;
  gap: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.status {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: var(--danger);
}

.documents {
  display: grid;
  gap: 10px;
}

.doc-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

/* --------------------------------------------------------- admin dashboard */

.dashboard-body {
  background: var(--bg);
}

.dashboard {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--brand);
  color: #ffffff;
  padding: 24px 18px;
}

/* The P3A mark is dark ink on transparency, so it needs a light plate to sit
   on rather than the deep green of the sidebar. */
.brand {
  background: #ffffff;
  border-radius: 10px;
  padding: 14px 16px;
}

.brand-mark { display: block; width: min(100%, 164px); height: auto; margin-inline: auto; }

.sidebar-caption {
  margin: -12px 0 0;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 2px;
}

/* Used for both the tab buttons and the plain links in the sidebar footer, so
   the button defaults (green fill, centred text) are reset here. */
.nav-link {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
  text-align: left;
  text-decoration: none;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-link.is-active,
.nav-link.is-active:hover {
  background: var(--gold);
  color: var(--brand-deep);
}

/* Only one tab panel is ever shown, so the stacking margins between panels are
   not wanted; the last block inside a panel should not add trailing space. */
.tab-panel + .tab-panel {
  margin-top: 0;
}

.tab-panel > :last-child {
  margin-bottom: 0;
}

.sidebar-foot {
  display: grid;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 16px;
}

.sidebar-foot .ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
}

.sidebar-foot .ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

button.block {
  width: 100%;
}

.workspace {
  min-width: 0;
  padding: 30px 32px 48px;
}

.workspace-head {
  margin-bottom: 22px;
}

.workspace-head h1 {
  margin-bottom: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.link-button.ghost,
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.link-button.ghost:hover,
button.ghost:hover {
  background: #e8eeeb;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #8a2929;
}

.link-button.small,
button.small {
  font-size: 13px;
  padding: 7px 11px;
}

.panel + .panel,
.admin-grid + .panel {
  margin-top: 20px;
}

.panel.narrow {
  max-width: 420px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.panel-head h2,
.panel-head p {
  margin-bottom: 4px;
}

.panel-head p {
  font-size: 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  display: grid;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}

.stat-card.accent {
  background: #fff9e7;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 26px;
  line-height: 1.1;
}

.stat-note {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ok-text {
  color: var(--accent);
}

.warn-text {
  color: var(--warn);
}

.danger-text {
  color: var(--danger);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fdf4e3;
  border: 1px solid #edd9ad;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  color: #6d4c11;
}

.banner button {
  flex-shrink: 0;
}

.dropzone {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 26px 18px;
  cursor: pointer;
  color: var(--muted);
}

.dropzone:hover,
.dropzone.is-active {
  border-color: var(--accent);
  background: #eef5f2;
}

.dropzone strong {
  color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #f6f9f7;
}

.data-table tr.is-answered {
  color: var(--muted);
}

.question-cell {
  max-width: 380px;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  background: #e8eeeb;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.tag.ok {
  background: #dcefe4;
  color: var(--brand);
}

.tag.warn {
  background: #fbeed3;
  color: var(--warn);
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.chip {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 7px 12px;
}

.chip:hover {
  background: #e8eeeb;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.empty {
  margin: 0;
  padding: 22px 0;
  text-align: center;
  color: var(--muted);
}

.contact-request span {
  display: grid;
  gap: 4px;
}

.contact-request em {
  color: var(--muted);
  font-size: 13px;
}

.contact-request time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Sidebar folds into a header strip so the workspace keeps full width. */
  .dashboard {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
  }

  .brand {
    padding: 8px 12px;
  }

  .brand-mark {
    width: 132px;
  }

  .sidebar-caption {
    margin: 0;
  }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
  }

  .sidebar-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 0 auto;
    border-top: 0;
    padding-top: 0;
  }

  .workspace {
    padding: 22px 18px 40px;
  }
}

@media (max-width: 720px) {
  .topbar,
  .admin-grid,
  .composer {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .admin-grid {
    display: grid;
  }

  .panel-head,
  .banner {
    flex-direction: column;
    align-items: stretch;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .link-button,
  button {
    width: 100%;
    text-align: center;
  }

  .contact-row {
    grid-template-columns: 1fr;
  }
}
