/* Parliamentary Scanner — Styles */

/* Universal box-sizing for better layout control */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --primary: #1a365d;
    --primary-light: #2a5298;
    --accent: #e53e3e;
    --bg: #f7fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #2d3748;
    --text-light: #718096;
    --green: #38a169;
    --amber: #d69e2e;
    --red: #e53e3e;
    --radius: 6px;
    --btn-secondary: #718096;
    --btn-secondary-hover: #5a6b7f;
    --source-hansard: #c05621;
    --source-written-qs: #2b6cb0;
    --source-written-stmts: #2c7a7b;
    --source-edms: #6b46c1;
    --source-bills: #9b2c2c;
    --source-divisions: #276749;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding: 0 20px 40px;
    max-width: 1400px;
    margin: 0 auto;
}

main {
    width: 100%;
}

header {
    padding: 24px 0 8px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    height: 40px;
    width: auto;
    flex-shrink: 0;
}

header h1 {
    color: var(--primary);
    font-size: 1.6rem;
}

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

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 10px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Grouped Control Card */
.control-group-card {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    max-width: 100%;
    box-sizing: border-box;
}

/* Controls */
#controls {
    margin-bottom: 16px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Date Range Picker */
.date-picker-wrapper {
    position: relative;
}

.date-picker-display {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    background: white;
    cursor: pointer;
    color: var(--text);
    white-space: nowrap;
    transition: border-color 0.2s;
}

.date-picker-display:hover {
    border-color: var(--primary-light);
}

.date-picker-display.placeholder {
    color: var(--text-light);
    font-weight: 400;
}

.calendar-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 12px;
    z-index: 100;
    min-width: 280px;
    user-select: none;
}

.calendar-dropdown.open {
    display: block;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.calendar-nav {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: var(--radius);
    color: var(--text);
    line-height: 1;
    transition: background 0.15s;
}

.calendar-nav:hover {
    background: #edf2f7;
}

.calendar-month-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-dow {
    margin-bottom: 2px;
}

.calendar-dow-cell {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    padding: 4px 0;
    text-transform: uppercase;
}

.calendar-day {
    text-align: center;
    padding: 6px 2px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    position: relative;
}

.calendar-day:hover:not(.future):not(.other-month) {
    background: #edf2f7;
}

.calendar-day.other-month {
    color: #cbd5e0;
    pointer-events: none;
}

.calendar-day.future {
    color: #cbd5e0;
    opacity: 0.45;
    pointer-events: none;
    cursor: default;
}

.calendar-day.today:not(.range-start):not(.range-end) {
    box-shadow: inset 0 0 0 1.5px var(--primary-light);
}

.calendar-day.in-range {
    background: #dbeafe;
    border-radius: 0;
}

.calendar-day.hover-range {
    background: #e8f0fe;
    border-radius: 0;
}

.calendar-day.range-start {
    background: var(--primary);
    color: white;
    border-radius: 4px 0 0 4px;
    font-weight: 700;
}

.calendar-day.range-end {
    background: var(--primary);
    color: white;
    border-radius: 0 4px 4px 0;
    font-weight: 700;
}

.calendar-day.range-start.range-end {
    border-radius: 4px;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-primary:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

.btn-danger {
    background: var(--accent);
    color: white;
    border-radius: var(--radius);
}

.btn-danger:hover {
    background: #c53030;
}

.btn-scan {
    background: var(--green);
    color: white;
    border-radius: var(--radius);
}
.btn-scan:hover {
    background: #2f855a;
}
.btn-scan:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

/* API Status Indicator */
.api-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
    cursor: default;
    margin-left: auto;  /* push to right in flex row */
    flex-shrink: 0;
}

.api-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.api-status--checking {
    background: #edf2f7;
    border-color: #cbd5e0;
    color: #718096;
}
.api-status--checking .api-status-dot {
    background: #a0aec0;
    animation: pulse-grey 1.5s infinite;
}

.api-status--ok {
    background: #f0fff4;
    border-color: #9ae6b4;
    color: #276749;
}
.api-status--ok .api-status-dot {
    background: #38a169;
}

.api-status--error {
    background: #fff5f5;
    border-color: #feb2b2;
    color: #c53030;
    cursor: help;
}
.api-status--error .api-status-dot {
    background: #e53e3e;
}

@keyframes pulse-grey {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.8rem;
    background: var(--btn-secondary);
    color: white;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-small:hover {
    background: var(--btn-secondary-hover);
}

/* Split All/None button */
.btn-split {
    display: inline-flex;
    border-radius: var(--radius);
    overflow: hidden;
}

.btn-split button {
    padding: 0 14px;
    height: 28px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--btn-secondary);
    color: white;
    border: none;
    cursor: pointer;
    min-width: 46px;
    text-align: center;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-split button:hover {
    background: var(--btn-secondary-hover);
}

.btn-split-left {
    border-right: 1px solid rgba(255,255,255,0.3);
}

/* Undo button — always visible, greyed when no undo available */
.btn-undo {
    padding: 0 10px;
    height: 28px;
    font-size: 1rem;
    font-weight: 600;
    background: var(--btn-secondary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
}

.btn-undo:hover {
    background: var(--btn-secondary-hover);
}

.btn-undo.disabled {
    background: #cbd5e0;
    cursor: default;
    opacity: 0.5;
}

/* Control section divider */
.control-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}

/* Source Toggles */
#source-toggles {
    margin-bottom: 0;
}

.source-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.source-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
}

