* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #060b17;
  color: #e7edf8;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding: 24px;
}

.page {
  max-width: 1880px;
  margin: 0 auto;
}

.auth-shell {
  min-height: calc(100vh - 48px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-page {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(360px, 520px);
  gap: 32px;
  align-items: center;
}

.auth-brand h1 {
  font-size: 52px;
}

.auth-subtitle {
  margin: 14px 0 0;
  color: #9ab0d7;
  font-size: 16px;
  line-height: 1.7;
}

.auth-card {
  margin-left: auto;
}

.topbar,
.filters,
.table-card,
.dialog-card,
.card {
  background: linear-gradient(180deg, rgba(19, 28, 46, 0.96), rgba(11, 18, 31, 0.96));
  border: 1px solid rgba(111, 141, 201, 0.2);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}

.topbar,
.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 18px;
}

.topbar {
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

h1 span {
  font-size: 14px;
  color: #8ea2c9;
  letter-spacing: 0.18em;
  margin-left: 10px;
}

#statusLine {
  margin: 8px 0 0;
  color: #91a6cb;
  font-size: 13px;
}

.toolbar,
.filters-right,
.tabs,
.window-bar,
.extra-filters,
.extra-filter-group,
.extra-filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.window-bar {
  margin: 16px 0;
}

.extra-filters {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(19, 28, 46, 0.96), rgba(11, 18, 31, 0.96));
  border: 1px solid rgba(111, 141, 201, 0.2);
}

.extra-filter-group {
  gap: 8px;
}

.subscription-window-group {
  align-items: flex-start;
  flex-direction: column;
}

.extra-filter-group label {
  color: #9fb3d8;
  font-size: 12px;
}

.extra-filter-actions {
  margin-left: auto;
}

button,
select,
input {
  border-radius: 12px;
  border: 1px solid rgba(111, 141, 201, 0.22);
  background: rgba(14, 21, 36, 0.88);
  color: #edf3ff;
  padding: 11px 14px;
  font-size: 14px;
}

button {
  cursor: pointer;
  transition: 0.18s ease;
}

button:hover,
select:hover,
input:hover {
  border-color: rgba(129, 167, 255, 0.55);
}

button.active,
.tab.active,
.window-chip.active {
  background: #5791ff;
  color: #fff;
  border-color: #5791ff;
}

button.danger {
  border-color: rgba(255, 111, 111, 0.42);
  color: #ffd7d7;
}

button.danger:hover {
  background: rgba(255, 89, 89, 0.14);
}

button.ghost:hover {
  background: rgba(88, 124, 196, 0.14);
}

.tab,
.window-chip {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(111, 141, 201, 0.22);
  background: rgba(10, 16, 27, 0.72);
  cursor: pointer;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.admin-controls {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.admin-control-card {
  border: 1px solid rgba(111, 141, 201, 0.14);
  border-radius: 16px;
  padding: 16px;
  background: rgba(12, 18, 31, 0.62);
}

.admin-control-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-control-title {
  font-size: 15px;
  font-weight: 600;
  color: #eef4ff;
}

.admin-field-matrix-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.admin-matrix-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(111, 141, 201, 0.14);
  background: rgba(10, 16, 27, 0.68);
}

.admin-matrix-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.admin-matrix-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.admin-matrix-section {
  display: grid;
  gap: 10px;
}

.admin-matrix-section-title {
  color: #dbe8ff;
  font-size: 13px;
  font-weight: 600;
}

.admin-field-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-field-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(111, 141, 201, 0.18);
  background: rgba(19, 28, 45, 0.72);
  color: #eef4ff;
  font-size: 13px;
  cursor: pointer;
}

.admin-field-chip input {
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
}

.admin-control-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.card {
  border-radius: 18px;
  padding: 18px;
}

.card-title {
  color: #94a6ca;
  font-size: 13px;
}

.card-value {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 700;
}

.table-card {
  border-radius: 20px;
  overflow: hidden;
}

.table-title {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(111, 141, 201, 0.12);
  color: #f3f7ff;
  font-size: 16px;
  font-weight: 600;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 320px);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid rgba(111, 141, 201, 0.12);
}

.pager-info {
  color: #8fa4cc;
  font-size: 13px;
}

.pager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager-actions button {
  padding: 6px 12px;
  font-size: 13px;
}

.pager-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pager-actions .pager-size {
  padding: 6px 10px;
  font-size: 13px;
}

.pager-current {
  min-width: 74px;
  text-align: center;
  color: #f3f7ff;
  font-size: 13px;
  font-weight: 600;
}

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

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(111, 141, 201, 0.09);
  white-space: nowrap;
  font-size: 14px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #101828;
  color: #a9bbdd;
  z-index: 1;
}

tr:hover td {
  background: rgba(88, 124, 196, 0.07);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.subline {
  margin-top: 4px;
  color: #7f94bc;
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.tag.low {
  background: #2f8f5a;
}

.tag.medium {
  background: #d9952f;
}

.tag.high {
  background: #d9536f;
}

.muted {
  margin-top: 8px;
  color: #89a0c8;
  font-size: 12px;
}

.empty {
  text-align: center;
  color: #91a6cb;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d6e0f5;
}

.feature-hint {
  color: #9fb3d8;
  font-size: 12px;
}

.feature-hint.ok {
  color: #93d6b0;
}

.feature-hint.warn {
  color: #ffd58f;
}

.switch input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.bar-value {
  display: inline-flex;
  min-width: 48px;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(68, 117, 233, 0.95), rgba(98, 156, 255, 0.95));
  color: #fff;
  font-weight: 700;
}

.table-action {
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  min-width: 64px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.modal.open {
  display: flex;
}

.dialog-card {
  width: min(520px, 100%);
  border-radius: 20px;
  padding: 24px;
}

.wide-card {
  width: min(1100px, 100%);
}

.dialog-card h2 {
  margin: 0 0 8px;
}

.dialog-card p {
  margin: 0 0 16px;
  color: #a4b7da;
}

.dialog-card input,
.dialog-card button {
  width: 100%;
  margin-top: 12px;
}

.login-error {
  min-height: 20px;
  margin-top: 14px;
  color: #ff9393;
  font-size: 13px;
}

.hidden {
  display: none;
}

.hint {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(57, 90, 153, 0.16);
  color: #b8c9e7;
  font-size: 13px;
}

.warn {
  color: #ffc69d !important;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions button {
  width: 100%;
}

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

.orders-list {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 240px);
  overflow: auto;
}

.order-item {
  border: 1px solid rgba(111, 141, 201, 0.16);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(12, 18, 31, 0.72);
}

.order-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 16px;
}

.order-cell-label {
  color: #8fa5cd;
  font-size: 12px;
}

.order-cell-value {
  margin-top: 4px;
  color: #eef4ff;
  font-size: 13px;
  word-break: break-all;
}

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

@media (max-width: 980px) {
  body {
    padding: 16px;
  }

  .auth-shell {
    min-height: calc(100vh - 32px);
  }

  .auth-page {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .auth-brand h1 {
    font-size: 38px;
  }

  .auth-card {
    margin-left: 0;
  }

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

  .table-wrap {
    max-height: calc(100vh - 280px);
  }
}
