/* Shared design system for the sign-in page, user panel and admin panel. */

:root {
  --bg: #0f1115;
  --surface: #181b21;
  --surface-2: #1e222a;
  --surface-3: #22262e;
  --border: #2b3039;
  --border-strong: #3a4150;
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --text-faint: #6b727c;
  --accent: #00d54b;
  --accent-dark: #04250f;
  --accent-hover: #00e953;

  --good: #00d54b;
  --good-bg: #0e2e1a;
  --warn: #f5b400;
  --warn-bg: #33270a;
  --bad: #ff6b6b;
  --bad-bg: #3a1d1d;
  --info: #59a9ff;
  --info-bg: #14243a;
  --muted: #9aa0a6;
  --muted-bg: #24282f;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: .85rem; }
.tiny { font-size: .78rem; }
.mono { font-family: var(--mono); font-size: .85em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }

/* --- Layout ------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 4px;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: 1.05rem;
  padding: 4px 10px 18px;
}
.sidebar .brand .logo { font-size: 1.3rem; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-dim); font-size: .93rem; font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface-3); color: var(--text); }
.nav-item .ico { width: 20px; text-align: center; font-size: 1rem; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); padding: 16px 12px 6px; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.content { padding: 26px 28px 60px; max-width: 1240px; width: 100%; }

.page-head { margin-bottom: 22px; }
.page-head p { color: var(--text-dim); margin-top: 5px; font-size: .92rem; max-width: 70ch; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; overflow-x: auto; padding: 10px;
    border-right: none; border-bottom: 1px solid var(--border); gap: 6px;
  }
  .sidebar .brand, .nav-section { display: none; }
  .nav-item { width: auto; white-space: nowrap; padding: 8px 12px; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* --- Cards -------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { flex: 1; }
.card-head p { color: var(--text-dim); font-size: .88rem; margin-top: 3px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* --- Stat tiles --------------------------------------------------------- */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.stat .label { color: var(--text-dim); font-size: .8rem; font-weight: 500; }
.stat .value { font-size: 1.7rem; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--text-faint); font-size: .78rem; margin-top: 2px; }
.stat.good .value { color: var(--good); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; font-size: .92rem; font-weight: 550;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-dark); }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.btn-secondary:not(:disabled):hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:not(:disabled):hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: #6b2b2b; }
.btn-danger:not(:disabled):hover { background: #4a2424; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 1rem; border-radius: 12px; }
.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }

/* --- Forms -------------------------------------------------------------- */
label, .field-label {
  display: block; font-size: .85rem; font-weight: 550;
  color: var(--text); margin-bottom: 6px;
}
.field { margin-bottom: 16px; }
.field .help { color: var(--text-dim); font-size: .82rem; margin-top: 6px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%; background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: 10px;
  color: var(--text); font-size: .95rem; padding: 10px 12px;
  outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-faint); }
input:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
select { cursor: pointer; }

.input-amount {
  font-size: 2rem; font-weight: 600; padding: 14px 16px;
  font-variant-numeric: tabular-nums;
}

.checkbox { display: flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 500; }
.checkbox input { width: auto; }

