/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a1628;
  --surface: #111827;
  --surface2: #1a2035;
  --surface3: #1e2d4a;
  --border: rgba(16, 185, 129, 0.12);
  --accent: #10b981;
  --accent2: #3b82f6;
  --accent-glow: rgba(16, 185, 129, 0.22);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --green: #4ade80;
  --red: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="light"] {
  --bg: #f0faf5;
  --surface: #ffffff;
  --surface2: #f0fdf4;
  --surface3: #dcfce7;
  --border: rgba(16, 185, 129, 0.18);
  --accent: #059669;
  --accent2: #2563eb;
  --accent-glow: rgba(5, 150, 105, 0.15);
  --text: #1e293b;
  --text-muted: #64748b;
  --text-soft: #475569;
  --green: #16a34a;
  --red: #dc2626;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 0%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 0%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

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

/* ===== Page Wrapper ===== */
.page-wrapper {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Cookie Banner ===== */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 22, 40, 0.97);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  z-index: 1000;
}

.cookie-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.cookie-text {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-soft);
  min-width: 200px;
}

.cookie-text strong { color: var(--accent); }

.cookie-btns { display: flex; gap: 8px; }

.cookie-accept {
  padding: 8px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.2s;
}

.cookie-accept:hover { filter: brightness(1.1); }

/* ===== Header ===== */
.site-header {
  text-align: center;
  padding: 48px 0 36px;
  position: relative;
}

.header-top {
  position: absolute;
  top: 16px;
  right: 0;
  display: flex;
  justify-content: flex-end;
}

.theme-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.theme-btn:hover {
  border-color: var(--accent);
  background: var(--surface3);
  transform: rotate(20deg);
}

.header-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 14px;
  display: block;
  filter: drop-shadow(0 0 20px rgba(16, 185, 129, 0.5));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.site-header h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #6ee7b7 0%, #10b981 40%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.site-header p {
  color: var(--text-soft);
  font-size: 1rem;
  font-weight: 400;
}

/* ===== Main ===== */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== Calculator Card ===== */
.calculator-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.3);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.form-group input,
.form-group select {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  outline: none;
}

.form-group input::placeholder { color: var(--text-muted); }

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.state-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.state-row select { flex: 1; }

#geo-btn {
  background: var(--surface2);
  color: var(--text-soft);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

#geo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface3);
}

#geo-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #059669);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.35);
  letter-spacing: 0.02em;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5);
}

.primary-btn:active { transform: translateY(0); }

/* ===== Result ===== */
.result {
  background: var(--surface2);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeUp 0.35s ease-out;
}

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

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
}

.total-row {
  border-top: 1px solid rgba(16, 185, 129, 0.2);
  padding-top: 12px;
}

.result-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.result-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 1.1rem;
}

.total-value {
  font-size: 1.5rem;
  color: var(--green);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rate-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding-top: 2px;
}

/* ===== Error ===== */
.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  animation: fadeUp 0.3s ease-out;
}

/* ===== Info Section ===== */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-title span { font-size: 1rem; }

.section-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.55;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.88rem;
}

thead th {
  background: var(--surface2);
  color: var(--text-muted);
  padding: 11px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--surface2); }

tbody td {
  padding: 10px 16px;
  color: var(--text);
}

tbody td:last-child {
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 28px 0 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-top: auto;
}

.site-footer a {
  color: var(--text-soft);
  text-decoration: none;
}

.site-footer a:hover { color: var(--accent); }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.4);
  padding: 36px 32px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  line-height: 1.7;
}

.modal-content h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}

.modal-content h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 20px;
  margin-bottom: 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-content p {
  font-size: 0.88rem;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.modal-content a { color: var(--accent2); }

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

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

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 520px) {
  .site-header h1 { font-size: 1.75rem; }
  .calculator-card { padding: 22px 18px; }
  .state-row { flex-direction: column; }
  #geo-btn { width: 100%; justify-content: center; }
  .modal-content { padding: 26px 18px; }
  .cookie-inner { flex-direction: column; align-items: flex-start; }
}
