:root {
    --page-bg: #f4f6fb;
    --panel-bg: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    --text: #0f172a;
    --subtext: #475467;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --minute-size: 0.49px;
    --schedule-day-width: 170px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 16px 36px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.page-header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.page-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.page-intro {
    flex: 1 1 360px;
}

.eyebrow {
    font-size: 0.75rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--primary);
}

.page-header h1 {
    margin: 0.25rem 0;
    font-size: clamp(1.9rem, 2.4vw, 2.9rem);
}

.page-header p {
    margin: 0;
    color: var(--subtext);
}

.header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    min-width: 220px;
}

.header-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.layout {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: minmax(80px, auto);
    gap: 1rem;
}

#event-inputs {
    grid-column: span 12;
}

.list-diagnostics-row {
    grid-column: span 12;
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

#event-list-panel {
    flex: 1 1 auto;
    min-width: 0;
}

#event-list-panel .table-wrapper {
    height: 700px;
    overflow-y: auto;
}

#linkage-panel {
    flex: 0 0 320px;
    min-width: 280px;
}

#linkage-panel .panel-title {
    margin-bottom: 0;
}

#linkage-panel .supporting-text {
    margin: 0;
    font-size: 0.85rem;
    color: var(--subtext);
}

#linkage-panel .diagnostic-status {
    margin-top: 0.35rem;
}

#schedule-container {
    grid-column: span 12;
}

.schedule-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.schedule-toolbar {
    display: flex;
    flex: 1 1 220px;
    justify-content: flex-end;
}

.schedule-toolbar .plan-zoom {
    justify-content: flex-end;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.panel-title {
    margin: 0;
    font-size: 1.25rem;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.diagnostics-heading-text {
    flex: 1 1 auto;
}

.diagnostics-heading .supporting-text {
    margin-top: 0.15rem;
}

.diagnostics-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.diagnostics-toggle {
    border: 1px solid var(--border);
    background: var(--panel-bg);
    color: var(--text);
    border-radius: 999px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.diagnostics-toggle:hover,
.diagnostics-toggle:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    outline: none;
}

.diagnostics-toggle .toggle-icon {
    width: 12px;
    height: 12px;
    position: relative;
}

.diagnostics-toggle .toggle-icon::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transform-origin: center;
    transition: transform 0.2s ease;
}

.diagnostics-toggle.is-collapsed .toggle-icon::before {
    transform: rotate(-135deg);
}

.diagnostics-count {
    position: absolute;
    top: -0.4rem;
    right: -0.4rem;
    min-width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: var(--border);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.diagnostics-toggle[data-has-conflicts="true"] .diagnostics-count {
    background: var(--error);
    color: #fff;
}

.list-diagnostics-row.is-diagnostics-collapsed {
    align-items: flex-start;
    gap: 0.5rem;
}

.list-diagnostics-row.is-diagnostics-collapsed #event-list-panel {
    flex: 1 1 100%;
}

.list-diagnostics-row.is-diagnostics-collapsed #linkage-panel {
    flex: 0 0 auto;
    min-width: 0;
}

.diagnostics-panel.is-collapsed {
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    align-items: flex-end;
    gap: 0;
    flex: 0 0 auto;
    min-width: 0;
}

.diagnostics-panel.is-collapsed .panel-heading {
    width: auto;
    margin: 0;
}

.diagnostics-panel.is-collapsed .diagnostics-heading-text,
.diagnostics-panel.is-collapsed .diagnostics-body {
    display: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.vehicle-settings {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    align-items: flex-start;
}

.vehicle-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 22px rgba(15, 23, 42, 0.08);
}

.vehicle-card--compact {
    flex: 0 0 auto;
    padding: 0.75rem 0.85rem;
    display: inline-flex;
    flex-direction: column;
    gap: 0.4rem;
    width: fit-content;
}

.travel-buffer-card {
    flex: 0 0 auto;
}

.vehicle-field-row--ev {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

.vehicle-field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.vehicle-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.8rem;
    color: var(--subtext);
    flex: 0 0 auto;
}

.vehicle-field span {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.vehicle-field input {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.3rem 0.5rem;
    font-size: 0.9rem;
    height: 34px;
    width: 100%;
}

.vehicle-field input[type="number"] {
    width: 8ch;
}

.vehicle-field--toggle input {
    width: auto;
    height: auto;
    margin-top: 0.2rem;
}

.vehicle-field--toggle {
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
}

.vehicle-hint {
    margin: 0;
    font-size: 0.75rem;
    color: var(--subtext);
}

.plan-zoom {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.plan-summary {
    margin-top: 0.5rem;
}

.toolbar-menu {
    position: relative;
}

.toolbar-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.15);
    min-width: 220px;
    padding: 0.5rem 0;
    display: none;
    z-index: 20;
}

