:root {
  --layout-red: #b91c13;
  --layout-red-dark: #8f120d;
  --layout-red-soft: #fff1f0;

  --bg-page: #f5f6f8;
  --bg-panel: #ffffff;
  --bg-soft: #f9fafb;

  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;

  --border: #e5e7eb;
  --border-dark: #d1d5db;

  --green: #15803d;
  --green-soft: #dcfce7;

  --yellow: #a16207;
  --yellow-soft: #fef9c3;

  --red-soft: #fee2e2;

  --shadow-soft: 0 14px 35px rgba(15, 23, 42, 0.06);
  --shadow-strong: 0 24px 80px rgba(15, 23, 42, 0.30);

  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(185, 28, 19, 0.08), transparent 36rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg-page) 45%, #eef0f3 100%);
  color: var(--text-main);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 28px;
}

.auth-card {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  width: min(1040px, 100%);
  overflow: hidden;
  border-radius: 30px;
  background: #ffffff;
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--border);
}

.auth-brand {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  padding: 48px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(185, 28, 19, 0.98), rgba(143, 18, 13, 0.98)),
    var(--layout-red);
}

.auth-brand::after {
  content: "";
  position: absolute;
  right: -110px;
  bottom: -150px;
  width: 370px;
  height: 370px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
}

.auth-logo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  height: 112px;
  margin-bottom: 34px;
  padding: 18px;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.18);
}

.auth-logo {
  width: 74px;
  height: 74px;
  object-fit: contain;
}

.auth-brand span {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-brand h1 {
  position: relative;
  z-index: 1;
  max-width: 440px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.04;
}

.auth-brand p {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.05rem;
  line-height: 1.6;
}

.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}

.auth-form h2 {
  margin: 0 0 8px;
  font-size: 1.7rem;
}

.auth-form p {
  margin: 0 0 24px;
  color: var(--text-muted);
  line-height: 1.5;
}

.auth-submit {
  width: 100%;
  margin-top: 10px;
}

.auth-message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 12px;
  color: var(--layout-red-dark);
  background: var(--layout-red-soft);
  font-weight: 800;
  line-height: 1.45;
}

.app-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.app-header {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 190px;
  padding: 30px;
  border-radius: 28px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(185, 28, 19, 0.98), rgba(143, 18, 13, 0.98)),
    var(--layout-red);
  box-shadow: var(--shadow-soft);
}

.app-header::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -130px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.brand-area {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 24px;
  align-items: center;
}

.brand-logo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 92px;
  min-width: 92px;
  padding: 12px;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.18);
}

.brand-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.brand-text {
  max-width: 780px;
}

.brand-kicker {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
}

.brand-text p {
  margin: 12px 0 0;
  max-width: 760px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1rem;
  line-height: 1.55;
}

.header-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.api-status,
.app-version {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.api-status {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.16);
}

.api-online {
  color: #dcfce7;
}

.api-offline {
  color: #fee2e2;
}

.app-version {
  color: var(--layout-red-dark);
  background: rgba(255, 255, 255, 0.96);
}

.user-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 52px;
  padding: 8px 13px;
  border-radius: 999px;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.16);
}

.user-badge strong {
  max-width: 130px;
  overflow: hidden;
  font-size: 0.82rem;
  line-height: 1.1;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge span {
  margin-top: 2px;
  font-size: 0.68rem;
  line-height: 1.1;
  font-weight: 900;
  opacity: 0.92;
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.module-tab {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-main);
  background: #ffffff;
  font-weight: 900;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.module-tab:hover {
  transform: translateY(-1px);
}

.module-tab.active {
  color: #ffffff;
  background: var(--layout-red);
  border-color: var(--layout-red);
}

.module-tab-logout {
  color: var(--layout-red-dark);
  border-color: rgba(185, 28, 19, 0.22);
  background: #ffffff;
}

.module-tab-logout:hover {
  color: #ffffff;
  background: var(--layout-red);
  border-color: var(--layout-red);
}

.main-content {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 20px;
}

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

.dashboard-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.dashboard-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.dashboard-card strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.2;
}

.content-panel {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--bg-panel);
  box-shadow: var(--shadow-soft);
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-title-row h2 {
  margin: 0 0 6px;
  font-size: 1.28rem;
}

.panel-title-row p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.filter-grid {
  display: grid;
  grid-template-columns: 2fr 1.5fr 220px 160px;
  gap: 16px;
  align-items: end;
}

.users-filter-grid,
.logs-filter-grid {
  display: grid;
  grid-template-columns: 1.4fr 220px 180px auto;
  gap: 16px;
  align-items: end;
}

.logs-filter-grid {
  grid-template-columns: 1.2fr 1.3fr 160px 160px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #374151;
  font-size: 0.9rem;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-dark);
  border-radius: 12px;
  outline: none;
  color: var(--text-main);
  background: #ffffff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--layout-red);
  box-shadow: 0 0 0 4px rgba(185, 28, 19, 0.12);
}

.filter-buttons,
.filter-buttons-inline {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-buttons-inline {
  grid-column: auto;
}

.button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 0;
  font-weight: 800;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  color: #ffffff;
  background: var(--layout-red);
  box-shadow: 0 10px 22px rgba(185, 28, 19, 0.22);
}