.source-btn {
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--text-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    color: var(--text-light);
}

.source-btn.active {
    background: var(--text-light);
    color: white;
}

/* Per-source colours */
.source-btn[data-source="hansard"] { border-color: var(--source-hansard); color: var(--source-hansard); }
.source-btn[data-source="hansard"].active { background: var(--source-hansard); color: white; }
.source-btn[data-source="written_questions"] { border-color: var(--source-written-qs); color: var(--source-written-qs); }
.source-btn[data-source="written_questions"].active { background: var(--source-written-qs); color: white; }
.source-btn[data-source="written_statements"] { border-color: var(--source-written-stmts); color: var(--source-written-stmts); }
.source-btn[data-source="written_statements"].active { background: var(--source-written-stmts); color: white; }
.source-btn[data-source="edms"] { border-color: var(--source-edms); color: var(--source-edms); }
.source-btn[data-source="edms"].active { background: var(--source-edms); color: white; }
.source-btn[data-source="bills"] { border-color: var(--source-bills); color: var(--source-bills); }
.source-btn[data-source="bills"].active { background: var(--source-bills); color: white; }
.source-btn[data-source="divisions"] { border-color: var(--source-divisions); color: var(--source-divisions); }
.source-btn[data-source="divisions"].active { background: var(--source-divisions); color: white; }

.source-btn.active:hover {
    opacity: 0.85;
}

.source-btn:not(.active):hover {
    opacity: 0.7;
}

/* Source button hover tooltip (via data-description) */
.source-btn {
    position: relative;
}

.source-btn[data-description]:hover::after {
    content: attr(data-description);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: var(--text);
    color: white;
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 400;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
    line-height: 1.3;
}

/* Topic Manager */
#topic-manager {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.section-header h2 {
    font-size: 1.1rem;
    color: var(--primary);
}

/* Topic section header uses same style as source label */
#topic-manager > .section-header > .source-label {
    margin: 0;
}

.toggle-icon {
    font-size: 0.8rem;
    color: var(--text-light);
    transition: transform 0.2s;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

/* Topic pills — shown when topic list is collapsed */
.topic-pills {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.topic-pills.visible {
    display: flex;
}

.topic-pill {
    padding: 4px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    color: var(--primary);
    user-select: none;
}

.topic-pill.active {
    background: var(--primary);
    color: white;
}

.topic-pill.active:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.topic-pill:not(.active):hover {
    border-color: var(--primary-light);
    color: var(--primary-light);
}

.topic-pill.highlight {
    animation: pillFlash 0.6s ease;
}

@keyframes pillFlash {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.3); }
}

