:root {
    --bg: #f6f6f2;
    --surface: #ffffff;
    --surface-soft: #efefe9;
    --ink: #191a17;
    --muted: #696b63;
    --line: #dedfd8;
    --accent: #254c3c;
    --accent-soft: #dfeae4;
    --current: #2f7053;
    --review: #9a6719;
    --old: #8a4f45;
    --radius: 14px;
    --shadow: 0 1px 0 rgba(25, 26, 23, .04), 0 10px 30px rgba(25, 26, 23, .035);
    color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.shell {
    width: min(1160px, calc(100% - 40px));
    margin-inline: auto;
}

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.brand-mark {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 9px;
    color: #fff;
    background: var(--accent);
    font-family: Georgia, serif;
    font-size: 19px;
}

.top-actions { display: flex; align-items: center; gap: 20px; }
.text-link, .back-link { color: var(--muted); font-size: 14px; text-decoration: none; }
.text-link:hover, .back-link:hover { color: var(--ink); }

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 650;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--accent); }
.button-primary:hover { background: #1c3f31; }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.button-secondary:hover { border-color: #c3c5bd; }

.page-content { padding: 42px 0 64px; }
h1, h2, p { margin-top: 0; }
.profile-title h1, .form-title h1 {
    margin-bottom: 16px;
    max-width: 720px;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 500;
    letter-spacing: -.035em;
    line-height: 1.04;
}

.filter-panel { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(420px, 500px); gap: 10px; }
.search-field {
    display: flex;
    height: 48px;
    align-items: center;
    gap: 13px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--muted);
}
.search-field:focus-within { border-color: #a7afa9; box-shadow: 0 0 0 3px rgba(37, 76, 60, .08); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 16px; }
.search-field input::placeholder { color: #92958c; }
.search-field kbd { padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); color: var(--muted); font-size: 12px; }
.group-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.group-filters button {
    min-width: 0;
    min-height: 48px;
    padding: 8px 6px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--muted);
    background: var(--surface);
    font-size: 13px;
    font-weight: 650;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.group-filters button:hover { border-color: #bfc4bd; color: var(--ink); }
.group-filters button[aria-pressed="true"] { border-color: var(--accent); color: #fff; background: var(--accent); }

.result-heading { display: flex; justify-content: flex-end; margin: 13px 2px 12px; }
.result-heading span { color: var(--muted); font-size: 13px; }
.supplier-list { display: grid; gap: 10px; }
.supplier-card {
    overflow: hidden;
    scroll-margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color .15s ease, transform .15s ease;
}
.supplier-card:hover { border-color: #c5c9c2; transform: translateY(-1px); }
.card-main {
    display: grid;
    grid-template-columns: 48px 1fr 135px;
    gap: 16px;
    align-items: start;
    padding: 18px 22px;
    color: inherit;
    text-decoration: none;
}
.avatar {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    flex: none;
    border-radius: 12px;
    color: var(--accent);
    background: var(--accent-soft);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .03em;
}
.avatar.has-image { overflow: hidden; border: 1px solid var(--line); background: #fff; }
.avatar.has-image img { width: 100%; height: 100%; padding: 4px; object-fit: contain; }
.card-identity { min-width: 0; }
.card-title-line { display: flex; align-items: center; gap: 9px; }
.card-title-line strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #aaa; }
.status-activo { background: var(--current); }
.status-contactado { background: #537db5; }
.status-por_contactar { background: #a7a9a2; }
.status-pausado { background: var(--review); }
.card-contact { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.card-products {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 10px;
    color: #3d3f39;
    font-size: 14px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.card-date { display: flex; align-items: end; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12px; }
.freshness { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.freshness::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.freshness-current { color: var(--current); }
.freshness-review { color: var(--review); }
.freshness-old { color: var(--old); }
.quick-actions {
    display: flex;
    gap: 18px;
    align-items: center;
    min-height: 45px;
    padding: 10px 22px;
    border-top: 1px solid #ecece7;
    background: #fbfbf9;
}
.quick-actions a, .quick-actions button { color: var(--muted); font-size: 12px; font-weight: 650; text-decoration: none; }
.quick-actions button { padding: 0; border: 0; background: transparent; }
.quick-actions a:hover, .quick-actions button:hover { color: var(--accent); }
.quick-actions .manage-link { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--accent); }
.expand-chevron { display: inline-block; font-size: 16px; line-height: 1; transition: transform .15s ease; }
.manage-link[aria-expanded="true"] .expand-chevron { transform: rotate(180deg); }

.card-expanded { padding: 26px 22px 30px; border-top: 1px solid var(--line); background: var(--surface); }
.expanded-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 34px; }
.expanded-main, .expanded-side { min-width: 0; }
.expanded-section + .expanded-section { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.expanded-section h3, .expanded-side-section h3 { margin: 0 0 16px; font-size: 14px; }
.expanded-overview .info-list { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.expanded-alias { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.expanded-side { padding-left: 26px; border-left: 1px solid var(--line); }
.expanded-side-section + .expanded-side-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.expanded-side .stack-form { margin-top: 0; }
.expanded-side .button { width: 100%; }
.observations-section textarea { min-height: 140px; background: #fbfbf8; }
.edit-record-link { width: 100%; margin-top: 24px; }
.empty-state { padding: 56px 20px; border: 1px dashed #c9cbc3; border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty-state p { margin-bottom: 8px; }
.text-button { border: 0; color: var(--accent); background: transparent; font-weight: 700; }
.footer { display: flex; justify-content: space-between; padding: 28px 0 42px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.footer a { text-decoration: none; }

.flash { margin-bottom: 24px; padding: 12px 15px; border: 1px solid #bfd1c5; border-radius: 9px; color: var(--accent); background: #edf4ef; font-size: 13px; }

.detail-content { padding: 54px 0 76px; }
.profile-header { display: grid; grid-template-columns: 72px 1fr auto; gap: 20px; align-items: center; margin-bottom: 40px; }
.avatar-large { width: 70px; height: 70px; border-radius: 18px; font-size: 18px; }
.profile-title h1 { margin: 7px 0 5px; font-size: clamp(34px, 5vw, 52px); }
.profile-title p { margin: 0; color: var(--muted); font-size: 13px; }
.profile-meta-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.relationship-pill { padding: 4px 8px; border-radius: 999px; color: #555; background: var(--surface-soft); font-weight: 700; }
.relationship-activo { color: var(--current); background: #e3eee7; }
.relationship-contactado { color: #426b9f; background: #e5edf7; }
.profile-actions { display: flex; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.detail-main { display: grid; gap: 18px; }
.detail-side { display: grid; position: sticky; top: 18px; gap: 18px; }
.panel { padding: 27px 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel h2 { margin-bottom: 18px; font-size: 15px; }
.compact-panel { padding: 22px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; }
.section-heading h2 { margin-bottom: 4px; }
.section-heading p { margin-bottom: 19px; color: var(--muted); font-size: 13px; }
.product-description, .preserve-lines { max-width: 750px; margin-bottom: 0; color: #3e403a; font-size: 15px; white-space: pre-line; }
.profile-information .info-list { margin-top: 24px; padding-top: 20px; border-top: 1px solid #ecece7; }
.info-list { margin: 0; }
.info-list > div { display: grid; grid-template-columns: 135px 1fr; padding: 12px 0; border-top: 1px solid #ecece7; }
.info-list > div:first-child { border-top: 0; padding-top: 0; }
.info-list dt { color: var(--muted); font-size: 12px; }
.info-list dd { margin: 0; font-size: 14px; }
.info-list a { text-decoration-color: #c6cbc4; text-underline-offset: 3px; }
.external-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 17px; }
.external-links a { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 700; }
.source-note { display: flex; flex-direction: column; gap: 4px; margin-top: 22px; padding: 13px 15px; border-radius: 9px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }
.source-note strong { color: var(--ink); }
.freshness-block { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; padding: 15px; border-radius: 10px; background: var(--surface-soft); }
.freshness-block strong { font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.freshness-block small { color: var(--muted); }
.freshness-block-current { background: #e8f1eb; }
.freshness-block-review { background: #f5eee2; }
.freshness-block-old { background: #f3e9e7; }
.helper { margin-bottom: 19px; color: var(--muted); font-size: 12px; }
.side-fact { display: flex; justify-content: space-between; padding-top: 15px; border-top: 1px solid var(--line); font-size: 12px; }
.side-fact span { color: var(--muted); }
.side-fact strong { font-weight: 650; }
.timeline { margin: 8px 0 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: 11px; padding-bottom: 23px; }
.timeline li:last-child { padding-bottom: 5px; }
.timeline-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.timeline-meta strong { font-size: 13px; }
.timeline-meta time { color: var(--muted); font-size: 11px; }
.timeline p { margin: 5px 0 0; color: #4c4f48; font-size: 13px; }
.muted { color: var(--muted); }
.inline-form-disclosure { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.inline-form-disclosure summary { color: var(--accent); font-size: 13px; font-weight: 750; cursor: pointer; }

.stack-form { display: grid; gap: 13px; margin-top: 17px; }
.stack-form label, .editor-form label { display: grid; gap: 6px; color: #565951; font-size: 12px; font-weight: 650; }
input, select, textarea {
    width: 100%;
    min-height: 41px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: 0;
    color: var(--ink);
    background: var(--surface);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #9fa9a2; box-shadow: 0 0 0 3px rgba(37, 76, 60, .07); }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-line { display: flex !important; align-items: center; gap: 8px !important; color: var(--muted) !important; font-weight: 500 !important; }
.check-line input { width: 16px; min-height: 16px; margin: 0; }
.align-start { justify-self: start; }

.form-page { max-width: 980px; padding: 55px 0 80px; }
.form-title { margin-bottom: 30px; }
.form-title h1 { margin-bottom: 0; font-size: clamp(36px, 5vw, 54px); }
.editor-form { display: grid; gap: 14px; }
.form-section { display: grid; grid-template-columns: 230px 1fr; gap: 40px; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.form-section h2 { margin-bottom: 7px; font-size: 15px; }
.form-section > div:first-child p { margin: 0; color: var(--muted); font-size: 12px; }
.form-fields { display: grid; gap: 15px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 9px; }

.visually-hidden { position: absolute; overflow: hidden; width: 1px; height: 1px; padding: 0; border: 0; margin: -1px; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 820px) {
    .filter-panel { grid-template-columns: 1fr; }
    .expanded-grid { grid-template-columns: 1fr; gap: 28px; }
    .expanded-side { padding: 26px 0 0; border-top: 1px solid var(--line); border-left: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-side { position: static; grid-row: 1; grid-template-columns: 1fr 1fr; }
    .profile-header { grid-template-columns: 60px 1fr; }
    .avatar-large { width: 58px; height: 58px; }
    .profile-actions { grid-column: 1 / -1; }
    .form-section { grid-template-columns: 1fr; gap: 22px; }
}

@media (max-width: 620px) {
    .shell { width: min(100% - 24px, 1160px); }
    .topbar { min-height: 65px; }
    .desktop-only { display: none; }
    .page-content { padding-top: 28px; }
    .group-filters { gap: 6px; }
    .group-filters button { padding-inline: 3px; font-size: 12px; }
    .card-main { grid-template-columns: 42px 1fr; gap: 12px; padding: 17px 16px 14px; }
    .avatar { width: 40px; height: 40px; border-radius: 10px; }
    .card-date { grid-column: 2; align-items: start; flex-direction: row; flex-wrap: wrap; }
    .quick-actions { overflow-x: auto; gap: 15px; padding-inline: 16px; }
    .quick-actions a, .quick-actions button { white-space: nowrap; }
    .card-expanded { padding: 23px 17px 26px; }
    .footer { gap: 10px; flex-direction: column; }
    .detail-content { padding-top: 35px; }
    .profile-header { margin-bottom: 25px; }
    .profile-title h1 { font-size: 34px; }
    .profile-actions .button { flex: 1; }
    .detail-side { grid-template-columns: 1fr; }
    .panel { padding: 21px 19px; }
    .info-list > div { grid-template-columns: 105px 1fr; }
    .two-columns { grid-template-columns: 1fr; }
    .form-page { padding-top: 38px; }
    .form-section { padding: 21px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; }
}
