:root {
  --brand-gradient-consistent: linear-gradient(135deg, #f15a29 0%, #c6392d 33%, #7d2844 66%, #264066 100%);
  --font-serif: 'Merriweather', serif;
  --font-sans: 'Montserrat', sans-serif;

  --brand-700: #264066;
  --brand-600: #7d2844;
  --brand-500: #c6392d;
  --brand-400: #f15a29;
  --brand-300: #fcd5ce;

  --bg: #FFFFFF;
  --text: #1F2937;
  --muted: #6B7280;
  --border: #E5E7EB;
  --surface: #F8FAFC;
  --card: #FFFFFF;
  --shadow: 0 6px 28px rgba(18, 18, 18, .08);
  --focus: 0 0 0 3px rgba(125, 40, 68, .25);
  --border-light: #E5E7EB;
}

body {
  margin: 0;
  padding: 40px 20px;
  font-family: var(--font-sans);
  background: var(--brand-400);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

html,
body {
  height: 100%;
}

.main-wrapper {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
}

.container {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 40px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
}

.header-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.firm-logo {
  height: 48px;
  width: auto;
  display: block;
  transition: transform 0.2s ease;
}

.firm-logo:hover {
  transform: scale(1.05);
}

h1.title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 2.2rem;
  background: var(--brand-gradient-consistent);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

/* Form Elements */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #374151;
  text-align: left;
  font-size: 0.95rem;
}

.checkbox-label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 1rem;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.checkbox-label:hover {
  background: rgba(0, 0, 0, 0.03);
}

input:not([type="checkbox"]),
.input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-light);
  border-radius: 12px;
  font-size: 1rem;
  font-family: var(--font-sans);
  background: var(--card);
  color: var(--text);
  margin-bottom: 1.25rem;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

input:not([type="checkbox"]):focus,
.input:focus {
  outline: none;
  border-color: var(--brand-600);
  background: var(--card);
  box-shadow: 0 0 0 4px rgba(125, 40, 68, 0.1);
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--brand-600);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

input[type="checkbox"]:checked {
  transform: scale(1.1);
}

/* Buttons */
.toggle-container {
  display: flex;
  background: var(--surface);
  padding: 6px;
  border-radius: 14px;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.toggle-container button {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-container button.active {
  background: var(--card);
  color: var(--brand-600);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.btn-brand,
button.calculate-btn {
  width: 100%;
  padding: 16px;
  background: var(--brand-gradient-consistent);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(125, 40, 68, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 1rem;
}

.btn-brand:hover,
button.calculate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(125, 40, 68, 0.2);
}

.btn-brand:active,
button.calculate-btn:active {
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

.error-message {
  margin: 0 0 20px 0;
  padding: 12px 16px;
  border: 1px solid rgba(161, 43, 61, .45);
  background: rgba(161, 43, 61, .08);
  color: #7a1a28;
  border-radius: 10px;
  font-size: 14px;
}

/* Shimmer Effect */
@keyframes shimmer-pass {
  0% {
    left: -30%;
  }

  100% {
    left: 130%;
  }
}

.calculate-btn {
  position: relative;
  overflow: hidden;
}

.calculate-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -30%;
  width: 30%;
  height: 100%;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
  transform: skewX(-20deg);
  pointer-events: none;
}

.calculate-btn.shimmer::after {
  animation: shimmer-pass 1s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

/* Hints adjustments */
.helper-text-styled {
  font-size: 0.85em;
  color: var(--muted);
  margin-top: -12px;
  margin-bottom: 16px;
  text-align: left;
  font-style: italic;
}

/* Print styles */
@media print {
  body {
    background: none;
    color: #000;
    box-shadow: none;
    animation: none;
    padding: 0;
  }

  .container {
    box-shadow: none;
    border: none;
    max-width: 100%;
    padding: 0;
  }
}

.landing {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, var(--brand-700) 0%, var(--brand-600) 50%, var(--brand-400) 100%);
  color: #fff;
}

.landing.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s ease;
}

.landing .panel {
  max-width: 720px;
  width: 92%;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  backdrop-filter: blur(6px);
}

.landing h1 {
  margin: 0 0 8px;
  font-size: 34px;
  letter-spacing: .2px;
}

.landing p {
  margin: 8px 0 16px;
  opacity: .92;
}

.landing .row {
  gap: 12px;
}

.landing .input {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-color: rgba(255, 255, 255, .35);
}

.landing .input:focus {
  background: rgba(255, 255, 255, .2) !important;
  color: #fff !important;
  border-color: #fff !important;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2) !important;
}

.landing .input::placeholder {
  color: rgba(255, 255, 255, .65);
}

.landing .btn-brand {
  background: #fff;
  color: var(--brand-700);
}

body.locked .main-wrapper,
body.locked .firm-logo {
  display: none !important;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 0.9em;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  opacity: 0;
  transform: translateX(40px);
  animation: toastIn 0.35s ease forwards;
  max-width: 360px;
}

.toast.success {
  background: linear-gradient(135deg, #059669, #047857);
}

.toast.error {
  background: linear-gradient(135deg, #DC2626, #991B1B);
  cursor: pointer;
}

.toast.dismissing {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* Confirmation Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

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

.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 480px;
  width: 92%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-title {
  margin: 0 0 16px;
  font-family: var(--font-serif);
  font-size: 1.3em;
  color: var(--brand-700);
}

.modal-body-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.92em;
  border-bottom: 1px solid var(--border-light);
}

.modal-body-row:last-child {
  border-bottom: none;
}

.modal-body-row .label {
  color: var(--muted);
}

.modal-body-row .value {
  font-weight: 600;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.btn-secondary {
  font-family: var(--font-sans);
  font-size: 0.92em;
  padding: 10px 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: var(--border-light);
}

/* Withholdings Section */
.withholdings-container {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  background: var(--surface);
}

.withholdings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.withholdings-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05em;
  color: var(--brand-700);
}

.withholding-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
  margin-bottom: 12px;
}

.withholding-table th {
  text-align: left;
  padding: 6px 8px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.withholding-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-light);
}

.withholding-row-pending td {
  color: var(--text);
}

.withholding-row-resolved td {
  color: #047857;
}

.withholding-badge {
  display: inline-block;
  font-size: 0.78em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.withholding-badge.pending {
  background: rgba(234, 179, 8, 0.12);
  color: #92400E;
}

.withholding-badge.resolved {
  background: rgba(34, 197, 94, 0.12);
  color: #047857;
}

.withholding-summary {
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(38, 64, 102, 0.06);
  border: 1px solid rgba(38, 64, 102, 0.12);
  font-size: 0.9em;
  margin-bottom: 12px;
}

.withholding-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.withholding-summary-row.net {
  font-weight: 700;
  border-top: 1px solid rgba(38, 64, 102, 0.15);
  padding-top: 6px;
  margin-top: 4px;
}

.withholding-empty {
  text-align: center;
  color: var(--muted);
  font-style: italic;
  padding: 12px;
  font-size: 0.9em;
}

/* Admin Dashboard */
.admin-dashboard {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  background: var(--surface);
}

.dashboard-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.1em;
  color: var(--brand-700);
}

.dashboard-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.dashboard-card .card-label {
  font-size: 0.82em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.dashboard-card .card-value {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--brand-700);
}

.dashboard-card .card-sub {
  font-size: 0.78em;
  color: var(--muted);
  margin-top: 4px;
}

.dashboard-details {
  margin-top: 8px;
}

.dashboard-details table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
}

.dashboard-details th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dashboard-details td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
}

