/* ==========================================================================
   Global Theme & Variables
   ========================================================================== */
:root {
    --bg-color: #f4f6f9;
    /* Very light grey background */
    --primary-color: #ffffff;
    /* White for containers */
    --secondary-color: #e9ecef;
    /* Light grey for borders, headers */
    --accent-color: #007bff;
    /* Professional blue for highlights */
    --text-color: #212529;
    /* Dark grey/black for text */
    --text-color-muted: #6c757d;
    /* Muted grey for secondary text */
    --link-text-color: #ffffff;

    /* Status Colors */
    --win-bg: #d1e7dd;
    /* Bootstrap-style light green */
    --loss-bg: #f8d7da;
    /* Bootstrap-style light red */
    --breakeven-bg: #fff3cd;
    /* Bootstrap-style light yellow */
    --win-text: #0f5132;
    /* Strong green */
    --loss-text: #842029;
    /* Strong red */
    --breakeven-text: #664d03;
    /* Strong yellow/amber */
}

html {
    /* Ensure the html element can scroll */
    overflow-y: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    /* CRITICAL FIXES FOR SCROLLING */
    min-height: 100vh;
    /* Ensure body can be at least the height of the screen */
    overflow-x: hidden;
    /* Prevent accidental horizontal scrolling */
    display: flex;
    /* Use flexbox for robust layout */
    flex-direction: column;
    /* Stack children vertically */
}

h1,
h2,
h3 {
    color: var(--text-color);
}

hr {
    border: none;
    border-top: 1px solid var(--secondary-color);
    margin: 1.5em 0;
}

/* ==========================================================================
   Main Layout & Header
   ========================================================================== */
.container {
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    /* Ensure it takes up available width */
    box-sizing: border-box;
    /* Include padding in width calculation */
    flex-grow: 1;
    /* Allow this container to grow to fill space */
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    margin-bottom: 2em;
}

.main-header h1 {
    margin: 0;
    font-size: 1.5em;
    color: var(--accent-color);
}

.main-nav {
    display: flex;
    gap: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background-color: #6c757d;
    /* Muted grey for nav buttons */
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.nav-link:hover {
    background-color: var(--accent-color);
}

.nav-link i {
    font-size: 1.1em;
}

.hamburger-menu {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.8em;
    cursor: pointer;
}

/* ==========================================================================
   Forms, Buttons & Inputs
   ========================================================================== */
.form-container,
.table-container,
.filter-container,
.results-wrapper,
.chat-wrapper,
.summary-card {
    background: var(--primary-color);
    padding: 1.5em;
    border-radius: 8px;
    margin-bottom: 2em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--secondary-color);
}

.form-container h2,
.table-container h2,
.filter-container h2,
.results-wrapper h2,
.chat-wrapper h2 {
    margin-top: 0;
    color: var(--text-color);
    border-bottom: 1px solid var(--secondary-color);
    padding-bottom: 0.5em;
    margin-bottom: 1em;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5em;
}

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

.form-group label {
    margin-bottom: 0.5em;
    font-weight: 600;
    font-size: 0.9em;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

input[type="date"],
input[type="time"],
input[type="number"],
input[type="password"],
input[type="text"],
select,
textarea {
    width: 100%;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #ced4da;
    color: var(--text-color);
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, .25);
    outline: none;
}

.submit-btn,
.header-actions-button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 1.1em;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    text-decoration: none;
    display: inline-block;
}

.submit-btn {
    width: 100%;
    margin-top: 1em;
}

.submit-btn:hover,
.header-actions-button:hover {
    background-color: #0056b3;
}

.autofilled-field {
    background-color: var(--secondary-color) !important;
    font-weight: bold;
    cursor: not-allowed;
}

/* ==========================================================================
   Checklist & Score
   ========================================================================== */
