:root {
  --page-bg: #f4f6f8;
  --page-bg-soft: #f8fafb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #f1f5f9;

  --sidebar-bg: #18212f;
  --sidebar-bg-deep: #111923;
  --sidebar-text: #e7edf5;
  --sidebar-muted: #9dacbc;
  --sidebar-active: rgba(255, 255, 255, 0.12);

  --text: #172033;
  --text-soft: #3d4a5e;
  --muted: #708096;

  --border: #dce3ea;
  --border-soft: #e8edf2;

  --accent: #1f5e9d;
  --accent-hover: #184d81;
  --accent-soft: #e7f0f8;

  --green: #16825d;
  --green-soft: #e4f4ed;

  --orange: #a86508;
  --orange-soft: #fff3dd;

  --red: #bd3346;
  --red-soft: #fcebed;

  --purple: #7152ad;
  --purple-soft: #f0ebfa;

  --shadow: 0 10px 30px rgba(34, 51, 71, 0.08);
  --shadow-strong: 0 20px 60px rgba(24, 38, 54, 0.18);

  --sidebar-width: 270px;
  --radius: 10px;
  --radius-small: 7px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page-bg);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--page-bg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

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

button {
  border: 0;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  color: #384a61;
  background: #edf1f5;
  font-size: 0.9em;
}

