:root {
  --whc-primary: #6366f1;
  --whc-primary-dark: #4f46e5;
  --whc-primary-glow: rgba(99, 102, 241, 0.15);
  --whc-success: #10b981;
  --whc-success-glow: rgba(16, 185, 129, 0.15);
  --whc-warning: #f59e0b;
  --whc-danger: #ef4444;
  --whc-bg-app: rgba(255, 255, 255, 0.9);
  --whc-bg-card: #ffffff;
  --whc-bg-input: #ffffff;
  --whc-border: #e5e7eb;
  --whc-text: #111827;
  --whc-text-muted: #4b5563;
  --whc-glass-border: rgba(255, 255, 255, 0.6);
  --whc-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --whc-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --whc-shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --whc-primary: #818cf8;
    --whc-primary-dark: #6366f1;
    --whc-primary-glow: rgba(129, 140, 248, 0.2);
    --whc-success: #34d399;
    --whc-success-glow: rgba(52, 211, 153, 0.2);
    --whc-warning: #fbbf24;
    --whc-danger: #f87171;
    --whc-bg-app: rgba(15, 23, 42, 0.9);
    --whc-bg-card: #1e293b;
    --whc-bg-input: #1e293b;
    --whc-border: rgba(255, 255, 255, 0.1);
    --whc-text: #f3f4f6;
    --whc-text-muted: #9ca3af;
    --whc-glass-border: rgba(255, 255, 255, 0.05);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: #f3f4f6;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--whc-text);
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  body {
    background-color: #0f172a;
  }
}

/* App Container */
.premium-calculator-app {
  width: 100%;
  max-width: 960px;
  margin: 40px auto;
  padding: 0 16px;
  overflow-x: hidden; /* prevent horizontal scroll on mobile */
}

.app-wrapper {
  background: var(--whc-bg-app);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--whc-glass-border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--whc-shadow-lg);
  position: relative;
}

/* Header */
.salary-calculator .app-header {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--whc-border);
  position: relative;
  width: 100%;
}

.salary-calculator .app-header-icon {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, rgba(10, 85, 140, 0.08) 0%, rgba(16, 185, 129, 0.08) 100%);
  border: 1.5px solid rgba(10, 85, 140, 0.2);
  border-radius: 18px;
  margin: 0 auto 12px !important;
  color: #0a558c;
  flex-shrink: 0;
}

.salary-calculator .app-header-icon svg {
  width: 36px;
  height: 36px;
}

.salary-calculator .app-title {
  margin: 0 0 6px;
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0a558c !important;
  line-height: 1.2;
  text-align: center !important;
  width: 100%;
}

.salary-calculator .app-subtitle {
  margin: 6px auto 0;
  font-size: 14px;
  color: var(--whc-text-muted);
  max-width: 500px;
  text-align: center !important;
}

.salary-calculator .header-right {
  display: flex;
  gap: 8px;
}

/* Cards */
.card {
  border: 1px solid var(--whc-border);
  border-radius: 16px;
  background: var(--whc-bg-card);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--whc-shadow);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--whc-shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--whc-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (prefers-color-scheme: dark) {
  .card-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  }
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--whc-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* Alert Boxes */
.alert {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
}

.alert-info {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}

@media (prefers-color-scheme: dark) {
  .alert-info {
    background-color: rgba(30, 58, 138, 0.2);
    border-color: rgba(30, 58, 138, 0.4);
    color: #93c5fd;
  }
}

/* Form Layouts */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--whc-text);
}

/* Inputs and Selects */
.form-input,
.form-select {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--whc-border);
  background: var(--whc-bg-input);
  font-size: 14px;
  color: var(--whc-text);
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input:hover,
.form-select:hover {
  border-color: var(--whc-primary);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--whc-primary);
  box-shadow: 0 0 0 4px var(--whc-primary-glow);
}

.form-hint {
  font-size: 11px;
  color: var(--whc-text-muted);
  margin: 2px 0 0;
}

/* Toggle Switch / Segments */
.segment-control {
  display: flex;
  flex-wrap: wrap;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 20px;
}

@media (prefers-color-scheme: dark) {
  .segment-control {
    background: #0f172a;
  }
}

