*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #333;
    background: #f5f5f5;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: #fff;
    border-bottom: 1px solid #ddd;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-left,
.header-right {
    min-width: 120px;
}

.header-right {
    text-align: right;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* List View */
.list-view {
    padding: 1.5rem 2rem;
}

.search-bar {
    margin-bottom: 1rem;
}

.search-bar input {
    width: 100%;
    max-width: 400px;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.875rem;
}

.table-wrap {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
    font-weight: 600;
}

tbody td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

tbody tr:hover {
    background: #f0f4ff;
}

.site-link {
    color: #2563eb;
    text-decoration: none;
}

.site-link:hover {
    text-decoration: underline;
}

.sites-table .notes-col {
    width: 33%;
}

.sites-table td.notes-col {
    white-space: normal;
    vertical-align: top;
}

.notes-cell {
    max-height: 4.5em;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.4;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.875rem;
}

.pagination button {
    padding: 0.375rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 0.875rem;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Page footer */
.page-footer {
    padding: 2rem;
    text-align: center;
}

.page-footer a {
    color: #999;
    font-size: 0.8125rem;
    text-decoration: none;
}

.page-footer a:hover {
    color: #666;
    text-decoration: underline;
}

/* Utility */
.loading,
.empty,
.error {
    padding: 2rem;
    text-align: center;
    color: #888;
}

.error {
    color: #dc2626;
}

/* Select View Layout */
.select-layout {
    display: flex;
    height: calc(100vh - 57px);
}

.coverage-menu {
    width: 200px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.coverage-menu h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 0.75rem 0.5rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.25rem;
}

.coverage-menu ul {
    list-style: none;
}

.coverage-menu li {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.coverage-menu li:hover {
    background: #f0f4ff;
    color: #2563eb;
}

/* Map */
.map-container {
    height: calc(100vh - 57px);
    flex: 1;
    min-width: 0;
}

/* Evaluation View */
.eval-layout {
    display: flex;
    height: calc(100vh - 57px);
    overflow: hidden;
}

.eval-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ddd;
    background: #1a1a1a;
}

.eval-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 1rem;
    position: relative;
}

.eval-image {
    width: 1024px;
    height: 1024px;
    object-fit: contain;
}

.roof-graph-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: #fff;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.15s,
        opacity 0.15s;
}

.roof-graph-toggle:hover {
    background: rgba(0, 0, 0, 0.8);
}

.roof-graph-toggle.roof-graph-hidden {
    opacity: 0.5;
}

.eval-image-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
}

.eval-meta {
    padding: 0.75rem 1rem;
    background: #fff;
    border-top: 1px solid #ddd;
    font-size: 0.875rem;
    line-height: 1.5;
}

.eval-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: #fff;
    border-top: 1px solid #eee;
    font-size: 0.875rem;
}

.eval-right {
    width: 840px;
    flex-shrink: 0;
    overflow-y: auto;
    background: #fff;
}

.data-panel {
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
        "details notes"
        "features obstructions";
    gap: 1.5rem;
    align-items: start;
}

.data-section {
    min-width: 0;
}

.data-section-details {
    grid-area: details;
}

.data-section-notes {
    grid-area: notes;
    display: flex;
    flex-direction: column;
    align-self: stretch;
}

.data-section-features {
    grid-area: features;
}

.data-section-obstructions {
    grid-area: obstructions;
}

.data-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #eee;
}

.notes-textarea {
    flex: 1;
    width: 100%;
    min-height: 80px;
    resize: vertical;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.875rem;
    box-sizing: border-box;
}

.notes-readonly {
    flex: 1;
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #eee;
    border-radius: 4px;
    background: #fafafa;
    font-size: 0.875rem;
    white-space: pre-wrap;
    overflow-y: auto;
    box-sizing: border-box;
}

.data-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.data-row label {
    min-width: 120px;
    font-weight: 500;
}

.data-row select,
.data-row input {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.875rem;
}

.feature-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.feature-table th {
    text-align: left;
    padding: 0.375rem 0.5rem;
    background: #f9fafb;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
}

.feature-table td {
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.count-cell {
    text-align: center;
    width: 70px;
}

.spin-input {
    width: 60px;
    text-align: center;
    padding: 0.2rem 0.25rem;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.btn-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

.measure-done {
    color: #16a34a;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Validation error styles */
.validation-error {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
}

.validation-error-text {
    color: #dc2626;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.modal h2 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.error-modal-details {
    margin: 0.5rem 0 0;
    margin-left: 1.25rem;
    font-size: 0.85rem;
    color: #555;
}

/* Issues View */
.issues-view {
    padding: 1.5rem 2rem;
    max-width: 900px;
}

.issue-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    padding: 1rem;
}

.issue-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.issue-rank {
    font-size: 1rem;
    font-weight: 700;
    color: #888;
    min-width: 2.5rem;
}

.issue-info {
    flex: 1;
    min-width: 0;
}

.issue-message {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.issue-function code {
    font-size: 0.8rem;
    color: #666;
    background: #f5f5f5;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.issue-count {
    background: #2563eb;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    white-space: nowrap;
}

.issue-locations {
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

.issue-locations summary {
    cursor: pointer;
    color: #2563eb;
    font-weight: 500;
}

.issue-locations ul {
    list-style: none;
    margin-top: 0.5rem;
    padding-left: 2.5rem;
}

.issue-locations li {
    padding: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.issue-locations a {
    color: #2563eb;
    text-decoration: none;
}

.issue-locations a:hover {
    text-decoration: underline;
}

.issue-loc-date {
    color: #999;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Login View */
.login-view {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 320px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2rem;
}

.login-card h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.login-card .error {
    padding: 0;
    text-align: left;
}

.login-card input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.875rem;
}
