:root {
  --bg: #0A0E17;
  --panel: #111726;
  --panel-2: #161E31;
  --border: #232F46;
  --text: #F1F5F9;
  --muted: #94A3B8;
  --emerald: #00B06F;
  --emerald-2: #10B981;
  --blue: #38BDF8;
  --gold: #FBBF24;
  --danger: #EF4444;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}
button, input, select { font-family: inherit; }

.app { display: flex; flex-direction: column; min-height: 100vh; }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.14), transparent 45%),
              radial-gradient(circle at 80% 15%, rgba(251, 191, 36, 0.10), transparent 45%),
              var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-screen.hidden { display: none; }
.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.auth-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-field { margin-bottom: 12px; }

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(5, 8, 15, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask.open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
}

.topbar {
  height: 58px;
  padding: 0 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284C7, #F59E0B);
  display: grid;
  place-items: center;
  font-size: 18px;
}
.brand-title { font-size: 16px; font-weight: 800; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.nav-tabs {
  display: flex;
  gap: 6px;
  background: #0B101B;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.nav-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
}
.nav-tab.active {
  background: var(--panel-2);
  color: #fff;
  box-shadow: inset 0 0 0 1px #334155;
}

.top-actions { display: flex; align-items: center; gap: 8px; }
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0B101B;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 4px 10px;
  font-size: 12px;
}

.btn {
  border: 1px solid #334155;
  background: #1B2437;
  color: var(--text);
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.btn:hover { background: #232F46; }
.btn.primary { background: var(--emerald); border-color: #059669; color: #042015; }
.btn.blue { background: #0284C7; border-color: #0369A1; color: #fff; }
.btn.danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #FCA5A5; }
.btn.sm { padding: 4px 8px; font-size: 11.5px; border-radius: 6px; }

.main { flex: 1; padding: 20px 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.tab-pane.hidden { display: none; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.stat-val { font-size: 24px; font-weight: 800; margin-top: 6px; color: #fff; }

.card-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 15px; }

.field-lbl { font-size: 11px; color: var(--muted); display: block; margin-bottom: 4px; }
.field-inp {
  width: 100%;
  background: #141C2E;
  border: 1px solid #334155;
  border-radius: 7px;
  color: #fff;
  padding: 8px 10px;
  font-size: 12.5px;
  outline: none;
}
.field-inp:focus { border-color: var(--blue); }

.grant-form {
  display: grid;
  grid-template-columns: 180px 110px 200px 1fr auto;
  gap: 10px;
  align-items: end;
}
.grant-result {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(0, 176, 111, 0.12);
  border: 1px solid var(--emerald);
  border-radius: 10px;
  font-size: 13px;
  display: none;
}

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid #1E293B; }
th { color: var(--muted); font-weight: 700; }

.pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(56,189,248,0.15);
  color: #7DD3FC;
  display: inline-block;
}
.pill.green { background: rgba(0,176,111,0.18); color: #6EE7B7; }
.pill.gold { background: rgba(251,191,36,0.16); color: #FDE68A; }
.pill.danger { background: rgba(239,68,68,0.16); color: #FCA5A5; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999;
  background: #1E293B;
  border: 1px solid var(--emerald);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: none;
}
