/* ============================================================
   Paircast Admin — Dark Theme
   ============================================================ */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0b0e14;
  --panel: #141a25;
  --border: #232c3f;
  --text: #e6ebf4;
  --muted: #8c9bb4;
  --accent: #8aa2ff;
  --positive: #59d5a3;
  --warning: #ffb86b;
  --negative: #ff6b81;

  --input-bg: #0f141e;
  --input-border: #2a3450;
  --row-bg: #12161f;
  --row-hover: #1a2233;

  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-sm: 5px;
}

html {
  font-size: 15px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- Noscript ---------- */
.noscript-msg {
  background: var(--negative);
  color: #fff;
  padding: 16px 24px;
  text-align: center;
  font-weight: 600;
}

/* ============================================================
   LOGIN VIEW
   ============================================================ */
.view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 28px;
  color: var(--text);
}

.login-error {
  background: rgba(255, 107, 129, 0.12);
  border: 1px solid var(--negative);
  color: var(--negative);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.login-submit {
  width: 100%;
  margin-top: 8px;
  padding: 11px 16px;
  font-size: 0.95rem;
}

.login-note {
  text-align: center;
  font-size: 0.8rem;
  margin-top: 20px;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.view-app {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-mark {
  color: var(--accent);
  font-size: 1.2rem;
}

.brand-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 2px;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-family: inherit;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-btn:hover {
  background: rgba(138, 162, 255, 0.08);
  color: var(--text);
}

.nav-btn.active {
  background: rgba(138, 162, 255, 0.14);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Main Area ---------- */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- Content ---------- */
.content {
  padding: 28px 32px 48px;
  max-width: 1100px;
  width: 100%;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

.section-content {
  min-height: 200px;
}

/* ============================================================
   STAT GRID
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--row-bg);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--row-hover);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 20px;
  line-height: 1.4;
  white-space: nowrap;
}

.badge.green {
  background: rgba(89, 213, 163, 0.14);
  color: var(--positive);
  border: 1px solid rgba(89, 213, 163, 0.3);
}

.badge.amber {
  background: rgba(255, 184, 107, 0.14);
  color: var(--warning);
  border: 1px solid rgba(255, 184, 107, 0.3);
}

.badge.red {
  background: rgba(255, 107, 129, 0.14);
  color: var(--negative);
  border: 1px solid rgba(255, 107, 129, 0.3);
}

.badge.blue {
  background: rgba(138, 162, 255, 0.14);
  color: var(--accent);
  border: 1px solid rgba(138, 162, 255, 0.3);
}

.badge.subtle {
  background: rgba(140, 155, 180, 0.1);
  color: var(--muted);
  border: 1px solid rgba(140, 155, 180, 0.2);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:hover {
  background: #1a2233;
  border-color: #2e3a52;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0e14;
}

.btn.primary:hover {
  background: #9db2ff;
  border-color: #9db2ff;
}

.btn.danger {
  background: var(--negative);
  border-color: var(--negative);
  color: #0b0e14;
}

.btn.danger:hover {
  background: #ff8598;
  border-color: #ff8598;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn.ghost:hover {
  background: rgba(138, 162, 255, 0.08);
  color: var(--text);
  border-color: #2e3a52;
}

.btn.small {
  font-size: 0.78rem;
  padding: 5px 11px;
}

/* ============================================================
   FORMS
   ============================================================ */
.field {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: #4a5670;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 162, 255, 0.18);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238c9bb4' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
}

.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: toast-in 0.25s ease-out;
}

.toast.error {
  border-left-color: var(--negative);
  border-color: var(--negative);
}

.toast.success {
  border-left-color: var(--positive);
}

.toast.warn {
  border-left-color: var(--warning);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ============================================================
   CHART BOX
   ============================================================ */
.chart-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.chart-box svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.muted {
  color: var(--muted);
}

.mono {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.warn {
  color: var(--warning);
}

.mt {
  margin-top: 16px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ============================================================
   RESPONSIVE — < 768px
   ============================================================ */
@media (max-width: 767px) {
  .view-app {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-brand {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    padding: 8px 10px;
    gap: 4px;
    overflow-x: auto;
    width: 100%;
  }

  .nav-btn {
    width: auto;
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 0.82rem;
    flex-shrink: 0;
  }

  .main-area {
    margin-left: 0;
  }

  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 20px 16px 40px;
  }

  .section-title {
    font-size: 1.15rem;
    margin-bottom: 18px;
  }

  .grid2 {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  .modal {
    padding: 20px;
  }

  .login-card {
    padding: 28px 22px;
  }
}


/* ---- JS-generated component classes (admin.js) ---- */
.toast-error { border-left: 3px solid #ff6b81; }
.modal-card { background: #141a25; border: 1px solid #232c3f; border-radius: 12px; max-width: 480px; width: calc(100% - 32px); padding: 20px 22px; box-shadow: 0 18px 48px rgba(0,0,0,.55); }
.modal-body { margin: 12px 0 16px; color: #c8d2e4; }
.modal-textarea, .modal-body textarea, .modal-body input {
  width: 100%; background: #0f141e; border: 1px solid #2a3450; color: #e6ebf4;
  border-radius: 8px; padding: 10px 12px; font: inherit; box-sizing: border-box; }
.modal-textarea:focus, .modal-body textarea:focus, .modal-body input:focus { outline: 2px solid #8aa2ff; border-color: #8aa2ff; }
.tabs { display: flex; gap: 8px; margin: 0 0 16px; border-bottom: 1px solid #232c3f; }
.tab { background: none; border: none; color: #8c9bb4; padding: 8px 14px; cursor: pointer; font: inherit; border-bottom: 2px solid transparent; }
.tab.active { color: #e6ebf4; border-bottom-color: #8aa2ff; }
.tab-panel.hidden { display: none; }
.hidden { display: none !important; }
.data-table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 13px; }
.data-table th { text-align: left; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; color: #8c9bb4; padding: 8px 10px; border-bottom: 1px solid #232c3f; }
.data-table td { padding: 8px 10px; border-bottom: 1px solid #1b2333; color: #d5dceb; vertical-align: top; }
.data-table tr:hover td { background: #1a2233; }
.data-table .empty { color: #6d7a92; text-align: center; padding: 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 16px; }
.toolbar input, .toolbar select { background: #0f141e; border: 1px solid #2a3450; color: #e6ebf4; border-radius: 8px; padding: 8px 12px; font: inherit; }
.clickable { cursor: pointer; }
.notice { background: #16202e; border: 1px solid #2a3450; border-left: 3px solid #8aa2ff; border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; color: #c8d2e4; }
.notice.warn { border-left-color: #ffb86b; }
.profile-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 0 0 18px; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.table-block { margin: 0 0 24px; }
.chart { width: 100%; height: auto; }
.form { display: grid; gap: 12px; max-width: 460px; }
.loading { color: #8c9bb4; padding: 24px; text-align: center; }
.codes-box { background: #0f141e; border: 1px dashed #8aa2ff; border-radius: 10px; padding: 14px; margin: 0 0 16px; }
.codes-box code { display: block; margin: 6px 0; color: #59d5a3; font-family: ui-monospace, monospace; }