.toolbar-menu:hover .toolbar-menu-panel,
.toolbar-menu:focus-within .toolbar-menu-panel {
    display: block;
}

.menu-item {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 0.6rem 1rem;
    font: inherit;
    color: var(--text);
    cursor: pointer;
}

.menu-item:hover {
    background: #f1f5f9;
}

.file-upload {
    position: relative;
}

.file-upload input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

label {
    font-weight: 600;
    color: var(--subtext);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

input,
select,
textarea {
    padding: 0.4rem 0.55rem; /* Reduced from 0.55rem 0.65rem for compact layout */
    border: 1px solid var(--border);
    border-radius: 6px; /* Reduced from 8px */
    font: inherit;
    color: var(--text);
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(37, 99, 235, 0.35);
    border-color: var(--primary);
}

textarea {
    min-height: 70px; /* Reduced from 90px for compact layout */
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.15s ease;
}

.button:hover {
    background: var(--primary-dark);
}

.button.secondary {
    background: #e4ecff;
    color: var(--primary-dark);
}

.button.ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.file-input {
    position: relative;
    overflow: hidden;
}

.file-input input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
}

.stat-card {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    background: #f8fbff;
}

.stat-card span {
    display: block;
    color: var(--subtext);
    font-size: 0.8rem;
}

.stat-card strong {
    font-size: 1.2rem;
    display: block;
    margin-top: 0.2rem;
}

.form-panel form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* Reduced from 1rem for compact layout */
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.toolbar-quick {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.inline-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 600;
    color: var(--subtext);
    font-size: 0.85rem;
}

.inline-toggle input {
    width: auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Reduced min from 220px */
    gap: 0.6rem; /* Reduced from 1rem for compact layout */
}

.address-field {
    width: 100%;
}

@media (min-width: 900px) {
    .core-grid {
        grid-template-columns: minmax(360px, 2fr) repeat(2, minmax(200px, 1fr));
    }

    .previous-route-row {
        justify-content: flex-start;
    }

    .previous-route-row .field {
        flex: 0 0 auto;
    }

.route-options-field {
    min-width: 420px;
    flex-grow: 1;
}

.start-end-row {
    justify-content: flex-start;
}

    .start-end-row .input-pair {
        grid-template-columns: 220px 140px;
    }
}

.form-section {
    border: 1px solid var(--border);
    border-radius: 12px; /* Reduced from 16px for compact layout */
    padding: 0.6rem 0.9rem; /* Reduced from 1rem 1.25rem */
    background: #fff;
    margin-bottom: 0.5rem; /* Reduced from 1rem */
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem; /* Reduced from 0.75rem for compact layout */
}

.section-header h3 {
    margin: 0;
    font-size: 1rem;
}

.section-hint {
    font-size: 0.8rem;
    color: var(--subtext);
}

.section-hint.required {
    color: var(--danger);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem; /* Reduced from 0.35rem for compact layout */
    font-size: 0.85rem;
}

.field > span {
    font-weight: 600;
    color: var(--subtext);
}

.required-field > span::after {
    content: '*';
    margin-left: 0.25rem;
    color: var(--danger);
}

.input-pair {
    display: flex;
    gap: 0.5rem;
}

.input-pair input {
    flex: 1;
}

.reference-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* Reduced min from 160px */
    gap: 0.4rem; /* Reduced from 0.5rem for compact layout */
}

.reference-field input {
    background: #f8fafc;
    border-color: var(--border);
    color: var(--subtext);
}

.previous-route-row {
    grid-column: span 3;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem; /* Reduced from 1rem for compact layout */
    align-items: flex-end;
}

.previous-route-row .field {
    margin: 0;
    flex: 1 1 240px;
}

.previous-event-field {
    max-width: 320px;
}

.route-options-field {
    min-width: 320px;
    flex: 2 1 360px;
}