/* ---------------------------------------------------------------
 * Login
 * --------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(
      135deg,
      #eef2f5 0%,
      #f9fafb 55%,
      #e9eff4 100%
    );
}

.login-card {
  width: min(100%, 410px);
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-strong);
}

.logo-mark,
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
}

.logo-mark {
  width: 48px;
  height: 48px;
  margin-bottom: 22px;
  border-radius: 8px;
  font-size: 21px;
}

.login-heading h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.04em;
}

.login-heading p {
  margin: 7px 0 27px;
  color: var(--muted);
}

.login-form,
.form-stack {
  display: grid;
  gap: 16px;
}

.login-form label,
.form-stack label {
  display: grid;
  gap: 7px;
}

.login-form label > span,
.form-stack label > span {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
}

.login-form input,
.form-stack input,
.form-stack select,
.search-box input,
.toolbar select,
.chat-composer textarea {
  width: 100%;
  outline: none;
  border: 1px solid #cbd5df;
  border-radius: var(--radius-small);
  color: var(--text);
  background: #ffffff;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.login-form input,
.form-stack input,
.form-stack select,
.toolbar select {
  height: 43px;
  padding: 0 12px;
}

.login-form input:focus,
.form-stack input:focus,
.form-stack select:focus,
.search-box input:focus,
.toolbar select:focus,
.chat-composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 94, 157, 0.13);
}

.form-error {
  padding: 10px 12px;
  border: 1px solid #edc2c9;
  border-radius: var(--radius-small);
  color: #9f2736;
  background: var(--red-soft);
  font-size: 13px;
}

.login-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* ---------------------------------------------------------------
 * Common controls
 * --------------------------------------------------------------- */

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  cursor: pointer;
  color: var(--text);
  background: transparent;
  font-weight: 700;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-primary {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-secondary {
  border-color: #cfd8e1;
  color: var(--text-soft);
  background: #ffffff;
}

.button-secondary:hover:not(:disabled) {
  border-color: #abb9c7;
  background: var(--surface-hover);
}

.button-danger-outline {
  border-color: #df9da7;
  color: #a92e3e;
  background: #ffffff;
}

.button-danger-outline:hover:not(:disabled) {
  background: var(--red-soft);
}

.button-full {
  width: 100%;
}

.link-button,
.small-link,
.button-as-link {
  padding: 0;
  cursor: pointer;
  color: var(--accent);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.link-button:hover,
.small-link:hover,
.button-as-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.icon-button {
  width: 33px;
  height: 33px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-soft);
  background: #eef2f6;
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.status-badge,
.location-badge,
.source-tag {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-success {
  color: #126b4d;
  background: var(--green-soft);
}

.status-progress {
  color: #1a5794;
  background: var(--accent-soft);
}

.status-danger {
  color: #a52a3a;
  background: var(--red-soft);
}

.status-muted,
.status-default {
  color: #5d6d80;
  background: #edf1f4;
}

.location-current,
.source-tag-current {
  color: #126b4d;
  background: var(--green-soft);
}

.location-archive,
.source-tag-archive {
  color: #65489d;
  background: var(--purple-soft);
}

.source-tag-danger {
  color: #a52a3a;
  background: var(--red-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 24px;
  border: 1px dashed #cdd7e0;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  min-height: 120px;
}

.form-help {
  margin: -5px 0 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

/* ---------------------------------------------------------------
 * Admin layout
 * --------------------------------------------------------------- */

.app-page,
.chat-page {
  overflow: hidden;
}

.app-layout,
.chat-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar,
.chat-sidebar {
  position: fixed;
  z-index: 30;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  color: var(--sidebar-text);
  background:
    linear-gradient(
      180deg,
      var(--sidebar-bg) 0%,
      var(--sidebar-bg-deep) 100%
    );
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 7px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  font-size: 17px;
}

.brand-text {
  display: grid;
  gap: 1px;
}

.brand-text strong {
  font-size: 15px;
  letter-spacing: -0.015em;
}

.brand-text span {
  color: var(--sidebar-muted);
  font-size: 11px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  margin-top: 38px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--sidebar-muted);
  background: transparent;
  text-align: left;
  font-weight: 650;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}

.nav-item:hover {
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.is-active {
  color: #ffffff;
  background: var(--sidebar-active);
}

.nav-icon {
  width: 18px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
  font-size: 16px;
}

.sidebar-bottom,
.chat-sidebar-bottom {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.current-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 7px;
}

.current-account > div:last-child {
  min-width: 0;
  display: grid;
}

.current-account strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.current-account span {
  overflow: hidden;
  color: var(--sidebar-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.avatar-admin {
  background: #7060a8;
}

.avatar-user {
  background: #24745b;
}

.sidebar-logout {
  padding: 9px 7px;
  cursor: pointer;
  color: var(--sidebar-muted);
  background: transparent;
  text-align: left;
  font-weight: 650;
}

.sidebar-logout:hover {
  color: #ffffff;
}

.mobile-sidebar-backdrop {
  display: none;
}

.main-content {
  min-width: 0;
  grid-column: 2;
  height: 100vh;
  overflow-y: auto;
  padding: 0 34px 42px;
}

.topbar {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.04em;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.mobile-menu-button {
  display: none;
  width: 37px;
  height: 37px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-soft);
  background: #eaf0f5;
  font-size: 18px;
}

.page-section {
  display: none;
}

.page-section.is-active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(36, 53, 72, 0.03);
}

.stat-card {
  min-height: 137px;
  padding: 18px;
}

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  color: var(--text);
  font-size: 28px;
  letter-spacing: -0.045em;
}

.stat-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.stat-dot-blue {
  background: var(--accent);
}

.stat-dot-green {
  background: var(--green);
}

.stat-dot-purple {
  background: var(--purple);
}

.stat-dot-orange {
  background: var(--orange);
}

.stat-card-skeleton {
  min-height: 137px;
  animation: skeleton-pulse 1.15s ease-in-out infinite alternate;
  background: #e9eef2;
}

@keyframes skeleton-pulse {
  from {
    opacity: 0.55;
  }

  to {
    opacity: 1;
  }
}

.content-grid {
  display: grid;
  gap: 16px;
  margin-top: 17px;
}

.content-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 17px;
}

.panel-header h2,
.action-panel h2,
.panel-note h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.panel-header p,
.action-panel p,
.panel-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.runs-list,
.events-list {
  display: grid;
}

.run-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 65px;
  padding: 11px 0;
  border-top: 1px solid var(--border-soft);
}

.run-item:first-child {
  border-top: 0;
}

.run-icon,
.panel-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  font-weight: 800;
}

.run-icon {
  width: 34px;
  height: 34px;
  color: #1c5c9c;
  background: var(--accent-soft);
  font-size: 17px;
}

.run-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.run-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.run-main span,
.run-side small {
  color: var(--muted);
  font-size: 11px;
}

.run-side {
  display: grid;
  justify-items: end;
  gap: 3px;
  margin-left: auto;
}

.event-item {
  display: flex;
  gap: 11px;
  min-height: 64px;
  padding: 11px 0;
  border-top: 1px solid var(--border-soft);
}

.event-item:first-child {
  border-top: 0;
}

.event-indicator {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  margin-top: 6px;
  border-radius: 50%;
}

.event-info .event-indicator {
  background: var(--accent);
}

.event-warning .event-indicator {
  background: var(--orange);
}

.event-error .event-indicator {
  background: var(--red);
}

.event-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.event-main strong {
  font-size: 12px;
  font-weight: 650;
}

.event-main span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.search-box {
  min-width: 260px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border: 1px solid #cbd5df;
  border-radius: var(--radius-small);
  color: var(--muted);
  background: #ffffff;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 94, 157, 0.13);
}

.search-box input {
  height: 41px;
  border: 0;
  background: transparent;
  box-shadow: none !important;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel .panel-header {
  padding: 20px 20px 0;
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 830px;
  border-collapse: collapse;
}

.data-table th {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: #718096;
  background: #f8fafc;
  text-align: left;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-soft);
  vertical-align: middle;
  font-size: 12px;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: #fafcff;
}

.table-loading,
.table-empty {
  padding: 42px !important;
  color: var(--muted) !important;
  text-align: center;
}

.table-project-name {
  min-width: 230px;
  display: grid;
  gap: 4px;
}

.table-project-name strong {
  color: var(--text);
  font-size: 12px;
}

.table-project-name span {
  max-width: 360px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.table-progress {
  display: grid;
  gap: 0;
}

.table-progress strong {
  color: var(--text);
}

.table-progress span {
  color: var(--muted);
  font-size: 10px;
}

.table-actions {
  width: 60px;
  text-align: right;
}

.indexing-grid {
  margin-top: 0;
}

.action-panel {
  min-height: 310px;
}

.panel-icon {
  width: 39px;
  height: 39px;
  margin-bottom: 15px;
  font-size: 20px;
}

.panel-icon-blue {
  color: #1c5c9c;
  background: var(--accent-soft);
}

.panel-icon-green {
  color: #137251;
  background: var(--green-soft);
}

.panel-icon-orange {
  color: #946000;
  background: var(--orange-soft);
}

.action-panel > p {
  max-width: 560px;
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.58;
}

.action-panel .form-stack {
  margin-top: 18px;
}

.panel-note {
  min-height: 210px;
}

.panel-note p {
  max-width: 520px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.events-full-list {
  display: grid;
  padding: 0 20px 10px;
}

.events-full-list .event-item {
  min-height: 70px;
}

.events-full-list .event-main strong {
  white-space: normal;
}

/* ---------------------------------------------------------------
 * Modal
 * --------------------------------------------------------------- */

.modal-root {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
}

.modal-root.is-open {
  display: grid;
  place-items: center;
  padding: 25px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 41, 57, 0.44);
}

.modal {
  position: relative;
  z-index: 1;
  width: min(100%, 1050px);
  max-height: min(850px, calc(100vh - 50px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--shadow-strong);
}

.modal-content {
  padding: 28px;
}

.modal-close {
  position: sticky;
  z-index: 2;
  top: 12px;
  float: right;
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-soft);
  background: #eef2f6;
  font-size: 21px;
}

.modal-close:hover {
  color: #a52a3a;
  background: var(--red-soft);
}

.project-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-right: 42px;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.project-modal-header h2 {
  max-width: 760px;
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.035em;
}

.project-modal-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.project-modal-actions,
.modal-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.project-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.project-info-grid > div {
  min-height: 78px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 13px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: #fafbfd;
}

.project-info-grid span {
  color: var(--muted);
  font-size: 10px;
}

.project-info-grid strong {
  overflow: hidden;
  color: var(--text-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.project-card-preview,
.notice-box {
  margin-top: 20px;
  padding: 17px;
  border: 1px solid #d8e4ee;
  border-radius: 8px;
  background: #f6faff;
}

.project-card-preview h3,
.project-card-preview h4 {
  margin: 0;
  color: var(--text);
}

.project-card-preview h4 {
  margin-top: 14px;
  font-size: 12px;
}

.project-card-preview p,
.notice-box {
  margin: 7px 0 0;
  color: var(--text-soft);
  white-space: pre-line;
  font-size: 12px;
  line-height: 1.58;
}

.notice-box {
  color: #445873;
}

.modal-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 27px 0 13px;
  font-size: 15px;
}

.modal-section-title span {
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--muted);
  background: #edf1f4;
  font-size: 11px;
}

.modal-files-list {
  display: grid;
  border-top: 1px solid var(--border-soft);
}

.modal-file-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}

.modal-file-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.modal-file-main strong {
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-size: 12px;
}

.modal-file-main span,
.modal-file-main small {
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 11px;
}

.error-text {
  color: #b42b3d !important;
}

.modal-file-side {
  display: grid;
  justify-items: end;
  gap: 8px;
  flex: 0 0 auto;
}

.modal-file-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

/* ---------------------------------------------------------------
 * Toast
 * --------------------------------------------------------------- */

.toast-root {
  position: fixed;
  z-index: 150;
  right: 20px;
  bottom: 20px;
  width: min(390px, calc(100vw - 40px));
  display: grid;
  gap: 9px;
}

.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 13px 13px 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-strong);
  color: var(--text-soft);
  background: #ffffff;
  animation: toast-in 0.2s ease-out;
  font-size: 13px;
}

