:root {
    --purple: #6f2c91;
    --purple-dark: #52206d;
    --purple-light: #f3eaf7;
    --yellow: #f7c934;
    --bg: #f6f5f8;
    --white: #ffffff;
    --text: #29252d;
    --muted: #7c7482;
    --border: #e6e1e9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

header {
    height: 68px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

header strong {
    color: var(--purple);
    font-size: 25px;
    margin-right: 18px;
}

header span {
    color: var(--muted);
}

header a {
    color: var(--purple);
    text-decoration: none;
    margin-left: 20px;
}

main {
    max-width: 1400px;
    margin: auto;
    padding: 36px;
}

h1 {
    font-size: 30px;
    margin-bottom: 6px;
}

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

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 22px;
    margin-top: 30px;
}

.project-card {
    background: white;
    border-radius: 16px;
    padding: 28px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    transition: .15s;
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0,0,0,.08);
}

.project-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--purple);
    color: white;
    font-weight: bold;
}

.open {
    color: var(--purple);
    margin-top: 20px;
    font-weight: bold;
}

.panel {
    margin-top: 28px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}

.kpis {
    display: flex;
    gap: 18px;
    margin-top: 24px;
}

.kpi {
    background: white;
    border-radius: 14px;
    padding: 20px 26px;
    border-top: 4px solid var(--yellow);
    min-width: 180px;
}

.kpi span {
    color: var(--muted);
    display: block;
}

.kpi strong {
    font-size: 32px;
    color: var(--purple);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 13px;
    color: var(--muted);
    border-bottom: 2px solid var(--purple-light);
}

td {
    padding: 13px;
    border-bottom: 1px solid var(--border);
}

.empty {
    text-align: center;
    color: var(--muted);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, var(--purple), var(--purple-dark));
}

.login-card {
    width: 390px;
    max-width: calc(100vw - 30px);
    background: white;
    padding: 38px;
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0,0,0,.20);
}

.brand {
    color: var(--purple);
    font-size: 34px;
    font-weight: bold;
}

.subtitle {
    margin-bottom: 28px;
    color: var(--muted);
}

label {
    display: block;
    margin-top: 14px;
    margin-bottom: 6px;
}

input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

button {
    width: 100%;
    margin-top: 24px;
    padding: 13px;
    background: var(--purple);
    color: white;
    border: 0;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

button:hover {
    background: var(--purple-dark);
}

.error {
    background: #fff0f0;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 8px;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.gallery img {
    width: 100%;
    border-radius: 12px;
}

.notice {
    background: var(--purple-light);
    color: var(--purple-dark);
    padding: 12px 16px;
    border-radius: 10px;
    margin-top: 20px;
}

.user-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 18px;
    align-items: end;
}

.user-form button {
    margin-top: 0;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form input {
    min-width: 150px;
}

.inline-form button,
.secondary-button {
    width: auto;
    margin: 0;
    white-space: nowrap;
}

.secondary-button {
    background: #ece8ef;
    color: var(--purple-dark);
}

.status-active {
    color: #21863a;
    font-weight: bold;
}

.status-disabled {
    color: #a33;
    font-weight: bold;
}

@media (max-width: 900px) {
    .user-form {
        grid-template-columns: 1fr;
    }
}

.review-kpis {
    flex-wrap: wrap;
}

.filter-kpi {
    text-decoration: none;
    color: inherit;
}

.status-unreviewed {
    border-top-color: #aaa;
}

.status-ok {
    border-top-color: #35a853;
}

.status-problem {
    border-top-color: #d64545;
}

.review-filter {
    margin-bottom: 16px;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
}

.clickable-row {
    cursor: pointer;
    transition: background .12s;
}

.clickable-row:hover {
    background: var(--purple-light);
}

.review-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
}

.review-badge.large {
    font-size: 15px;
    padding: 9px 15px;
}

.badge-unreviewed {
    background: #eeeeee;
    color: #666;
}

.badge-ok {
    background: #e5f6e9;
    color: #247b39;
}

.badge-problem {
    background: #fde8e8;
    color: #a62929;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;
    margin-bottom: 25px;
}

.detail-header h1 {
    margin-top: 4px;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    gap: 22px;
}

.detail-grid .panel {
    margin-top: 0;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.info-grid div {
    padding: 15px;
    background: var(--bg);
    border-radius: 10px;
}

.info-grid span,
.text-block span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 5px;
}

.text-block {
    margin-top: 18px;
    padding: 16px;
    background: var(--bg);
    border-radius: 10px;
}

.text-block p {
    margin: 0;
    line-height: 1.5;
}

.review-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px;
    font: inherit;
}

.review-actions {
    display: grid;
    gap: 10px;
    margin-top: 15px;
}

.review-button {
    margin: 0;
}

.button-ok {
    background: #31924a;
}

.button-ok:hover {
    background: #247b39;
}

.button-problem {
    background: #c83b3b;
}

.button-problem:hover {
    background: #a62929;
}

