:root {
    --bg: #f0f4f8;
    --surface: #fff;
    --border: #c5d0dc;
    --text: #1a2b3c;
    --muted: #5a6b7d;
    --primary: #1e5a8e;
    --primary-hover: #164770;
    --danger: #b42318;
    --success: #067647;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.site-header {
    background: var(--primary);
    color: #fff;
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.site-header nav a {
    color: #fff;
    margin-left: 1rem;
    text-decoration: none;
}

.site-header nav a:hover {
    text-decoration: underline;
}

.btn-nav {
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.panel h2 {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    color: var(--primary);
    border-bottom: 2px solid var(--bg);
    padding-bottom: 0.5rem;
}

.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.panel-head h2 {
    margin: 0;
    border: none;
    padding: 0;
}

.panel-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.form-row-inline {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr minmax(5.5rem, 7rem);
    gap: 1rem;
    align-items: end;
}

.form-row-cargo {
    grid-template-columns: 1fr minmax(9rem, 12rem);
}

.form-row-inline label {
    margin: 0;
}

.form-row-inline-narrow input {
    text-align: center;
}

@media (max-width: 500px) {
    .form-row-inline {
        grid-template-columns: 1fr;
    }
}

label span {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
}

textarea {
    resize: vertical;
}

.btn {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #e8eef4;
    color: var(--text);
}

.btn-danger {
    background: #b42318;
    color: #fff;
}

.btn-danger:hover {
    background: #912018;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.3;
}

a.btn:not(.btn-icon) {
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-secondary:hover {
    background: #d5e0eb;
}

.actions-cell {
    white-space: nowrap;
    width: 1%;
    vertical-align: middle;
}

.actions-group {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    line-height: 0;
}

a.btn.btn-icon,
button.btn.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    padding: 0;
    min-width: 2.15rem;
    border: 1px solid transparent;
    flex-shrink: 0;
    line-height: 0;
    vertical-align: middle;
    box-sizing: border-box;
}

.btn-icon svg,
.btn-icon .icon {
    display: block;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex-shrink: 0;
}

.btn-icon.btn-secondary {
    background: #e8eef4;
    border-color: #c5d0dc;
    color: var(--primary);
}

.btn-icon.btn-secondary:hover {
    background: #d5e0eb;
}

.btn-icon.btn-danger {
    background: #fee4e2;
    border-color: #fecdca;
    color: #b42318;
}

.btn-icon.btn-danger:hover {
    background: #fecdca;
    color: #912018;
}

.inline-delete {
    display: inline-flex;
    margin: 0;
    vertical-align: middle;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 2rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: #e8f0f8;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.repeatable-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.repeatable-fieldset {
    position: relative;
    border: 1px solid #d0dce8;
    border-radius: var(--radius);
    padding: 1rem 1rem 0.5rem;
    margin: 0;
    background: #f6f9fc;
}

.repeatable-item:nth-child(odd) .repeatable-fieldset {
    background: #eef3f9;
    border-color: #c5d4e4;
}

.repeatable-item:nth-child(even) .repeatable-fieldset {
    background: #f8fafb;
    border-color: #d8e2ea;
}

.repeatable-fieldset legend {
    font-weight: 600;
    color: var(--primary);
    padding: 0 0.5rem;
    background: inherit;
}

.repeatable-item:nth-child(odd) .repeatable-fieldset legend {
    background: #eef3f9;
}

.repeatable-item:nth-child(even) .repeatable-fieldset legend {
    background: #f8fafb;
}

.btn-remove-row {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    border: none;
    background: #fee4e2;
    color: var(--danger);
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.btn-remove-row:hover {
    background: #fecdca;
}

.btn-remove-row.hidden {
    display: none;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.65rem;
    text-align: left;
}

.data-table th {
    background: #e8eef4;
    font-weight: 600;
}

.detail-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0.5rem 1rem;
}

.detail-grid dt {
    font-weight: 600;
    color: var(--muted);
}

.detail-grid dd {
    margin: 0;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    color: var(--success);
}

.alert-error {
    background: #fef3f2;
    border: 1px solid #fecdca;
    color: var(--danger);
}

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

.site-footer {
    padding: 1.5rem 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

.site-header--admin {
    background: #2c3e50;
}

.site-header--public .logo {
    font-size: 1rem;
}

.nav-user {
    color: rgba(255, 255, 255, 0.85);
    margin-left: 1rem;
    font-size: 0.9rem;
}

.badge-count {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--bg);
}

.login-container {
    max-width: 420px;
    margin: 2rem auto;
}

.login-panel h2 {
    margin: 0 0 0.25rem;
    color: var(--primary);
}

.login-subtitle {
    margin: 0 0 1.25rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.login-form label {
    display: block;
    margin-bottom: 1rem;
}

.login-form label span {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
    line-height: 1.4;
    min-height: 2.75rem;
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

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

.test-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #fff8e6;
    border: 1px dashed #d4a017;
    border-radius: var(--radius);
}

.test-tools-hint {
    font-size: 0.85rem;
    color: var(--muted);
}

.btn-test {
    background: #b45309;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.btn-test:hover {
    background: #92400e;
}

.success-lead {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--success);
    margin: 0 0 0.5rem;
}

.comprobante-actions {
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.comprobante-actions p {
    margin: 0;
    flex: 1 1 100%;
}

.comprobante {
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 1.75rem 2rem;
    max-width: 640px;
    margin: 0 auto 2rem;
    box-shadow: var(--shadow);
}

.comprobante-header {
    text-align: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}

.comprobante-header h2 {
    margin: 0;
    color: var(--primary);
    font-size: 1.35rem;
}

.comprobante-subtitle {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.comprobante-datos {
    margin: 0;
}

.comprobante-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 0.5rem 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid #e8eef4;
}

.comprobante-row:last-of-type {
    border-bottom: none;
}

.comprobante-row dt {
    margin: 0;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.9rem;
}

.comprobante-row dd {
    margin: 0;
    font-size: 1rem;
}

.comprobante-row--highlight dd {
    font-size: 1.15rem;
    color: var(--primary);
}

.comprobante-nota {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.5;
}

.comprobante-footer-id {
    margin: 1rem 0 0;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: right;
}

@media print {
    body {
        background: #fff;
    }

    .site-header,
    .site-footer,
    .no-print {
        display: none !important;
    }

    main.container {
        max-width: 100%;
        padding: 0;
    }

    .comprobante {
        border: 2px solid #000;
        box-shadow: none;
        max-width: 100%;
        margin: 0;
    }
}

@media (max-width: 600px) {
    .comprobante-row {
        grid-template-columns: 1fr;
    }
}

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

    .detail-grid dt {
        margin-top: 0.5rem;
    }
}
