:root {
    --bg-color: hsl(220, 30%, 94%);
    --btn-bg: hsl(220, 29%, 20%);
    --text-color: hsl(220, 25%, 25%);
    --highlight: hsl(22, 90%, 55%);
    --shadow-light: hsl(220, 30%, 100%);
    --shadow-dark: hsl(220, 30%, 86%);
    --btn-text: var(--shadow-light);
    --btn-surface: hsl(22, 100%, 94%);
    --btn-default-gradient: linear-gradient(180deg, hsl(220, 20%, 95%), hsl(220, 20%, 85%) 60%, hsl(220, 20%, 90%) 70%, hsl(220, 20%, 85%));
    --btn-gradient: linear-gradient(180deg, hsl(42, 95%, 80%) 10%, hsl(42, 100%, 60%) 30%, hsl(22, 90%, 50%) 60%, hsl(22, 90%, 60%) 75%, hsl(22, 90%, 50%));
    --btn-shadow-dark: hsl(22, 50%, 84%);
    --btn-shadow-light: hsl(22, 50%, 98%);
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    margin: 0;
    padding: 1rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    min-height: 100vh;
}

h1, h2, h3 {
    color: hsl(220, 30%, 20%);
    margin-top: 0;
    margin-bottom: 0;
    text-align: center;
}