.checklist-container {
    background-color: var(--primary-color);
    padding: 1.5em;
    border-radius: 8px;
    margin: 2em 0;
    border: 1px solid var(--secondary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.checklist-container h2 {
    text-align: center;
    margin-top: 0;
    color: var(--accent-color);
}

.checklist-grid {
    display: grid;
    /* Create 2 columns on desktop, 1 on mobile (handled in media query) */
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 20px;
    margin-bottom: 1.5em;
}

.check-item {
    background-color: var(--bg-color);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid var(--secondary-color);
}

.check-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    cursor: pointer;
}

.check-item input[type="checkbox"] {
    width: auto;
    /* Override default width */
    transform: scale(1.4);
    /* Make checkboxes a bit bigger */
}

.check-item img {
    height: 25px;
    width: auto;
}

.conditional-check {
    display: none;
    /* Hidden by default */
    background-color: #eef;
    /* A slightly different background to show it's a sub-question */
}

.conditional-check.visible {
    display: block;
    /* Class to make it visible */
}

.score-display {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.5em;
    font-weight: bold;
    transition: background-color 0.3s, color 0.3s;
}

.score-value {
    margin: 0 10px;
}

/* Grade-specific coloring */
.grade-no-trade {
    background-color: var(--loss-bg);
    color: var(--loss-text);
}

.grade-a-minus {
    background-color: var(--breakeven-bg);
    color: var(--breakeven-text);
}

.grade-a,
.grade-a-plus {
    background-color: var(--win-bg);
    color: var(--win-text);
}

/* ==========================================================================
   Calculator Specific Styles
   ========================================================================== */
.calculator-body h1 {
    text-align: center;
    color: var(--accent-color);
    margin-bottom: 1em;
}

/* This is the new grid layout for desktop */
.calculator-layout {
    display: grid;
    /* Desktop: Two columns. Form is 400px, Results take the rest */
    grid-template-columns: 400px 1fr;
    gap: 30px;
    align-items: flex-start;
}

/* We are using the generic .form-container and .results-wrapper classes,
   which are already styled. We just add this specific alignment. */
.results-wrapper {
    position: sticky;
    /* Make the results stick to the top as you scroll */
    top: 20px;
}

#tradingStatus,
#priceRangeStatus {
    font-size: 1.1em;
    font-weight: bold;
    padding: 12px;
    margin-bottom: 15px;
    text-align: center;
    border-radius: 5px;
    border: 1px solid transparent;
}

#tradingStatus.trading-active,
#priceRangeStatus.range-valid {
    background-color: var(--win-bg);
    color: var(--win-text);
    border-color: #b1dfbb;
}

#tradingStatus.trading-inactive,
#priceRangeStatus.range-invalid {
    background-color: var(--loss-bg);
    color: var(--loss-text);
    border-color: #f5c2c7;
}

.header-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.header-actions button {
    padding: 10px 15px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
}

.header-actions button:hover {
    background-color: #5a6268;
}

.results p {
    margin: 10px 0;
}

.results .profit {
    color: var(--win-text);
    font-weight: bold;
}

.results .limit1 {
    color: #fd7e14;
}

.results .limit2 {
    color: #0d6efd;
}

.results .risk {
    color: var(--loss-text);
    font-weight: bold;
}

.important {
    background: var(--loss-bg);
    border: 1px solid #f5c2c7;
    border-radius: 10px;
    padding: 15px;
    color: var(--loss-text);
    width: 100%;
    margin: 2em 0;
    box-sizing: border-box;
}

.important ul {
    margin: 0;
    padding-left: 20px;
}

/* ==========================================================================
   Stats Summary Dashboard
   ========================================================================== */
.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 2em;
}

.stats-card {
    background: var(--primary-color);
    padding: 1.5em;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid var(--secondary-color);
}

.stats-card h3 {
    margin-top: 0;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
    font-size: 1.2em;
    color: var(--text-color);
}

.r-pos { color: var(--win-text); font-weight: bold; }
.r-neg { color: var(--loss-text); font-weight: bold; }
.r-neu { color: var(--text-color-muted); }


/* ==========================================================================
   Rules Section
   ========================================================================== */
.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.rule-box {
    padding: 15px;
    border-radius: 6px;
    border-left: 5px solid #ccc;
    background-color: var(--bg-color);
}

