:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e5e5;
  --accent: #5b3df5;
  --accent-hover: #4a2fe0;
  --radius: 12px;
  --danger: #b91c1c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
}

.auth-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
}

.auth-hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.auth-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 14px;
}

.auth-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 10px;
}

.dash-layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-bottom: 24px;
}

.dash-brand a {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}
.dash-brand a:hover {
  color: var(--accent);
}

.breadcrumbs {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  min-width: 120px;
}

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.btn:hover {
  background: var(--bg);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  width: 100%;
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.btn.ghost:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.widget-label {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

.widget-value {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
}

.widget-note {
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0 0;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data th,
table.data td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data th {
  font-weight: 600;
  background: var(--bg);
  white-space: nowrap;
}

table.data tbody tr:hover {
  background: rgba(91, 61, 245, 0.04);
}

table.data a.row-link {
  color: inherit;
  text-decoration: none;
  display: block;
  margin: -10px -14px;
  padding: 10px 14px;
}
table.data a.row-link:hover {
  color: var(--accent);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 720px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.msg.client {
  border-left: 3px solid var(--accent);
}

.msg.ai {
  border-left: 3px solid #10b981;
}

.msg-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.45;
}

.page-error {
  padding: 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--danger);
}

.loading {
  color: var(--muted);
  padding: 24px;
}

.empty {
  color: var(--muted);
  padding: 16px;
  font-size: 14px;
}
