:root {
    --color-bg: #f4f3f1;
    --color-surface: #ffffff;
    --color-border: #dde5de;
    --color-text: #202521;
    --color-text-muted: #667066;
    --color-primary: #3f9142;
    --color-primary-dark: #2f6f33;
    --color-danger: #c0392b;
    --color-success: #2f7d46;
    --color-warning: #b8860b;
    --color-warning-bg: #fdf1d8;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

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

header {
    background: var(--color-primary);
    color: #fff;
    padding: 1.5rem 2rem;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

header p {
    margin: 0.25rem 0 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

section h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

/* ---------- Tabs ---------- */

nav.tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    font: inherit;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
}

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

/* ---------- Formularios ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

input, select, textarea {
    font: inherit;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.toggle-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.toggle-row input {
    width: auto;
}

/* ---------- Botones ---------- */

.btn {
    font: inherit;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

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

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

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

.btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    margin-right: 0.35rem;
}

.btn-edit {
    background: #e3ebe4;
    color: var(--color-text);
}

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

/* ---------- Feedback ---------- */

.feedback {
    font-size: 0.9rem;
}

.feedback-success {
    color: var(--color-success);
}

.feedback-error {
    color: var(--color-danger);
}

/* ---------- Tabla ---------- */

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

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

th, td {
    text-align: left;
    padding: 0.65rem 0.6rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr.row-low-stock {
    background: var(--color-warning-bg);
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-warning {
    background: var(--color-warning);
    color: #fff;
}

[id$="-empty-state"] {
    padding: 1rem 0;
    color: var(--color-text-muted);
    text-align: center;
}

/* ---------- Líneas de producto en la venta ---------- */

.sale-item-line {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    align-items: center;
}

/* ---------- Reportes ---------- */

.report-block {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.report-block + .report-block {
    margin-top: 1rem;
}

.report-output {
    font-size: 0.95rem;
    color: var(--color-text);
}

/* ---------- Modal ---------- */

dialog {
    border: none;
    border-radius: var(--radius);
    padding: 1.5rem;
    width: min(560px, 90vw);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

dialog h2 {
    margin-top: 0;
}

dialog ul {
    padding-left: 1.2rem;
}

footer {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    padding-bottom: 2rem;
}