h1 {
    font-size: 4rem;
    text-align: center;
    background: linear-gradient(180deg, hsl(calc(22deg + 20deg) 95% 80%) 10%, hsl(calc(22deg + 20deg) 100% 60%) 30%, hsl(22deg 90% 50%) 60%, hsl(22deg 90% 60%) 75%, hsl(22deg 90% 50%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 0;
    letter-spacing: 4px;
    font-weight: bold;
}

p {
    font-size: 1.2rem;
    text-align: center;
    font-weight: 500;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header.panel {
    text-align: center;
    margin-bottom: 1rem;
    padding: 0rem 0.8rem;
    gap: 0.2rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

/* Soft UI Panel (Extruded) */
.panel {
    background: var(--bg-color);
    border-radius: 50px;
    padding: 1rem;
    box-shadow: 20px 20px 60px var(--shadow-dark),
                -20px -20px 60px var(--shadow-light);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Input Fields & Data Containers (Pressed/Inset) */
.inset {
    background: var(--bg-color);
    border: none;
    border-radius: 20px;
    padding: 1rem;
    color: #333;
    box-shadow: inset 10px 10px 20px var(--shadow-dark),
                inset -10px -10px 20px var(--shadow-light);
    width: 100%;
    box-sizing: border-box;
    font-family: monospace;
    font-size: 1rem;
}

.inset:focus {
    outline: none;
    color: #fff;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 600;
}

textarea.inset {
    resize: vertical;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.7;
    margin-top: -0.4rem;
    display: block;
}

.module-def {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.8;
    text-align: center;
    line-height: 1;
    margin-top: -1rem;
    margin-bottom: 0rem;
    padding: 0 1rem;
}

/* Buttons (Tactile - State-Based Gradient) */
.btn {
    background: var(--btn-default-gradient);
    border: none;
    border-radius: 20px;
    padding: 1rem 2rem;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 8px 8px 16px var(--shadow-dark),
                -8px -8px 16px var(--shadow-light);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover {
    background: var(--btn-gradient);
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transform: translateY(-2px);
    box-shadow: 12px 12px 24px var(--btn-shadow-dark),
                -12px -12px 24px var(--btn-shadow-light);
}

.btn:active, .btn.active {
    box-shadow: inset 5px 5px 15px rgba(0,0,0,0.3),
                inset -5px -5px 15px rgba(255,255,255,0.3);
    transform: translateY(0);
}

.tabs {
    display: flex;
    gap: 1rem;
}

.tabs .btn {
    flex: 1;
}

/* Results & Visualization Areas */
.results {
    min-height: 60px;
    white-space: pre-wrap;
    font-size: 0.9rem;
    color: #555;
}

.viz-container {
    width: 100%;
    min-height: 350px;
    height: auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible; /* Ensure tooltips or large graphs don't get clipped */
}

/* Ensure canvas and svg within viz-container scale properly */
.viz-container canvas, 
.viz-container svg {
    max-width: 100%;
    height: auto !important;
}

/* D3.js Styling */
.node circle {
    fill: var(--bg-color);
    stroke: var(--highlight);
    stroke-width: 3px;
    filter: drop-shadow(5px 5px 10px var(--shadow-dark)) drop-shadow(-5px -5px 10px var(--shadow-light));
}

.node text {
    fill: #333;
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: bold;
}

.link {
    fill: none;
    stroke: #888;
    stroke-width: 2px;
}

/* Custom Toggle Switch Styles from Uiverse.io */
.toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  --hue: 220deg;
  --width: 10rem; /* Shortened to prevent label wrapping */
  --accent-hue: 22deg;
  --duration: 0.6s;
  --easing: cubic-bezier(1, 0, 1, 1);
}

.togglesw {
  display: none;
}

.switch {
  --shadow-offset: calc(var(--width) / 20);
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  width: var(--width);
  height: calc(var(--width) / 2.5);
  border-radius: var(--width);
  box-shadow: inset 10px 10px 10px hsl(var(--hue) 20% 80%),
    inset -10px -10px 10px hsl(var(--hue) 20% 93%);
}

.indicator {
  content: '';
  position: absolute;
  width: 40%;
  height: 60%;
  transition: all var(--duration) var(--easing);
  box-shadow: inset 0 0 2px hsl(var(--hue) 20% 15% / 60%),
    inset 0 0 3px 2px hsl(var(--hue) 20% 15% / 60%),
    inset 0 0 5px 2px hsl(var(--hue) 20% 45% / 60%);
}

.indicator.left {
  --hue: var(--accent-hue);
  overflow: hidden;
  left: 10%;
  border-radius: 100px 0 0 100px;
  background: linear-gradient(180deg, hsl(calc(var(--accent-hue) + 20deg) 95% 80%) 10%, hsl(calc(var(--accent-hue) + 20deg) 100% 60%) 30%, hsl(var(--accent-hue) 90% 50%) 60%, hsl(var(--accent-hue) 90% 60%) 75%, hsl(var(--accent-hue) 90% 50%));
}

.indicator.left::after {
  content: '';
  position: absolute;
  opacity: 0.6;
  width: 100%;
  height: 100%;
}

.indicator.right {
  right: 10%;
  border-radius: 0 100px 100px 0;
  background-image: linear-gradient(180deg, hsl(var(--hue) 20% 95%), hsl(var(--hue) 20% 65%) 60%, hsl(var(--hue) 20% 70%) 70%, hsl(var(--hue) 20% 65%));
}

.button-knob {
  position: absolute;
  z-index: 1;
  width: 55%;
  height: 80%;
  left: 5%;
  border-radius: 100px;
  background-image: linear-gradient(160deg, hsl(var(--hue) 20% 95%) 40%, hsl(var(--hue) 20% 65%) 70%);
  transition: all var(--duration) var(--easing);
  box-shadow: 2px 2px 3px hsl(var(--hue) 18% 50% / 80%),
    2px 2px 6px hsl(var(--hue) 18% 50% / 40%),
    10px 20px 10px hsl(var(--hue) 18% 50% / 40%),
    20px 30px 30px hsl(var(--hue) 18% 50% / 60%);
}

.button-knob::before, 
.button-knob::after {
  content: '';
  position: absolute;
  top: 10%;
  width: 41%;
  height: 80%;
  border-radius: 100%;
}

.button-knob::before {
  left: 5%;
  box-shadow: inset 1px 1px 2px hsl(var(--hue) 20% 85%);
  background-image: linear-gradient(-50deg, hsl(var(--hue) 20% 95%) 20%, hsl(var(--hue) 20% 85%) 80%);
}

.button-knob::after {
  right: 5%;
  box-shadow: inset 1px 1px 3px hsl(var(--hue) 20% 70%);
  background-image: linear-gradient(-50deg, hsl(var(--hue) 20% 95%) 20%, hsl(var(--hue) 20% 75%) 80%);
}

.togglesw:checked ~ .button-knob {
  left: 40%;
}

.togglesw:not(:checked) ~ .indicator.left,
.togglesw:checked ~ .indicator.right {
  box-shadow: inset 0 0 5px hsl(var(--hue) 20% 15% / 100%),
    inset 20px 20px 10px hsl(var(--hue) 20% 15% / 100%),
    inset 20px 20px 15px hsl(var(--hue) 20% 45% / 100%);
}

#inv-eoq-inputs, #inv-cont-inputs {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.calc-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: auto;
}

.btn {
    width: 100%;
    box-sizing: border-box;
}

.switch-label {
    margin-right: 1rem;
    font-weight: bold;
    color: var(--text-color);
    white-space: nowrap;
}

footer {
    text-align: center;
    padding: 3rem 1rem;
    margin-top: 2rem;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
}

footer a {
    color: var(--highlight);
    text-decoration: none;
    font-weight: bold;
    transition: filter 0.2s ease;
}

footer a:hover {
    filter: brightness(1.2);
    text-decoration: underline;
}
