:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d8dee8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--primary);
}

.login-page {
  background:
    radial-gradient(circle at top left, rgba(219, 234, 254, 0.84), transparent 36%),
    linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%);
  min-height: 100vh;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 28px 18px;
  place-items: center;
}

.login-panel {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 22px 58px rgba(15, 23, 42, 0.12);
  padding: 30px;
  width: min(100%, 400px);
}

.login-header {
  margin-bottom: 22px;
  text-align: center;
}

.login-header h1 {
  color: #0f172a;
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1.15;
  margin: 0;
}

.login-header p {
  color: var(--muted);
  font-size: 16px;
  margin: 8px 0 0;
}

.login-form {
  display: grid;
  gap: 15px;
}

.login-form label {
  color: #0f172a;
  display: grid;
  font-weight: 700;
  gap: 7px;
}

.login-form input {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 11px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.login-form input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
  outline: none;
}

.login-submit {
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  margin-top: 6px;
  min-height: 44px;
  padding: 10px 14px;
  width: 100%;
}

.login-submit:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.login-error {
  background: var(--error-bg);
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--error-text);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  padding: 10px 12px;
  text-align: center;
}

.app-shell {
  align-items: flex-start;
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  align-self: stretch;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex: 0 0 264px;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  transition: flex-basis 0.18s ease, width 0.18s ease;
  width: 264px;
  z-index: 10;
}

.sidebar-header {
  padding: 2px 8px 10px;
}

.sidebar-title {
  color: #0f172a;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.sidebar-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
}

.sidebar-group,
.sidebar-section {
  display: grid;
  gap: 6px;
}

.sidebar-section-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0;
  text-transform: uppercase;
}

.sidebar-group-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
  text-align: left;
  width: 100%;
}

.sidebar-group-toggle:hover {
  background: transparent;
  color: var(--text);
}

.sidebar-group-chevron {
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  transition: transform 0.16s ease;
}

.sidebar-group.is-collapsed .sidebar-group-chevron {
  transform: rotate(-90deg);
}

.sidebar-group.is-collapsed .sidebar-group-content {
  display: none;
}

.sidebar-group-content {
  display: grid;
  gap: 6px;
}

.sidebar-form {
  margin: 0;
}

.sidebar-item {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  display: flex;
  font-size: 14px;
  font-weight: 600;
  gap: 10px;
  line-height: 1.2;
  padding: 10px 10px;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

button.sidebar-item {
  cursor: pointer;
}

.sidebar-item:hover {
  background: #f8fafc;
  color: var(--text);
}

.sidebar-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary);
}

.sidebar-item.disabled {
  color: #9ca3af;
  cursor: not-allowed;
}

.sidebar-item:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.sidebar-icon {
  align-items: center;
  display: inline-flex;
  flex: 0 0 20px;
  justify-content: center;
  line-height: 1;
}

.sidebar-profile-item {
  padding-left: 12px;
}

.sidebar-profile-dot {
  border-radius: 999px;
  flex: 0 0 9px;
  height: 9px;
  width: 9px;
}

.sidebar-profile-dot.enabled {
  background: #10b981;
}

.sidebar-profile-dot.disabled {
  background: #9ca3af;
}

.sidebar-badge {
  background: var(--primary);
  border-radius: 999px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  margin-left: auto;
  min-width: 22px;
  padding: 4px 7px;
  text-align: center;
}

.sidebar-toggle {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  display: flex;
  font-size: 14px;
  font-weight: 700;
  gap: 10px;
  justify-content: center;
  padding: 10px;
}

.sidebar-toggle:hover {
  background: #f8fafc;
  color: var(--text);
}

.sidebar-toggle-icon {
  font-size: 18px;
  line-height: 1;
}

body.sidebar-collapsed .sidebar {
  flex-basis: 72px;
  width: 72px;
}

