/* Domain Checker — pure CSS, light & dark */

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

:root {
  --bg: #f3f3f5;
  --card: #ffffff;
  --text: #1f1f1f;
  --muted: #888888;
  --border: #e0e0e4;
  --primary: #4b00a8;
  --primary-2: #6a00d4;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --danger: #c62828;
  --danger-bg: #d32f2f;
  --success-bg: #e6f7ec;
  --success-fg: #1e7a3b;
  --indicated-bg: #fde9e9;
  --indicated-fg: #b3261e;
  --error-bg: #fff4e0;
  --error-fg: #b86b00;
  --pending-bg: #f0f0f0;
  --pending-fg: #666666;
  --active-bg: #e8f8ef;
  --active-fg: #1b7a3e;
  --toast-bg: #1f1f1f;
  --toast-fg: #ffffff;
  --overlay: rgba(15, 15, 20, 0.45);
  --transition: 180ms ease;
}

body.dark {
  --bg: #151515;
  --card: #222222;
  --text: #f2f2f2;
  --muted: #aaaaaa;
  --border: #3a3a3a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --success-bg: #1b3a28;
  --success-fg: #8fd9a8;
  --indicated-bg: #3d1f1f;
  --indicated-fg: #f0a8a4;
  --error-bg: #3d2e12;
  --error-fg: #f0c878;
  --pending-bg: #333333;
  --pending-fg: #cccccc;
  --active-bg: #1b3a28;
  --active-fg: #8fd9a8;
  --toast-bg: #efefef;
  --toast-fg: #111111;
  --overlay: rgba(0, 0, 0, 0.6);
}

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

/* -------------------------------------------------------------------------- */
/* Login                                                                      */
/* -------------------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  position: relative;
  width: min(100%, 380px);
  background: var(--card);
  border-radius: 14px;
  padding: 36px 28px 30px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  text-align: center;
  color: var(--primary);
  font-size: 22px;
  letter-spacing: 0.04em;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  margin: 8px 0 26px;
  font-size: 14px;
}

.theme-toggle {
  position: absolute;
  right: 14px;
  top: 12px;
  border: 0;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 6px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 14px 0 7px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(75, 0, 168, 0.12);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.45;
}

.turnstile-wrap {
  margin: 16px 0;
  min-height: 65px;
  display: flex;
  justify-content: center;
}

.cf-turnstile {
  width: 100%;
  display: flex;
  justify-content: center;
}

.muted-note {
  margin-top: 10px;
  line-height: 1.45;
}

.muted-note a {
  color: var(--primary);
}

.muted-note code {
  font-size: 11px;
  word-break: break-all;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.icon-btn {
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition), border-color var(--transition);
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover,
.icon-btn:hover {
  opacity: 0.92;
}

.primary-btn:disabled,
.secondary-btn:disabled,
.danger-btn:disabled,
.action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-btn {
  width: 100%;
  background: linear-gradient(90deg, var(--primary-2), var(--primary));
  color: #ffffff;
  font-weight: 700;
  margin-top: 4px;
}

.secondary-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.danger-btn {
  background: var(--danger-bg);
  color: #ffffff;
  font-weight: 700;
}

.icon-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  min-width: 42px;
  padding: 8px 12px;
  font-size: 16px;
  line-height: 1;
}

.helper {
  font-size: 12px;
  text-align: center;
  color: var(--muted);
  margin: 16px 0 0;
}

.error {
  min-height: 18px;
  color: #c62828;
  text-align: center;
  font-size: 13px;
  margin: 8px 0 0;
}

/* -------------------------------------------------------------------------- */
/* Dashboard header                                                           */
/* -------------------------------------------------------------------------- */

.topbar {
  min-height: 72px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.app-name {
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--primary);
  line-height: 1.2;
}

.user-name {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--active-bg);
  color: var(--active-fg);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22a85a;
  box-shadow: 0 0 0 3px rgba(34, 168, 90, 0.18);
}

/* -------------------------------------------------------------------------- */
/* Layout                                                                     */
/* -------------------------------------------------------------------------- */