.rule-box.stop { border-color: var(--loss-text); background-color: var(--loss-bg); }
.rule-box.go { border-color: var(--win-text); background-color: var(--win-bg); }
.rule-box.info { border-color: var(--accent-color); background-color: #e3f2fd; }
.rule-box.warn { border-color: #ffc107; background-color: #fff3cd; }

.rule-box h4 { margin: 0 0 5px 0; font-size: 0.9em; text-transform: uppercase; letter-spacing: 1px; }
.rule-box p { margin: 0; font-weight: 500; font-size: 1.1em; }


/* ==========================================================================
   Matrix Table Display
   ========================================================================== */
.stats-card table {
    border-collapse: collapse;
    width: 100%;
    min-width: 600px; /* Forces the table to maintain a readable width, triggering scroll if needed */
    margin: 0;
}

.stats-card th, .stats-card td {
    border: 1px solid #dddddd;
    text-align: left;
    padding: 12px;
    white-space: nowrap; /* Prevents text from wrapping too aggressively */
}

.stats-card th {
    background-color: #f8f9fa; /* Light grey background for headers */
    font-weight: bold;
    vertical-align: top;
    color: #333;
}

/* Sticky First Column (Optional: Keeps "Day" visible while scrolling) */
.stats-card th:first-child, .stats-card td:first-child {
    position: sticky;
    left: 0;
    background-color: #fff; /* Match background to hide content sliding under */
    z-index: 1;
    border-right: 2px solid #ddd; /* Visual separator */
}

.stats-card th:first-child {
    background-color: #f8f9fa;
    z-index: 2; /* Ensure header stays on top of sticky column */
}

/* Alternating row colors */
.stats-card tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.stats-card tbody tr:nth-child(even) td:first-child {
    background-color: #f9f9f9; /* Fix for sticky column on striped rows */
}

.stats-card .title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    color: #333;
}
  
.stats-card .chart-icon {
    margin-right: 8px;
}

/* Header specific styling */
.stats-card .header-icon {
    font-size: 1.2em;
    display: block;
    margin-bottom: 5px;
}

.stats-card .header-sub {
    font-weight: normal;
    font-size: 0.85em;
    color: #666;
    display: block;
    margin-top: 4px;
}
 

/* ==========================================================================
   Table & Data Display
   ========================================================================== */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1em;
}

th,
td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--secondary-color);
}

th {
    background-color: var(--secondary-color);
    font-weight: 600;
}

tbody tr.win {
    background-color: var(--win-bg);
}

tbody tr.loss {
    background-color: var(--loss-bg);
}

tbody tr.breakeven {
    background-color: var(--breakeven-bg);
}

td.result-win {
    font-weight: bold;
    color: var(--win-text);
}

td.result-loss {
    font-weight: bold;
    color: var(--loss-text);
}

td.result-breakeven {
    font-weight: bold;
    color: var(--breakeven-text);
}

td.trade-images img {
    max-width: 100px;
    max-height: 100px;
    width: auto;
    height: auto;
}

.form-group .trade-images img {
    max-width: 500px
}

.preview-item img {
    max-width: 200px
}

.action-links a {
    color: var(--link-text-color);
    text-decoration: none;
    margin-right: 10px;
    padding: 4px 8px;
    border-radius: 3px;
    display: inline-block;
}

.action-links a.edit {
    background-color: #0d6efd;
}

/* Blue */
.action-links a.delete {
    background-color: #dc3545;
}

/* Red */
.action-links a.ai-analyze-btn {
    background-color: #6f42c1;
}

/* Purple */