.previous-route-row select {
    width: 100%;
}
.route-select {
    background: linear-gradient(120deg, #eef2ff 0%, #f5fbff 100%);
    border-color: #cbd5ff;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.08), 0 10px 24px rgba(79, 70, 229, 0.08);
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #0f172a;
    padding-right: 2.6rem;
    min-height: 44px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.route-select:hover {
    border-color: #94a3ff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.14), 0 14px 32px rgba(79, 70, 229, 0.12);
}

.route-select:focus {
    transform: translateY(-1px);
}

.route-select option {
    font-weight: 600;
}

.route-select option[value=""] {
    color: var(--subtext);
    font-weight: 500;
}

.span-2 {
    grid-column: span 2;
}

.start-end-row {
    grid-column: span 3;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem; /* Reduced from 1rem for compact layout */
    align-items: flex-end;
}

.start-end-row .field {
    margin: 0;
    flex: 0 0 auto;
}

.start-end-row .duration-field {
    flex: 1 1 260px;
    align-self: flex-end;
}

.start-end-row .input-pair {
    display: grid;
    grid-template-columns: minmax(200px, auto) minmax(110px, auto);
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-start;
}

@media (max-width: 520px) {
    .start-end-row .input-pair {
        grid-template-columns: 1fr;
    }
}

.duration-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem; /* Reduced from 0.4rem for compact layout */
}

.duration-chip {
    border: 1px dashed var(--border);
    background: #f8fafc;
    color: var(--text);
    padding: 0.3rem 0.6rem; /* Reduced from 0.45rem 0.8rem for compact layout */
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.8rem; /* Added smaller font size */
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.duration-chip:hover {
    background: #eef4ff;
    transform: translateY(-1px);
}

.duration-chip:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
}

.duration-chip.is-active {
    background: #e4ecff;
    border-color: var(--primary);
    color: var(--primary-dark);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--subtext);
}

.toggle-chip input {
    accent-color: var(--primary);
}

.optional-panel {
    border: 1px dashed var(--border);
    border-radius: 12px; /* Reduced from 16px for compact layout */
    padding: 0.4rem 0.75rem 0.5rem; /* Reduced from 0.5rem 1rem 0.75rem */
    background: #fff;
    margin-bottom: 0.5rem; /* Reduced from 1rem */
}

.optional-panel summary {
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.optional-panel summary::-webkit-details-marker {
    display: none;
}

.optional-content {
    margin-top: 0.5rem; /* Reduced from 0.75rem for compact layout */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Reduced min from 220px */
    gap: 0.6rem; /* Reduced from 1rem */
}

.core-grid {
    align-items: flex-start;
}

.travel-section {
    padding: 0.5rem 0.75rem 0.6rem; /* Reduced from 0.9rem 1rem 1.1rem for compact layout */
}

.travel-placeholder {
    margin: 0;
    font-size: 0.85rem;
    color: var(--subtext);
    font-style: italic;
}

.travel-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Reduced min from 220px */
    gap: 0.5rem; /* Reduced from 0.75rem for compact layout */
    margin-top: 0.35rem; /* Reduced from 0.5rem */
    align-items: flex-start;
}

.travel-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.field.slim select {
    min-width: 160px;
}

.travel-section.inactive .travel-controls {
    display: none;
}

.travel-section.inactive .travel-placeholder {
    display: block;
}

.travel-section:not(.inactive) .travel-placeholder {
    display: none;
}

.with-tabs {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.event-view-tabs {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.tab-button {
    border: 1px solid var(--border);
    background: #f8fafc;
    color: var(--text);
    border-radius: 10px;
    padding: 0.45rem 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 120ms ease;
}

.tab-button.is-active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.2);
}

.events-view {
    margin-top: 1rem;
}

.map-view-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.map-panel {
    flex: 1 1 auto;
    min-width: 320px;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.25rem 0.1rem 0;
}

.map-legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-weight: 600;
    color: var(--text);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.map-legend-swatch {
    width: 24px;
    height: 24px;
    border-radius: 10px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    border: 2px solid #fff;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
    background: var(--pin-bg, #0f172a);
}

#events-map-view #map {
    width: 100%;
    height: 420px;
}

#map {
    width: 100%;
    height: 260px;
    border-radius: 14px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.map-marker-icon {
    background: none;
    border: none;
    overflow: visible !important;
}

.map-pin {
    --pin-bg: #0f172a;
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 14px;
    background: var(--pin-bg);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.05rem;
    border: 2px solid #fff;
    box-shadow: 0 12px 22px rgba(15, 23, 42, 0.28);
}

.map-pin::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 9px 0 9px;
    border-color: var(--pin-bg) transparent transparent transparent;
    filter: drop-shadow(0 6px 10px rgba(15, 23, 42, 0.25));
}

.map-pin-number {
    line-height: 1;
    font-size: 1.05rem;
    padding-right: 6px;
}

