.table-responsive {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.data-table {
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    word-wrap: break-word;
}

.data-table th {
    position: relative;
    background-color: #f3f3f3;
    padding: 6px 25px 6px 8px;
    text-align: center;
    font-weight: bold;
    border: 1px solid #ddd;
    cursor: pointer;
}

.data-table th:hover {
    background-color: #e5e5e5;
}

.data-table td {
    padding: 6px 8px;
    border: 1px solid #ddd;
    text-align: right;
    vertical-align: middle;
}

.data-table th:first-child,
.data-table td:first-child {
    text-align: left;
    padding-left: 8px;
}

.data-table td:first-child a {
    font-weight: normal;
}

.data-table tr:nth-child(even) {
    background-color: #f8f8f8;
}

.data-table tr:hover {
    background-color: #f1f1f1;
}

.positive {
    color: green;
}

.negative {
    color: red;
}

.positive-change {
    color: #28a745;
    font-weight: bold;
}

.negative-change {
    color: #dc3545;
    font-weight: bold;
}

.error-data {
    color: #dc3545;
    text-align: center;
}

.loading-data {
    text-align: center !important;
    padding: 20px;
    font-style: italic;
    color: #666;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.sortable-header::after {
    content: '\2195';
    position: absolute;
    right: 5px;
    opacity: 0.3;
}

.sortable-header.sort-asc::after {
    content: '\2191';
    opacity: 1;
}

.sortable-header.sort-desc::after {
    content: '\2193';
    opacity: 1;
}

.three-line-legend {
    height: auto;
    background-color: rgba(255, 255, 255, 0.85);
    border-radius: 4px;
}

.three-line-legend .tooltip-title {
    background-color: transparent;
    height: fit-content;
    padding: 0;
}

.legend-year {
    font-weight: bold;
    margin: 2px 0;
}

.condition-links {
    margin: 15px 0;
    text-align: center;
}

.condition-links p {
    margin: 5px 0;
}

.condition-links a {
    text-decoration: none;
    cursor: pointer;
    padding: 1px 3px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.condition-links a:hover {
    background-color: #f0f0f0;
}

.condition-links a.active {
    background-color: #007bff;
    color: white;
}

.chart-mode-link,
.chart-unit-link,
.chart-source-link,
.chart-type-link,
.chart-irrigation-link,
.table-irrigation-link,
.table-source-link,
.table-view-link {
    text-decoration: none !important;
    cursor: pointer;
    padding: 1px 3px;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.chart-mode-link:hover,
.chart-unit-link:hover,
.chart-source-link:hover,
.chart-type-link:hover,
.chart-irrigation-link:hover,
.table-irrigation-link:hover,
.table-source-link:hover,
.table-view-link:hover {
    text-decoration: none !important;
    background-color: #f0f0f0;
}

.chart-irrigation-link.is-disabled,
.table-irrigation-link.is-disabled {
    color: #aaaaaa !important;
    background: transparent !important;
    cursor: default;
    pointer-events: none;
    text-decoration: none !important;
}

.chart-mode-link.active,
.chart-unit-link.active,
.chart-source-link.active,
.chart-type-link.active,
.chart-irrigation-link.active,
.table-irrigation-link.active,
.table-source-link.active,
.table-view-link.active {
    text-decoration: none !important;
    background-color: #007bff;
    color: #ffffff !important;
}

.table-source-row,
.table-view-row,
.table-county-year-row,
.table-irrigation-row {
    text-align: left;
    margin: 0 0 10px;
}

.table-county-year-row select {
    margin-left: 4px;
    padding: 3px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #222;
    font: inherit;
    font-size: 14px;
}

.county-map {
    margin: 20px 0 30px;
    padding: 16px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.county-map-title {
    margin: 0;
    color: #20262e;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
}

.county-map-controls {
    margin: 8px 0 0;
}

.county-measure-link,
.county-view-link,
.county-source-link,
.county-unit-link,
.county-irrigation-link {
    text-decoration: none !important;
    cursor: pointer;
    padding: 1px 3px;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.county-measure-link:hover,
.county-view-link:hover,
.county-source-link:hover,
.county-unit-link:hover,
.county-irrigation-link:hover {
    background-color: #f0f0f0;
}

.county-measure-link.active,
.county-view-link.active,
.county-source-link.active,
.county-unit-link.active,
.county-irrigation-link.active {
    background-color: #007bff;
    color: #ffffff !important;
}

.county-map-controls select {
    margin-left: 4px;
    padding: 3px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #222;
    font: inherit;
    font-size: 14px;
}

.county-map-loading {
    padding: 14px;
    text-align: center;
    color: #667380;
    font-style: italic;
}

.county-map-loading.is-empty {
    font-style: normal;
}

.county-map-canvas {
    position: relative;
}

.county-map-canvas svg {
    display: block;
    width: 100%;
    height: auto;
}

.county-map-watermark {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 4px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.84);
    color: #20262e;
    font-size: 11px;
    line-height: 1.25;
    text-align: left;
    pointer-events: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.county-map-watermark-brand {
    font-weight: 700;
}

.county-map-watermark-stat {
    color: #333;
}

.county-map .county {
    stroke: #ffffff;
    stroke-width: 0.35px;
    cursor: pointer;
    vector-effect: non-scaling-stroke;
}

.county-map .county:hover {
    stroke: #12181f;
    stroke-width: 1.1px;
}

.county-map .state {
    stroke: #000000;
    stroke-width: 0.9px;
    cursor: pointer;
    vector-effect: non-scaling-stroke;
}

.county-map .state:hover {
    stroke: #000000;
    stroke-width: 1.2px;
}

.county-map .selected-county {
    fill: none;
    stroke: #000000;
    stroke-width: 2.5px;
    pointer-events: none;
    vector-effect: non-scaling-stroke;
}

.county-map .statemesh {
    fill: none;
    stroke: #000000;
    stroke-width: 0.9px;
    pointer-events: none;
    vector-effect: non-scaling-stroke;
}

.county-map .nationmesh {
    fill: none;
    stroke: #2f3b47;
    stroke-width: 1.1px;
    pointer-events: none;
    vector-effect: non-scaling-stroke;
}

.county-map-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 5px 12px;
    padding: 8px 4px 2px;
    color: #5c6b7a;
    font-size: 12px;
}

.county-legend-title {
    margin-right: 4px;
    color: #667380;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.county-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.county-legend-swatch {
    display: inline-block;
    width: 22px;
    height: 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 2px;
}

.county-map-note {
    padding: 4px 4px 0;
    color: #8a97a5;
    font-size: 11.5px;
    text-align: center;
}

.county-map-tooltip {
    position: fixed;
    z-index: 10000;
    display: none;
    min-width: 190px;
    padding: 9px 12px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    color: #1f2a36;
    font-size: 12.5px;
    pointer-events: none;
}

.county-tooltip-name {
    margin-bottom: 4px;
    font-size: 13.5px;
    font-weight: 700;
}

.county-tooltip-note {
    color: #667380;
}

.county-map-tooltip table {
    border-collapse: collapse;
}

.county-map-tooltip td {
    padding: 1px 0;
}

.county-map-tooltip td:first-child {
    padding-right: 12px;
    color: #667380;
}

.county-map-tooltip td:last-child {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.table-unit-link {
    text-decoration: none !important;
    cursor: pointer;
    padding: 1px 3px;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.table-unit-link:hover {
    text-decoration: none !important;
    background-color: #f0f0f0;
}

.table-unit-link.active {
    text-decoration: none !important;
    background-color: #007bff;
    color: #ffffff !important;
}

.legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 5px;
    border-radius: 2px;
    vertical-align: baseline;
}

.table-footnote {
    font-size: 12px;
    margin-top: 10px;
    color: #666;
    font-style: italic;
}

.forecast-source {
    font-weight: 600;
    font-size: 0.85em;
    letter-spacing: 0.02em;
}

.forecast-source-nass {
    color: #2f7d1f;
}

.forecast-source-fsa {
    color: #c2410c;
}

.forecast-current {
    font-size: 0.75em;
    color: #666;
    margin-left: 4px;
}

#forecast-table {
    font-size: 12px;
}

#forecast-table.forecast-both {
    font-size: 10.5px;
}

#forecast-table th,
#forecast-table td {
    padding: 4px 5px;
}

#forecast-table.forecast-both th,
#forecast-table.forecast-both td {
    padding: 2px 3px;
}

#forecast-table th {
    white-space: nowrap;
}

.error-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.popup-content h3 {
    margin: 0 0 15px 0;
    color: #dc3545;
    font-size: 1.5em;
}

.popup-content p {
    margin: 0 0 20px 0;
    color: #333;
    line-height: 1.5;
}

.popup-content button {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s;
}

.popup-content button:hover {
    background: #0056b3;
}

.table-options {
    margin-bottom: 2rem;
}

/* Category toggles: keep the row above Source and centered. */
.chart-category,
.county-map-category-row {
    text-align: center;
    margin: 10px 0;
}
.chart-category .table-view-link,
.county-map-category-row .table-view-link {
    white-space: nowrap;
}
.chart-use {
    text-align: center;
    margin: 10px 0;
}
.county-map-use-row {
    text-align: center;
    margin: 10px 0;
}
