* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #f0f0f0;
    color: #111;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: sans-serif;
}

/* ── HEADER ── */
.header {
    background: #111;
    color: #fff;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header a {
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
}

.header span {
    font-size: 11px;
    color: #888;
}

/* ── TOOLBAR ── */
.toolbar {
    background: #fff;
    border-bottom: 2px solid #ccc;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-label {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #555;
}

.tab-btn {
    background: #f0f0f0;
    border: 1px solid #ccc;
    padding: 5px 14px;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    font-weight: bold;
    /* larger tap target on mobile */
    min-height: 32px;
}

.tab-btn.active {
    background: #111;
    color: #fff;
    border-color: #111;
}

.tab-btn:hover:not(.active) {
    background: #e0e0e0;
}

.divider {
    width: 1px;
    height: 20px;
    background: #ccc;
    margin: 0 4px;
}

.period-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.period-section.hidden {
    display: none;
}

/* ── CONTENT ── */
.content {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── STATS ROW ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.stat-card {
    background: #fff;
    border: 1px solid #ccc;
    border-left: 4px solid #111;
    padding: 12px 14px;
}

.stat-card.green { border-left-color: #16a34a; }
.stat-card.amber { border-left-color: #d97706; }
.stat-card.red   { border-left-color: #e53e3e; }

.stat-label {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #888;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 22px;
    font-weight: bold;
}

.stat-sub {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

/* ── CHARTS ── */
.chart-card {
    background: #fff;
    border: 1px solid #ccc;
    padding: 14px;
}

.chart-title {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 3px;
    color: #111;
    margin-bottom: 14px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.chart-wrap {
    position: relative;
    height: 280px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── EMPLOYEE TABLE ── */
.emp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.emp-table th {
    text-align: left;
    font-size: 10px;
    letter-spacing: 2px;
    color: #888;
    font-weight: bold;
    padding: 6px 8px;
    border-bottom: 2px solid #ccc;
}

.emp-table td {
    padding: 7px 8px;
    border-bottom: 1px solid #eee;
}

.emp-table tr:last-child td {
    border-bottom: none;
}

.bar-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bar-bg {
    flex: 1;
    height: 6px;
    background: #eee;
}

.bar-fill {
    height: 6px;
    background: #16a34a;
}

.pct-label {
    font-size: 11px;
    font-weight: bold;
    min-width: 36px;
    text-align: right;
}

/* ── MISC ── */
.empty {
    color: #aaa;
    font-size: 11px;
    padding: 20px;
    text-align: center;
}

#loading {
    color: #aaa;
    font-size: 11px;
    padding: 40px;
    text-align: center;
    letter-spacing: 2px;
}

/* ── INACTIVE / COUNTY BLOCKS ── */
.inactive-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 4px;
}

.county-block {
    background: #fff;
    border: 1px solid #ccc;
    border-left: 4px solid #111;
    margin-bottom: 8px;
}

.county-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    gap: 12px;
}

.county-summary:hover {
    background: #f8f8f8;
}

.county-name {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    flex: 1;
}

.county-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.county-pill {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #555;
    background: #f0f0f0;
    border: 1px solid #ccc;
    padding: 2px 8px;
}

.county-pill.red {
    border-color: #e53e3e;
    color: #e53e3e;
    background: #fff5f5;
}

.county-arrow {
    font-size: 10px;
    color: #888;
    min-width: 12px;
    transition: transform 0.15s;
}

.county-arrow.open {
    transform: rotate(90deg);
}

.county-body {
    display: none;
    border-top: 1px solid #eee;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.county-body.open {
    display: block;
}

/* ── CUSTOMER TABLE ── */
.cust-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.cust-table th {
    text-align: left;
    font-size: 10px;
    letter-spacing: 1px;
    color: #888;
    font-weight: bold;
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    white-space: nowrap;
}

.cust-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f5f5f5;
    white-space: nowrap;
}

.cust-table tr:last-child td {
    border-bottom: none;
}

.cust-table tr:hover td {
    background: #f9f9f9;
}

.days-badge {
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    letter-spacing: 1px;
    white-space: nowrap;
}

.days-badge.over2y {
    color: #e53e3e;
    background: #fff5f5;
    border: 1px solid #e53e3e;
}

.days-badge.over1y {
    color: #d97706;
    background: #fffbeb;
    border: 1px solid #d97706;
}

.days-badge.never {
    color: #888;
    background: #f5f5f5;
    border: 1px solid #ccc;
}

.sort-btn {
    background: none;
    border: none;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #aaa;
    cursor: pointer;
    padding: 0;
}

.sort-btn.active-sort {
    color: #111;
}

/* ── MAP LAYOUT ── */
.inactive-layout {
    display: grid;
    grid-template-columns: 520px 1fr;
    gap: 16px;
    align-items: start;
    min-height: 760px;
}

.map-panel {
    background: #9ec7f3;
    border: 1px solid #ccc;
    padding: 12px;
    overflow: hidden;
}

#ireland-map {
    width: 100%;
    height: 700px;
    border: none;
    background: #fff;
}

.map-title {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.selected-county {
    margin-top: 10px;
    font-size: 11px;
    color: #666;
}

/* ── COUNTY SIDEBAR ── */
.county-sidebar {
    background: #fff;
    border: 1px solid #ccc;
    padding: 0;
    overflow-y: auto;
    max-height: 740px;
    min-height: 740px;
}

.sidebar-header {
    padding: 12px 14px;
    border-bottom: 2px solid #111;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
}

.sidebar-title {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 2px;
}

.sidebar-sub {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

/* ── MAP SVG ── */
#ireland text          { pointer-events: none; }
#ireland .lbl,
#ireland .city-lbl     { pointer-events: none; }
#ireland               { overflow: visible; }

#ireland .county:hover {
    stroke: #333 !important;
    stroke-width: 2px !important;
    fill: rgba(0, 0, 0, 0.1) !important;
}

#ireland .county.active {
    stroke: #111 !important;
    stroke-width: 2px !important;
    fill: rgba(0, 0, 0, 0.2) !important;
}

#ireland .city-dot {
    cursor: pointer;
    transition: r 0.12s;
}

#ireland .city-dot:hover { r: 7; }

/* ── RESPONSIVE ── */

/* Tablet — 1000px and below */
@media (max-width: 1000px) {
    .inactive-layout {
        grid-template-columns: 1fr;
        min-height: unset;
    }

    .county-sidebar {
        min-height: unset;
        max-height: unset;
    }

    #ireland-map {
        height: 500px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile — 600px and below */
@media (max-width: 600px) {
    .header {
        font-size: 13px;
        padding: 10px 14px;
        letter-spacing: 1px;
    }

    .header a {
        font-size: 13px;
        letter-spacing: 1px;
    }

    .content {
        padding: 10px;
        gap: 10px;
    }

    .toolbar {
        padding: 8px 10px;
        gap: 6px;
    }

    /* Stack view buttons on their own row */
    .toolbar-label {
        width: 100%;
    }

    .divider {
        display: none;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-value {
        font-size: 18px;
    }

    .chart-wrap {
        height: 220px;
    }

    .inactive-layout {
        grid-template-columns: 1fr;
        gap: 10px;
        min-height: unset;
    }

    .map-panel {
        padding: 8px;
    }

    /* Make the SVG map a good height on phone */
    .map-panel svg#ireland {
        height: 420px;
        width: 100%;
        display: block;
    }

    .county-sidebar {
        min-height: unset;
        max-height: unset;
        /* Let it grow naturally below the map on mobile */
    }

    .sidebar-header {
        padding: 10px 12px;
        /* Unstick on mobile so it doesn't eat screen space */
        position: static;
    }

    .cust-table {
        font-size: 11px;
    }

    .cust-table th,
    .cust-table td {
        padding: 6px 8px;
    }

    /* Hide less important columns on small screens */
    .cust-table th:nth-child(4),
    .cust-table td:nth-child(4) {
        display: none;
    }

    .days-badge {
        font-size: 9px;
        padding: 2px 4px;
    }

    .tab-btn {
        padding: 6px 10px;
        font-size: 10px;
    }

    .county-summary {
        padding: 10px 12px;
        gap: 8px;
    }

    .county-meta {
        display: none;
        /* Hide pill counts on very small screens to save space */
    }
}