.map-pin-letter {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    color: var(--pin-bg, #0f172a);
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    box-shadow: 0 3px 6px rgba(15, 23, 42, 0.25);
    border: 1px solid rgba(15, 23, 42, 0.1);
    z-index: 2;
}

.map-pin.marker-travel,
.map-legend-swatch.marker-travel {
    --pin-bg: #2563eb;
    background: var(--pin-bg);
}

.map-pin.marker-dining,
.map-legend-swatch.marker-dining {
    --pin-bg: #f97316;
    background: var(--pin-bg);
}

.map-pin.marker-entertainment,
.map-legend-swatch.marker-entertainment {
    --pin-bg: #a855f7;
    background: var(--pin-bg);
}

.map-pin.marker-accommodation,
.map-legend-swatch.marker-accommodation {
    --pin-bg: #0ea5e9;
    background: var(--pin-bg);
}

.map-pin.marker-transportation-gas,
.map-legend-swatch.marker-transportation-gas {
    --pin-bg: #059669;
    background: var(--pin-bg);
}

.map-pin.marker-other,
.map-legend-swatch.marker-other {
    --pin-bg: #111827;
    background: var(--pin-bg);
}

.leaflet-popup.map-event-popup .leaflet-popup-content-wrapper {
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
    padding: 0;
}

.leaflet-popup.map-event-popup .leaflet-popup-content {
    margin: 12px 14px;
}

.leaflet-popup.map-event-popup .leaflet-popup-tip {
    display: none;
}

.map-popup {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 220px;
}

.map-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.map-popup-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    background: #f1f5f9;
    border-radius: 10px;
    color: var(--text);
}

.map-popup-meta {
    color: var(--subtext);
    font-size: 0.85rem;
    font-weight: 700;
}

.map-popup-title {
    font-weight: 800;
    font-size: 1rem;
}

.map-popup-row {
    color: var(--subtext);
    font-size: 0.9rem;
}

.map-popup-edit {
    margin-top: 0.35rem;
    width: 100%;
}

@media (max-width: 960px) {
    .map-view-layout {
        gap: 0.65rem;
    }
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.route-link-field {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.route-link-field input {
    flex: 1 1 200px;
    min-width: 0;
}

.route-link-field button {
    flex: 0 0 auto;
}

.travel-time-detail {
    font-size: 0.82rem;
    color: var(--text);
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    margin-top: -0.1rem;
    grid-column: 1 / -1;
    justify-self: flex-start;
    max-width: 360px;
}

.travel-time-detail strong {
    color: var(--primary);
}

.manual-travel-panel {
    grid-column: 1 / -1;
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    background: #f8fafc;
}

.manual-travel-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.manual-travel-hint {
    margin: 0.35rem 0 0.6rem;
    font-size: 0.8rem;
    color: var(--subtext);
}

.manual-travel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

#manual-travel-panel[hidden] {
    display: none !important;
}

#manual-travel-panel .field span {
    font-size: 0.85rem;
}

#manual-travel-panel input {
    width: 100%;
}

.travel-time-detail.is-disabled {
    background: #f1f5f9;
    color: var(--subtext);
}

.field textarea {
    min-height: 110px;
    width: 100%;
    font: inherit;
    padding: 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.location-cell {
    max-width: 180px;
    white-space: nowrap;
}

.location-link {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.form-status {
    min-height: 1.2rem;
    font-size: 0.9rem;
}

.form-status.success {
    color: var(--success);
}

.form-status.error {
    color: var(--danger);
}

.table-wrapper {
    border-radius: 14px;
    border: 1px solid var(--border);
    overflow-x: auto;
    background: #fff;
}

@media (max-width: 1200px) {
    .list-diagnostics-row {
        flex-direction: column;
    }

    #linkage-panel {
        flex: 1 1 auto;
        min-width: 0;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

thead {
    background: #eef4ff;
    position: sticky;
    top: 0;
    z-index: 2;
}

th,
td {
    text-align: left;
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: top;
}

tbody tr:nth-child(odd) td {
    background: #f9fbff;
}

tbody tr:hover td {
    background: #eef2ff;
}

.event-name-cell {
    max-width: 320px;
    min-width: 220px;
    line-height: 1.25;
    white-space: normal;
}

.event-name-cell strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.event-row .details-toggle {
    display: inline-flex;
    margin-top: 0.35rem;
}

.event-detail-row td {
    padding: 0.4rem 0.65rem 0.85rem;
    background: #f9fbff;
    border-bottom: 1px solid var(--border);
}

.event-detail-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    font-size: 0.9rem;
}

.detail-block {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid #c7d7fe;
    border-radius: 12px;
    padding: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.detail-block.travel-block {
    border-left-color: #bfdbfe;
}

.detail-title {
    margin: 0 0 0.4rem;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--subtext);
}

.detail-value p {
    margin: 0;
}

.detail-empty {
    margin: 0;
    color: var(--subtext);
    font-style: italic;
}

.travel-breakdown-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.travel-breakdown-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.travel-breakdown-list span {
    color: var(--subtext);
}

.travel-breakdown-list strong {
    color: var(--text);
}
}

th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--subtext);
}

.actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.action-menu summary {
    list-style: none;
    cursor: pointer;
}

.action-menu summary::-webkit-details-marker {
    display: none;
}

.action-menu[open] summary {
    color: var(--primary);
    font-weight: 600;
}

.action-menu-items {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-top: 0.35rem;
}

.link-button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
}

.event-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.weather-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: #eef2ff;
    border: 1px solid #dbeafe;
    color: #0f172a;
    font-size: 0.85rem;
    font-weight: 600;
}

.weather-chip .weather-icon {
    line-height: 1;
    font-size: 1rem;
}

.weather-chip.is-muted {
    background: #f4f4f5;
    border-color: #e5e7eb;
    color: #4b5563;
}

.event-chip[data-category="dining"],
.event-block[data-category="dining"] {
    background: #22c55e;
    color: #052e16;
}

.event-chip[data-category="transportation-gas"],
.event-block[data-category="transportation-gas"] {
    background: #14b8a6;
    color: #022c22;
}

.event-chip[data-category="travel"],
.event-block[data-category="travel"] {
    background: #6366f1;
    color: #eef2ff;
}

.event-chip[data-category="entertainment"],
.event-block[data-category="entertainment"] {
    background: #f97316;
    color: #fafaf9;
}

.event-chip[data-category="accommodation"],
.event-block[data-category="accommodation"] {
    background: #0ea5e9;
    color: #f0f9ff;
}

.event-chip[data-category="other"],
.event-block[data-category="other"] {
    background: #64748b;
    color: #f8fafc;
}

.memo-details {
    margin-top: 0.35rem;
}

.memo-details summary {
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--primary);
}

.memo-details p {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
}

.schedule-board {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.schedule-scroll {
    overflow-x: auto;
    padding-bottom: 0.35rem;
}

.schedule-head-row {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    padding-bottom: 0.25rem;
    min-width: fit-content;
}

.time-spacer {
    width: 80px;
    flex-shrink: 0;
}

.schedule-head {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: var(--schedule-day-width);
    gap: 0.75rem;
    min-width: fit-content;
}

.schedule-date {
    background: #eef2ff;
    border-radius: 12px;
    padding: 0.5rem 0.65rem;
    white-space: nowrap;
    text-align: center;
}

.schedule-date span {
    display: block;
    font-size: 0.78rem;
    color: var(--subtext);
}

.schedule-date strong {
    display: block;
    font-size: 0.95rem;
    margin-top: 0.15rem;
    letter-spacing: 0.01em;
}

.schedule-body {
    display: flex;
    gap: 0.75rem;
    min-width: fit-content;
    height: 700px;
    min-height: 500px;
    max-height: 700px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.diagnostics-panel {
    min-height: 220px;
}

.diagnostic-status {
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.diagnostic-status.success {
    background: #ecfdf5;
    color: #0f766e;
    border-color: #0f766e1a;
}

.diagnostic-status.warning {
    background: #fff7ed;
    color: #d97706;
    border-color: #f973161a;
}

.conflict-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.diagnostic-accordion summary {
    cursor: pointer;
    padding: 0.35rem 0;
    font-weight: 600;
    color: var(--primary);
    list-style: none;
}

.diagnostic-accordion summary::-webkit-details-marker {
    display: none;
}

.diagnostic-accordion {
    border-top: 1px solid var(--border);
    padding-top: 0.35rem;
}

.conflict-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.6rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.conflict-item.warning {
    border-color: rgba(249, 115, 22, 0.3);
    background: #fff7ed;
}

.conflict-item.error {
    border-color: rgba(220, 38, 38, 0.35);
    background: #fef2f2;
}

.conflict-item h3 {
    margin: 0;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.conflict-badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: #eff6ff;
    color: var(--primary);
    border-radius: 999px;
    padding: 0.1rem 0.65rem;
}

.conflict-item p {
    margin: 0.3rem 0 0.25rem;
    color: var(--subtext);
    font-size: 0.82rem;
}

.conflict-actions {
    margin: 0.25rem 0 0;
    padding-left: 0.95rem;
    color: var(--text);
    font-size: 0.8rem;
}

.conflict-placeholder {
    color: var(--subtext);
    font-size: 0.8rem;
}

.time-column {
    width: 80px;
    flex-shrink: 0;
    color: var(--subtext);
    font-size: 0.85rem;
    position: sticky;
    left: 0;
    top: 0;
    align-self: flex-start;
    background: linear-gradient(to right, var(--panel-bg) 80%, rgba(255, 255, 255, 0));
    z-index: 3;
    padding-right: 0.25rem;
}

.time-slot {
    height: calc(var(--minute-size) * 60);
    border-bottom: 1px dashed var(--border);
    padding-right: 0.35rem;
    text-align: right;
}

.day-columns {
    flex: 1;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: var(--schedule-day-width);
    gap: 0.75rem;
    min-width: fit-content;
}

.day-column {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.7rem;
    background: #fbfdff;
    display: flex;
    flex-direction: column;
}

.day-column-body {
    position: relative;
    margin-top: 0.5rem;
    height: calc(var(--minute-size) * 1440);
    border-radius: 14px;
    background-image: linear-gradient(
            to bottom,
            rgba(148, 163, 184, 0.25) 1px,
            transparent 1px
    );
    background-size: 100% calc(var(--minute-size) * 60);
    overflow: hidden;
}

.event-block {
    position: absolute;
    left: 6px;
    right: 6px;
    border-radius: 12px;
    padding: 0.4rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.14);
}

.event-block span {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
}

.linkage-meta {
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--subtext);
}

.empty-placeholder {
    margin: 0;
    text-align: center;
    color: var(--subtext);
    font-style: italic;
}

#schedule-container.full-screen {
    position: fixed;
    inset: 0;
    background: rgba(244, 246, 251, 0.98);
    padding: 2rem;
    z-index: 999;
    overflow: auto;
}