.segment-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--whc-text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment-btn.active {
  background: var(--whc-bg-card);
  color: var(--whc-primary);
  box-shadow: var(--whc-shadow-sm);
}

/* Timesheet Grid (Detailed Input) */
.timesheet-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.timesheet-day {
  background: #f8fafc;
  border: 1px solid var(--whc-border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (prefers-color-scheme: dark) {
  .timesheet-day {
    background: #1e293b;
  }
}

.day-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--whc-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.day-input {
  text-align: center;
  padding: 8px;
  font-size: 15px;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  text-decoration: none;
  min-height: 44px;
}

.btn-primary {
  background: var(--whc-primary);
  color: #ffffff;
  border-color: var(--whc-primary-dark);
  box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
  background: var(--whc-primary-dark);
  box-shadow: 0 6px 12px rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--whc-bg-card);
  color: var(--whc-text-muted);
  border-color: var(--whc-border);
  box-shadow: var(--whc-shadow-sm);
}

.btn-secondary:hover {
  background: #f8fafc;
  color: var(--whc-text);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

@media (prefers-color-scheme: dark) {
  .btn-secondary:hover {
    background: #0f172a;
    border-color: #475569;
  }
}

.btn-sm {
  padding: 8px 16px;
  font-size: 12.5px;
  min-height: 36px;
}

.button-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Tabs (Internal to Card) */
.tabs-header {
  display: flex;
  border-bottom: 2px solid var(--whc-border);
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.tab-link {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--whc-text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.tab-link:hover {
  color: var(--whc-text);
}

.tab-link.active {
  color: var(--whc-primary);
}

.tab-link.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--whc-primary);
  border-radius: 2px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Results Section Layout */
.results-container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}

.chart-wrapper {
  background: #f8fafc;
  border: 1px solid var(--whc-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  position: relative;
}

#salaryChart {
  max-width: 220px;
  max-height: 220px;
  width: 100%;
}

@media (prefers-color-scheme: dark) {
  .chart-wrapper {
    background: #0f172a;
  }
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--whc-border);
  border-radius: 12px;
  background: var(--whc-bg-card);
  transition: all 0.2s ease;
}

.result-row:hover {
  border-color: #cbd5e1;
}

.result-row.highlight {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(79, 70, 229, 0.05) 100%);
  border-color: rgba(99, 102, 241, 0.3);
}

.result-row.success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(5, 150, 105, 0.05) 100%);
  border-color: rgba(16, 185, 129, 0.3);
}

.result-label {
  font-size: 13.5px;
  color: var(--whc-text-muted);
  flex: 1 1 auto;      /* allows label to grow AND shrink */
  min-width: 0;        /* critical: allows text to shrink below natural width */
  padding-right: 10px;
}

.result-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--whc-text);
  text-align: right;
  white-space: nowrap; /* keep number on one line */
  flex-shrink: 0;      /* value stays readable, label gives up space */
}

.result-value.big {
  font-size: 20px;
  color: var(--whc-primary);
}

.result-value.green {
  font-size: 20px;
  color: var(--whc-success);
}

/* Badges / Tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.tag-blue {
  background: #dbeafe;
  color: #1e40af;
}

.tag-orange {
  background: #ffedd5;
  color: #c2410c;
}

.tag-red {
  background: #fee2e2;
  color: #b91c1c;
}

.tag-green {
  background: #d1fae5;
  color: #065f46;
}

/* Progress Bar */
.progress-container {
  margin-top: 14px;
}

.progress-bar-wrapper {
  width: 100%;
  height: 8px;
  background: var(--whc-border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--whc-primary);
  width: 0%;
  transition: width 0.4s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--whc-text-muted);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--whc-border);
  border-radius: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--whc-border);
}

.data-table th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--whc-text);
}

@media (prefers-color-scheme: dark) {
  .data-table th {
    background: #0f172a;
  }
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background-color: rgba(99, 102, 241, 0.02);
}

/* FAQ Accordions */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  border: 1px solid var(--whc-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--whc-bg-card);
}

.faq-question {
  width: 100%;
  padding: 16px 20px;
  background: none;
  border: none;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--whc-text);
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.faq-question:hover {
  background: #f8fafc;
}

@media (prefers-color-scheme: dark) {
  .faq-question:hover {
    background: #0f172a;
  }
}

