:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --accent-glow: rgba(59, 130, 246, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Background */
.background-globes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.globe {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}

.globe-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
    animation: float 10s infinite ease-in-out;
}

.globe-2 {
    width: 500px;
    height: 500px;
    background: #8b5cf6;
    /* Violet */
    bottom: -150px;
    right: -150px;
    animation: float 12s infinite ease-in-out reverse;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, 50px);
    }

    100% {
        transform: translate(0, 0);
    }
}

.container {
    width: 100%;
    max-width: 1100px;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Glass Cards */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

/* Input Section */
.input-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: end;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="date"] {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.8rem;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    color-scheme: dark;
    transition: all 0.3s ease;
}

input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn-row {
    grid-column: span 2;
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
}

.primary-btn {
    flex: 4;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.reset-btn {
    flex: 1;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.reset-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}

/* Results Section */
.hidden {
    display: none;
}

.results-section {
    animation: fadeInUp 0.5s ease-out;
}

.result-summary {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.summary-item {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 1rem 2rem;
    border-radius: 12px;
    text-align: center;
}

.summary-item .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.legislation-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
}

.legislation-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: white;
}

.legislation-desc {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1.5rem;
}

.divider {
    height: 1px;
    background: var(--glass-border);
    margin: 1.5rem 0;
}

.legislation-card h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--text-color);
}

.offences-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.offence-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 1.2rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.offence-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.offence-item.selected {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.06);
}

/* Row top: checkbox + toggle side by side */
.offence-row-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Custom checkbox */
.offence-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.offence-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--glass-border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}

.offence-checkbox:checked+.checkbox-custom {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.offence-checkbox:checked+.checkbox-custom::after {
    content: '✓';
    font-size: 13px;
    color: white;
    font-weight: 700;
}

.offence-checkbox-label:hover .checkbox-custom {
    border-color: var(--primary-color);
}

/* Toggle fills remaining space */
.offence-row-top .offence-toggle {
    flex: 1;
    min-width: 0;
}

/* Offences list header */
.offences-list-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.offences-list-header h3 {
    margin: 0;
}

.select-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

/* ── Export Section ─────────────────────────────────────────────────────────── */
.export-toolbar {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 14px;
    margin-top: 1.25rem;
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.1);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.export-toolbar:has(#export-panel:not([hidden])) {
    box-shadow: 0 0 32px rgba(59, 130, 246, 0.18);
}

/* Trigger row — always visible */
.export-trigger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
}

.export-trigger-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
}

.export-trigger-left svg {
    color: var(--primary-color);
    flex-shrink: 0;
}

.selected-count-badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: 99px;
    white-space: nowrap;
}

/* "Prepare Export" trigger button */
.export-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.87rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}

.export-toggle-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.export-toggle-btn[aria-expanded="true"] {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.export-chevron {
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.export-toggle-btn[aria-expanded="true"] .export-chevron {
    transform: rotate(180deg);
}

/* Collapsible panel body */
.export-panel {
    padding: 0 1.5rem 1.5rem;
    animation: exportPanelIn 0.25s ease-out;
}

@keyframes exportPanelIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.export-panel-divider {
    height: 1px;
    background: var(--glass-border);
    margin-bottom: 1.25rem;
}

.export-panel-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 0.75rem;
}

.export-panel-hint {
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: rgba(148, 163, 184, 0.7);
}

/* 2-column grid for export fields */
.export-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.export-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* full-width field */
.export-field-full {
    grid-column: span 2;
}

.export-field-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.export-field-group input[type="text"],
.export-field-group input[type="date"] {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.export-field-group input[type="text"]::placeholder,
.export-field-group input[type="date"]::placeholder {
    color: rgba(148, 163, 184, 0.45);
}

.export-field-group input[type="text"]:focus,
.export-field-group input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Label row: field name left, checkbox right */
.export-field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0;
}

.export-field-label-row label[for] {
    margin-bottom: 0;
}

.diff-location-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    padding: 0.2rem 0;
    transition: opacity 0.2s ease;
}

.diff-location-checkbox-label:hover {
    opacity: 0.85;
}

.diff-location-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.diff-checkbox-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--glass-border);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.diff-location-checkbox-label input[type="checkbox"]:checked+.diff-checkbox-custom {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.diff-location-checkbox-label input[type="checkbox"]:checked+.diff-checkbox-custom::after {
    content: '✓';
    font-size: 10px;
    color: white;
    font-weight: 700;
}

.diff-checkbox-text {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Revealed proceeding location field — hidden until checkbox is ticked */
#exp-diff-location-group[hidden] {
    display: none !important;
}

#exp-diff-location-group:not([hidden]) {
    animation: exportPanelIn 0.2s ease-out;
}

/* Format buttons row */
.export-format-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1.3rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.export-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.export-pdf-btn {
    background: #dc2626;
    color: white;
}

.export-word-btn {
    background: #2563eb;
    color: white;
}

@media (max-width: 600px) {
    .export-fields-grid {
        grid-template-columns: 1fr;
    }

    .export-field-full {
        grid-column: span 1;
    }

    .export-format-row {
        flex-direction: column;
    }

    .export-btn {
        justify-content: center;
    }

    .export-trigger-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .export-toggle-btn {
        width: 100%;
        justify-content: center;
    }
}

.offence-toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0;
    text-align: left;
    color: inherit;
}

.offence-toggle:hover .offence-name {
    color: var(--primary-color);
}

.toggle-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.offence-toggle[aria-expanded="true"] .toggle-icon {
    color: var(--primary-color);
}

.offence-body {
    margin-top: 0.75rem;
}

.offence-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section-number {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.offence-name {
    font-weight: 600;
    font-size: 1.05rem;
    transition: color 0.2s ease;
}

.selection-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary-color);
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 99px;
    line-height: 1.4;
    white-space: nowrap;
    margin-left: 0.25rem;
}

.offence-notes {
    font-size: 0.83rem;
    color: var(--text-muted);
    margin-top: 0.6rem;
    line-height: 1.5;
}

footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 600px) {
    .input-card {
        grid-template-columns: 1fr;
    }

    .primary-btn {
        grid-column: span 1;
    }

    .sub-offences-table {
        display: block;
        overflow-x: auto;
    }
}

/* Sub-offences Table */
.sub-offences-table-wrapper {
    overflow-x: auto;
    margin-top: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.sub-offences-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.sub-offences-table thead tr {
    background: rgba(59, 130, 246, 0.15);
}

.sub-offences-table th {
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--glass-border);
}

.sub-offences-table td {
    padding: 0.65rem 0.8rem;
    vertical-align: top;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: #cbd5e1;
    line-height: 1.5;
}

.sub-offences-table tbody tr:last-child td {
    border-bottom: none;
}

.sub-offences-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.sub-id {
    white-space: nowrap;
    font-family: monospace;
    color: var(--primary-color) !important;
    font-weight: 600;
    font-size: 0.82rem;
    width: 90px;
}

.sub-label {
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-color) !important;
    width: 200px;
}

.sub-penalty {
    white-space: nowrap;
    color: #fbbf24 !important;
    font-size: 0.83rem;
    width: 200px;
}

/* Checkbox column — keep it tight */
.sub-check-head,
.sub-check-cell {
    width: 32px;
    min-width: 32px;
    padding: 0.65rem 0.4rem 0.65rem 0.8rem !important;
}