.is-readonly {
    background: #f8fafc;
}

@media (max-width: 1200px) {
    .layout {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    #event-inputs,
    .list-diagnostics-row,
    #schedule-container {
        grid-column: span 6;
        min-width: 0;
    }

    .header-actions {
        width: 100%;
        align-items: flex-start;
    }

    .header-buttons {
        justify-content: flex-start;
    }

    .schedule-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .schedule-toolbar,
    .schedule-toolbar .plan-zoom {
        width: 100%;
        justify-content: flex-start;
    }

    .vehicle-settings {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .layout {
        grid-template-columns: 1fr;
    }

    #event-inputs,
    .list-diagnostics-row,
    #schedule-container {
        grid-column: 1 / -1;
    }

    .page {
        padding: 20px 16px 32px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
.toggle-row {
    display: flex;
    align-items: center;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1200;
}

.modal-card {
    background: var(--panel-bg);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.15);
}

.modal-card h3 {
    margin-top: 0;
    margin-bottom: 0.35rem;
}

.modal-card p {
    margin: 0 0 1rem;
    color: var(--subtext);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#shift-confirm-modal[hidden] {
    display: none !important;
}
#lock-shift-modal[hidden] {
    display: none !important;
}

/* ============================================
   Budget Line Items Styles
   ============================================ */

/* Budget line items container - force full width in grid */
#budget-line-items-container {
    grid-column: 1 / -1;
}

/* Header with title and add button */
.budget-line-items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.budget-section-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.add-item-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

/* Line items list container */
.budget-line-items-list {
    margin-bottom: 1rem;
}

.budget-empty-message {
    color: var(--subtext);
    font-style: italic;
    text-align: center;
    padding: 1rem;
    margin: 0;
}

/* Individual line item row */
.budget-line-item-row {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem; /* Reduced from 0.75rem for compact layout */
    background: var(--surface);
    margin-bottom: 0.35rem; /* Reduced from 0.5rem */
    overflow: visible;
}

.budget-line-item-row:hover {
    background: #fafafa;
}

/* Line item inputs grid - 4 columns: name, qty, price, remove button */
.line-item-inputs {
    display: grid;
    grid-template-columns: minmax(120px, 2fr) minmax(60px, 80px) minmax(80px, 100px) 42px;
    gap: 0.5rem;
    align-items: end;
}

.line-item-inputs .field {
    margin: 0;
}

.line-item-name-field {
    grid-column: 1;
}

.line-item-qty-field {
    grid-column: 2;
}

.line-item-price-field {
    grid-column: 3;
}

