/* ==========================================================================
   XLSDeal Financial Calculators - Common Professional Design System
   Matches index.html glassmorphic dark theme
   ========================================================================== */

:root {
  --bg: #07151f;
  --bg-gradient: radial-gradient(ellipse at 12% 8%, rgba(29, 154, 160, .22), transparent 34%),
                 radial-gradient(ellipse at 92% 24%, rgba(88, 83, 196, .20), transparent 31%),
                 linear-gradient(135deg, #07151f 0%, #0a1b2a 48%, #10172c 100%);
  --line: rgba(255, 255, 255, .13);
  --line-strong: rgba(255, 255, 255, .22);
  --text: #f4f8fb;
  --text-bright: #ffffff;
  --muted: #a5b8c5;
  --muted-dark: #6e8294;
  --accent: #70f0d0;
  --mint: #70f0d0;
  --accent-glow: rgba(112, 240, 208, .28);
  --accent-soft: rgba(112, 240, 208, .12);
  --purple: #8e7aff;
  --purple-glow: rgba(142, 122, 255, .25);
  --blue: #4da5ff;
  --amber: #ffbe4d;
  --rose: #ff6b8b;
  --card-bg: linear-gradient(145deg, rgba(255, 255, 255, .105), rgba(255, 255, 255, .035));
  --card-bg-hover: linear-gradient(145deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .05));
  --card-border: rgba(255, 255, 255, .13);
  --card-border-glow: rgba(112, 240, 208, .45);
  --glass-shadow: 0 18px 46px rgba(0, 0, 0, .4), inset 0 1px rgba(255, 255, 255, .14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .14;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(#000, transparent 95%);
  z-index: 0;
}

.shell {
  position: relative;
  width: min(1260px, calc(100% - 36px));
  margin: 0 auto;
  padding-bottom: 50px;
  z-index: 1;
}

/* Header & Navigation */
header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 84px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
  transition: opacity .2s;
}

.brand:hover {
  opacity: .92;
}

.brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 5px 16px rgba(44, 228, 196, .35));
}

.brand-name {
  font-family: "Manrope", sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.6px;
}

.brand-name span {
  color: var(--mint);
}

.brand-sub {
  display: block;
  color: #91a7b5;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.header-link,
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #dce6e6;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 10px 18px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, .06);
  backdrop-filter: blur(12px);
  transition: all .25s ease;
  white-space: nowrap;
}

.header-link:hover,
.back-btn:hover {
  background: rgba(112, 240, 208, .15);
  border-color: rgba(112, 240, 208, .45);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(112, 240, 208, .22);
  border-radius: 100px;
  padding: 8px 14px;
  background: rgba(112, 240, 208, .065);
  color: #aaf8e5;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.header-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

/* Page Intro */
.page-intro {
  padding: 34px 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  margin-bottom: 28px;
}

.intro-content {
  max-width: 780px;
}

.calc-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.calc-title {
  font-family: "Manrope", sans-serif;
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 800;
  letter-spacing: -1.2px;
  margin: 0 0 10px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
}

.calc-title-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .25);
}

.calc-title-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.calc-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  margin: 0;
}

/* Calculator Grid Layout */
.calculator-grid {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 26px;
  align-items: start;
}

@media (max-width: 1020px) {
  .calculator-grid {
    grid-template-columns: 1fr;
  }
}

/* Glass Panels */
.glass-panel {
  position: relative;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  padding: 26px;
}

.glass-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 10% 0%, rgba(112, 240, 208, .08), transparent 48%);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.panel-title {
  font-family: "Manrope", sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--muted);
}

/* Form Controls & Input Groups */
.form-group {
  margin-bottom: 22px;
}

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

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 9px;
}

.field-label {
  font-size: 13.5px;
  font-weight: 600;
  color: #e4edf3;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-label .req {
  color: #ff6b8b;
  font-size: 14px;
}

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  cursor: help;
  position: relative;
  transition: all .2s;
}

.help-tip:hover {
  background: var(--accent);
  color: #07151f;
  transform: scale(1.1);
}