.container {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 18px 48px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: border-color var(--transition);
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.input-hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.input-hint.has-issue {
  color: var(--error-fg);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.form-actions .primary-btn {
  width: auto;
  margin-top: 0;
}

/* -------------------------------------------------------------------------- */
/* Stats                                                                      */
/* -------------------------------------------------------------------------- */

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

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  transition: border-color var(--transition), transform var(--transition);
}

.stat-card:hover {
  border-color: rgba(75, 0, 168, 0.35);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.stat-icon {
  font-size: 14px;
  line-height: 1;
}

.stat-card strong {
  display: block;
  font-size: 26px;
  margin-top: 10px;
  letter-spacing: -0.02em;
}

/* -------------------------------------------------------------------------- */
/* Monitoring info                                                            */
/* -------------------------------------------------------------------------- */

.monitoring-panel {
  padding: 16px 20px;
}

.monitoring-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.status-pill.compact {
  margin-bottom: 0;
}

.auto-refresh-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.auto-refresh-pill.on {
  background: var(--active-bg);
  color: var(--active-fg);
  border-color: transparent;
}

.auto-refresh-pill.off .status-dot {
  background: #999;
  box-shadow: none;
}

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

.monitoring-meta .meta-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.monitoring-meta strong {
  font-size: 14px;
  font-weight: 700;
}

/* -------------------------------------------------------------------------- */
/* Toolbar / table                                                            */
/* -------------------------------------------------------------------------- */

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.search-field {
  position: relative;
  margin: 0;
  min-width: min(100%, 240px);
}

.search-field .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
}

.search-field input {
  padding-left: 34px;
  min-width: 220px;
}

#statusFilter {
  width: auto;
  min-width: 150px;
  padding: 11px 12px;
  cursor: pointer;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(75, 0, 168, 0.25);
  background: rgba(75, 0, 168, 0.06);
  border-radius: 10px;
}

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

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 13px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.col-check {
  width: 42px;
}

.col-check input {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}

.sort-btn {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  padding: 0;
}

.sort-btn.active {
  color: var(--primary);
}

.sort-indicator {
  display: inline-block;
  min-width: 1em;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: rgba(75, 0, 168, 0.04);
}

body.dark tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.actions-cell {
  white-space: nowrap;
}

.link-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.link-btn:hover strong {
  color: var(--primary);
  text-decoration: underline;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.badge-clickable {
  cursor: pointer;
}

.badge-clickable:hover {
  filter: brightness(0.97);
}

.badge.safe {
  background: var(--success-bg);
  color: var(--success-fg);
}

.badge.indicated {
  background: var(--indicated-bg);
  color: var(--indicated-fg);
}

.badge.error {
  background: var(--error-bg);
  color: var(--error-fg);
}

.badge.pending {
  background: var(--pending-bg);
  color: var(--pending-fg);
}

.change-badge {
  display: inline-block;
  margin-top: 6px;
  background: #fff3cd;
  color: #8a6d00;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.change-badge.inline {
  margin-top: 0;
  margin-left: 8px;
  vertical-align: middle;
}

body.dark .change-badge {
  background: #3d3412;
  color: #f0d878;
}

.action-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
  font-weight: 600;
  transition: opacity var(--transition);
}

.action-btn.danger {
  color: var(--danger);
}

.action-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.history-domain {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px !important;
}