.faq-question::after {
  content: "▾";
  font-size: 18px;
  color: var(--whc-text-muted);
  transition: transform 0.2s ease;
}

.faq-item.open .faq-question::after {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
}

.faq-answer-inner {
  padding: 0 20px 16px;
  font-size: 13.5px;
  color: var(--whc-text-muted);
}

.faq-answer-inner p {
  margin: 0 0 10px;
}

.faq-answer-inner p:last-child {
  margin-bottom: 0;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}

.toast {
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.3s ease-out;
}

.toast-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
}

.toast-close:hover {
  color: #ffffff;
}

/* Animations */
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .premium-calculator-app {
    padding: 0 8px;
    margin: 16px auto;
  }

  .app-wrapper {
    padding: 20px 16px;
    border-radius: 16px;
  }

  /* Keep header centered on all screens */
  .salary-calculator .app-header {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  .header-right {
    width: 100%;
    justify-content: center;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
  
  .form-input, .form-select {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .timesheet-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Financial Report Card — stack chart above results list */
  .results-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .chart-wrapper {
    min-height: 200px;
    width: 100%;
    padding: 16px 10px;
  }
  
  #salaryChart {
    max-width: 180px;
    max-height: 180px;
  }

  /* Result rows */
  .result-row {
    padding: 10px 12px;
    gap: 6px;
  }

  .result-label {
    font-size: 13px;
  }

  .result-value {
    font-size: 14px;
  }

  .result-value.big,
  .result-value.green {
    font-size: 17px;
  }

  .button-bar {
    flex-direction: column;
    gap: 8px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .app-wrapper {
    padding: 14px 10px; /* tighter wrapper on small phones */
  }

  /* Reduce card-body padding so result rows have more room */
  .card-body {
    padding: 14px 12px;
  }

  .card-header {
    padding: 12px 14px;
  }

  .card-title {
    font-size: 14px;
  }

  .timesheet-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .results-container {
    gap: 10px;
  }

  .chart-wrapper {
    min-height: 160px;
    padding: 12px 10px;
  }

  #salaryChart {
    max-width: 150px;
    max-height: 150px;
  }

  .result-list {
    gap: 8px;
  }

  .result-row {
    padding: 9px 10px;
    gap: 4px;
  }

  .result-label {
    font-size: 12px;
    padding-right: 6px;
  }

  .result-value {
    font-size: 13px;
  }

  .result-value.big,
  .result-value.green {
    font-size: 15px;
  }

  .tab-link {
    padding: 9px 10px;
    font-size: 12.5px;
  }

  .alert {
    padding: 10px 12px;
    font-size: 12.5px;
  }
}

@media (max-width: 360px) {
  .app-wrapper { padding: 14px 10px; }
  .timesheet-grid { grid-template-columns: repeat(2, 1fr); }
  .button-bar { gap: 6px; }
  .result-row { padding: 8px 10px; }
}

/* Print Styles */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12pt;
  }

  .premium-calculator-app {
    margin: 0;
    padding: 0;
    max-width: 100%;
  }

  .app-wrapper {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0;
  }

  .header-right,
  .segment-control,
  .timesheet-grid,
  .button-bar,
  .faq-list,
  .btn,
  .form-hint,
  .toast-container {
    display: none !important;
  }

  .card {
    border: none !important;
    box-shadow: none !important;
    margin-bottom: 20px;
    page-break-inside: avoid;
  }

  .card-header {
    border-bottom: 2px solid #000000 !important;
    background: transparent !important;
    padding: 8px 0 !important;
  }

  .card-title {
    color: #000000 !important;
    font-size: 14pt !important;
  }

  .card-body {
    padding: 10px 0 !important;
  }

  .results-container {
    grid-template-columns: 1fr !important;
  }

  .chart-wrapper {
    display: none !important;
  }

  .result-row {
    border: none !important;
    border-bottom: 1px solid #e5e7eb !important;
    padding: 6px 0 !important;
    background: transparent !important;
  }

  .result-value {
    color: #000000 !important;
  }

  .result-value.big,
  .result-value.green {
    font-size: 15pt !important;
    color: #000000 !important;
  }

  .data-table th,
  .data-table td {
    border-bottom: 1px solid #000000 !important;
  }
}
