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

:root {
  --navy:       #0D1B35;
  --navy-light: #162040;
  --pink:       #FF3FAD;
  --orange:     #FF7A2F;
  --coral:      #FF5A4A;
  --mint:       #2EDEAA;
  --blue:       #4B7EFF;
  --teal:       #2EB89A;
  --yellow:     #FFB03A;
  --surface:    #ffffff;
  --surface2:   #F4F5F9;
  --border:     #E2E5EF;
  --text:       #0D1B35;
  --text-muted: #6B7594;
  --radius:     14px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--surface2);
  color: var(--text);
  min-height: 100vh;
}

/* ═══════════════════════════════
   LOGIN SCREEN
═══════════════════════════════ */
#login-screen {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(255,63,173,0.18) 0%, transparent 65%);
  pointer-events: none;
}

#login-screen::after {
  content: '';
  position: absolute;
  bottom: -100px; left: -80px;
  width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(46,222,170,0.12) 0%, transparent 65%);
  pointer-events: none;
}

.login-card {
  background: white;
  border-radius: 24px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo-mark {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  color: white;
  letter-spacing: -1px;
  flex-shrink: 0;
}

.login-logo-text { line-height: 1.2; }
.login-logo-name { font-weight: 800; font-size: 16px; color: var(--navy); }
.login-logo-sub  { font-size: 12px; color: var(--text-muted); }

.login-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 7px;
}

.form-group { margin-bottom: 18px; }

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255,63,173,0.12);
}

.form-input.error {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255,90,74,0.12);
}

/* PIN dots */
.pin-wrap {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.pin-input {
  width: 100%;
  min-width: 0;
  padding: 14px 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-text-security: disc;
}

.pin-input:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255,63,173,0.12);
}

.pin-input.error {
  border-color: var(--coral);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-5px); }
  75%       { transform: translateX(5px); }
}

.login-error {
  background: #FFF0EE;
  border: 1px solid #FFBDB8;
  color: #8A1C14;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

.btn-login {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  color: white;
  box-shadow: 0 6px 20px rgba(255,63,173,0.35);
  transition: all 0.2s;
  margin-top: 4px;
  font-family: inherit;
}

.btn-login:hover  { opacity: 0.9; box-shadow: 0 8px 24px rgba(255,63,173,0.45); }
.btn-login:active { transform: scale(0.98); }

/* ═══════════════════════════════
   APP (post-login)
═══════════════════════════════ */
#app { display: none; }
#app.visible { display: block; }

/* ── Header ── */
header {
  background: var(--navy);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  font-weight: 800;
  font-size: 17px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: white;
  letter-spacing: -1px;
}

.logo-sub { font-size: 12px; font-weight: 400; opacity: 0.5; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

.header-user strong { color: white; }

.role-switcher {
  display: flex;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.role-btn {
  padding: 7px 18px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: rgba(255,255,255,0.5);
  transition: all 0.2s;
  font-family: inherit;
}

.role-btn.active { background: white; color: var(--navy); }

.btn-logout {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-logout:hover { border-color: rgba(255,255,255,0.4); color: white; }

/* ── Layout ── */
main { max-width: 1100px; margin: 0 auto; padding: 36px 24px; }

.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 26px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.5px; }
.page-header p  { color: var(--text-muted); font-size: 14px; }

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card:nth-child(1)::before { background: linear-gradient(90deg, var(--pink), var(--orange)); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--blue), var(--mint)); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--orange), var(--yellow)); }

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.stat-value { font-size: 36px; font-weight: 900; letter-spacing: -1px; }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Section title ── */
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Partner list ── */
.partner-list { display: flex; flex-direction: column; gap: 14px; }

.partner-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 22px 26px;
  display: grid;
  grid-template-columns: auto 200px 1fr auto;
  align-items: center;
  gap: 20px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
}

.partner-card:hover {
  box-shadow: 0 6px 20px rgba(13,27,53,0.1);
  transform: translateY(-1px);
  border-color: var(--pink);
}

.partner-card.low-tokens { border-left: 4px solid var(--coral); }

/* ── Avatar ── */
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
  letter-spacing: -0.5px;
}