/* --- Messages ----------------------------------------------------------- */
.alert {
  border-radius: 10px; padding: 12px 14px; font-size: .89rem;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.alert .ico { flex-shrink: 0; }
.alert-error { background: var(--bad-bg); border-color: #6b2b2b; color: #ffb4b4; }
.alert-success { background: var(--good-bg); border-color: #1c6b38; color: #8ff0b3; }
.alert-warn { background: var(--warn-bg); border-color: #6b5620; color: #ffdc8a; }
.alert-info { background: var(--info-bg); border-color: #2a4d78; color: #b3d5ff; }

/* --- Badges ------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: var(--muted-bg); color: var(--muted); }
.badge.plain::before { display: none; }

/* --- Tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
thead th {
  text-align: left; padding: 11px 14px; font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  white-space: nowrap; position: sticky; top: 0;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* --- Empty / loading states --------------------------------------------- */
.empty { padding: 44px 20px; text-align: center; color: var(--text-dim); }
.empty .big { font-size: 2.4rem; margin-bottom: 10px; opacity: .75; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { font-size: .89rem; max-width: 46ch; margin: 0 auto; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; height: 14px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.25);
  border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dot-pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* --- Filters ------------------------------------------------------------ */
.filters {
  display: grid; gap: 10px; margin-bottom: 14px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
}
.filters .field { margin-bottom: 0; }
.filters label { font-size: .78rem; color: var(--text-dim); }

.pagination { display: flex; align-items: center; gap: 10px; margin-top: 14px; justify-content: flex-end; font-size: .87rem; color: var(--text-dim); }

/* --- Modal / drawer ------------------------------------------------------ */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; padding: 24px;
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { flex: 1; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.icon-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 1.2rem; padding: 2px 6px; border-radius: 6px; line-height: 1; font-family: inherit;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* --- Definition list (detail views) ------------------------------------- */
.details { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.details dt { background: var(--surface-2); padding: 9px 13px; font-size: .83rem; color: var(--text-dim); font-weight: 500; }
.details dd { background: var(--surface); padding: 9px 13px; font-size: .88rem; word-break: break-word; }

/* --- Toast -------------------------------------------------------------- */
.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 11px 18px; border-radius: 999px; font-size: .89rem; font-weight: 550;
  box-shadow: var(--shadow); animation: rise .2s ease-out; max-width: 90vw;
}
.toast.good { background: var(--accent); color: var(--accent-dark); }
.toast.bad { background: #ff6b6b; color: #3a0d0d; }
.toast.info { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* --- Steps -------------------------------------------------------------- */
.steps { display: flex; align-items: center; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 7px; font-size: .84rem; color: var(--text-faint); }
.step .num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3);
  display: grid; place-items: center; font-size: .76rem; font-weight: 650; color: var(--text-dim);
}
.step.active { color: var(--text); }
.step.active .num { background: var(--accent); color: var(--accent-dark); }
.step.done .num { background: var(--good-bg); color: var(--good); }
.step-sep { color: var(--text-faint); }

/* --- Payment method picker ---------------------------------------------- */
.method-group { margin-bottom: 20px; }
.method-group-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 9px; }
.method-group-head h3 { font-size: .92rem; }
.method-list { display: grid; gap: 9px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.method {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 14px; cursor: pointer; font-family: inherit; color: var(--text); width: 100%;
  transition: border-color .12s, background .12s;
}
.method:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-3); }
.method.selected { border-color: var(--accent); background: var(--good-bg); }
.method:disabled { opacity: .45; cursor: not-allowed; }
.method .icon { font-size: 1.5rem; width: 30px; text-align: center; flex-shrink: 0; }
.method .icon img { width: 26px; height: 26px; object-fit: contain; border-radius: 5px; }
.method .name { font-weight: 600; font-size: .92rem; }
.method .desc { color: var(--text-dim); font-size: .79rem; margin-top: 2px; line-height: 1.35; }

/* --- Amount presets ------------------------------------------------------ */
.presets { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.presets button {
  flex: 1; min-width: 62px; background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 9px; padding: 8px 0; cursor: pointer;
  font-size: .88rem; font-family: inherit; font-weight: 550;
}
.presets button:hover { background: var(--border); color: var(--text); }

/* --- Payment result screens ---------------------------------------------- */
.qr-wrap { text-align: center; margin: 18px 0; }
.qr-wrap img { border-radius: 12px; background: #fff; padding: 8px; max-width: 250px; width: 100%; }
.code-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-family: var(--mono); font-size: .74rem; color: var(--text-dim);
  word-break: break-all; max-height: 76px; overflow: hidden; margin-top: 12px;
}
.result { text-align: center; padding: 18px 0; }
.result .big { font-size: 3.2rem; line-height: 1; }
.result h2 { margin-top: 14px; }
.result p { color: var(--text-dim); margin-top: 8px; font-size: .92rem; }

.status-line { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 16px; color: var(--text-dim); font-size: .89rem; }
.timer { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

/* --- Sign-in page -------------------------------------------------------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .logo { font-size: 2.4rem; }
.auth-brand h1 { margin-top: 8px; }
.auth-brand p { color: var(--text-dim); font-size: .92rem; margin-top: 6px; }

/* --- Misc ---------------------------------------------------------------- */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .mono { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.setup-item:last-child { border-bottom: none; }
.setup-item .mark { font-size: 1.1rem; line-height: 1.4; }
.kbd { font-family: var(--mono); font-size: .8em; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 5px; }