.topic-container {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.topic-container.collapsed {
    display: none;
}

.topic-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    transition: box-shadow 0.3s;
}

.topic-item.highlight {
    animation: topicFlash 1s ease;
}

@keyframes topicFlash {
    0%, 100% { box-shadow: none; }
    30% { box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.35); }
    70% { box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.35); }
}

.topic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.topic-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.topic-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.topic-actions {
    display: flex;
    gap: 6px;
}

.topic-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-light);
    padding: 2px 6px;
    display: flex;
    align-items: center;
    line-height: 1;
}

.topic-actions button:hover {
    color: var(--accent);
}

.keyword-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword-chip {
    background: #edf2f7;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.keyword-chip .remove-kw {
    cursor: pointer;
    font-weight: bold;
    color: var(--text-light);
}

.keyword-chip .remove-kw:hover {
    color: var(--accent);
}

.keyword-input {
    margin-top: 6px;
    display: flex;
    gap: 6px;
}

.keyword-input input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
}

.topic-add {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

.topic-add input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

/* Progress */
#progress-section {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    max-width: 100%;
    overflow-x: hidden;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Stage indicator */
.stage-indicator {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    padding: 4px 0 12px;
}

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 80px;
}

.stage-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light);
    transition: all 0.3s;
}

.stage.active .stage-circle {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    animation: stagePulse 1.5s ease-in-out infinite;
}

.stage.completed .stage-circle {
    border-color: var(--green);
    background: var(--green);
    color: white;
}

@keyframes stagePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(26, 54, 93, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(26, 54, 93, 0); }
}

.stage-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    text-align: center;
    white-space: nowrap;
}

.stage.active .stage-label,
.stage.completed .stage-label {
    color: var(--text);
}

.stage-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 6px;
    margin-bottom: 20px;
    transition: background 0.3s;
}

.stage-line.completed {
    background: var(--green);
}

.btn-minimize {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    transition: transform 0.2s;
}

.btn-minimize:hover {
    color: var(--text);
}

.btn-minimize.collapsed {
    transform: rotate(-90deg);
}

#progressContent {
    transition: max-height 0.3s;
}

#progressContent.collapsed {
    display: none;
}

#progressLabel {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Keyword progress panel (full width) */
.keyword-progress-panel {
    margin-top: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.kw-summary {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.kw-topic-group {
    margin-bottom: 12px;
}

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

.kw-topic-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border);
}

.kw-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.kw-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #e2e8f0;
    color: var(--text-light);
    transition: background 0.3s, color 0.3s, box-shadow 0.3s;
}

.kw-chip.kw-active {
    background: #bee3f8;
    color: #2b6cb0;
    animation: kwPulse 1.2s ease-in-out infinite;
}

.kw-chip.kw-done {
    background: #c6f6d5;
    color: #22543d;
}

.kw-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 700;
}

@keyframes kwPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(43, 108, 176, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(43, 108, 176, 0); }
}

/* Pipeline stat boxes (horizontal row) */
.pipeline-stats-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.pipe-box {
    flex: 1 1 0;
    min-width: 100px;
    background: #edf2f7;
    border-radius: 10px;
    padding: 10px 14px;
    text-align: center;
}

.pipe-box-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.pipe-box-label {
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.pipe-box.pipe-box-relevant {
    background: #c6f6d5;
}

.pipe-box.pipe-box-relevant .pipe-box-value {
    color: #22543d;
}

.pipe-box.pipe-box-discarded {
    background: #fed7d7;
}

.pipe-box.pipe-box-discarded .pipe-box-value {
    color: #742a2a;
}

.pipe-box.pipe-box-error {
    background: #feebc8;
    border: 1px solid #dd6b20;
}

.pipe-box.pipe-box-error .pipe-box-value {
    color: #7b341e;
}

.api-error-warning {
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: #feebc8;
    border: 1px solid #dd6b20;
    border-radius: 6px;
    color: #7b341e;
    font-size: 0.82rem;
}

/* History */
#history-section {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    max-width: 100%;
    overflow-x: hidden;
}

#history-section h2 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.85rem;
}