.avatar img { width: 100%; height: 100%; object-fit: contain; }
.avatar.has-logo { background: #fff; border: 1px solid var(--border); padding: 7px; }
.avatar-lg  { width: 64px; height: 64px; border-radius: 18px; font-size: 20px; }
.avatar-lg.has-logo { padding: 9px; }

.partner-name { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.partner-meta { font-size: 12px; color: var(--text-muted); }

/* ── Token bar ── */
.token-bar-wrap { min-width: 0; }

.token-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.token-bar-labels strong { color: var(--text); font-weight: 700; }

.token-bar { height: 8px; background: #ECEEF4; border-radius: 99px; overflow: hidden; }

.token-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}

.fill-green  { background: linear-gradient(90deg, var(--mint), var(--teal)); }
.fill-yellow { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.fill-red    { background: linear-gradient(90deg, var(--coral), var(--pink)); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-warning { background: #FFF3D6; color: #8A5700; }
.badge-danger  { background: #FFE8E6; color: #9B2318; }
.badge-ok      { background: #D6FAF0; color: #0B6B4A; }

/* ── Buttons ── */
.btn {
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-light); }

.btn-accent {
  background: linear-gradient(135deg, var(--pink), var(--orange));
  color: white;
  box-shadow: 0 4px 14px rgba(255,63,173,0.3);
}

.btn-accent:hover { opacity: 0.9; }

.btn-outline {
  background: white;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-outline:hover { border-color: var(--pink); color: var(--pink); }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }

/* ── Alerts ── */
.alert {
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.5;
}

.alert-warning { background: #FFF8E6; border: 1px solid #FFD98A; color: #7A4A00; }
.alert-danger  { background: #FFF0EE; border: 1px solid #FFBDB8; color: #8A1C14; }
.top-alerts { margin-bottom: 24px; }

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,27,53,0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal-backdrop.open { display: flex; }

.modal {
  background: white;
  border-radius: 20px;
  width: 620px;
  max-width: calc(100vw - 32px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(13,27,53,0.25);
  animation: popIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header-left { display: flex; align-items: center; gap: 16px; }

.modal-close {
  background: #F0F2F8;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  font-family: inherit;
}

.modal-close:hover { background: #E2E5EF; color: var(--text); }

/* ── Log entries ── */
.log-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.log-entry {
  background: var(--surface2);
  border-radius: 12px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 12px;
}

.log-entry-date { font-size: 11px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.log-entry-desc { font-size: 13px; line-height: 1.55; }

.log-entry-tokens {
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-delete-log {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  padding: 2px 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
  opacity: 0;
  font-family: inherit;
}

.log-entry:hover .btn-delete-log { opacity: 1; }
.btn-delete-log:hover { color: var(--coral); background: #FFF0EE; }

/* ── Forms ── */
.form-group-modal { margin-bottom: 16px; }

.form-input-modal, .form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
}

.form-input-modal:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255,63,173,0.12);
}

.form-textarea { resize: vertical; min-height: 84px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; }

/* ── Box sections ── */
.box-section {
  border-radius: 14px;
  padding: 20px;
  border: 1.5px dashed var(--border);
  background: var(--surface2);
}

.box-section-green { border-color: #A8F0DA; background: #F0FDF8; }
.box-section-blue  { border-color: #B0C8FF; background: #F0F4FF; }

.box-section-title { font-size: 14px; font-weight: 800; margin-bottom: 14px; }

/* ── Package chips ── */
.package-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.package-chip {
  padding: 8px 18px;
  border-radius: 99px;
  border: 2px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: white;
  transition: all 0.18s;
  color: var(--text);
  font-family: inherit;
}

.package-chip:hover    { border-color: var(--pink); color: var(--pink); }
.package-chip.selected {
  border-color: transparent;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  color: white;
  box-shadow: 0 4px 12px rgba(255,63,173,0.3);
}

hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

.view        { display: none; }
.view.active { display: block; }

/* ── Partner Hero ── */
.partner-hero {
  background: var(--navy);
  color: white;
  border-radius: 20px;
  padding: 32px 36px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.partner-hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,63,173,0.3) 0%, transparent 70%);
  pointer-events: none;
}

.partner-hero-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; opacity: 0.5; margin-bottom: 6px; }
.partner-hero h2    { font-size: 22px; font-weight: 800; }

.token-count {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  margin: 12px 0 6px;
  letter-spacing: -2px;
  background: linear-gradient(135deg, #fff 30%, rgba(255,255,255,0.6));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.token-sub { font-size: 14px; opacity: 0.6; }

.partner-hero .token-bar { background: rgba(255,255,255,0.12); margin-top: 20px; height: 10px; }

/* ── Card ── */
.card { background: white; border-radius: var(--radius); border: 1px solid var(--border); padding: 24px; }

/* ── PIN display in admin ── */
.pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  font-family: monospace;
}

/* ── Empty ── */
.empty-state { text-align: center; padding: 36px; color: var(--text-muted); font-size: 14px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--navy);
  color: white;
  padding: 14px 22px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(13,27,53,0.25);
  z-index: 999;
  transform: translateY(90px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 340px;
}

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

/* ── Responsive ── */
@media (max-width: 720px) {
  .stats-row    { grid-template-columns: 1fr; }
  .partner-card { grid-template-columns: auto 1fr; }
  header        { padding: 0 16px; }
  main          { padding: 20px 16px; }
  .login-card   { padding: 32px 24px; }
}

/* ── PIN reveal (hashed PINs: shown only at creation/reset) ── */
.pin-reveal {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #FFF8E6;
  border: 1px solid #FFD98A;
  color: #7A4A00;
  font-size: 13px;
}

.pin-reveal.show { display: flex; }

.pin-reveal .pin-badge {
  background: white;
  font-size: 16px;
  letter-spacing: 3px;
}

/* date input matches the other modal inputs */
input[type="date"].form-input-modal { width: 160px; }