/* --- Progress Bars --- */
.progress-bar-container {
    width: 100%;
    background-color: var(--secondary-color);
    border-radius: 10px;
    height: 22px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.progress-bar {
    background-color: var(--accent-color);
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.progress-bar-text {
    position: relative;
    z-index: 2;
    font-size: 12px;
    color: var(--text-color);
    font-weight: bold;
}

/* ==========================================================================
   Reminders
   ========================================================================== */

.dynamic-reminder ul {
    margin-left: 20px;
    margin-bottom: 15px;
}
.dynamic-reminder h3 {
    margin-bottom: 10px;
}

.dynamic-reminder {
	color: #ff0000;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal,
.modal-overlay {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 20px 30px;
    border: none;
    width: 80%;
    max-width: 1050px;
    /* A good default max-width */
    border-radius: 8px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    color: var(--text-color);
    /* Ensure text color is correct for light theme */
}

/* Specific styling for the AI modal content */
.ai-modal-content {
    /* This class can be used for specific overrides if needed,
       but it will inherit all the good styles from .modal-content */
}

.modal-content h2,
.ai-modal-content h3 {
    margin-top: 0;
    color: var(--accent-color);
}

.modal-content.image-modal-content {
    max-width: 90%;
    /* Allow image modal to be wider */
    max-height: 85vh;
    overflow-y: auto;
    padding: 15px;
}

.modal-content.image-modal-content img {
    width: 100%;
    height: auto;
    margin-bottom: 5px;
}

.close-button,
.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
    cursor: pointer;
    line-height: 1;
}

.close-button:hover,
.close-button:focus,
.close-modal:hover,
.close-modal:focus {
    color: #333;
}

/* ==========================================================================
   Miscellaneous Components
   ========================================================================== */
.message {
    padding: 1em;
    border-left: 4px solid var(--accent-color);
    margin-bottom: 1em;
    border-radius: 4px;
    background-color: var(--secondary-color);
}

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1em 5px;
    border-top: 1px solid var(--secondary-color);
    margin-top: 1em;
}

.pagination-summary {
    font-size: 0.9em;
    color: var(--text-color-muted);
}

.pagination {}

.pagination a {
    padding: 5px;
    text-decoration: none;
    color: #000
}

.pagination a:hover {
    color: #007bff
}

.pagination a.active {
    color: #842029
}

a.logout-btn {
    padding: 10px;
    color: #fff;
    text-decoration: none;
    border-radius: 5px
}

/* ==========================================================================
   Trading Performance Report
   ========================================================================== */
.report-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
	gap: 2em;
}
.chart-container {
	background: var(--primary-color);
	padding: 1.5em;
	border-radius: 8px;
	box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.chart-container h3 {
	margin-top: 0;
	text-align: center;
	color: var(--accent-color);
}
.summary-list {
	list-style-type: none;
	padding: 0;
	margin: 0;
	font-size: 1.1em;
}
.summary-list li {
	display: flex;
	justify-content: space-between;
	padding: 12px 5px;
	border-bottom: 1px solid var(--secondary-color);
}
.summary-list li:last-child {
	border-bottom: none;
}
.summary-list span:last-child {
	font-weight: bold;
}
.pnl-positive {
	color: #2ecc71; /* Green for positive numbers */
}
.pnl-negative {
	color: #e74c3c; /* Red for negative numbers */
}
.chat-wrapper {
	background: var(--primary-color);
	padding: 1.5em;
	border-radius: 8px;
	box-shadow: 0 4px 15px rgba(0,0,0,0.3);
	margin-top: 2em;
}
.chat-wrapper h3 {
	margin-top: 0;
	text-align: center;
	color: var(--accent-color);
}
.chat-container {
	height: 300px;
	overflow-y: auto;
	border: 1px solid var(--secondary-color);
	border-radius: 5px;
	padding: 10px;
	margin-bottom: 10px;
	background-color: var(--bg-color);
	display: flex;
	flex-direction: column-reverse; /* Shows latest messages at the bottom */
}
.chat-message {
	margin-bottom: 10px;
	padding: 8px 12px;
	border-radius: 15px;
	max-width: 80%;
	line-height: 1.4;
}
.chat-message.user {
	background-color: #2980b9;
	color: white;
	align-self: flex-end;
	border-bottom-right-radius: 3px;
}
.chat-message.ai {
	background-color: var(--secondary-color);
	color: var(--text-color);
	align-self: flex-start;
	border-bottom-left-radius: 3px;
}
.chat-message.ai.thinking {
	color: #888;
	font-style: italic;
}
#chat-input-form {
	display: flex;
	gap: 10px;
}
#chat-input {
	flex-grow: 1;
	padding: 10px;
	background-color: var(--secondary-color);
	border: 1px solid #0f3460;
	color: var(--text-color);
	border-radius: 4px;
}

/* ==========================================================================
   Money Management
   ========================================================================== */
.summary-grid { 
	display: grid; 
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
	gap: 1.5em; 
}
.summary-card { 
	background: var(--primary-color); 
	padding: 1.5em; 
	border-radius: 8px; 
}
.summary-card h3 { 
	margin-top: 0; 
	color: var(--accent-color); 
}
.summary-card .value { 
	font-size: 2em; 
	font-weight: bold; 
}
.summary-card .label { 
	color: #aab8c2; 
}
.stage-risk_off_1, .stage-risk_off_2 { 
	color: #e67e22; 
}
.stage-compounding { 
	color: #2ecc71; 
}

