:root {
    --bg: #f5f6f4;
    --surface: #ffffff;
    --text: #202420;
    --muted: #737a73;
    --line: #e1e5e0;
    --accent: #456b4f;
    --accent-soft: #e8f0ea;
    --danger-soft: #f5e9e7;
    --danger: #8a4b44;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

.container {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    margin-bottom: 38px;
}

.topbar-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.brand-main {
    font-size: 22px;
    font-weight: 750;
}

.brand-sub {
    color: var(--muted);
    font-size: 14px;
}

.readonly {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}

h1 {
    margin: 3px 0 5px;
    font-size: 32px;
    letter-spacing: -.025em;
}

h2 {
    margin: 0 0 22px;
    font-size: 19px;
}

h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin: 20px 0 10px;
}

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

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.page-heading,
.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
}

.page-heading {
    margin-bottom: 24px;
}

.section-heading span {
    color: var(--muted);
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.search-box input {
    width: min(620px, 100%);
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 15px;
}

button,
.button-secondary {
    border: 0;
    border-radius: 8px;
    padding: 11px 17px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

button {
    background: var(--accent);
    color: white;
}

.button-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 24px;
}

.table-card {
    padding: 0;
    overflow: hidden;
}

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

th {
    text-align: left;
    padding: 13px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: #fafbfa;
}

td {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    vertical-align: top;
}

.person-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 650;
}

.person-link:hover,
.back a:hover {
    color: var(--accent);
}

.badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
}

.badge-on {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-off {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-neutral {
    background: #eef0ee;
    color: #606660;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 25px;
    align-items: center;
    margin: 25px 0 50px;
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
}

.back {
    margin-bottom: 20px;
}

.back a {
    color: var(--muted);
    text-decoration: none;
}

.profile-header {
    margin-bottom: 28px;
}

.eyebrow {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    font-size: 12px;
}

.profile-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
}

.section {
    margin-top: 20px;
}

.data-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 30px;
    margin: 0;
}

.data-list div {
    min-width: 0;
}

.data-list .wide {
    grid-column: 1 / -1;
}

dt {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

dd {
    margin: 0;
}

.contact-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 9px 0;
}

.subsection {
    margin-top: 28px;
}

.apiary {
    border-top: 1px solid var(--line);
    padding: 18px 0;
}

.apiary:first-of-type {
    border-top: 0;
}

.apiary-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.apiary-meta {
    display: flex;
    gap: 15px;
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

.census-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 13px;
}

.census-item {
    background: #f3f5f2;
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 12px;
}

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

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

    .data-list {
        grid-template-columns: 1fr;
    }

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

    .brand-sub {
        display: none;
    }
}


/* -------------------------------------------------
   Vista operativa de explotaciones
-------------------------------------------------- */

.filters-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.filter-search {
    margin-bottom: 18px;
}

.filter-search label,
.filter-field > label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    margin-bottom: 6px;
}

.filter-search input {
    width: min(650px, 100%);
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    font-size: 14px;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 14px;
}

.filter-field {
    min-width: 190px;
}

.filter-field select {
    width: 100%;
    min-height: 40px;
    padding: 8px 34px 8px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    font-size: 14px;
}

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

.multi-select {
    position: relative;
    min-width: 230px;
}

.multi-select summary {
    list-style: none;
    cursor: pointer;
    min-height: 40px;
    padding: 9px 34px 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    font-size: 14px;
    position: relative;
}

.multi-select summary::-webkit-details-marker {
    display: none;
}

.multi-select summary::after {
    content: "▾";
    position: absolute;
    right: 12px;
    color: var(--muted);
}

.multi-select[open] summary {
    border-color: var(--accent);
}

.multi-panel {
    position: absolute;
    left: 0;
    top: calc(100% + 5px);
    width: 270px;
    z-index: 30;
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 14px 35px rgba(0, 0, 0, .13);
    padding: 10px;
}

.multi-actions {
    display: flex;
    gap: 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.mini-button {
    background: #f1f3f1;
    color: var(--text);
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
}

.tipo-lista {
    padding-top: 7px;
}

.tipo-opcion {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 6px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.tipo-opcion:hover {
    background: #f5f6f4;
}

.tipo-opcion input {
    width: 16px;
    height: 16px;
}

.sheet-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 50px;
}

.sheet-toolbar {
    min-height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.sheet-wrap {
    overflow: auto;
    max-height: calc(100vh - 305px);
    min-height: 360px;
}

.sheet-table {
    white-space: nowrap;
    min-width: 1380px;
}

.sheet-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f4f6f3;
    box-shadow: 0 1px 0 var(--line);
}

.sheet-table td {
    padding-top: 10px;
    padding-bottom: 10px;
}

.sheet-table tbody tr:hover td {
    background: #f7f9f6;
}

.sheet-table .rega-cell {
    position: sticky;
    left: 0;
    z-index: 4;
    background: white;
    font-weight: 650;
}

.sheet-table thead th:first-child {
    left: 0;
    z-index: 15;
}

.sheet-table tbody tr:hover .rega-cell {
    background: #f7f9f6;
}

.titular-cell {
    min-width: 265px;
}

.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 800px) {
    .filter-field,
    .multi-select {
        width: 100%;
    }

    .filter-buttons {
        width: 100%;
    }

    .filter-buttons button,
    .filter-buttons a {
        flex: 1;
        text-align: center;
    }
}

.sheet-table th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 28px;
    position: sticky;
}

.sheet-table th.sortable::after {
    content: "↕";
    position: absolute;
    right: 9px;
    opacity: .28;
}

.sheet-table th.sortable.sort-asc::after {
    content: "↑";
    opacity: 1;
}

.sheet-table th.sortable.sort-desc::after {
    content: "↓";
    opacity: 1;
}

.sheet-table th.sortable:hover {
    background: #e9ede8;
}
/* -------------------------------------------------
   Menú principal
-------------------------------------------------- */

.home {
    max-width: 920px;
    margin: 70px auto;
}

.home-heading {
    margin-bottom: 32px;
}

.home-heading h1 {
    font-size: 36px;
    margin-bottom: 8px;
}

.home-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.home-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 18px;

    min-height: 180px;
    padding: 28px;

    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;

    color: var(--text);
    text-decoration: none;

    transition:
        transform .15s ease,
        border-color .15s ease,
        box-shadow .15s ease;
}

.home-card:hover {
    transform: translateY(-2px);
    border-color: #c8d3c9;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .07);
}

.home-card h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.home-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.home-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 48px;
    height: 48px;
    flex: 0 0 48px;

    border-radius: 10px;
    background: var(--accent-soft);

    font-size: 23px;
}

.home-arrow {
    position: absolute;
    right: 22px;
    bottom: 20px;

    color: var(--accent);
    font-size: 22px;
}

@media (max-width: 700px) {
    .home {
        margin-top: 30px;
    }

    .home-menu {
        grid-template-columns: 1fr;
    }
}

.rega-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.rega-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.rega-title {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: -.02em;
}

.holder-name {
    margin: 0 0 22px;
    color: var(--text);
    font-size: 21px;
    text-transform: none;
    letter-spacing: normal;
}

.card-actions {
    margin-top: 25px;
}