.button-reset {
    background: #e9e6ec;
    color: #555;
}

.button-reset:hover {
    background: #dcd7e1;
}

.gps-coordinates {
    margin-bottom: 12px;
    color: var(--muted);
}

.map-frame {
    width: 100%;
    height: 360px;
    border: 0;
    border-radius: 12px;
}

.photo-comment {
    margin-bottom: 18px;
    padding: 14px;
    background: var(--purple-light);
    border-radius: 9px;
}

.gallery a {
    display: block;
}

.gallery img {
    display: block;
    height: 260px;
    object-fit: cover;
    cursor: zoom-in;
}

@media (max-width: 900px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

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

    .detail-header {
        flex-direction: column;
    }

    .gallery img {
        height: auto;
    }
}
/* CLICKABLE VISITS */

.clickable-row td {
    transition:
        background .14s ease,
        color .14s ease,
        box-shadow .14s ease;
}

.clickable-row td:first-child {
    border-left: 4px solid transparent;
}

.clickable-row:hover td {
    background: #f3eaf7;
}

.clickable-row:hover td:first-child {
    border-left-color: var(--purple);
}

.clickable-row:hover td {
    color: var(--purple-dark);
}

.clickable-row:hover .open-row {
    font-weight: 700;
    color: var(--purple);
}

.clickable-row:hover {
    cursor: pointer;
}

.open-row {
    color: var(--purple);
    white-space: nowrap;
    font-weight: 600;
}


/* REVIEW STATUS DOT */

.review-status-text {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    font-weight: 600;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-ok {
    background: #2e9b4b;
    box-shadow: 0 0 0 3px #e4f5e8;
}

.dot-problem {
    background: #d33d3d;
    box-shadow: 0 0 0 3px #fde5e5;
}

.dot-unreviewed {
    background: #999;
    box-shadow: 0 0 0 3px #eeeeee;
}


/* SELECTED REVIEW */

.review-button {
    position: relative;
    border: 3px solid transparent;
    opacity: .72;
    transition:
        transform .12s,
        opacity .12s,
        box-shadow .12s,
        border-color .12s;
}

.review-button:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.selected-review {
    opacity: 1;
    transform: scale(1.015);
    font-weight: 800;
}

.selected-ok {
    border-color: #176c30;
    box-shadow: 0 0 0 4px #dff3e5;
}

.selected-problem {
    border-color: #8f2020;
    box-shadow: 0 0 0 4px #f9dddd;
}

.selected-reset {
    border-color: #777;
    box-shadow: 0 0 0 4px #eeeeee;
}

.selected-mark {
    position: absolute;
    right: 12px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .6px;
    background: rgba(255,255,255,.92);
    color: #333;
    padding: 3px 7px;
    border-radius: 999px;
}


/* FIELD REP NOTES */

.visit-note,
.photo-comment {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.visit-note {
    background: #fff8df;
    border-left: 4px solid var(--yellow);
}

.photo-comment {
    background: var(--purple-light);
    border-left: 4px solid var(--purple);
}

.visit-note p,
.photo-comment p {
    margin: 6px 0 0;
    line-height: 1.5;
}

/* PROJECT FILTERS */

.filter-panel {
    margin-top: 24px;
}

.filters-form {
    display: grid;
    grid-template-columns:
        minmax(170px, 1fr)
        minmax(150px, .8fr)
        minmax(145px, .7fr)
        minmax(145px, .7fr)
        minmax(200px, 1.2fr)
        auto;
    gap: 14px;
    align-items: end;
}

.filters-form label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
}

.filters-form select,
.filters-form input {
    width: 100%;
    height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    font: inherit;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-buttons button {
    width: auto;
    height: 42px;
    margin: 0;
    padding: 0 18px;
}

.clear-filter {
    display: inline-flex;
    align-items: center;
    height: 42px;
    padding: 0 14px;
    border-radius: 8px;
    background: #ece8ef;
    color: var(--purple-dark);
    text-decoration: none;
    white-space: nowrap;
}

.table-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table-title-row h2 {
    margin: 0 0 15px;
}

.visits-table {
    min-width: 1100px;
}

.visits-table th {
    white-space: nowrap;
}

.date-cell {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.store-cell {
    font-weight: 700;
}

.clickable-row td {
    position: relative;
}

.clickable-row:hover td {
    background: #eee2f5 !important;
}

.clickable-row:hover {
    outline: 2px solid rgba(111,44,145,.15);
    outline-offset: -2px;
}

.open-row {
    opacity: .55;
    transition: opacity .15s, transform .15s;
}

.clickable-row:hover .open-row {
    opacity: 1;
    transform: translateX(3px);
}

.active-kpi {
    box-shadow: 0 0 0 3px var(--purple);
    transform: translateY(-2px);
}

@media (max-width: 1150px) {
    .filters-form {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 650px) {
    .filters-form {
        grid-template-columns: 1fr;
    }
}