.dashboard-details .section-label {
  font-weight: 600;
  color: var(--brand-700);
  margin: 16px 0 8px;
  font-size: 0.95em;
  font-family: var(--font-serif);
}

/* Contract Expiry Banner */
.contract-expiry-banner {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.92em;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
  line-height: 1.5;
}

.contract-expiry-banner.warning-amber {
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #92400E;
}

.contract-expiry-banner.warning-red {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.4);
  color: #991B1B;
}

.contract-expiry-banner.expired {
  background: rgba(220, 38, 38, 0.15);
  border: 2px solid #DC2626;
  color: #7F1D1D;
  font-size: 1em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Section transitions */
.section-animate {
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.3s ease;
  max-height: 0;
  opacity: 0;
}

.section-animate.visible {
  max-height: 600px;
  opacity: 1;
}

/* Ad Hoc Line Items */
.adhoc-toggle-wrapper {
  margin-bottom: 1.25rem;
}

.adhoc-toggle-btn {
  width: 100%;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.adhoc-container {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  background: var(--surface);
}

.adhoc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.adhoc-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05em;
  color: var(--brand-700);
}

.adhoc-item {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--card);
  position: relative;
}

.adhoc-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.adhoc-item-number {
  font-weight: 600;
  font-size: 0.9em;
  color: var(--brand-700);
}

.adhoc-remove-btn {
  background: none;
  border: none;
  color: #991B1B;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
  font-family: var(--font-sans);
}

.adhoc-remove-btn:hover {
  background: rgba(220, 38, 38, 0.08);
}

.adhoc-item .adhoc-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.adhoc-item label {
  font-size: 0.85em;
  margin-bottom: 4px;
  font-weight: 600;
}

.adhoc-item input,
.adhoc-item textarea {
  margin-bottom: 10px;
}

.adhoc-item textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border-light);
  border-radius: 10px;
  font-size: 0.92em;
  font-family: var(--font-sans);
  background: var(--card);
  color: var(--text);
  resize: vertical;
  min-height: 48px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.adhoc-item textarea:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 4px rgba(125, 40, 68, 0.1);
}

.adhoc-total {
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(38, 64, 102, 0.06);
  border: 1px solid rgba(38, 64, 102, 0.12);
  font-size: 0.92em;
  font-weight: 700;
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  color: var(--brand-700);
}

/* Loading spinner for buttons */
.btn-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile responsiveness */
@media (max-width: 600px) {
  body {
    padding: 16px 8px;
  }

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

  h1.title {
    font-size: 1.5rem;
  }

  .toggle-container {
    flex-direction: column;
  }

  .toggle-container button {
    padding: 10px;
    font-size: 0.88em;
  }

  .landing h1 {
    font-size: 24px;
  }

  .landing .panel {
    padding: 20px;
  }

  .modal-card {
    padding: 20px;
  }

  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    max-width: 100%;
  }

  .withholding-table {
    font-size: 0.82em;
  }

  .dashboard-cards {
    grid-template-columns: 1fr;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}