/* Official INDUS Tech Connect product palette. */
:root {
  color-scheme: light;
  --brand: #922BAC;
  --brand-dark: #6F1F87;
  --brand-deep: #4B125D;
  --teal: #00D6AD;
  --cyan: #00D6F6;
  --coral: #F25854;
  --bg: #F4F3FD;
  --panel: #ffffff;
  --text: #0B1B2B;
  --muted: #566171;
  --line: #DED9EE;
  --accent: #922BAC;
  --accent-dark: #6F1F87;
  --danger: #a53333;
  --warn: #8a6011;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  accent-color: var(--brand);
}

::selection { background: var(--teal); color: var(--text); }

.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: 14px;
}

.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: #F4F3FD;
}

.chat-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-brand img {
  display: block;
  width: 104px;
  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;
}

.brand {
  padding: 10px 12px;
  display: flex;
  justify-content: center;
  border-radius: 12px;
  background: #ffffff;
}

.brand-mark {
  display: block;
  width: 88px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.sidebar-caption {
  margin: -12px 0 0;
  color: var(--accent);
  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 (brand 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(--accent);
  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-login {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.workspace-login .workspace-head {
  text-align: center;
}

.workspace-login #login-panel {
  width: min(100%, 420px);
  margin-inline: auto;
}

.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: #F4F3FD;
}

.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 {
  max-height: min(62vh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #9baca6 #edf2f0;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #edf2f0;
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #9baca6;
  border: 2px solid #edf2f0;
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: #71847d;
}

.table-wrap:focus-visible {
  border-radius: 6px;
  outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 3px;
}

.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 {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  box-shadow: 0 1px 0 var(--line);
  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 {
    width: 120px;
    padding: 8px 10px;
  }

  .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) {

  .shell {
    width: min(100% - 24px, 1040px);
    padding: 18px 0;
  }

  .topbar {
    gap: 14px;
    margin-bottom: 16px;
  }

  .chat-panel {
    grid-template-rows: minmax(280px, 42vh) auto;
  }

  .table-wrap {
    max-height: min(56vh, 520px);
  }

  .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;
  }
}

.delete-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid #DED9EE;
  border-radius: 18px;
  background: #fff;
  color: #0B1B2B;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .22);
}

.delete-dialog::backdrop {
  background: rgba(11, 27, 43, .48);
  backdrop-filter: blur(3px);
}

.delete-dialog h2 {
  margin: 0 0 12px;
  font-size: 22px;
  text-align: center;
}

.delete-dialog p {
  line-height: 1.6;
  color: #566171;
}

.delete-dialog .delete-dialog-filename {
  padding: 12px 14px;
  border-radius: 8px;
  background: #F4F3FD;
  color: #0B1B2B;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.delete-dialog-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.delete-dialog .delete-dialog-cancel {
  background: #fff;
  color: #0B1B2B;
  border: 1px solid #DED9EE;
}

.delete-dialog button:focus-visible {
  outline: 3px solid #00D6AD;
  outline-offset: 3px;
}
