* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #f5f6fb;
  color: #1b1f2a;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

body.login-centered .page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.login-centered main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.login-centered #loginView {
  width: min(420px, 100%);
  margin: 0;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.subtitle {
  margin: 0;
  color: #5a6274;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 6px 24px rgba(28, 33, 44, 0.08);
  margin-bottom: 16px;
}

.hidden {
  display: none;
}

.hint {
  margin: 0 0 16px;
  color: #5a6274;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  min-width: 160px;
}

.field input,
.field select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d6dbe5;
  font-size: 14px;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  background: #4a8fbf;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.btn:hover {
  background: #3b7aa3;
}

.btn-secondary {
  background: #e8ecf8;
  color: #2f3b52;
}

.btn-secondary:hover {
  background: #dbe1f4;
}

.error {
  color: #c0392b;
  margin-top: 10px;
}

.error-banner {
  background: #fff2f0;
  color: #c0392b;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #f7c9c2;
  margin-bottom: 12px;
  font-size: 14px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.logs-mode .controls,
.stats-mode .controls {
  opacity: 0.2;
  pointer-events: none;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-button {
  border: 1px solid #d6dbe5;
  background: #ffffff;
  color: #2f3b52;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.tab-button.active {
  background: #4a8fbf;
  color: #ffffff;
  border-color: #4a8fbf;
}



.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.feed {
  padding: 0;
}

.stats {
  padding: 18px 20px;
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  border: 1px solid #eef1f7;
  border-radius: 10px;
  padding: 12px 14px;
  background: #f9fafc;
}

.stat-title {
  font-size: 12px;
  color: #5a6274;
  margin-bottom: 6px;
}

.stat-hint {
  font-size: 11px;
  color: #8a94a6;
  margin-top: 6px;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  color: #1b1f2a;
}

.stats-lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.stats-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.stats-table {
  display: grid;
  grid-template-columns: 1.2fr 0.6fr 0.8fr;
  gap: 8px;
  font-size: 13px;
}

.stats-table > div {
  display: contents;
}

.stats-table > div > div {
  padding: 4px 0;
  border-bottom: 1px dashed #eef1f7;
}

.stats-table > div:last-child > div {
  border-bottom: none;
}

.stats-table-header {
  font-weight: 600;
  color: #5a6274;
}

.stats-table-header > div {
  border-bottom: none;
}

.stats-sort-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stats-sort-button:disabled {
  cursor: default;
  color: #5a6274;
}

.stats-sort-button.active {
  color: #1b1f2a;
}

.sort-indicator {
  font-size: 11px;
  color: #8a94a6;
}

.logs {
  padding: 18px 20px;
}

.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.logs-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logs-date {
  border: 1px solid #d6dbe5;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.logs-select {
  border: 1px solid #d6dbe5;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.logs-content {
  background: #0f1620;
  color: #d7e2f0;
  border-radius: 8px;
  padding: 12px;
  max-height: 60vh;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.logs-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.logs-tab-button {
  border: 1px solid #d6dbe5;
  background: #ffffff;
  color: #2f3b52;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.logs-tab-button.active {
  background: #4a8fbf;
  color: #ffffff;
  border-color: #4a8fbf;
}

.logs-errors {
  max-height: 60vh;
  overflow: auto;
}

.logs-errors-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  color: #5a6274;
}

.logs-errors-meta {
  font-size: 12px;
  color: #8a94a6;
}

.logs-error-card {
  border: 1px solid #eef1f7;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f9fafc;
}

.logs-error-card.is-error {
  border-color: #f2b3b3;
  background: #fff5f5;
}

.logs-error-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
}

.logs-error-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #5a6274;
  margin-bottom: 6px;
}

.logs-error-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.logs-error-details {
  background: #0f1620;
  color: #d7e2f0;
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 8px;
}

.model-link {
  color: #4a8fbf;
  cursor: pointer;
  text-decoration: underline;
}