.help-tip .tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 135%;
  left: 50%;
  transform: translateX(-50%);
  width: 230px;
  background: rgba(10, 25, 38, .98);
  border: 1px solid rgba(112, 240, 208, .3);
  color: #e2f1f5;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
  pointer-events: none;
  z-index: 50;
  transition: opacity .2s, visibility .2s;
  text-align: left;
}

.help-tip .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(10, 25, 38, .98) transparent transparent transparent;
}

.help-tip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Input Fields with Currency/Unit adornments */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix,
.input-suffix {
  position: absolute;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
}

.input-prefix {
  left: 14px;
}

.input-suffix {
  right: 14px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: all .2s ease;
}

.form-input.has-prefix {
  padding-left: 32px;
}

.form-input.has-suffix {
  padding-right: 48px;
}

.form-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, .09);
  box-shadow: 0 0 0 3px rgba(112, 240, 208, .18);
}

select.form-input {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a5b8c5' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

select.form-input option {
  background: #0d1e2d;
  color: #fff;
}

/* Custom Styled Range Slider */
.slider-container {
  margin-top: 10px;
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
  outline: none;
  cursor: pointer;
  transition: background .2s;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent);
  transition: transform .15s, background .15s;
  border: 2px solid #07151f;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.range-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent);
  border: 2px solid #07151f;
}

.slider-limits {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted-dark);
  margin-top: 5px;
}

/* Segmented / Toggle Radios */
.segmented-control {
  display: flex;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.segmented-control label {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
  user-select: none;
}

.segmented-control input[type="radio"] {
  display: none;
}

.segmented-control input[type="radio"]:checked + label {
  background: rgba(112, 240, 208, .18);
  color: var(--accent);
  border: 1px solid rgba(112, 240, 208, .35);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

/* KPI Summary Cards */
.results-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, .04);
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
  transition: transform .25s, border-color .25s;
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, .25);
}

.kpi-card.highlight {
  background: linear-gradient(135deg, rgba(112, 240, 208, .15), rgba(77, 165, 255, .06));
  border-color: rgba(112, 240, 208, .4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .25), 0 0 20px rgba(112, 240, 208, .08);
}

.kpi-card.highlight-purple {
  background: linear-gradient(135deg, rgba(142, 122, 255, .16), rgba(112, 240, 208, .05));
  border-color: rgba(142, 122, 255, .4);
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-family: "Manrope", sans-serif;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 800;
  letter-spacing: -.6px;
  color: #fff;
}

.kpi-card.highlight .kpi-value {
  color: var(--accent);
}

.kpi-card.highlight-purple .kpi-value {
  color: #b9aaff;
}

.kpi-sub {
  font-size: 10.5px;
  color: var(--muted-dark);
  margin-top: 4px;
}

/* Chart Canvas Section */
.chart-section {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(0, 0, 0, .2);
  margin-bottom: 22px;
}

.chart-wrapper {
  position: relative;
  height: 240px;
  width: 100%;
}

/* Action Export Buttons Bar */
.action-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 100px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all .25s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(110deg, #70f0d0 0%, #4da5ff 100%);
  color: #07151f;
  border: none;
  box-shadow: 0 4px 18px rgba(112, 240, 208, .3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(112, 240, 208, .45);
  filter: brightness(1.05);
}

.btn-outline {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #e4edf3;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .35);
  color: #fff;
  transform: translateY(-2px);
}

.btn-excel {
  background: linear-gradient(120deg, rgba(33, 115, 70, .35), rgba(33, 115, 70, .15));
  border: 1px solid rgba(75, 185, 125, .4);
  color: #a4f5cb;
}

.btn-excel:hover {
  background: rgba(33, 115, 70, .6);
  border-color: #55d693;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(33, 115, 70, .4);
}

.btn-pdf {
  background: linear-gradient(120deg, rgba(200, 40, 40, .35), rgba(200, 40, 40, .15));
  border: 1px solid rgba(255, 107, 139, .4);
  color: #ffb4c3;
}

.btn-pdf:hover {
  background: rgba(200, 40, 40, .6);
  border-color: #ff6b8b;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(200, 40, 40, .4);
}

/* Schedule Table Container */
.table-panel {
  margin-top: 26px;
}

.table-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(0, 0, 0, .25);
  max-height: 420px;
  overflow-y: auto;
}