body.sidebar-collapsed .sidebar-header,
body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-text,
body.sidebar-collapsed .sidebar-toggle-text,
body.sidebar-collapsed .sidebar-subtitle,
body.sidebar-collapsed .sidebar-title,
body.sidebar-collapsed .sidebar-badge {
  display: none;
}

body.sidebar-collapsed .sidebar-item,
body.sidebar-collapsed .sidebar-toggle {
  justify-content: center;
  padding-left: 8px;
  padding-right: 8px;
}

body.sidebar-collapsed .sidebar-icon {
  flex-basis: auto;
}

body.sidebar-collapsed .sidebar-group-toggle {
  justify-content: center;
  padding-left: 8px;
  padding-right: 8px;
}

body.sidebar-collapsed .sidebar-group-chevron {
  display: none;
}

body.sidebar-collapsed .sidebar-profile-dot {
  flex-basis: 9px;
}

body.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.layout {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  margin: 0 auto;
  padding: 18px 20px;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  font-size: 22px;
  font-weight: 700;
}

.topbar-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.nav a.active {
  border-color: var(--primary);
  color: var(--primary);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.panel h1,
.panel h2 {
  margin: 0 0 16px;
}

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

.metric {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.metric.small {
  min-width: 118px;
  padding: 10px 12px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
}

.metric-label {
  color: var(--muted);
  font-size: 14px;
}

.actions,
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.table-header h2 {
  margin: 0;
}

.keyword-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.keyword-search input {
  max-width: 420px;
}

[hidden] {
  display: none !important;
}

.danger-zone {
  border-color: #fecaca;
  background: #fffafa;
}

.danger-zone h2 {
  margin-bottom: 6px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.42);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 20px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 50;
}

.confirm-dialog {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.24);
  max-width: 460px;
  padding: 22px;
  width: 100%;
}

.confirm-dialog h2 {
  margin-top: 0;
}

.confirm-dialog p {
  margin-bottom: 18px;
}