.remove-line-item-btn {
    grid-column: 4;
    padding: 0.35rem; /* Reduced from 0.5rem 0.75rem for compact layout */
    min-width: 32px; /* Reduced from 38px */
    height: 32px; /* Reduced from 38px */
    color: var(--error, #ef4444);
    font-size: 1.2rem; /* Reduced from 1.4rem */
    line-height: 1;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-bg, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-line-item-btn:hover {
    background-color: rgba(239, 68, 68, 0.1) !important;
    border-color: var(--error, #ef4444);
}

/* Line item subtotal display */
.line-item-subtotal {
    font-size: 0.85rem;
    color: var(--subtext);
    text-align: right;
    margin-top: 0.5rem;
}

.line-item-subtotal-value {
    color: var(--text);
}

/* ============================================
   Combined Tax/Tip/Summary Row - Inline Layout
   Tax % and Tip % inputs with summary totals on same row
   ============================================ */

/* Inline row container for Tax, Tip, and Summary totals */
.budget-totals-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Compact field for Tax/Tip percentage inputs */
.field-compact {
    flex: 0 0 auto;
    min-width: 70px;
    max-width: 90px;
}

.field-compact input {
    width: 100%;
    text-align: center;
}

/* Inline summary display - shows Subtotal, Tax, Tip, Total horizontally */
.budget-inline-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-left: auto;
    font-size: 0.85rem;
}

.budget-inline-summary span {
    color: var(--subtext);
}

.budget-inline-summary strong {
    color: var(--text);
}

.budget-inline-summary .budget-total {
    font-weight: 600;
}

.budget-inline-summary .budget-total strong {
    color: var(--primary);
    font-size: 1rem;
}

/* Responsive: stack on narrow screens */
@media (max-width: 640px) {
    .budget-totals-row {
        flex-direction: column;
        align-items: stretch;
    }

    .budget-inline-summary {
        margin-left: 0;
        margin-top: 0.5rem;
        justify-content: space-between;
    }
}

/* Budget breakdown in event details (reuses travel-breakdown-list styles) */
.budget-block {
    margin-top: 0.5rem;
}

.budget-breakdown-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.budget-breakdown-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.budget-breakdown-list span {
    color: var(--subtext);
}

.budget-breakdown-list strong {
    color: var(--text);
}

.budget-breakdown-list .budget-total-line {
    border-top: 1px solid var(--border);
    padding-top: 0.3rem;
    margin-top: 0.3rem;
}

.budget-breakdown-list .budget-total-line span {
    font-weight: 600;
    color: var(--text);
}

/* ============================================================
   Notes & Attachments Section Styles
   Allows users to attach multiple document or URL notes to events
   ============================================================ */

/* ============================================
   Side-by-Side Notes Columns Layout
   Notes textarea on left, Notes & Attachments on right
   ============================================ */

/* Two-column grid for notes sections */
.notes-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    grid-column: 1 / -1;
}

/* Notes textarea should fill height */
.notes-columns .field textarea {
    min-height: 120px;
    height: 100%;
}

/* Notes & Attachments container matches height */
.notes-columns #event-notes-container {
    display: flex;
    flex-direction: column;
}

.notes-columns .notes-list {
    flex: 1;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
}

/* Responsive: stack on narrow screens */
@media (max-width: 768px) {
    .notes-columns {
        grid-template-columns: 1fr;
    }
}

/* Notes container - no longer needs full width since inside .notes-columns */
#event-notes-container {
    margin-top: 0;
}

/* Header with title and add button */
.notes-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.notes-section-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

/* Notes list container */
.notes-list {
    margin-bottom: 1rem;
}

.notes-empty-message {
    color: var(--subtext);
    font-style: italic;
    text-align: center;
    padding: 1rem;
    margin: 0;
}

/* Compact note row - shows title, type badge, and action buttons */
.note-compact-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.note-compact-row:hover {
    background: #f3f4f6;
}