.history-item:hover {
    background: #f7fafc;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item span:nth-child(2) {
    min-width: 70px;
    text-align: right;
}

.history-date {
    font-weight: 600;
}

.history-conducted {
    font-size: 0.75rem;
    color: var(--text-light);
    min-width: 90px;
}

.history-status {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.history-status.completed {
    background: #c6f6d5;
    color: var(--green);
}

.history-status.cancelled {
    background: #fed7d7;
    color: var(--red);
}

.history-status.error {
    background: #fed7d7;
    color: var(--red);
}

.history-status.running {
    background: #fefcbf;
    color: var(--amber);
}

.history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.page-info {
    font-size: 0.8rem;
    color: var(--text-light);
}

.history-pagination .btn-small:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Results */
#results-section {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-width: 100%;
    overflow-x: hidden;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.results-header h2 {
    font-size: 1.1rem;
    color: var(--primary);
}

.table-container {
    overflow-x: auto;
}

#resultsTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#resultsTable th {
    background: var(--primary);
    color: white;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

#resultsTable th[data-col] {
    cursor: pointer;
    user-select: none;
}

#resultsTable th[data-col]:hover {
    background: var(--primary-light);
}

.sort-indicator {
    font-size: 0.7rem;
    margin-left: 4px;
}

#resultsTable td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

#resultsTable tbody tr:hover {
    background: #f7fafc;
}

/* Confidence color coding */
.confidence-high {
    background: #c6f6d5;
    color: #22543d;
    font-weight: 600;
    text-align: center;
    border-radius: 3px;
}

.confidence-medium {
    background: #fefcbf;
    color: #744210;
    font-weight: 600;
    text-align: center;
    border-radius: 3px;
}

.confidence-low {
    background: #fed7d7;
    color: #742a2a;
    font-weight: 600;
    text-align: center;
    border-radius: 3px;
}

.new-badge {
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Quote links */
.quote-link {
    color: var(--primary-light);
    text-decoration: none;
}

.quote-link:hover {
    text-decoration: underline;
}

/* Pill badges for party and type */
.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    margin-top: 2px;
}

/* Per-source stat circles */
.source-circles-row {
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.stat-circle {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #e8f0fe;
    text-align: center;
}

.stat-circle .stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-circle .stat-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-light);
    line-height: 1.2;
    text-align: center;
}

