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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #475569; /* Darker secondary */
    --success-color: #059669; /* Darker green */
    --danger-color: #dc2626; /* Darker red */
    --background: #f1f5f9; /* Slightly darker bg */
    --surface: #ffffff;
    --text-primary: #0f172a; /* Darkest slate */
    --text-secondary: #334155; /* Darker slate */
    --border-color: #cbd5e1; /* Darker border */
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --sidebar-width: 320px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --font-xs: 0.75rem;
    --font-sm: 0.85rem;
    --font-base: 0.9rem;
    --color-border: #cbd5e1;
    --color-bg-subtle: #f1f5f9;
    --color-text-main: #0f172a;
    --color-text-muted: #475569;
}

/* Utility Classes */
.mb-2 { margin-bottom: 0.5rem; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.w-100 { width: 100%; }
.d-none { display: none; }

/* Text Colors */
.text-create { color: var(--success-color); }
.text-delete { color: var(--danger-color); }
.text-modify-new { color: var(--primary-color); }
.text-modify-old { color: #f59e0b; }
.text-muted { color: var(--text-secondary); }

/* Header Actions */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.btn-refresh {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

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

/* BBox Inputs */
.bbox-size-row {
    display: flex;
    gap: 0.5rem;
}

.bbox-size-group {
    flex: 1;
}

/* Panel Styles */
.panel-header {
    padding: 0.5rem;
    border-bottom: 1px solid #cbd5e1;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.panel-title-row {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

.panel-title-row h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.panel-links {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.panel-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 2px;
}

.panel-link:hover {
    color: var(--text-primary);
}

.panel-comment {
    background: var(--background);
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    font-style: italic;
    color: var(--text-primary);
}

.btn-filter-inline {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 4px;
    font-size: 0.875rem;
    color: var(--secondary-color);
}

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

.user-id, .status-text-muted {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.tags-summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
}

.tags-table-container {
    overflow-x: auto;
    margin-top: 8px;
}

.tags-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.tags-table th {
    padding: 8px;
    border-bottom: 2px solid var(--border-color);
    width: 30%;
    color: var(--text-secondary);
    font-weight: 600;
}

.tags-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.tags-table td:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.no-tags {
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 8px;
}

.empty-filters {
    color: var(--text-secondary);
    font-style: italic;
}

/* Popup Styles */
.popup-content {
    font-size: 0.9rem;
    max-width: 300px;
}

.popup-content h3 {
    margin: 0 0 5px 0;
    font-size: 1rem;
}

.popup-meta {
    margin-bottom: 8px;
}

.change-type {
    font-weight: bold;
    text-transform: capitalize;
}

.version-text {
    color: #666;
}

.popup-tags {
    margin-top: 5px;
    border-top: 1px solid #eee;
    padding-top: 5px;
}

.popup-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}

.popup-table td {
    word-break: break-word;
}

.popup-table td:first-child {
    font-weight: bold;
    padding-right: 5px;
    vertical-align: top;
}

/* Diff Styles */
.diff-add { background-color: #dcfce7; }
.diff-add td { color: #166534; }
.diff-del { background-color: #fee2e2; }
.diff-del td { color: #991b1b; }
.diff-mod { background-color: #fff7ed; }
.diff-mod-key { color: #9a3412; }
.diff-old-val { background-color: #fee2e2; text-decoration: line-through; color: #991b1b; margin-right: 4px; }
.diff-new-val { background-color: #dcfce7; color: #166534; }

/* Body */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    color: #020617; /* Almost black */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    display: flex;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: #fff;
    border-right: 1px solid #94a3b8; /* Much darker border */
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 0.5rem;
    border-bottom: 1px solid #cbd5e1;
    background: #f1f5f9;
}

.sidebar-header h1 {
    margin: 0;
    font-size: 1.1rem; /* Smaller font */
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subtitle {
    margin: 0.125rem 0 0 0;
    font-size: 0.75rem;
    color: #334155; /* Darker */
}

/* Filters */
.filters {
    border-bottom: 1px solid #cbd5e1;
    background: #fff;
}

.filters-header {
    padding: 0.375rem 0.5rem; /* Tighter padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: #e2e8f0; /* Darker header bg */
}

.filters-header h2 {
    margin: 0;
    font-size: 0.9rem;
    color: #0f172a;
    font-weight: 600;
}

.filters-summary {
    flex: 1;
    margin: 0 0.5rem;
    font-size: 0.75rem;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filters-content {
    padding: 0.5rem;
    display: block;
}

.filters.collapsed .filters-content {
    display: none;
}

.filter-group {
    margin-bottom: 0.5rem;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
    color: #1e293b;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 0.375rem;
    border: 1px solid #94a3b8; /* Darker border */
    border-radius: 0.25rem;
    font-size: 0.8rem;
    box-sizing: border-box;
    color: #020617;
    background-color: #fff;
}

input::placeholder {
    color: #64748b; /* Darker placeholder */
}

/* Buttons */
.btn {
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    width: 100%;
    margin-bottom: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e2e8f0;
    color: #1e293b;
    border: 1px solid #94a3b8;
}

.btn-secondary:hover {
    background: #cbd5e1;
    color: #0f172a;
    border-color: #64748b;
}

/* Changeset List */
.changeset-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.changeset-list-header-container {
    padding: 0.375rem 0.5rem;
    background: #f1f5f9;
    border-bottom: 1px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 5;
}

.changeset-list-header-container h2 {
    margin: 0;
    font-size: 0.9rem;
    color: #0f172a;
    font-weight: 600;
}

.changeset-items {
    flex: 1;
}

.changeset-item {
    padding: 0.5rem; /* Tighter padding */
    border-bottom: 1px solid #cbd5e1;
    cursor: pointer;
    transition: background-color 0.1s;
}

.changeset-item:hover {
    background-color: #f1f5f9;
}

.changeset-item.active {
    background-color: #dbeafe;
    border-left: 4px solid #1d4ed8;
}

.changeset-item.read {
    opacity: 1; /* Remove opacity reduction for better contrast */
    background-color: #f8fafc;
}

.changeset-item.read .changeset-id,
.changeset-item.read .changeset-user,
.changeset-item.read .changeset-meta {
    color: #475569; /* Darker gray for read items */
}

.changeset-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.125rem;
    align-items: baseline;
}

.changeset-id {
    font-weight: 700;
    color: #1d4ed8; /* Darker blue */
    font-size: 0.9rem;
}

.changeset-status {
    font-size: 0.7rem;
    padding: 0 0.25rem;
    border-radius: 2px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-open {
    background-color: #bbf7d0;
    color: #14532d; /* Dark green text */
    border: 1px solid #86efac;
}

.status-closed {
    background-color: #e2e8f0;
    color: #334155; /* Dark slate text */
    border: 1px solid #cbd5e1;
}

.changeset-user {
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.125rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.changeset-meta {
    font-size: 0.75rem;
    color: #334155; /* Darker */
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.125rem;
}

.changeset-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.changeset-comment {
    font-size: 0.8rem;
    color: #1e293b; /* Darker */
    font-style: italic;
    margin-top: 0.25rem;
    line-height: 1.3;
    background: #f8fafc;
    padding: 2px 4px;
    border-radius: 2px;
    border: 1px solid #e2e8f0;
}

/* Map */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

.map-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.btn-icon {
    width: 32px; /* Smaller buttons */
    height: 32px;
    border-radius: 4px;
    background: white;
    border: 1px solid #94a3b8; /* Darker border */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-size: 1.1rem;
    color: #1e293b;
}

.btn-icon:hover {
    background: #f1f5f9;
    color: #000;
    border-color: #64748b;
}

/* Detail Panel */
.changeset-detail-panel {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    width: 400px;
    max-height: 60vh;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    z-index: 20;
    display: none; /* Hidden by default */
    flex-direction: column;
    border: 1px solid #94a3b8;
}

.changeset-detail-panel.active {
    display: flex;
}

.panel-close-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #475569;
    z-index: 30;
    padding: 4px;
}

.panel-close-btn:hover {
    color: #000;
    background: #f1f5f9;
    border-radius: 4px;
}

#panelContent {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.panel-grid {
    padding: 0.5rem;
}

.panel-section {
    margin-bottom: 0.5rem;
}

.panel-section p {
    margin: 0.25rem 0;
}

/* Read state for changesets */
.changeset-item.read {
    background-color: #f8fafc;
}

.changeset-item.read .changeset-id,
.changeset-item.read .changeset-user {
    color: #64748b; /* Darker than before */
}

/* Ensure active state overrides read background and text color */
.changeset-item.active.read {
    background-color: #dbeafe;
}

.changeset-item.active.read .changeset-id {
    color: #1e3a8a;
}

.changeset-item.active.read .changeset-user {
    color: #0f172a;
}

/* BBox Display */
.bbox-display {
    padding: 0.375rem;
    background: #f1f5f9;
    border: 1px solid #94a3b8;
    border-radius: 0.25rem;
    margin-bottom: 0.375rem;
    font-size: 0.75rem;
    color: #0f172a;
    text-align: center;
    font-family: monospace;
}

.bbox-coords {
    font-family: monospace;
    color: #0f172a;
    font-weight: 600;
}

.bbox-placeholder {
    color: #94a3b8;
    font-style: italic;
    font-family: monospace;
}