/* Note title - flex-grow to fill available space, truncate overflow */
.note-compact-title {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Type badge - small colored label */
.note-type-badge {
    font-size: 0.7rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    background: var(--primary-light, #e0e7ff);
    color: var(--primary, #4f46e5);
    flex-shrink: 0;
}

/* Action buttons container */
.note-compact-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Small action buttons for compact row */
.note-compact-actions .button.small {
    padding: 0.25rem 0.5rem;
    min-width: auto;
    font-size: 0.9rem;
    line-height: 1;
}

/* Remove note button - red color on hover */
.note-compact-actions .remove-note-btn {
    color: var(--subtext);
}

.note-compact-actions .remove-note-btn:hover {
    color: var(--error, #ef4444);
    background-color: rgba(239, 68, 68, 0.1);
}

/* ============================================================
   Document Viewer Modal Styles
   Displays rendered markdown content for document-type notes
   ============================================================ */

/* Document viewer modal card - larger than standard modals for full-width text preview */
.document-viewer-card {
    max-width: 900px;
    width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

/* Header with title and close button */
.document-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.document-viewer-header h3 {
    margin: 0;
    flex: 1;
    padding-right: 1rem;
    word-break: break-word;
}

.document-close-btn {
    flex-shrink: 0;
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
    min-width: auto;
}

/* Scrollable content area for rendered markdown - no horizontal scroll */
.document-viewer-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid var(--border);
    max-height: 50vh;
}

/* Markdown content styling */
.document-viewer-content h1 {
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 700;
    color: var(--text);
}

.document-viewer-content h2 {
    font-size: 1.25rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
}

.document-viewer-content h3 {
    font-size: 1.1rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
}

.document-viewer-content p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.document-viewer-content ul,
.document-viewer-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.document-viewer-content li {
    margin-bottom: 0.25rem;
}

.document-viewer-content code {
    background: #e5e7eb;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.document-viewer-content pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
}

.document-viewer-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.document-viewer-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: var(--subtext);
    font-style: italic;
}

.document-viewer-content a {
    color: var(--primary);
    text-decoration: underline;
}

.document-viewer-content a:hover {
    color: var(--primary-hover);
}

/* Table styling for document viewer - use full width for text preview */
.document-viewer-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    table-layout: fixed;
}

.document-viewer-content th,
.document-viewer-content td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border: 1px solid var(--border);
    word-wrap: break-word;
}

.document-viewer-content th {
    background: #e5e7eb;
    font-weight: 600;
}

.document-viewer-content tr:nth-child(even) td {
    background: #f3f4f6;
}

/* Ensure hidden attribute works for modal */
#document-viewer-modal[hidden] {
    display: none !important;
}

/* ============================================================
   Note Editor Modal Styles
   Modal form for adding/editing notes (replaces inline editing)
   ============================================================ */

/* Note editor modal card */
.note-editor-card {
    max-width: 600px;
    width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

/* Header with title and close button */
.note-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.note-editor-header h3 {
    margin: 0;
    flex: 1;
    padding-right: 1rem;
}

.note-editor-close-btn {
    flex-shrink: 0;
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
    min-width: auto;
}

/* Form content area */
.note-editor-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.5rem 0;
    overflow-y: auto;
    flex: 1;
}

/* Markdown content textarea - larger height for editing */
#note-editor-content-text {
    min-height: 200px;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
}

/* Ensure hidden attribute works for note editor modal */
#note-editor-modal[hidden] {
    display: none !important;
}

/* ============================================================
   Notes Detail Block Styles (Event List)
   Displays notes in the expandable event detail row
   ============================================================ */

/* Notes detail block - purple accent border */
.notes-block {
    border-left-color: #a78bfa;
}

.notes-detail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.note-detail-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px dashed var(--border);
}

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

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

/* Clickable link for document notes - opens document viewer modal */
.note-detail-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    text-align: left;
}

.note-detail-link:hover {
    color: var(--primary-hover);
}

/* Direct link for URL notes - opens in new tab */
.note-detail-url {
    font-weight: 600;
    color: var(--primary);
    text-decoration: underline;
}

.note-detail-url:hover {
    color: var(--primary-hover);
}

.budget-breakdown-list .budget-total-line strong {
    color: var(--primary);
}

/* ============================================================
   Event Row Click-to-Expand Styles
   Enables clicking on event rows to expand/collapse detail rows
   ============================================================ */

/* Event row click-to-expand cursor styling */
.event-row {
    cursor: pointer;
}

/* Action elements have their own cursor - don't inherit row cursor */
.event-row .actions,
.event-row .action-menu {
    cursor: default;
}

.event-row .link-button,
.event-row a {
    cursor: pointer;
}

/* Visual indicator for expanded event rows */
.event-row.is-expanded td {
    background: #eef4ff;
    border-bottom-color: transparent;
}

/* Ensure detail row has consistent styling with expanded parent */
.event-row.is-expanded + .event-detail-row td {
    background: #f1f5ff;
}

/* Responsive adjustments for line items */
@media (max-width: 640px) {
    .line-item-inputs {
        grid-template-columns: 1fr 1fr 42px;
    }

    .line-item-name-field {
        grid-column: 1 / -1;
        margin-bottom: 0.5rem;
    }

    .line-item-qty-field {
        grid-column: 1;
    }

    .line-item-price-field {
        grid-column: 2;
    }

    .remove-line-item-btn {
        grid-column: 3;
    }
}