.table-responsive::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, .2);
}

.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .15);
  border-radius: 4px;
}

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

.calc-table th {
  position: sticky;
  top: 0;
  background: #0d1e2d;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  font-size: 11px;
  padding: 13px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .15);
  z-index: 10;
  white-space: nowrap;
}

.calc-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  color: #dce5ec;
  white-space: nowrap;
}

.calc-table tr:hover td {
  background: rgba(255, 255, 255, .04);
}

.calc-table td.text-right,
.calc-table th.text-right {
  text-align: right;
}

.calc-table td.highlight-cell {
  color: var(--accent);
  font-weight: 700;
}

/* Informative Guides / Tips Accordion */
.info-accordion {
  margin-top: 28px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .03);
  overflow: hidden;
}

.accordion-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: rgba(255, 255, 255, .04);
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  transition: background .2s;
  user-select: none;
}

.accordion-header:hover {
  background: rgba(255, 255, 255, .08);
}

.accordion-icon {
  transition: transform .3s;
  color: var(--accent);
}

.info-accordion.open .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 20px;
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, padding .35s ease;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.info-accordion.open .accordion-content {
  padding: 18px 20px;
  max-height: 800px;
}

.info-list {
  padding-left: 20px;
  margin: 10px 0;
}

.info-list li {
  margin-bottom: 6px;
}

/* Formula Box */
.formula-box {
  background: rgba(0, 0, 0, .35);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 12px 16px;
  margin: 14px 0;
  font-family: "Consolas", monospace;
  font-size: 12.5px;
  color: #bbf7e9;
  overflow-x: auto;
}

/* Footer */
footer.app-footer {
  margin-top: 60px;
  border-top: 1px solid var(--line);
  padding: 24px 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: #8a99a4;
  font-size: 12px;
  flex-wrap: wrap;
}

footer.app-footer a {
  color: #bdcacd;
  text-decoration: none;
  transition: color .2s;
}

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

/* Toast Notification */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(10, 28, 40, .96);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6), 0 0 20px rgba(112, 240, 208, .2);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(20px);
  transition: all .3s ease;
  pointer-events: none;
}

.toast-notice.show {
  opacity: 1;
  transform: translateY(0);
}

/* Print Stylesheet for Clean PDF / Paper fitting */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 10pt;
  }
  body::before,
  header.app-header .header-actions,
  .action-bar,
  .range-slider,
  .slider-limits,
  .btn,
  .info-accordion,
  .help-tip,
  footer.app-footer {
    display: none !important;
  }
  .shell {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .calculator-grid {
    display: block !important;
  }
  .glass-panel {
    border: 1px solid #ccc !important;
    background: #fff !important;
    box-shadow: none !important;
    color: #000 !important;
    margin-bottom: 20px !important;
    page-break-inside: avoid;
  }
  .form-input {
    border: 1px solid #aaa !important;
    color: #000 !important;
    background: #fdfdfd !important;
  }
  .kpi-card {
    border: 1px solid #ddd !important;
    background: #f9f9f9 !important;
    color: #000 !important;
  }
  .kpi-value {
    color: #000 !important;
  }
  .table-responsive {
    max-height: none !important;
    overflow: visible !important;
    border: 1px solid #ccc !important;
  }
  .calc-table th {
    background: #eee !important;
    color: #000 !important;
    border-bottom: 2px solid #999 !important;
  }
  .calc-table td {
    color: #000 !important;
    border-bottom: 1px solid #ddd !important;
  }
}

/* Responsive adjustments */
@media (max-width: 680px) {
  .shell {
    width: calc(100% - 22px);
  }
  header.app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .page-intro {
    padding: 20px 0 16px;
  }
  .calc-title {
    font-size: 24px;
  }
  .glass-panel {
    padding: 18px;
  }
  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .btn {
    width: 100%;
  }
}

