:root {
    --wine-900: #4A0F24;
    --wine-700: #7B1E3A;
    --wine-500: #A63D5A;
    --wine-400: #C85C7E;
    --rose-200: #E9B3C3;
    --bg-primary: #FFFFFF;
    --bg-soft: #F5F6F8;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-soft: #E5E7EB;
    --success: #22C55E;
    --danger: #EF4444;
    --warning: #F59E0B;
    --radius-md: 10px;
    --radius-sm: 8px;
    --shadow-soft: 0 8px 20px rgba(31, 41, 55, 0.08);
    --gradient-primary: linear-gradient(160deg, #A63D5A 0%, #4A0F24 100%);
    --gradient-secondary: linear-gradient(160deg, #7B1E3A 0%, #C85C7E 100%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    color: var(--text-primary);
    background: var(--bg-soft);
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 270px 1fr;
}

.sidebar {
    background: var(--gradient-primary);
    color: #fff;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.3px;
    margin-bottom: 24px;
}

.brand span {
    color: #ffd7e2;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: #F8E9EE;
    transition: 0.2s ease;
    font-size: 14px;
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.14);
}

.menu-link.is-active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 600;
}

.content-shell {
    display: grid;
    grid-template-rows: 76px 1fr;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-secondary);
}

.main {
    padding: 24px;
}

.page-title {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 700;
}

.page-subtitle {
    margin: 0 0 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 16px;
}

.card-title {
    margin: 0 0 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
}

.kpi-meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    border: 0;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

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

.btn-secondary {
    background: #EEF0F3;
    color: #374151;
}

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

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

.btn:hover {
    transform: translateY(-1px);
}

.input,
.select {
    width: 100%;
    border: 1px solid #D1D5DB;
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
}

.input:focus,
.select:focus {
    outline: none;
    border-color: var(--wine-500);
    box-shadow: 0 0 0 3px rgba(166, 61, 90, 0.15);
}

.input.is-error {
    border-color: var(--danger);
}

.input.is-success {
    border-color: var(--success);
}

.input:disabled {
    background: #F3F4F6;
    color: #9CA3AF;
}

.table-wrap {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fff;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid #EEF0F3;
    text-align: left;
}

.table th {
    background: #FAFBFC;
    color: #374151;
    font-weight: 600;
}

.table tr:hover td {
    background: #FCFCFD;
}

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: rgba(34, 197, 94, 0.14);
    color: #166534;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.18);
    color: #92400E;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.14);
    color: #991B1B;
}

.badge-neutral {
    background: #E5E7EB;
    color: #374151;
}

.modal-backdrop {
    background: rgba(17, 24, 39, 0.5);
    border-radius: var(--radius-md);
    padding: 16px;
}

.modal {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 16px;
    max-width: 520px;
}

.chart-placeholder {
    height: 220px;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, rgba(166, 61, 90, 0.13) 0%, rgba(166, 61, 90, 0.04) 100%);
    border: 1px dashed rgba(166, 61, 90, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wine-700);
    font-weight: 600;
}

.dropzone {
    border: 2px dashed rgba(166, 61, 90, 0.45);
    border-radius: var(--radius-md);
    padding: 26px;
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
}

.muted {
    color: var(--text-secondary);
    font-size: 13px;
}

.spacer-16 {
    height: 16px;
}

@media (max-width: 1180px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: static;
    }

    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Inline edit on double click (clientes/pedidos) */
.table td[data-editable="true"] {
    cursor: text;
}

.table td[data-editable="true"]:hover {
    background: #F8FAFC;
}

.table td.is-editing {
    padding: 6px 8px;
}

.inline-edit-input {
    width: 100%;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    color: var(--text-primary);
    background: #fff;
}

.inline-edit-input:focus {
    outline: none;
    border-color: var(--wine-500);
    box-shadow: 0 0 0 3px rgba(166, 61, 90, 0.15);
}
