@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #f6f6f2;
  --surface: #ffffff;
  --border: #e2e0d6;
  --ink: #1c1f1b;
  --muted: #6b6f66;
  --primary: #0f6b5c;
  --primary-dark: #0b5346;
  --primary-tint: #e4f0ec;
  --amber: #b8752b;
  --amber-tint: #f7ecdd;
  --red: #a8402f;
  --red-tint: #f6e6e2;
  --radius: 10px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

a { color: inherit; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* --- Layout shells --- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 1px 2px rgba(28, 31, 27, 0.04);
}

.brand {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.brand .dot { color: var(--primary); }

.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
}

input[type="checkbox"] { width: auto; accent-color: var(--primary); cursor: pointer; }

textarea { font-family: var(--font-mono); font-size: 13px; resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
}
.btn-ghost:hover { color: var(--ink); }

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  padding: 7px 13px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.back-btn:hover { color: var(--ink); border-color: var(--ink); }

.switch-line {
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
}
.switch-line button { background: none; color: var(--primary); font-weight: 600; padding: 0; }

.error-msg {
  background: var(--red-tint);
  color: var(--red);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.error-msg.show { display: block; }

.success-msg {
  background: var(--primary-tint);
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.success-msg.show { display: block; }

/* --- App shell (dashboard & admin) --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand { padding: 0 8px; margin-bottom: 24px; }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
  min-height: 40px;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--primary-tint); color: var(--primary-dark); font-weight: 600; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.main {
  flex: 1;
  padding: 28px 32px;
  max-width: 1000px;
  min-width: 0;
}

.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; margin-top: 6px; word-break: break-word; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card h3 { margin: 0 0 14px; font-size: 15px; }

.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 180px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
tbody tr:hover { background: var(--bg); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.empty-row td { text-align: center; color: var(--muted); padding: 24px; }

/* Signature element: ledger stamp badge for status */
.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  transform: rotate(-2deg);
  white-space: nowrap;
}
.stamp.approved, .stamp.paid { color: var(--primary); background: var(--primary-tint); }
.stamp.pending { color: var(--amber); background: var(--amber-tint); }
.stamp.rejected, .stamp.revoked { color: var(--red); background: var(--red-tint); }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  background: none;
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 600; }

.referral-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-tint);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--primary-dark);
  font-weight: 600;
  width: fit-content;
  max-width: 100%;
  word-break: break-all;
}

.action-btn {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
  font-weight: 600;
  margin-right: 4px;
  margin-bottom: 4px;
}
.action-approve { background: var(--primary-tint); color: var(--primary-dark); }
.action-reject { background: var(--red-tint); color: var(--red); }

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}

.hidden { display: none !important; }

main > section:not(.hidden) { animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Responsive --- */
@media (max-width: 900px) {
  .main { padding: 24px; }
}

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    align-items: center;
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(28, 31, 27, 0.05);
  }
  .sidebar .brand { display: none; }
  .sidebar-footer { display: none; }
  .nav-item { white-space: nowrap; width: auto; margin-bottom: 0; margin-right: 4px; }
  .main { padding: 18px; }
  .page-title { font-size: 19px; }
  .auth-card { padding: 26px 20px; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
}