@keyframes toast-in {
  from {
    transform: translateY(9px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast-success {
  border-left: 4px solid var(--green);
}

.toast-error {
  border-left: 4px solid var(--red);
  color: #9d2635;
}

.toast button {
  margin: -3px -3px 0 0;
  cursor: pointer;
  color: inherit;
  background: transparent;
  font-size: 19px;
  line-height: 1;
}

/* ---------------------------------------------------------------
 * Chat
 * --------------------------------------------------------------- */

.chat-layout {
  background: var(--page-bg-soft);
}

.chat-sidebar {
  padding-bottom: 17px;
}

.chat-sidebar-card {
  display: grid;
  gap: 9px;
  margin: 34px 5px 0;
  padding: 15px;
  border: 1px solid rgba(194, 211, 228, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.chat-sidebar-card-icon {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #d7e8f7;
  background: rgba(91, 148, 204, 0.28);
}

.chat-sidebar-card strong {
  font-size: 13px;
}

.chat-sidebar-card p {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 11px;
  line-height: 1.55;
}

.chat-sidebar-hints {
  display: grid;
  gap: 6px;
  margin: 27px 5px 0;
}

.chat-sidebar-hints > span {
  margin-bottom: 3px;
  padding: 0 2px;
  color: #8392a2;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.question-suggestion {
  padding: 8px 9px;
  border-radius: 5px;
  cursor: pointer;
  color: #c9d5e0;
  background: transparent;
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
}

.question-suggestion:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.chat-main {
  position: relative;
  min-width: 0;
  grid-column: 2;
  height: 100vh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #f8fafb;
}

.chat-mobile-menu-button {
  position: absolute;
  z-index: 10;
  top: 14px;
  left: 14px;
}

.chat-messages {
  overflow-y: auto;
  padding: 34px max(34px, calc((100vw - var(--sidebar-width) - 1080px) / 2));
  scroll-behavior: smooth;
}

.chat-welcome {
  width: min(100%, 820px);
  margin: 7vh auto 0;
  text-align: center;
}

.chat-welcome-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 23px;
}

.chat-welcome h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.045em;
}

.chat-welcome > p {
  max-width: 620px;
  margin: 10px auto 27px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.welcome-question-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  text-align: left;
}

.welcome-question {
  min-height: 95px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  background: #ffffff;
  text-align: left;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.welcome-question:hover {
  border-color: #9ab9d8;
  background: #f7fbff;
}

.welcome-question strong {
  font-size: 13px;
}

.welcome-question span {
  color: var(--muted);
  font-size: 11px;
}

.chat-message {
  width: min(100%, 900px);
  display: flex;
  gap: 12px;
  margin: 0 auto 26px;
}

.message-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.message-avatar-ai {
  background: var(--accent);
}

.message-avatar-user {
  background: #24745b;
}

.message-body {
  min-width: 0;
  flex: 1;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.message-meta strong {
  font-size: 12px;
}

.message-meta span {
  color: var(--muted);
  font-size: 10px;
}

.message-content {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.67;
}

.chat-message-user .message-content {
  max-width: 760px;
  padding: 12px 14px;
  border: 1px solid #d8e3ec;
  border-radius: 3px 9px 9px 9px;
  color: #22314a;
  background: #edf5fb;
}

.message-content p {
  margin: 10px 0;
}

.message-content p:first-child {
  margin-top: 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 20px 0 8px;
  color: var(--text);
  line-height: 1.3;
}

.message-content h2 {
  font-size: 17px;
}

.message-content h3 {
  font-size: 15px;
}

.message-content h4 {
  font-size: 14px;
}

.message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
}

.message-content code {
  color: #3a506a;
  background: #edf2f6;
  font-size: 0.9em;
}

.markdown-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 13px 0;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.markdown-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 12px;
}

.markdown-table th,
.markdown-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

.markdown-table th {
  color: var(--text-soft);
  background: #f6f8fa;
}

.markdown-table tr:last-child td {
  border-bottom: 0;
}

.message-actions {
  display: flex;
  gap: 9px;
  margin-top: 8px;
}

.message-copy-button {
  padding: 3px 0;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.message-copy-button:hover {
  color: var(--accent);
}

.sources-details {
  max-width: 850px;
  margin-top: 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
}

.sources-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text-soft);
  list-style: none;
  font-size: 12px;
  font-weight: 700;
}

.sources-details summary::-webkit-details-marker {
  display: none;
}

.sources-details summary::before {
  content: "›";
  color: var(--muted);
  font-size: 18px;
  transition: transform 0.15s ease;
}

.sources-details[open] summary::before {
  transform: rotate(90deg);
}

.sources-details summary strong {
  min-width: 19px;
  height: 19px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  color: #1b5b98;
  background: var(--accent-soft);
  font-size: 10px;
}

.sources-list {
  display: grid;
  padding: 0 10px 10px;
  border-top: 1px solid var(--border-soft);
}

.source-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border-soft);
}

