/* Sales page layout */
#sales-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #f5f6f8;
}

/* Header */
#sales-header {
    background: #1a2332;
    color: white;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.header-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.header-left h1 { font-size: 18px; font-weight: 700; }
.header-left h1 a { color: white; text-decoration: none; }
.header-left .subtitle { font-size: 13px; opacity: 0.6; }
.town-select-sales {
    font-size: 18px;
    font-weight: 700;
    color: white;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
    padding-right: 18px;
}
.town-select-sales option {
    color: #1a2332;
    background: white;
}
.header-nav { display: flex; gap: 4px; }
.header-nav a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 14px;
    border-radius: 4px;
    transition: all 0.15s;
}
.header-nav a:hover { color: white; background: rgba(255,255,255,0.1); }
.header-nav a.active { color: white; background: rgba(255,255,255,0.15); }

/* Content */
#sales-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

/* Stats bar */
#stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.stat-card {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    flex: 1;
    min-width: 160px;
    border: 1px solid #e5e7eb;
}
.stat-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #1a2332;
}
.stat-value.green { color: #16a34a; }

/* Search */
#sales-search {
    margin-bottom: 16px;
}
#search-address {
    width: 100%;
    max-width: 400px;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
}
#search-address:focus {
    border-color: #3388ff;
    box-shadow: 0 0 0 3px rgba(51, 136, 255, 0.15);
}

/* Filters */
#filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filter-group label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.filter-group select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    min-width: 140px;
}
.filter-group select:focus {
    border-color: #3388ff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(51, 136, 255, 0.15);
}

/* Table */
#sales-table-wrap {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow-x: auto;
}
#sales-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
#sales-table thead {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}
#sales-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
#sales-table th.num { text-align: right; }
#sales-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
}
#sales-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
#sales-table tbody tr:hover { background: #f8fafc; }
#sales-table tbody tr { cursor: pointer; }

.sale-address {
    font-weight: 600;
    color: #1a2332;
}
.sale-date {
    color: #6b7280;
    font-size: 13px;
}
.sale-price {
    font-weight: 600;
    color: #1a2332;
}
.sale-assessed { color: #6b7280; }
.sale-ratio {
    font-size: 13px;
}
.ratio-over { color: #dc2626; font-weight: 600; }
.ratio-under { color: #16a34a; font-weight: 600; }
.ratio-fair { color: #6b7280; }
.sale-type {
    font-size: 12px;
    color: #6b7280;
}
.sale-lot { color: #6b7280; font-size: 13px; }
.sale-sqft { color: #6b7280; }
.sale-ppsf { font-weight: 600; color: #1a2332; }

/* U/N badges */
.badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-left: 4px;
    position: relative;
    cursor: help;
}
.badge-nonusable {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}
.badge-nonusable .badge-tip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a2332;
    color: white;
    font-size: 12px;
    font-weight: 400;
    padding: 6px 10px;
    border-radius: 5px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}
.badge-nonusable .badge-tip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a2332;
}
.badge-nonusable:hover .badge-tip { display: block; }
.row-nonusable { opacity: 0.75; }

/* Expanded detail row */
.detail-expand td {
    padding: 0 !important;
    border-bottom: 2px solid #e5e7eb;
}
.detail-expand-inner {
    display: flex;
    gap: 24px;
    padding: 14px 16px;
    background: #f9fafb;
    flex-wrap: wrap;
}
.detail-expand-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}
.detail-expand-col .de-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    font-weight: 600;
}
.detail-expand-col .de-value {
    font-size: 13px;
    color: #1a2332;
}
.detail-expand-link {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #3388ff;
    background: white;
    border: 1px solid #3388ff;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.15s;
}
.detail-expand-link:hover {
    background: #3388ff;
    color: white;
}
tr.row-selected > td {
    background: #eef5ff;
    border-bottom-color: transparent;
}

td.loading {
    padding: 40px;
    text-align: center;
    color: #999;
}

/* Pagination */
#pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}
.page-btn {
    padding: 8px 14px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s;
}
.page-btn:hover { background: #f3f4f6; border-color: #9ca3af; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn.active { background: #1a2332; color: white; border-color: #1a2332; }
.page-info {
    font-size: 14px;
    color: #6b7280;
    padding: 0 8px;
}

/* Mobile */
@media (max-width: 768px) {
    #sales-content { padding: 12px; }
    .stat-card { min-width: 120px; padding: 12px; }
    .stat-value { font-size: 18px; }
    #sales-table { font-size: 13px; }
    #sales-table th, #sales-table td { padding: 8px 10px; }
    .header-inner { padding: 0; }
}