/* ==========================================================================
   Calendar Display
   ========================================================================== */
#calendar-container {
	background-color: var(--primary-color);
	padding: 2em;
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
/* Style the calendar header (Prev, Next, Title) */
.fc-header-toolbar {
	color: var(--text-color);
	margin-bottom: 1.5em !important;
}
.fc .fc-button-primary {
	background-color: var(--accent-color);
	border-color: var(--accent-color);
}
.fc .fc-button-primary:hover {
	background-color: #0056b3;
	border-color: #0056b3;
}
/* Style the day headers (Sun, Mon, etc.) */
.fc .fc-col-header-cell-cushion {
	color: var(--text-color-muted);
	text-decoration: none;
}
/* Style the event blocks */
.fc-event {
	font-size: 0.9em;
	font-weight: bold;
	cursor: pointer;
}
/* Styling for the Platform Totals inside the cell */
.weekly-total-container {
	margin-top: 3px;
    padding-top: 2px;
	padding-right: 10px;
	border-top: 1px dashed #ccc;
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.platform-total-row {
	display: flex;
	flex-direction: column;
	line-height: 1.1;
	text-align: right;
	padding-right: 5px;
	margin-bottom: 2px;
}

.platform-label {
	font-size: 9px;
	color: #888;
	font-weight: bold;
	text-transform: uppercase;
}

.platform-value {
	font-size: 11px;
	font-weight: 800;
}

/* Ensure the Saturday cell can grow to fit the totals */
.fc-daygrid-day-frame {
	min-height: 50px !important; /* Default is often 100px. Adjust as needed. */
	display: flex;
	flex-direction: column;
}
/* 2. Reduce the padding around the day number (top of the cell) */
.fc-daygrid-day-top {
    padding: 2px !important;
    flex-direction: row !important; /* Keeps number at the top right/left compactly */
}

/* 3. Shrink the day number font size if you want it even tighter */
.fc-daygrid-day-number {
    font-size: 0.8em;
    padding: 2px 5px !important;
}

/* 4. Reduce spacing between the daily events */
.fc-daygrid-event-harness {
    margin-top: 1px !important;
    margin-bottom: 0px !important;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */
@media (max-width: 768px) {

    /* --- Global Mobile Styles --- */
    body {
        padding: 10px;
    }

    .main-header h1 {
        font-size: 1.2em;
    }

    .form-container,
    .table-container,
    .filter-container,
    .results-wrapper,
    .chat-wrapper,
    .summary-card {
        padding: 1em;
        /* Reduce padding on smaller screens */
    }

    /* --- Header Hamburger Menu --- */
    .hamburger-menu {
        display: block;
    }

    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        background-color: var(--primary-color);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
        flex-direction: column;
        width: 250px;
        border-radius: 0 0 0 8px;
        z-index: 100;
    }

    .main-nav.is-active {
        display: flex;
    }

    .nav-link {
        width: 100%;
        border-radius: 0;
        border-bottom: 1px solid var(--secondary-color);
        padding: 15px 20px;
        justify-content: flex-start;
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .important {
        font-size: 14px;
    }

    .checklist-grid {
        grid-template-columns: 1fr;
        /* Stack checklist items on mobile */
    }

    /* --- NEW: CALCULATOR RESPONSIVE STYLES --- */
    .calculator-container {
        flex-direction: column;
        /* Stack the form and results vertically */
        align-items: stretch;
        /* Make them take up the full width */
    }

    .calculator-layout {
        /* This is the key fix: it changes the two-column grid to a single-column layout */
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .calculator-body h1 {
        font-size: 1.5em;
    }

    .results-wrapper {
        position: static;
        /* Unstick the results panel on mobile */
    }

    .header-actions {
        flex-direction: column;
        /* Stack the guideline buttons */
    }

    .header-actions button {
        width: 100%;
        /* Make buttons full-width */
    }

    .important {
        width: 100%;
        /* Make the important box full-width */
        box-sizing: border-box;
        /* Include padding in the width calculation */
    }

    /* Make modals take up more of the screen on mobile */
    .modal-content {
        max-width: 300px;
        width: 95%;
        margin: 5% auto;
    }

    .modal-content img {
        width: 100%
    }
}