:root {
    --bg: #0f1117;
    --panel: #151821;
    --panel-muted: #1c2030;
    --text: #e8eaf1;
    --muted: #8b92a7;
    --accent: #7dd3fc;
    --accent-2: #a78bfa;
    --border: #262b3d;
    --success: #22c55e;
    --warning: #facc15;
    --danger: #f87171;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: radial-gradient(circle at 20% 20%, rgba(167, 139, 250, 0.12), transparent 28%),
        radial-gradient(circle at 80% 0%, rgba(125, 211, 252, 0.12), transparent 26%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.app {
    max-width: 1360px;
    margin: 0 auto;
    padding: 30px 26px 40px;
    display: grid;
    gap: 18px;
}

.app-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.branding {
    display: flex;
    align-items: center;
    gap: 14px;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1 {
    margin: 4px 0 0;
    font-size: 28px;
    font-weight: 700;
}

.icon-btn {
    border: 1px solid var(--border);
    background: var(--panel-muted);
    color: var(--text);
    border-radius: 10px;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover {
    border-color: var(--accent);
    background: rgba(125, 211, 252, 0.08);
}

.icon-btn.spinning svg {
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tabs {
    display: inline-flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
}

.tab {
    background: transparent;
    color: var(--text);
    border: 1px solid transparent;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0c10;
    border-color: transparent;
    box-shadow: 0 12px 34px rgba(0,0,0,0.32);
}

.controls {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 18px;
    gap: 12px;
}

.date-range label {
    color: var(--muted);
    font-size: 14px;
    margin-right: 10px;
}

input[type="date"],
input[type="search"] {
    background: var(--panel-muted);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 14px;
}

.control-actions {
    display: flex;
    gap: 8px;
}

button {
    font-family: inherit;
}

button.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
}

.cards {
    display: grid;
    grid-template-columns: 220px 220px minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
}

.cards .card:nth-child(1),
.cards .card:nth-child(2) {
    min-width: 200px;
    max-width: 260px;
}

.card {
    background: linear-gradient(150deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card.distribution {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 18px;
}

.card-label {
    color: var(--muted);
    margin: 0 0 8px;
}

.distribution-bars {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    background: var(--panel-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
}

.distribution-bars .bar {
    background: #0f172a;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}

.bar .label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
}

.bar .value {
    font-size: 18px;
    font-weight: 700;
    margin-top: 4px;
}

.distribution-bars .bar.active {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(125, 211, 252, 0.15);
}

.charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    align-items: stretch;
}

@media (max-width: 1100px) {
    .app { padding: 22px 18px 30px; }
    .cards {
        grid-template-columns: 200px 200px minmax(0, 1fr);
    }
}

.chart-card {
    padding: 18px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 340px;
}

.chart-body {
    display: flex;
    gap: 16px;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.chart-body--split {
    align-items: center;
    justify-content: center;
}

.chart-body--split .chart-legend { align-self: stretch; }

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 140px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex-shrink: 0;
}

.legend-label {
    color: var(--muted);
    flex: 1;
    text-transform: capitalize;
    font-size: 13px;
}

.legend-value {
    font-weight: 700;
}

.chart-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chart-card canvas:not(#distributionChart) {
    width: 100%;
    height: 260px !important;
    min-height: 220px;
}

#distributionChart {
    width: min(320px, 100%);
    height: auto !important;
    aspect-ratio: 1 / 1;
    max-height: 320px;
    min-height: 240px;
    align-self: center;
    flex: 0 1 auto;
}

.table-section {
    padding: 16px;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-actions .page-size {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

.table-actions select {
    background: var(--surface-100);
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
}

.table-actions .small {
    padding: 6px 10px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}



.muted { color: var(--muted); }

#reviewsTable {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

#reviewsTable th,
#reviewsTable td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    vertical-align: top;
}

#reviewsTable th {
    color: var(--muted);
    font-weight: 600;
    position: relative;
    background: var(--panel);
}

#reviewsTable th:last-child,
#reviewsTable td:last-child {
    border-right: none;
}

#reviewsTable th .col-resizer {
    position: absolute;
    top: 0;
    right: -6px;
    width: 12px;
    height: 100%;
    cursor: col-resize;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#reviewsTable th .col-resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 5px;
    width: 1px;
    background: var(--border);
}

#reviewsTable th:hover .col-resizer {
    opacity: 0.6;
}

#reviewsTable th:hover .col-resizer::after,
body.resizing #reviewsTable th .col-resizer::after {
    background: var(--accent);
}

body.resizing {
    cursor: col-resize;
    user-select: none;
}

#reviewsTable th[data-col="location"],
#reviewsTable td[data-col="location"] {
    width: 12%;
}

#reviewsTable th[data-col="reviewer"],
#reviewsTable td[data-col="reviewer"] {
    width: 14%;
}

#reviewsTable th[data-col="date"],
#reviewsTable td[data-col="date"] {
    width: 14%;
}

#reviewsTable th[data-col="rating"],
#reviewsTable td[data-col="rating"] {
    width: 10%;
}

#reviewsTable th[data-col="original"],
#reviewsTable td[data-col="original"],
#reviewsTable th[data-col="response"],
#reviewsTable td[data-col="response"] {
    width: 25%;
}

#reviewsTable tr:hover td {
    background: var(--panel-muted);
}

.text-wrap {
    color: #c7d2fe;
    word-break: break-word;
}

.truncate {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
}

.expandable {
    white-space: pre-wrap;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.pagination button {
    background: var(--panel-muted);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.pagination button.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #0b0c10;
    border-color: transparent;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 10px;
    display: none;
}

@media (max-width: 720px) {
    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cards {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .distribution-bars {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .controls {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .charts {
        grid-template-columns: 1fr;
    }

    .chart-card {
        min-height: 320px;
    }

    .chart-card canvas:not(#distributionChart) {
        height: 240px !important;
        min-height: 200px;
    }

    #distributionChart {
        max-height: 280px;
        min-height: 200px;
    }

    .chart-body {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-legend {
        min-width: unset;
        width: 100%;
    }

    #reviewsTable {
        table-layout: auto;
    }

    #reviewsTable th,
    #reviewsTable td {
        padding: 8px 6px;
        min-width: 0;
    }
}

@media (max-width: 640px) {
    .app { padding: 18px 14px 28px; }
    .cards { grid-template-columns: 1fr; }
    .cards .card { max-width: none; }
    .distribution-bars { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .controls { gap: 10px; }
    .charts { grid-template-columns: 1fr; gap: 14px; }
    .chart-card { min-height: 280px; padding: 16px; }
    .chart-card canvas:not(#distributionChart) { height: 220px !important; }
    #distributionChart { max-height: 240px; min-height: 200px; width: min(260px, 100%); }
    .chart-body { gap: 12px; }
    .table-wrapper { overflow-x: hidden; }
    #reviewsTable { width: 100%; max-width: 100%; }
}
