:root {
  /* Colors */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #16a34a;
  --color-success-hover: #15803d;
  --color-danger: #dc2626;
  --color-warning: #f59e0b;

  /* Light Theme variables */
  --bg-body: #f6f7fb;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-input: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --border-radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme variables */
[data-theme="dark"] {
  --bg-body: #111827;
  --bg-card: #1f2937;
  --bg-header: #1f2937;
  --bg-input: #374151;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.6;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  transition: background-color var(--transition), color var(--transition);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-hover);
}

p {
  margin-bottom: 1rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.2;
  margin-bottom: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

ul,
ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

/* Typography Utilities */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.text-sm {
  font-size: 0.875rem;
}

.text-lg {
  font-size: 1.125rem;
}

.text-xl {
  font-size: 1.25rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.font-bold {
  font-weight: bold;
}

.mb-1 {
  margin-bottom: 0.25rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 1rem;
}

.mb-4 {
  margin-bottom: 1.5rem;
}

.mb-5 {
  margin-bottom: 2rem;
}

.mt-4 {
  margin-top: 1.5rem;
}

.mt-5 {
  margin-top: 2rem;
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.main-content {
  flex: 1;
  padding: 2rem 0;
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 768px) {
  .md\:grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {

  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 1rem;
}

.gap-4 {
  gap: 1.5rem;
}

/* Components */

/* Header */
.header {
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 1rem 0;
  transition: background-color var(--transition), border-color var(--transition);
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo span {
  color: var(--color-primary);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-link {
  color: var(--text-main);
  font-weight: 500;
}

.nav-link:hover {
  color: var(--color-primary);
}

.theme-toggle,
.mobile-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.theme-toggle:hover,
.mobile-menu-btn:hover {
  background-color: var(--border-color);
}

.mobile-menu-btn {
  display: none;
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--bg-header);
    flex-direction: column;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
  }

  .nav-links.active {
    display: flex;
  }

  .nav-link {
    width: 100%;
    text-align: center;
    padding: 0.75rem 0;
  }

  .mobile-menu-btn {
    display: flex;
  }
}

/* Top Banner */
.top-banner {
  background-color: var(--color-primary);
  color: white;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.875rem;
  position: relative;
  display: none;
  /* JS will toggle if needed */
}

.top-banner a {
  color: white;
  text-decoration: underline;
}

.close-banner {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: white;
  cursor: pointer;
}

/* Breadcrumbs */
.breadcrumbs {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs a:hover {
  color: var(--color-primary);
}

.breadcrumbs span {
  margin: 0 0.5rem;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s, background-color var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}

.card-icon {
  width: 40px;
  height: 40px;
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

[data-theme="dark"] .card-icon {
  background-color: rgba(37, 99, 235, 0.2);
}

/* Tool Interface Card */
.tool-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
  transition: background-color var(--transition);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-main);
  font-size: 0.875rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[disabled] {
  background-color: var(--border-color);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  gap: 0.5rem;
  text-align: center;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  color: white;
}

.btn-success {
  background-color: var(--color-success);
  color: white;
}

.btn-success:hover {
  background-color: var(--color-success-hover);
  color: white;
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: var(--bg-body);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

/* Tabs */
.tabs-container {
  background-color: var(--bg-body);
  /* Changed to body bg so it blends, white panels inside */
  margin-bottom: 2rem;
}

.tab-list {
  display: flex;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  position: sticky;
  top: 60px;
  /* Below the header */
  z-index: 40;
  box-shadow: var(--shadow-sm);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.tab-list::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background-color: rgba(37, 99, 235, 0.05);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-content {
  padding: 2rem 0;
  max-width: 900px;
  margin: 0 auto;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Result Box */
.result-box {
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  position: relative;
  transition: background-color var(--transition);
}

.result-box h3 {
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.result-row.total {
  font-weight: bold;
  font-size: 1.125rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}

/* AdSense Placeholders */
.ad-placeholder {
  background-color: var(--bg-card);
  border: 1px dashed var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 1.5rem auto;
  border-radius: 8px;
  width: 100%;
}

.ad-header {
  height: 90px;
  max-width: 728px;
}

.ad-inline {
  height: 250px;
  max-width: 300px;
}

.ad-footer {
  height: 90px;
  max-width: 728px;
}

/* Sticky Mobile Ad */
.ad-mobile-sticky {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  z-index: 100;
  align-items: center;
  justify-content: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.ad-mobile-sticky .close-ad {
  position: absolute;
  top: -24px;
  right: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .ad-mobile-sticky {
    display: flex;
  }

  body {
    padding-bottom: 60px;
  }
}

/* FAQ Accordion */
.accordion {
  margin-top: 2rem;
}

.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 1rem;
  background-color: var(--bg-card);
  overflow: hidden;
}

.accordion-header {
  width: 100%;
  text-align: left;
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.accordion-content {
  padding: 0 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.3s ease;
  color: var(--text-muted);
}

.accordion-item.active .accordion-content {
  padding: 1rem 1.5rem;
  max-height: 1000px;
  border-top: 1px solid var(--border-color);
}

.accordion-icon {
  transition: transform 0.3s ease;
}

.accordion-item.active .accordion-icon {
  transform: rotate(180deg);
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  display: none;
}

.alert-success {
  background-color: rgba(22, 163, 74, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.alert-danger {
  background-color: rgba(220, 38, 38, 0.1);
  color: var(--color-danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* Footer */
.footer {
  background-color: var(--bg-header);
  border-top: 1px solid var(--border-color);
  padding: 3rem 0 1.5rem;
  margin-top: auto;
  transition: background-color var(--transition);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-col h4 {
  margin-bottom: 1rem;
  font-size: 1.125rem;
}

.footer-links {
  list-style: none;
  padding: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--color-primary);
}

.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Utilities */
.hidden {
  display: none !important;
}

.block {
  display: block !important;
}