input[type="text"] {
  min-width: 260px;
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: var(--panel);
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.45;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

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

button,
.button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:hover,
.button:hover {
  background: var(--primary-hover);
}

button.secondary {
  background: #4b5563;
}

button.secondary:hover {
  background: #374151;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
}

button.inline {
  padding: 7px 10px;
  font-size: 14px;
}

.button.inline-link {
  display: inline-block;
  padding: 7px 10px;
  font-size: 14px;
}

.button.secondary-link {
  background: #4b5563;
}

.button.secondary-link:hover {
  background: #374151;
}

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.alert.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.alert.error {
  background: var(--error-bg);
  color: var(--error-text);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

.messages-table {
  table-layout: fixed;
}

.messages-date-col {
  width: 86px;
}

.messages-profile-col {
  width: 88px;
}

.messages-status-col {
  width: 86px;
}

.messages-keyword-col {
  width: 105px;
}

.messages-fragment-col {
  width: 95px;
}

.messages-chat-col,
.messages-author-col {
  width: 112px;
}

.messages-link-col {
  width: 72px;
}

.messages-text-col {
  width: auto;
}

.message-date span {
  display: block;
  white-space: nowrap;
}

.message-cell {
  min-width: 300px;
}

.message-text {
  max-width: none;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  word-break: normal;
}

.message-toggle-checkbox {
  display: none;
}

.message-toggle-checkbox:not(:checked) + .message-text {
  display: -webkit-box;
  max-height: 6em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.message-toggle {
  color: var(--primary);
  cursor: pointer;
  display: inline-block;
  font-size: 14px;
  margin-top: 6px;
}

.message-hide,
.message-toggle-checkbox:checked ~ .message-toggle .message-show {
  display: none;
}

.message-toggle-checkbox:checked ~ .message-toggle .message-hide {
  display: inline;
}

.status-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
}

.profile-has-new {
  background: #eff6ff;
}

.new-count {
  background: var(--primary);
  border-radius: 999px;
  color: #ffffff;
  display: inline-block;
  font-weight: 700;
  min-width: 28px;
  padding: 3px 8px;
  text-align: center;
}

.profile-shell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  margin-bottom: 12px;
  padding: 22px;
}

.profile-header {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.profile-kicker {
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.profile-title-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-title-row h1 {
  font-size: 32px;
  line-height: 1.15;
  margin: 0;
}

.profile-description {
  color: var(--muted);
  margin: 10px 0 0;
}

.profile-status {
  align-items: center;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  padding: 5px 10px;
}

.profile-status.enabled {
  background: var(--success-bg);
  color: var(--success-text);
}

.profile-status.disabled {
  background: var(--error-bg);
  color: var(--error-text);
}

.profile-header-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-left: auto;
}

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

.profile-stat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  min-height: 94px;
  padding: 16px 18px;
}

.profile-stat-card.has-new {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.profile-stat-card .stat-label {
  color: #475569;
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.profile-stat-card strong {
  display: block;
  font-size: 28px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-stat-card .stat-subtitle {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 6px;
}

.profile-tabs-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 0 18px;
}

.profile-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.profile-tabs a {
  border-bottom: 2px solid transparent;
  color: #475569;
  font-weight: 600;
  padding: 14px 0 12px;
  text-decoration: none;
}

.profile-tabs a.active {
  background: transparent;
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.profile-overview-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(280px, 420px) minmax(280px, 1fr);
}

.overview-card h2 {
  margin-bottom: 10px;
}

.overview-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.overview-list div {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
}

.overview-list dt {
  color: var(--muted);
}

.overview-list dd {
  font-weight: 700;
  margin: 0;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-panel {
  padding: 14px 18px;
}

.data-panel {
  padding: 18px;
}

.add-panel summary {
  cursor: pointer;
  font-weight: 700;
  list-style-position: outside;
}

.add-panel form {
  margin-top: 12px;
}

.add-panel textarea {
  min-height: 112px;
}

.admin-table-header {
  align-items: center;
  margin-bottom: 10px;
}

.profile-section-heading {
  align-items: center;
}

.profile-section-heading h2 {
  margin-bottom: 0;
}

.bulk-toolbar {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.bulk-toolbar input {
  flex: 1 1 260px;
  min-width: 220px;
}

.bulk-toolbar select {
  min-width: 170px;
  padding: 8px 10px;
}

.bulk-copy-form,
.bulk-delete-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-table {
  table-layout: fixed;
}

.admin-table th,
.admin-table td {
  padding: 8px 7px;
}

.select-col {
  width: 38px;
}

.number-col {
  width: 44px;
}

.chat-input-col {
  width: 20%;
}

.chat-title-col {
  width: auto;
}

.chat-id-col {
  width: 170px;
}

.keyword-col {
  width: auto;
}

.date-col {
  width: 138px;
}

.status-col {
  width: 96px;
}

.author-col {
  width: 150px;
}

.message-wide-col {
  width: 42%;
}

.actions-col {
  width: 76px;
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.keyword-text {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.compact-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.settings-panel {
  max-width: 860px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.toggle-row {
  align-items: center;
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.list-controls,
.copy-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.list-controls input {
  max-width: 420px;
}

.copy-actions form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small-form {
  margin-top: 8px;
}

.progress-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
}

.compact-actions {
  align-items: flex-start;
  gap: 6px;
}

.candidate-controls {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.candidate-controls select,
.candidate-controls input {
  min-width: 150px;
}

.candidate-search-field {
  flex: 1 1 260px;
}

.compact-label {
  font-size: 13px;
  margin-bottom: 4px;
}

.view-toggle {
  display: flex;
  gap: 6px;
}

.view-toggle button.active {
  background: var(--primary);
}

.candidates-table {
  table-layout: fixed;
}

.candidate-number-col {
  width: 42px;
}

.candidate-title-col {
  width: 21%;
}

.candidate-link-col {
  width: 25%;
}

.candidate-type-col {
  width: 78px;
}

.candidate-source-col {
  width: 122px;
}

.candidate-detail-col {
  width: 16%;
}

.candidate-date-col {
  width: 90px;
}

.candidate-status-col {
  width: 86px;
}

.candidate-actions-col {
  width: 54px;
}

.candidate-title,
.candidates-table td {
  overflow-wrap: break-word;
  word-break: normal;
}

.candidates-table.compact-mode .candidate-detail,
.candidates-table.compact-mode .candidate-detail-col {
  display: none;
}

.row-number {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.row-menu {
  display: inline-block;
  position: relative;
}

.row-menu summary {
  align-items: center;
  background: #eef2f7;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 20px;
  height: 30px;
  justify-content: center;
  line-height: 1;
  list-style: none;
  width: 34px;
}

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

.row-menu-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  min-width: 210px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: 36px;
  z-index: 20;
}

.row-menu-list button,
.row-menu-list a {
  background: transparent;
  border-radius: 6px;
  color: var(--text);
  display: block;
  font-size: 14px;
  padding: 8px 9px;
  text-align: left;
  width: 100%;
}

.row-menu-list button:hover,
.row-menu-list a:hover {
  background: #f3f4f6;
}

.row-menu-list .danger-link {
  color: var(--danger);
}

.status-badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 13px;
  padding: 3px 8px;
}

.status-new {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-viewed {
  background: #f3f4f6;
  color: #4b5563;
}

.status-added {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-rejected {
  background: var(--error-bg);
  color: var(--error-text);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
}

.dot.on {
  background: #10b981;
}

.dot.off {
  background: #ef4444;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    min-height: auto;
    position: static;
    width: 100%;
  }

  body.sidebar-collapsed .sidebar {
    flex-basis: auto;
    width: 100%;
  }

  body.sidebar-collapsed .sidebar-nav {
    display: none;
  }

  body.sidebar-collapsed .sidebar-header {
    display: block;
  }

  body.sidebar-collapsed .sidebar-title,
  body.sidebar-collapsed .sidebar-subtitle {
    display: block;
  }

  .layout {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  td {
    border-bottom: 0;
    padding: 6px 0;
  }

  tr {
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
  }

  .message-cell {
    min-width: 0;
  }

  .message-date span {
    display: inline;
  }
}

/* Focused profile page layout. Do not affect global navigation or other pages. */
.profile-hero {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 22px;
}

.profile-hero .profile-header {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.profile-hero .profile-title-block {
  min-width: 0;
}

.profile-hero .profile-kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.profile-hero .profile-title-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.profile-hero h1 {
  font-size: 32px;
  line-height: 1.15;
  margin: 0;
}

.profile-status-badge {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  padding: 5px 10px;
}

.profile-status-badge.enabled {
  background: var(--success-bg);
  color: var(--success-text);
}

.profile-status-badge.disabled {
  background: var(--error-bg);
  color: var(--error-text);
}

.profile-description {
  color: var(--muted);
  margin: 10px 0 0;
}

.profile-hero-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.profile-hero-actions form {
  margin: 0;
}

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

.profile-stats-grid .profile-stat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 92px;
  padding: 16px 18px;
}

.profile-stats-grid .profile-stat-card.has-new {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.profile-stats-grid .profile-stat-card strong {
  color: var(--text);
  display: block;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-stats-grid .profile-stat-card .stat-label {
  color: var(--muted);
  display: block;
  font-size: 14px;
  margin-top: 8px;
}

.profile-tabs-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 10px;
}

.profile-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-tabs a {
  background: #ffffff;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  padding: 9px 12px;
  text-decoration: none;
}

.profile-tabs a:hover {
  background: #f8fafc;
  border-color: var(--border);
}

.profile-tabs a.active {
  background: #dbeafe;
  border-color: var(--primary);
  color: var(--primary);
}

@media (max-width: 900px) {
  .profile-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-hero-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 560px) {
  .profile-stats-grid {
    grid-template-columns: 1fr;
  }
}