.history-list {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.history-item.changed {
  border-color: rgba(138, 109, 0, 0.35);
}

.history-time {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.history-status {
  font-weight: 700;
  margin-bottom: 4px;
}

.history-change {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.detail-grid {
  display: grid;
  gap: 12px;
  margin: 14px 0 4px;
}

.detail-grid .meta-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.switch-row input {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.settings-note {
  margin-top: 14px !important;
}

.modal-wide {
  width: min(100%, 520px);
}

.modal-primary {
  width: auto;
  margin-top: 0;
}

/* -------------------------------------------------------------------------- */
/* Empty state                                                                */
/* -------------------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 42px 16px 34px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 34px;
  margin-bottom: 10px;
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 6px;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

/* -------------------------------------------------------------------------- */
/* Toast                                                                      */
/* -------------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  top: 84px;
  right: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100% - 36px));
  pointer-events: none;
}

.toast {
  background: var(--toast-bg);
  color: var(--toast-fg);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--transition), transform var(--transition);
  border-left: 4px solid transparent;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left-color: #22a85a;
}

.toast-warning {
  border-left-color: #e0a100;
}

.toast-error {
  border-left-color: #d32f2f;
}

.toast-info {
  border-left-color: #4b00a8;
}

/* -------------------------------------------------------------------------- */
/* Modal                                                                      */
/* -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--overlay);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(100%, 420px);
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.modal-card p {
  margin: 0 0 8px;
  line-height: 1.5;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* -------------------------------------------------------------------------- */
/* Responsive — legacy fallbacks (canonical rules in responsive.css)          */
/* -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .monitoring-meta {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 12px 14px;
    align-items: flex-start;
  }

  .status-pill:not(.compact) {
    display: none;
  }

  .container {
    margin-top: 16px;
    padding: 0 14px 36px;
  }

  .toolbar-left,
  .toolbar-right,
  .search-field,
  .bulk-actions {
    width: 100%;
  }

  .search-field input,
  #statusFilter {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 430px) {
  .app-name {
    font-size: 14px;
  }

  .top-actions {
    gap: 6px;
  }
}

/* -------------------------------------------------------------------------- */
/* Auth extras                                                                */
/* -------------------------------------------------------------------------- */

.brand-top {
  text-align: center;
  color: var(--primary);
  font-weight: 800;
  letter-spacing: 0.05em;
  font-size: 12px;
  margin: 0 0 10px;
}

.auth-switch {
  margin-top: 16px;
  line-height: 1.6;
}

.auth-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px;
}

.login-card a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.login-card a:hover {
  text-decoration: underline;
}

.error-list .error {
  margin: 4px 0;
}

.pending-card .info-box,
.info-box {
  background: rgba(75, 0, 168, 0.06);
  border: 1px solid rgba(75, 0, 168, 0.18);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 18px;
}

.info-box p {
  margin: 0 0 8px;
  line-height: 1.5;
}

.info-box p:last-child {
  margin-bottom: 0;
}

.full-width {
  width: 100%;
}

.link-btn-block {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  margin-top: 8px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.welcome-panel h2 {
  margin-bottom: 4px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.info-grid .meta-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.mt-16 {
  margin-top: 16px !important;
}

.flash-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100% - 32px));
}

.flash {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
  background: var(--toast-bg);
  color: var(--toast-fg);
  border-left: 4px solid #4b00a8;
}

.flash-success { border-left-color: #22a85a; }
.flash-error { border-left-color: #d32f2f; }
.flash-info { border-left-color: #4b00a8; }

.badge.status-pending { background: var(--pending-bg); color: var(--pending-fg); }
.badge.status-active { background: var(--success-bg); color: var(--success-fg); }
.badge.status-suspended { background: var(--error-bg); color: var(--error-fg); }
.badge.status-rejected { background: var(--indicated-bg); color: var(--indicated-fg); }

.account-panel {
  margin-bottom: 16px;
}

.account-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.status-dot.inline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  vertical-align: middle;
  background: #22a85a;
}

.subscription-warning {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff6e5;
  color: #8a5a00;
  border: 1px solid #f0d59a;
  font-size: 14px;
}

body.dark .subscription-warning {
  background: #3a2e14;
  color: #ffd78a;
  border-color: #6a5420;
}

.expiry-flag {
  margin-top: 4px;
  font-size: 12px;
  color: #c62828;
  font-weight: 600;
}

.expiry-flag.warn {
  color: #b26a00;
}

.admin-users-table table {
  min-width: 960px;
}

.modal-user-line {
  margin: 0 0 12px;
}

.modal-card label {
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 600;
}

.modal-card select,
.modal-card input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

@media (max-width: 720px) {
  .info-grid {
    grid-template-columns: 1fr;
  }
}