.button-primary:hover {
  background: var(--layout-red-dark);
}

.button-secondary {
  color: var(--layout-red-dark);
  border: 1px solid rgba(185, 28, 19, 0.18);
  background: var(--layout-red-soft);
}

.button-light {
  color: var(--text-main);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.result-title-row {
  align-items: center;
}

.pagination {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pagination span {
  min-width: 120px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 800;
}

.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.table-container-spaced {
  margin-top: 18px;
}

.result-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.users-table {
  min-width: 1180px;
}

.logs-table {
  min-width: 1180px;
  table-layout: fixed;
}

.logs-table th:nth-child(1),
.logs-table td:nth-child(1) {
  width: 150px;
  white-space: nowrap;
}

.logs-table th:nth-child(2),
.logs-table td:nth-child(2) {
  width: 240px;
}

.logs-table th:nth-child(3),
.logs-table td:nth-child(3) {
  width: 80px;
  text-align: center;
}

.logs-table th:nth-child(4),
.logs-table td:nth-child(4) {
  width: 115px;
  white-space: nowrap;
}

.logs-table th:nth-child(5),
.logs-table td:nth-child(5) {
  width: 165px;
}

.logs-table th:nth-child(6),
.logs-table td:nth-child(6) {
  width: auto;
}

.logs-table th:nth-child(7),
.logs-table td:nth-child(7) {
  width: 115px;
  text-align: center;
}

.logs-table th:nth-child(8),
.logs-table td:nth-child(8) {
  width: 90px;
  text-align: center;
  white-space: nowrap;
}

.logs-table td {
  word-break: normal;
}

.logs-table .muted-text {
  display: inline-block;
  max-width: 100%;
  word-break: break-word;
}

.log-date {
  display: block;
  font-weight: 700;
  white-space: nowrap;
}

.log-time {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.log-user-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-user-email {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  word-break: break-word;
}

.log-action {
  color: var(--layout-red-dark);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.log-route-method {
  display: inline-block;
  min-width: 44px;
  color: var(--text-main);
  font-weight: 900;
}

.log-route-url {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  word-break: break-word;
}

.result-table th,
.result-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.result-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #374151;
  background: #f9fafb;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-table tbody tr:hover {
  background: #fffafa;
}

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

.code-cell {
  color: var(--layout-red-dark);
  font-weight: 900;
  white-space: nowrap;
}

.description-cell {
  max-width: 650px;
  line-height: 1.45;
}

.date-cell {
  color: #374151;
  white-space: nowrap;
}

.empty-row {
  padding: 34px !important;
  color: var(--text-muted);
  text-align: center !important;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-active {
  color: var(--green);
  background: var(--green-soft);
}

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

.status-error {
  color: var(--layout-red-dark);
  background: var(--red-soft);
}

.status-unknown {
  color: var(--yellow);
  background: var(--yellow-soft);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 260px;
}

.action-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #374151;
  background: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
}

.action-button:hover {
  color: var(--layout-red-dark);
  background: var(--layout-red-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.58);
}

.modal-card {
  display: flex;
  flex-direction: column;
  width: min(940px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--shadow-strong);
}

.modal-card-small {
  width: min(560px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 22px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(185, 28, 19, 0.98), rgba(143, 18, 13, 0.98)),
    var(--layout-red);
}

.modal-header span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
}

.modal-header h2 {
  margin: 0;
  line-height: 1.2;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 1.6rem;
  line-height: 1;
}

.modal-content {
  overflow: auto;
  padding: 22px;
}

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

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

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

.detail-box {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-soft);
}

.detail-box span,
.description-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.detail-box strong {
  word-break: break-word;
}

.description-box {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.description-box p {
  margin: 0;
  line-height: 1.55;
}

.json-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  margin-bottom: 10px;
}

.json-header h3 {
  margin: 0;
}

pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: 16px;
  color: #e5e7eb;
  background: #111827;
  font-size: 0.86rem;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  max-width: 430px;
  padding: 14px 16px;
  border-radius: 14px;
  color: #ffffff;
  background: #111827;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.error-text {
  color: var(--layout-red-dark);
  font-weight: 900;
}

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

.strong-text {
  font-weight: 900;
}

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

  .filter-grid,
  .users-filter-grid,
  .logs-filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-table {
    grid-column: 1 / -1;
  }

  .filter-buttons-inline {
    grid-column: 1 / -1;
  }
}

@media (max-width: 920px) {
  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 340px;
  }

  .module-tabs {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 28px, 1440px);
    padding-top: 14px;
  }

  .app-header,
  .brand-area,
  .panel-title-row,
  .json-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-logo-box {
    min-width: 0;
    width: 100%;
    max-width: 320px;
  }

  .header-actions {
    align-items: flex-start;
  }

  .dashboard-grid,
  .filter-grid,
  .users-filter-grid,
  .logs-filter-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .filter-buttons,
  .filter-buttons-inline,
  .modal-actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .pagination {
    width: 100%;
    justify-content: space-between;
  }

  .pagination .button {
    width: auto;
  }

  .auth-form,
  .auth-brand {
    padding: 32px;
  }

  .module-tab {
    width: 100%;
  }

  .user-badge {
    width: 100%;
    align-items: flex-start;
    border-radius: 14px;
  }
}