:root {
    --bg: #f3f6f4;
    --surface: #fff;
    --surface-soft: #f7faf8;
    --text: #1f2a24;
    --muted: #66736b;
    --line: #dce5df;
    --brand: #278a52;
    --brand-dark: #1f7043;
    --danger: #c33c3c;
    --danger-dark: #a92f2f;
    --shadow: 0 12px 34px rgba(31, 55, 41, .10);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
    width: 100%; min-height: 100vh; margin: 0 !important; padding: 28px 20px 48px !important;
    background: linear-gradient(180deg, #edf5ef 0, var(--bg) 260px) !important;
    color: var(--text); display: flex; flex-direction: column; align-items: center;
}
h1 { margin: 24px 0 20px !important; font-size: clamp(1.75rem, 4vw, 2.35rem); line-height: 1.1; color: var(--text) !important; text-align: center; }
h2 { margin: 26px 0 14px; font-size: clamp(1.25rem, 3vw, 1.55rem); color: var(--text) !important; }
p { line-height: 1.55; }
a { color: var(--brand-dark); font-weight: 650; text-underline-offset: 3px; }

.topbar {
    width: min(1180px, 100%); min-height: 62px; padding: 10px 14px; border: 1px solid var(--line);
    border-radius: 14px; background: rgba(255,255,255,.94); box-shadow: 0 6px 22px rgba(31,55,41,.07);
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.topbar .brand { text-decoration: none; color: var(--text); font-size: 1.25rem; font-weight: 800; }
.topbar nav { margin: 0; display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.topbar nav a { padding: 9px 11px; border-radius: 8px; text-decoration: none; }
.topbar nav a:hover { background: #eaf4ed; }
.topbar nav a.active { color: #fff; background: var(--brand); }
.topbar nav a.account-link { margin-left: 8px; border-left: 1px solid var(--line); border-radius: 0 8px 8px 0; }
.topbar form { display: inline; margin: 0 !important; }

.container, body > main {
    width: min(1180px, 100%) !important; max-width: 1180px !important; margin: 0 auto !important;
    padding: clamp(18px, 3vw, 30px) !important; border: 1px solid var(--line); border-radius: 16px !important;
    background: var(--surface) !important; box-shadow: var(--shadow) !important;
}
body > main { align-self: center; }

form { max-width: 100%; }
label { display: block; margin: 0 0 6px; color: #34423a; font-weight: 700; }
input, select, textarea {
    width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px !important; margin: 4px 0 12px !important;
    border: 1px solid #cbd6cf !important; border-radius: 9px !important; background: #fff; color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(39,138,82,.16); border-color: var(--brand) !important; }
button, .button {
    min-height: 42px; width: auto; margin: 4px 0 !important; padding: 9px 15px !important;
    border: 0 !important; border-radius: 9px !important; background: var(--brand) !important; color: #fff !important;
    font: inherit; font-weight: 750; cursor: pointer; box-shadow: none !important; transition: background .15s, transform .15s;
}
.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.button-secondary { color: var(--brand-dark) !important; background: #e8f3eb !important; }
.button-secondary:hover { color: #fff !important; background: var(--brand-dark) !important; }
.button-danger { background: var(--danger) !important; }
.button-danger:hover { background: var(--danger-dark) !important; }
.button-small { height: 38px; min-height: 38px; padding: 7px 11px !important; font-size: .9rem; }
button:hover { background: var(--brand-dark) !important; transform: translateY(-1px); }
button.delete, button[onclick*="eliminar"], button[onclick*="Eliminar"] { background: var(--danger) !important; }
button.delete:hover, button[onclick*="eliminar"]:hover, button[onclick*="Eliminar"]:hover { background: var(--danger-dark) !important; }

.form-section { width: 100%; display: block !important; }
.form-section > div, .form-section > form { width: 100% !important; }
.inline-fields { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px !important; align-items: end !important; }
.inline-fields > div, .inline-fields .field-group { width: 100% !important; min-width: 0 !important; align-items: stretch !important; }
.inline-fields .field-group > div { display: grid !important; grid-template-columns: 1fr 1fr; gap: 7px !important; }
.precio-input { width: 100% !important; }
.price-toolbar { grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(150px, .8fr) minmax(180px, 1fr) !important; }
.action-field { align-self: end; }
.action-field button { width: 100%; margin-bottom: 12px !important; }
.form-submit { width: 100%; }
.panel-section { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.panel-section h2 { margin-top: 0; }
.entity-create-form { display: grid !important; grid-template-columns: minmax(220px, 1fr) auto; gap: 12px; align-items: end; }
.entity-create-form label { grid-column: 1 / -1; margin: 0; }
.entity-create-form input { margin-bottom: 0 !important; }
.entity-create-form button { min-width: 190px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.form-actions > * { flex: 1; margin: 0 !important; }
#personas-fields { margin: 14px 0; padding: 14px; border-radius: 10px; background: var(--surface-soft); }
#informes-form { width: 100%; display: grid !important; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 14px; align-items: end !important; }
#informes-form .report-field { min-width: 0; }
#informes-form .report-actions { grid-column: 1 / -1; display: flex; gap: 9px; flex-wrap: wrap; }
#informes-form .report-actions button { flex: 1 1 145px; }

table { width: 100% !important; border-collapse: separate !important; border-spacing: 0; font-size: .94rem; }
th { background: #edf4ef !important; color: #34423a; text-align: left; }
th, td { padding: 12px !important; border: 0 !important; border-bottom: 1px solid var(--line) !important; vertical-align: middle; }
tbody tr:hover { background: #f8fbf9; }
td.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
td.actions form { display: inline-flex !important; margin: 0 !important; }
td.actions button { min-height: 38px; }
.small-text, #informe-result { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.message, .error, .success { padding: 12px 14px !important; border-radius: 9px !important; }
.error { color: #8e2727 !important; background: #fff0f0 !important; border: 1px solid #f2caca; }
.success { color: #176338 !important; background: #ecf9f0 !important; border: 1px solid #c9e9d3; }
.requirements, .hint { color: var(--muted) !important; }
.password-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.password-field input { margin-bottom: 4px !important; }
.password-field button { min-width: 82px; margin: 4px 0 !important; background: #e8f3eb !important; color: var(--brand-dark) !important; }
.password-field button:hover { color: #fff !important; background: var(--brand-dark) !important; }
.password-requirements { margin: 14px 0 0; padding: 14px 16px; list-style: none; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.password-requirements li { margin: 7px 0; color: #7d3939; }
.password-requirements li::before { content: "○"; display: inline-block; width: 1.4em; font-weight: 800; }
.password-requirements li.valid { color: var(--brand-dark); }
.password-requirements li.valid::before { content: "✓"; }

main nav { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px !important; }
section.new { padding: 18px !important; border: 1px solid var(--line); background: var(--surface-soft) !important; }
form.user { grid-template-columns: minmax(130px,1.2fr) minmax(190px,1.5fr) minmax(130px,1fr) auto auto !important; gap: 10px !important; }

body:has(> main) { justify-content: center; }
body:has(.topbar) { justify-content: flex-start; }
body > main { max-width: 520px !important; }
body > main:has(form.user) { max-width: 980px !important; }

@media (max-width: 760px) {
    body { padding: 12px 10px 32px !important; }
    .topbar { border-radius: 11px; padding: 10px; }
    .topbar .brand { width: 100%; text-align: center; }
    .topbar nav { width: 100%; justify-content: center; }
    .topbar nav a, .topbar nav form { flex: 1 1 auto; text-align: center; }
    .topbar nav button { width: 100%; }
    .container, body > main { padding: 16px !important; border-radius: 12px !important; }
    .inline-fields { grid-template-columns: 1fr !important; }
    .price-toolbar, .entity-create-form { grid-template-columns: 1fr !important; }
    .action-field button { margin-bottom: 4px !important; }
    .entity-create-form button { width: 100%; }
    #informes-form { grid-template-columns: 1fr !important; }
    #informes-form .report-actions { display: grid; grid-template-columns: 1fr; }
    form.user { display: grid !important; grid-template-columns: 1fr !important; padding: 16px 0 !important; }
    form.user button { width: 100%; }
    table { min-width: 600px; }
    .container > table, section > table { min-width: 0; table-layout: auto; }
    .small-text table, #informe-result table { min-width: 760px; }
    .container > table th, .container > table td { padding: 10px 8px !important; }
    td.actions { min-width: 185px; }
    h1 { margin-top: 18px !important; }
}

@media (max-width: 420px) {
    .topbar nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar nav a { width: 100%; }
    .topbar nav a.account-link { margin-left: 0; border-left: 0; border-radius: 8px; }
    .topbar nav form { grid-column: 1 / -1; width: 100%; }
    button { width: 100%; }
    td.actions button { width: auto; }
}
