* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #2c3e50;
    --color-secondary: #34495e;
    --color-accent: #3498db;
    --color-success: #27ae60;
    --color-warning: #f39c12;
    --color-danger: #e74c3c;
    --color-light-bg: #ecf0f1;
    --color-white: #ffffff;
    --color-text: #2c3e50;
    --color-text-light: #7f8c8d;

    /* Tax band colours */
    --color-personal-allowance: #95a5a6;
    --color-basic-rate: #3498db;
    --color-higher-rate: #e67e22;
    --color-additional-rate: #e74c3c;
    --color-sacrifice: #9b59b6;

    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

header {
    background: var(--color-primary);
    color: var(--color-white);
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1rem;
    color: var(--color-light-bg);
    opacity: 0.9;
}

main {
    padding: 30px;
}

/* ============================================================
   Section headings
   ============================================================ */

.input-section h2,
.results-section h2,
.chart-section h2,
.allocation-section h2 {
    color: var(--color-primary);
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: 10px;
}

/* ============================================================
   Input section
   ============================================================ */

.input-section {
    margin-bottom: 40px;
}

.input-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 10px;
}

.input-subsection {
    margin-bottom: 25px;
}

.input-subsection h3 {
    color: var(--color-secondary);
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.input-field {
    display: flex;
    flex-direction: column;
}

.input-field label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-secondary);
    font-size: 0.95rem;
}

.input-field input {
    padding: 12px;
    border: 2px solid var(--color-light-bg);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-field input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}

.input-field input.input-has-warning {
    border-color: var(--color-warning);
}

.input-field input.input-has-warning:focus {
    border-color: var(--color-warning);
    box-shadow: 0 0 0 3px rgba(243,156,18,0.15);
}

.input-field input.input-has-error {
    border-color: var(--color-danger);
}

.input-field input.input-has-error:focus {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(231,76,60,0.15);
}

.input-field small {
    margin-top: 5px;
    font-size: 0.82rem;
    color: var(--color-text-light);
    font-style: italic;
}

.input-validation-message {
    margin-top: 6px;
    font-size: 0.82rem;
    font-style: italic;
}

.input-validation-message.warning {
    color: var(--color-warning);
}

.input-validation-message.error {
    color: var(--color-danger);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--color-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-accent);
}

.tax-code-info {
    color: var(--color-text-light);
    font-style: italic;
    font-size: 0.82rem;
    min-height: 1.2em;
    margin-top: 5px;
}

.tax-code-info.warning { color: var(--color-warning); }
.tax-code-info.success { color: var(--color-success); }

/* ============================================================
   Monthly results grid
   ============================================================ */

.results-section {
    margin-bottom: 40px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.result-card {
    background: var(--color-light-bg);
    border-radius: 10px;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 4px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.result-card.gross        { border-top-color: #95a5a6; }
.result-card.taxable      { border-top-color: #3498db; }
.result-card.tax          { border-top-color: #e74c3c; }
.result-card.ni           { border-top-color: #e67e22; }
.result-card.pension      { border-top-color: #9b59b6; }
.result-card.net          { border-top-color: #27ae60; background: #eafaf1; }

.result-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.2;
}

.result-card.net .result-value {
    color: #1a7a3f;
    font-size: 1.7rem;
}

.result-sub {
    font-size: 0.78rem;
    color: var(--color-text-light);
}

.bonus-month-note {
    background: #fff8e6;
    border: 1px solid #f6d860;
    border-left: 4px solid var(--color-warning);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.875rem;
    color: var(--color-secondary);
    margin-bottom: 16px;
}

.employer-note {
    background: #f0f3ff;
    border: 1px solid #c5cae9;
    border-radius: 8px;
    padding: 12px 18px;
    font-size: 0.9rem;
    color: var(--color-secondary);
}

/* ============================================================
   Tax band chart
   ============================================================ */

.chart-section {
    margin-bottom: 40px;
}

.chart-container {
    margin-bottom: 20px;
}

#taxBandChart {
    display: flex;
    width: 100%;
    height: 28px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(0,0,0,0.06);
}

.tax-bar-seg {
    height: 100%;
    transition: width 0.3s ease;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--color-secondary);
}

.legend-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-info {
    background: #e8f4f8;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid var(--color-accent);
}

.legend-info p {
    color: var(--color-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* ============================================================
   Taper section
   ============================================================ */

.taper-section {
    margin-bottom: 40px;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--color-light-bg);
    background: #fff8e6;
    border-left: 4px solid var(--color-warning);
}

.taper-section h2 {
    color: var(--color-primary);
    font-size: 1.25rem;
    margin-bottom: 10px;
    border-bottom: none;
    padding-bottom: 0;
}

.taper-text {
    color: var(--color-secondary);
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.taper-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
    margin-bottom: 14px;
}

.taper-metric {
    background: var(--color-white);
    border-radius: 6px;
    padding: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}

.taper-label {
    display: block;
    font-size: 0.85rem;
    color: var(--color-text-light);
    font-weight: 600;
    margin-bottom: 4px;
}

.taper-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-primary);
}

.taper-bar { margin-top: 10px; }

.taper-bar-track {
    width: 100%;
    height: 14px;
    background: rgba(0,0,0,0.08);
    border-radius: 999px;
    overflow: hidden;
}

.taper-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-success), var(--color-warning));
    border-radius: 999px;
    transition: width 0.2s ease;
}

.taper-bar-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--color-text-light);
    font-weight: 600;
}