/* Source-specific circle tints */
.stat-circle.source-hansard { background: #feebc8; }
.stat-circle.source-hansard .stat-value { color: var(--source-hansard); }
.stat-circle.source-written-qs { background: #bee3f8; }
.stat-circle.source-written-qs .stat-value { color: var(--source-written-qs); }
.stat-circle.source-written-stmts { background: #b2f5ea; }
.stat-circle.source-written-stmts .stat-value { color: var(--source-written-stmts); }
.stat-circle.source-edms { background: #e9d8fd; }
.stat-circle.source-edms .stat-value { color: var(--source-edms); }
.stat-circle.source-bills { background: #feb2b2; }
.stat-circle.source-bills .stat-value { color: var(--source-bills); }
.stat-circle.source-divisions { background: #9ae6b4; }
.stat-circle.source-divisions .stat-value { color: var(--source-divisions); }

/* Audit panel */
#audit-section {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 16px;
    max-width: 100%;
    overflow-x: hidden;
}

#audit-section .section-header {
    cursor: pointer;
    user-select: none;
}

#audit-section h2 {
    font-size: 1.1rem;
    color: var(--primary);
}

.audit-summary {
    display: flex;
    gap: 16px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.audit-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.audit-count .count-badge {
    background: #fed7d7;
    color: #742a2a;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.8rem;
}

.audit-count .count-badge.procedural {
    background: #fefcbf;
    color: #744210;
}

.audit-container {
    max-height: 400px;
    overflow-y: auto;
}

.audit-container.collapsed {
    display: none;
}

.audit-item {
    display: grid;
    grid-template-columns: minmax(120px, 160px) 1fr minmax(80px, 100px);
    gap: 12px;
    align-items: start;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}

.audit-item:last-child {
    border-bottom: none;
}


.audit-item .audit-member {
    font-weight: 600;
}

.audit-item .audit-preview {
    color: var(--text-light);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

/* Audit toggle button — not-relevant / relevant states */
.audit-toggle-btn {
    padding: 3px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.audit-toggle-btn.not-relevant {
    background: #c53030;
    color: white;
}

.audit-toggle-btn.not-relevant.hover-relevant {
    background: #c6f6d5;
    color: #22543d;
}

.audit-toggle-btn.relevant {
    background: #2f855a;
    color: white;
}

.audit-toggle-btn.relevant.hover-not-relevant {
    background: #fed7d7;
    color: #742a2a;
}

.audit-toggle-btn.processing {
    background: #a0aec0;
    color: white;
    cursor: wait;
}

.audit-toggle-btn:disabled {
    cursor: wait;
    opacity: 0.7;
}

@keyframes flashReject {
    0%, 100% { background: #c53030; }
    50% { background: #fc8181; }
}

.audit-toggle-btn.flash-reject {
    animation: flashReject 0.3s ease 2;
}

.audit-toggle-btn.procedural {
    background: #b7791f;
    color: white;
    cursor: default;
}

/* Empty state previews for sections */
.empty-state-preview {
    color: var(--text-light);
    font-style: italic;
    padding: 32px 20px;
    text-align: center;
    background: #f7fafc;
    border-radius: var(--radius);
    margin: 16px 0;
}

/* Add to master button — three states */
.btn-add-master {
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* State: not in master (blue +) */
.btn-add-master.state-add {
    background: var(--primary-light);
    color: white;
}

.btn-add-master.state-add:hover {
    background: var(--primary);
}

/* State: in master (green ✓) */
.btn-add-master.state-added {
    background: var(--green);
    color: white;
    cursor: default;
}

/* State: in master + hover (grey ✗) */
.btn-add-master.state-added:hover {
    background: #a0aec0;
    cursor: pointer;
}

/* State: removing */
.btn-add-master.state-removing {
    background: #a0aec0;
    color: white;
    cursor: wait;
}

/* Record Tab — Master Stakeholder Table */
#record-section {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

#record-section h2 {
    font-size: 1.1rem;
    color: var(--primary);
}

#masterTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#masterTable th {
    background: var(--primary);
    color: white;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

#masterTable td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

#masterTable tbody tr:hover {
    background: #f7fafc;
}

#masterTable select,
#masterTable input[type="text"] {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    width: 100%;
}

#masterTable select {
    width: auto;
    min-width: 80px;
}

.master-remove-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
}

.master-remove-btn:hover {
    color: var(--accent);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}


/* ========== RESPONSIVE DESIGN ========== */

@media (max-width: 1200px) {
    .control-group-card,
    #history-section,
    #results-section,
    #audit-section,
    #progress-section {
        margin-bottom: 12px;
    }

    .source-toggle-row {
        gap: 6px;
    }

    .source-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    /* Reduce overall padding */
    body {
        padding: 12px;
    }

    main {
        width: 100%;
    }

    .control-group-card,
    #history-section,
    #results-section,
    #audit-section,
    #progress-section {
        padding: 12px 16px;
    }

    /* Ensure tables don't overflow */
    .table-container {
        overflow-x: auto;
        max-width: 100%;
    }

    /* Control wrapping */
    .control-row {
        gap: 10px;
    }

    /* Date picker */
    .date-picker-display {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .calendar-dropdown {
        max-width: calc(100vw - 40px);
    }

    /* Stage indicator - reduce sizes */
    .stage-circle {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .stage-label {
        font-size: 0.7rem;
    }

    /* Source buttons - stack more */
    .source-btn {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    .keyword-progress-panel {
        max-height: 250px;
    }

    .pipe-box {
        min-width: 80px;
    }

    /* Stat circles - smaller */
    .stat-circle {
        width: 64px;
        height: 64px;
    }

    .stat-circle .stat-value {
        font-size: 1rem;
    }

    .stat-circle .stat-label {
        font-size: 0.65rem;
    }

    /* Topic pills - smaller text */
    .topic-pill {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    /* Results table - reduce font */
    #resultsTable {
        font-size: 0.8rem;
    }

    #resultsTable th,
    #resultsTable td {
        padding: 8px 6px;
    }
}

/* Mobile devices (480px and below) */
@media (max-width: 480px) {
    /* Tighter spacing */
    body {
        padding: 8px;
    }

    .control-group-card,
    #history-section,
    #results-section,
    #audit-section,
    #progress-section {
        padding: 10px 12px;
        margin-bottom: 12px;
    }

    /* Control row - single column */
    .control-row {
        flex-direction: column;
        align-items: stretch;
    }

    .date-picker-display {
        width: 100%;
        text-align: center;
    }

    .btn,
    .btn-scan,
    .btn-danger {
        width: 100%;
    }

    /* Calendar dropdown - fit screen */
    .calendar-dropdown {
        min-width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
        left: 8px !important;
        right: 8px !important;
    }

    /* Source buttons - smaller with better wrapping */
    .source-toggle-row {
        gap: 6px;
    }

    .source-btn {
        font-size: 0.7rem;
        padding: 4px 8px;
        flex: 1 1 auto;
        min-width: fit-content;
    }

    /* Stage indicator - allow wrapping */
    .stage-indicator {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .stage {
        min-width: auto;
    }

    .stage-line {
        display: none; /* Hide connecting lines on mobile */
    }

    .stage-label {
        white-space: normal;
        text-align: center;
        font-size: 0.65rem;
    }

    .stage-circle {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    /* Source circles - smaller */
    .stat-circle {
        width: 56px;
        height: 56px;
        min-width: 56px;
    }

    .stat-circle .stat-value {
        font-size: 0.9rem;
    }

    .stat-circle .stat-label {
        font-size: 0.6rem;
    }

    /* Audit items - responsive grid */
    .audit-item {
        grid-template-columns: 1fr 80px; /* Name/preview | Button */
        grid-template-rows: auto auto;
        gap: 6px;
    }

    .audit-item .audit-member {
        grid-column: 1 / -1; /* Full width */
        font-size: 0.8rem;
    }

    .audit-item .audit-preview {
        grid-column: 1;
        grid-row: 2;
        -webkit-line-clamp: 2; /* Show less on mobile */
    }

    .audit-toggle-btn {
        grid-column: 2;
        grid-row: 2;
        font-size: 0.7rem;
        padding: 4px 8px;
        min-width: auto;
    }

    /* Topic items - better mobile layout */
    .topic-item {
        padding: 8px;
    }

    .topic-header {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Results table - smaller */
    #resultsTable {
        font-size: 0.75rem;
    }

    #resultsTable th,
    #resultsTable td {
        padding: 6px 4px;
    }

    .pill {
        font-size: 0.7rem;
        padding: 1px 8px;
    }

    /* Buttons */
    .btn-small {
        font-size: 0.7rem;
        padding: 4px 8px;
    }

    /* Section headers */
    h2 {
        font-size: 1.1rem;
    }

    h3 {
        font-size: 1rem;
    }
}

/* Small phones (375px and below) */
@media (max-width: 375px) {
    body {
        padding: 6px;
    }

    /* Even tighter spacing */
    .control-group-card,
    #history-section,
    #results-section,
    #audit-section,
    #progress-section {
        padding: 8px 10px;
    }

    /* Calendar - full width */
    .calendar-dropdown {
        min-width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        left: 4px !important;
    }

    /* Source buttons - stack vertically */
    .source-toggle-row {
        flex-direction: column;
        align-items: stretch;
    }

    .source-btn {
        width: 100%;
        justify-content: center;
    }

    /* Source circles - smaller and scrollable */
    .source-circles-row {
        gap: 8px;
    }

    .stat-circle {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }

    .stat-circle .stat-value {
        font-size: 0.8rem;
    }

    .stat-circle .stat-label {
        font-size: 0.55rem;
    }

    /* Topic pills - full width */
    .topic-pill {
        flex: 1 1 100%;
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* Buttons - smaller */
    .btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}


/* ========== LOOK AHEAD TAB ========== */

/* Event type colour variables */
:root {
    --event-debate: #2563eb;
    --event-oral-qs: #7c3aed;
    --event-committee: #0891b2;
    --event-bill-stage: #dc2626;
    --event-westminster-hall: #ca8a04;
    --event-statement: #16a34a;
    --event-gen-committee: #9333ea;
}

/* Controls row */
.lookahead-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.lookahead-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lookahead-date-label {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
    min-width: 130px;
    text-align: center;
}

/* View toggle (Week / List) */
.lookahead-view-toggle {
    display: inline-flex;
    border-radius: var(--radius);
    overflow: hidden;
    margin-left: auto;
}

.la-view-btn {
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    background: white;
    border: 2px solid var(--primary);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.la-view-btn.active {
    background: var(--primary);
    color: white;
}

.la-view-btn:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
    border-right: none;
}

.la-view-btn:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* Event type toggle buttons */
.la-type-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.la-type-btn {
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--text-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    color: var(--text-light);
    position: relative;
}

.la-type-btn[data-type="debate"] { border-color: var(--event-debate); color: var(--event-debate); }
.la-type-btn[data-type="debate"].active { background: var(--event-debate); color: white; }
.la-type-btn[data-type="oral_questions"] { border-color: var(--event-oral-qs); color: var(--event-oral-qs); }
.la-type-btn[data-type="oral_questions"].active { background: var(--event-oral-qs); color: white; }
.la-type-btn[data-type="committee"] { border-color: var(--event-committee); color: var(--event-committee); }
.la-type-btn[data-type="committee"].active { background: var(--event-committee); color: white; }
.la-type-btn[data-type="bill_stage"] { border-color: var(--event-bill-stage); color: var(--event-bill-stage); }
.la-type-btn[data-type="bill_stage"].active { background: var(--event-bill-stage); color: white; }
.la-type-btn[data-type="westminster_hall"] { border-color: var(--event-westminster-hall); color: var(--event-westminster-hall); }
.la-type-btn[data-type="westminster_hall"].active { background: var(--event-westminster-hall); color: white; }
.la-type-btn[data-type="statement"] { border-color: var(--event-statement); color: var(--event-statement); }
.la-type-btn[data-type="statement"].active { background: var(--event-statement); color: white; }
.la-type-btn[data-type="general_committee"] { border-color: var(--event-gen-committee); color: var(--event-gen-committee); }
.la-type-btn[data-type="general_committee"].active { background: var(--event-gen-committee); color: white; }

.la-type-btn.active:hover { opacity: 0.85; }
.la-type-btn:not(.active):hover { opacity: 0.7; }

/* Tooltip on hover */
.la-type-btn[data-description]:hover::after {
    content: attr(data-description);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: var(--text);
    color: white;
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 400;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
    line-height: 1.3;
}

/* House toggle buttons */
.la-house-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.la-house-btn {
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    color: var(--primary);
}

.la-house-btn.active {
    background: var(--primary);
    color: white;
}

.la-house-btn.active:hover { opacity: 0.85; }
.la-house-btn:not(.active):hover { opacity: 0.7; }

/* Topic filter header */
.la-topic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.la-filter-toggles {
    display: flex;
    gap: 16px;
    align-items: center;
}

.la-checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-light);
    cursor: pointer;
    user-select: none;
}

.la-checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

/* Topic pills in Look Ahead */
.la-topic-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    transition: opacity 0.2s;
}

/* ========== Look Ahead Sidebar Layout ========== */

.la-main-area {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.la-filter-sidebar {
    width: 180px;
    min-width: 180px;
    flex-shrink: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.la-filter-section {
    margin-bottom: 16px;
}

.la-filter-section:last-child {
    margin-bottom: 0;
}

.la-filter-section .source-label {
    display: block;
    margin-bottom: 6px;
}

.la-filter-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 0;
    color: var(--text);
    user-select: none;
}

.la-filter-item input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.la-topic-checkboxes {
    margin-top: 6px;
    transition: opacity 0.2s;
}

.la-topic-filter-item {
    font-size: 0.8rem;
}

.la-content-area {
    flex: 1;
    min-width: 0;
}

/* ========== Week View ========== */

.la-week-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.la-day-column {
    flex: 1;
    min-width: 180px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.la-day-column.la-today {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.la-day-header {
    background: var(--primary);
    color: white;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    gap: 6px;
}

.la-day-column.la-today .la-day-header {
    background: var(--primary-light);
}

.la-day-name {
    font-weight: 700;
}

.la-day-date {
    font-size: 0.75rem;
    opacity: 0.8;
}

.la-day-count {
    background: rgba(255,255,255,0.2);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: auto;
}

.la-day-events {
    padding: 4px;
    flex: 1;
    overflow-y: auto;
    max-height: 600px;
}

.la-no-events {
    padding: 16px;
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    font-size: 0.8rem;
}

/* Event Card */
.la-event-card {
    margin: 4px 0;
    padding: 8px 10px;
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.8rem;
    transition: box-shadow 0.15s;
}

.la-event-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.la-event-time {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    display: block;
    margin-bottom: 2px;
}

.la-event-title {
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.3;
    margin-bottom: 4px;
}

.la-event-link {
    color: inherit;
    text-decoration: none;
}

.la-event-link:hover {
    text-decoration: underline;
}

.la-event-detail {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-bottom: 4px;
    line-height: 1.3;
}

.la-event-meta {
    display: flex;
    gap: 6px;
    align-items: center;
}

.la-event-type-badge {
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    color: white;
}

.la-event-house {
    font-size: 0.7rem;
    color: var(--text-light);
}


/* Star button */
.la-star-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #cbd5e0;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
    margin-left: auto;
}

.la-star-btn:hover {
    color: #ca8a04;
}

.la-star-btn.starred {
    color: #ca8a04;
}

/* ========== List View ========== */

.la-list-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

#laListTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#laListTable th {
    background: var(--primary);
    color: white;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

#laListTable td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

#laListTable tbody tr:hover {
    background: #f7fafc;
}

.la-list-date {
    white-space: nowrap;
    font-weight: 600;
}

.la-list-detail {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
}

/* Empty message */
.la-empty-message {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-style: italic;
}

/* ========== Look Ahead Responsive ========== */

@media (max-width: 1200px) {
    .la-week-container {
        gap: 6px;
    }

    .la-day-column {
        min-width: 160px;
    }
}

@media (max-width: 768px) {
    .la-main-area {
        flex-direction: column;
    }

    .la-filter-sidebar {
        width: 100%;
        min-width: auto;
        position: static;
        display: flex;
        flex-wrap: wrap;
        gap: 16px;
        padding: 12px 16px;
    }

    .la-filter-section {
        margin-bottom: 0;
        min-width: 140px;
    }

    .la-week-container {
        flex-direction: column;
    }

    .la-day-column {
        min-width: auto;
    }

    .la-day-events {
        max-height: 300px;
    }

    .lookahead-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .lookahead-view-toggle {
        margin-left: 0;
    }

    .lookahead-nav {
        justify-content: center;
    }

    .la-list-card {
        padding: 12px 16px;
    }

    #laListTable {
        font-size: 0.8rem;
    }
}

/* ========== ALERTS TAB ========== */

.alert-actions-cell {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.alert-actions-cell .btn-small {
    padding: 4px 10px;
    font-size: 0.75rem;
}

#alertsTable td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

#alertsTable tbody tr:hover {
    background: #f7fafc;
}

@media (max-width: 480px) {
    .la-type-btn {
        font-size: 0.7rem;
        padding: 4px 8px;
        flex: 1 1 auto;
    }

    .la-event-card {
        padding: 6px 8px;
    }

    .lookahead-date-label {
        font-size: 0.9rem;
        min-width: auto;
    }

    #laListTable {
        font-size: 0.75rem;
    }

    #laListTable th,
    #laListTable td {
        padding: 6px 4px;
    }
}