.image-modal {
  max-width: 80vw;
  max-height: 80vh;
  width: auto;
}

.image-body {
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 55vh;
  overflow: hidden;
}

.image-body img,
.image-body video {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  width: auto;
  border-radius: 8px;
  border: 1px solid #eef1f7;
  object-fit: contain;
}

.image-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #eef1f7;
}

.feed-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: #5a6274;
}

.loading {
  color: #4a8fbf;
  font-weight: 600;
}

.activities {
  display: flex;
  flex-direction: column;
}

.activity {
  display: grid;
  grid-template-columns: 160px 1fr 140px 140px 120px 120px 2fr;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f2f8;
  font-size: 14px;
  align-items: center;
}

.activity-header {
  font-weight: 600;
  background: #f5f6fb;
}

.activity-header > div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity > div {
  white-space: normal;
  overflow: visible;
}

.activity > div .cell-muted {
  white-space: normal;
  overflow: visible;
}

.cell-muted {
  color: #5a6274;
  font-size: 11px;
  line-height: 1.2;
}

.activity:last-child {
  border-bottom: none;
}

.status-success {
  color: #1f8b4c;
  font-weight: 600;
}

.status-error {
  color: #c0392b;
  font-weight: 600;
}

.empty {
  padding: 20px;
  text-align: center;
  color: #5a6274;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid #eef1f7;
  font-size: 14px;
  color: #5a6274;
}

.page-buttons {
  display: flex;
  gap: 6px;
}

.page-button {
  border: 1px solid #d6dbe5;
  background: #ffffff;
  color: #2f3b52;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.page-button.active {
  background: #4a8fbf;
  color: #ffffff;
  border-color: #4a8fbf;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.user-link {
  color: #4a8fbf;
  cursor: pointer;
  text-decoration: underline;
}

.user-link:hover {
  color: #3b7aa3;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-split {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: min(1240px, 100%);
}

.modal-content {
  background: #ffffff;
  border-radius: 10px;
  padding: 16px 18px;
  width: 100%;
  box-shadow: 0 10px 24px rgba(28, 33, 44, 0.12);
  border: 1px solid #eef1f7;
  max-height: 80vh;
  overflow: hidden;
}

.profile-panel {
  flex: 0 0 320px;
}

.activity-panel {
  flex: 1;
}

.payment-panel {
  flex: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 13px;
  line-height: 1.4;
}

.modal-body dt {
  font-weight: 500;
  color: #5a6274;
}

.modal-body dd {
  margin: 0;
  color: #1b1f2a;
  word-break: break-word;
}

.profile-section {
  margin-bottom: 0;
}

.profile-activities {
  padding-top: 4px;
  max-height: 60vh;
  overflow: auto;
}

.profile-activities h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.profile-activity-row {
  display: grid;
  grid-template-columns: 140px 90px 110px 90px 90px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed #eef1f7;
  font-size: 13px;
}

.profile-activity-row:last-child {
  border-bottom: none;
}

.profile-activity-header {
  font-weight: 600;
  color: #5a6274;
}

.profile-payment-body {
  max-height: 60vh;
  overflow: auto;
}

.profile-payment-row {
  display: grid;
  grid-template-columns: 140px 100px 80px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed #eef1f7;
  font-size: 13px;
}

.profile-payment-row:last-child {
  border-bottom: none;
}

.profile-payment-header {
  font-weight: 600;
  color: #5a6274;
}

@media (max-width: 900px) {
  .modal-split {
    flex-direction: column;
  }

  .profile-panel {
    flex: 1;
  }
}

@media (max-width: 720px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .control-row {
    flex-direction: column;
    align-items: stretch;
  }

  .control-row .btn {
    width: 100%;
  }

  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }

  .activity {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-lists {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .activity {
    grid-template-columns: 1fr 1fr;
  }

  .activity-header {
    display: none;
  }
}