/* ============================================================
   Pay allocation section
   ============================================================ */

.allocation-section {
    margin-bottom: 40px;
}

.allocation-intro {
    color: var(--color-text-light);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.allocation-input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 16px;
}

.alloc-info-box {
    background: #f0f7ff;
    border: 1px solid #c5dff8;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alloc-info-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--color-secondary);
    line-height: 1.5;
}

.alloc-info-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.allocation-summary {
    background: var(--color-light-bg);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.alloc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 1rem;
}

.alloc-row.take-home-row {
    background: var(--color-white);
    font-weight: 700;
    font-size: 1.1rem;
    border-bottom: 2px solid #ddd;
    margin-bottom: 4px;
}

.alloc-row.deduction-row {
    color: var(--color-secondary);
}

.alloc-row.deduction-row:hover {
    background: rgba(0,0,0,0.03);
    border-radius: 6px;
}

.alloc-row.remaining-row {
    background: #eafaf1;
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: 4px;
    border-top: 2px solid #c3e6cb;
}

.alloc-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.alloc-value {
    font-weight: 700;
    font-size: 1rem;
}

.alloc-value.positive { color: #1a7a3f; }
.alloc-value.negative { color: var(--color-danger); }

.alloc-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.remaining-dot {
    background: #27ae60;
}

/* Stacked allocation bar */

.alloc-bar-wrap {
    height: 28px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(0,0,0,0.06);
    display: flex;
    margin-bottom: 12px;
}

.alloc-bar {
    display: flex;
    height: 100%;
    width: 100%;
}

.alloc-bar-seg {
    height: 100%;
    transition: width 0.3s ease;
}

.alloc-bar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
}

.alloc-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-secondary);
}

.alloc-legend-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ============================================================
   Footer
   ============================================================ */

footer {
    background: var(--color-light-bg);
    padding: 20px 30px;
    border-top: 1px solid #ddd;
}

.disclaimer {
    font-size: 0.85rem;
    color: var(--color-text-light);
    text-align: center;
    margin-bottom: 6px;
}

.disclaimer:last-child { margin-bottom: 0; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
    body { padding: 10px; }
    header { padding: 20px; }
    header h1 { font-size: 1.5rem; }
    .subtitle { font-size: 0.9rem; }
    main { padding: 20px; }
    .input-group,
    .allocation-input-grid { grid-template-columns: 1fr; gap: 15px; }
    .results-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-container { }
    .chart-legend { gap: 10px; }
    .taper-metrics { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    header h1 { font-size: 1.3rem; }
    .results-grid { grid-template-columns: 1fr 1fr; }
    .result-value { font-size: 1.2rem; }
    .result-card.net .result-value { font-size: 1.4rem; }
    .taper-metrics { grid-template-columns: 1fr; }
    .legend-item { font-size: 0.85rem; }
}
