* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-outer: #16111f;
  --bg-card: #221a35;
  --bg-inner: #1a1428;
  --border: #352a52;
  --border-focus: #a78bfa;
  --text: #f5f3ff;
  --text-muted: #9d93b8;
  --text-faint: #6a5f8a;
  --accent: #a78bfa;
  --accent-soft: #c4b5fd;
  --success: #34d399;
  --error: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(ellipse at top, #2a1f45 0%, #16111f 60%) fixed;
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 24px 16px 60px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: 440px; }

/* HEADER */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.logo { display: flex; align-items: center; gap: 10px; }

.logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff;
  box-shadow: 0 6px 20px rgba(167, 139, 250, 0.35);
}

.logo-text { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.logo-sub { font-size: 11px; color: var(--text-faint); margin-top: 1px; }

.auth-chip {
  background: rgba(167, 139, 250, 0.1);
  color: var(--accent-soft);
  border: 1px solid rgba(167, 139, 250, 0.3);
  padding: 8px 16px; border-radius: 100px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}

.auth-chip:active {
  transform: scale(0.96);
  background: rgba(167, 139, 250, 0.2);
}

.user-chip {
  font-size: 11px; color: var(--text-faint);
  text-align: right; margin-top: -14px; margin-bottom: 18px;
  word-break: break-all;
}

/* HERO */
.hero { margin-bottom: 24px; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 6px; }
.subtitle { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* CARD */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

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

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

.input-wrap {
  position: relative; display: flex; align-items: center;
  background: var(--bg-inner);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: all 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
  background: #1e1832;
}

.input-prefix, .input-suffix {
  color: var(--text-faint); font-size: 14px; font-weight: 500;
  user-select: none; flex-shrink: 0;
}
.input-prefix { margin-right: 8px; }
.input-suffix { margin-left: 8px; }

input, select {
  flex: 1; background: transparent; border: none;
  color: var(--text); font-size: 15px; font-weight: 500;
  padding: 14px 0; outline: none; font-family: inherit;
  -webkit-appearance: none; appearance: none;
  width: 100%; min-width: 0;
}

input::placeholder { color: var(--text-faint); font-weight: 400; }

select { cursor: pointer; padding-right: 20px; }
select option { background: var(--bg-card); color: var(--text); }

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

input[type="date"] { color-scheme: dark; cursor: pointer; }

.input-wrap:has(select)::after {
  content: ''; position: absolute; right: 18px;
  width: 8px; height: 8px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: rotate(45deg) translateY(-3px);
  pointer-events: none;
}

.row { display: flex; gap: 12px; }
.col { flex: 1; min-width: 0; }

/* BUTTONS */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%);
  color: #1a1428;
  border: none;
  padding: 16px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 20px;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 8px 24px rgba(167, 139, 250, 0.3);
  letter-spacing: -0.01em;
}

.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-secondary:active {
  background: rgba(167, 139, 250, 0.08);
  border-color: var(--border-focus);
  transform: scale(0.98);
}

/* RESULTS */
.results { margin-top: 24px; animation: fadeInUp 0.4s ease; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-hero {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.15) 0%, rgba(124, 58, 237, 0.08) 100%);
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 12px;
  text-align: center;
}

.results-label {
  font-size: 11px; font-weight: 700;
  color: var(--accent-soft); letter-spacing: 0.1em; margin-bottom: 8px;
}

.payout-amount {
  font-size: 40px; font-weight: 800; color: #fff;
  letter-spacing: -0.03em; line-height: 1.1; margin-bottom: 6px;
  text-shadow: 0 2px 24px rgba(167, 139, 250, 0.4);
}

.profit-text { font-size: 13px; color: var(--accent-soft); font-weight: 500; }

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 20px;
}

.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); font-weight: 500; }
.detail-value { font-weight: 600; text-align: right; color: var(--text); }

/* TIMELINE */
.timeline {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 16px; padding: 16px;
  background: var(--bg-inner);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  justify-content: center;
}

.timeline-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border); transition: all 0.3s;
}
.timeline-dot.weekend { background: #4c1d95; opacity: 0.5; }
.timeline-dot.business {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.5);
}
.timeline-dot.final {
  background: var(--success);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.6);
  transform: scale(1.2);
}

/* CALENDAR BUTTON */
#calendar-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; font-weight: 600; margin-top: 16px;
}

/* HISTORY */
#history-list { margin-top: 16px; }

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  animation: fadeInUp 0.3s ease;
}

.history-item .name { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.history-item .meta { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.history-item .payout {
  color: var(--accent-soft); font-size: 22px; font-weight: 700;
  margin: 6px 0; letter-spacing: -0.02em;
}

.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: 13px;
}
.empty-state .icon { font-size: 36px; margin-bottom: 12px; opacity: 0.5; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 6, 20, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 32px 24px 24px;
  border-radius: 20px;
  width: 100%; max-width: 380px;
  position: relative;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-icon { font-size: 32px; text-align: center; margin-bottom: 12px; }
.modal-box h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.modal-sub {
  font-size: 13px; color: var(--text-muted); margin-bottom: 20px;
  text-align: center; line-height: 1.5;
}

.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: rgba(167, 139, 250, 0.1);
  border: none; color: var(--text-muted); font-size: 16px;
  cursor: pointer; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}

.modal-close:active {
  background: rgba(167, 139, 250, 0.2); transform: scale(0.9);
}

.modal-status {
  margin-top: 14px; font-size: 13px; color: var(--accent-soft);
  text-align: center; min-height: 18px; line-height: 1.4;
}

/* TOAST */
.toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px; border-radius: 100px;
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 90vw; text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(52, 211, 153, 0.5); color: var(--success); }
.toast.error { border-color: rgba(248, 113, 113, 0.5); color: var(--error); }
.history-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.history-actions button {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
}

.btn-edit:active {
  background: rgba(167, 139, 250, 0.1);
  border-color: var(--accent);
  color: var(--accent-soft);
  transform: scale(0.97);
}

.btn-delete:active {
  background: rgba(248, 113, 113, 0.1);
  border-color: var(--error);
  color: var(--error);
  transform: scale(0.97);
}