.source-card:last-child {
  border-bottom: 0;
}

.source-card-number {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 5px;
  color: #1b5b98;
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 800;
}

.source-card-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.source-card-main strong {
  overflow: hidden;
  color: var(--text-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.source-card-main span,
.source-card-main small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.source-card-tags {
  display: flex;
  gap: 5px;
  margin-top: 3px;
}

.source-tag {
  min-height: 18px;
  padding: 2px 6px;
  font-size: 9px;
}

.source-drive-link {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  border-radius: 5px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 15px;
}

.source-drive-link:hover {
  color: #ffffff;
  background: var(--accent);
}

.chat-composer-wrap {
  padding: 10px max(34px, calc((100vw - var(--sidebar-width) - 1080px) / 2)) 14px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.chat-composer {
  width: min(100%, 900px);
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin: 0 auto;
  padding: 6px 7px 6px 12px;
  border: 1px solid #cbd5df;
  border-radius: 9px;
  background: #ffffff;
  box-shadow: 0 3px 13px rgba(31, 49, 67, 0.06);
}

.chat-composer textarea {
  max-height: 150px;
  min-height: 36px;
  resize: none;
  padding: 8px 0;
  border: 0;
  color: var(--text);
  background: transparent;
  box-shadow: none !important;
  line-height: 1.45;
}

.chat-composer textarea::placeholder {
  color: #8c9aad;
}

.chat-send-button {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  cursor: pointer;
  color: #ffffff;
  background: var(--accent);
  font-size: 20px;
  font-weight: 700;
}

.chat-send-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.chat-send-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

/* ---------------------------------------------------------------
 * Responsive
 * --------------------------------------------------------------- */

@media (max-width: 1160px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 850px) {
  :root {
    --sidebar-width: 258px;
  }

  .app-layout,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .chat-sidebar {
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-strong);
  }

  .mobile-sidebar-open .sidebar,
  .mobile-chat-sidebar-open .chat-sidebar {
    transform: translateX(0);
  }

  .mobile-sidebar-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: none;
    cursor: default;
    background: rgba(17, 27, 38, 0.32);
  }

  .mobile-sidebar-open .mobile-sidebar-backdrop,
  .mobile-chat-sidebar-open .mobile-sidebar-backdrop {
    display: block;
  }

  .main-content,
  .chat-main {
    grid-column: 1;
  }

  .main-content {
    padding: 0 18px 30px;
  }

  .topbar {
    min-height: 82px;
    justify-content: flex-start;
  }

  .mobile-menu-button {
    display: grid;
  }

  .topbar .button {
    margin-left: auto;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .content-grid-two {
    grid-template-columns: 1fr;
  }

  .chat-messages {
    padding: 24px 18px;
  }

  .chat-composer-wrap {
    padding: 9px 18px 12px;
  }

  .chat-welcome {
    margin-top: 25px;
  }
}

@media (max-width: 580px) {
  .login-card {
    padding: 28px 22px;
  }

  .topbar p {
    display: none;
  }

  .topbar .button {
    padding: 0 10px;
    font-size: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    min-height: 125px;
    padding: 14px;
  }

  .stat-card strong {
    font-size: 23px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .search-box {
    min-width: 100%;
  }

  .toolbar select {
    flex: 1;
  }

  .indexing-grid .action-panel {
    min-height: auto;
  }

  .modal-root.is-open {
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .modal-content {
    padding: 20px;
  }

  .project-modal-header {
    padding-right: 35px;
  }

  .project-modal-header h2 {
    font-size: 18px;
  }

  .project-info-grid {
    grid-template-columns: 1fr;
  }

  .modal-file-item {
    display: grid;
  }

  .modal-file-side {
    justify-items: start;
  }

  .modal-file-actions {
    justify-content: flex-start;
  }

  .welcome-question-grid {
    grid-template-columns: 1fr;
  }

  .chat-message {
    gap: 9px;
    margin-bottom: 22px;
  }

  .message-avatar {
    width: 29px;
    height: 29px;
    border-radius: 6px;
  }

  .message-content {
    font-size: 13px;
  }

  .source-card-main strong,
  .source-card-main span,
  .source-card-main small {
    white-space: normal;
  }
}