@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&family=DM+Mono:wght@400;500&display=swap');

:root {
  --color-bg-base:        #0E0B0F;
  --color-bg-surface:     #161219;
  --color-bg-elevated:    #1E1824;
  --color-bg-overlay:     #251F2E;
  --color-burgundy:       #7B2D42;
  --color-burgundy-light: #A63D5A;
  --color-burgundy-muted: #3D1622;
  --color-gold:           #C4963A;
  --color-gold-light:     #E2B96A;
  --color-gold-muted:     #4A3520;
  --color-text-primary:   #F0EAE2;
  --color-text-secondary: #A89E96;
  --color-text-muted:     #6B6068;
  --color-text-inverse:   #0E0B0F;
  --color-border:         #2A2330;
  --color-border-subtle:  #1E1824;
  --color-border-accent:  #4A3042;
  --color-success:        #4A8C6A;
  --color-success-bg:     #1A2E24;
  --color-warning:        #C4963A;
  --color-warning-bg:     #2A2010;
  --color-error:          #C44A4A;
  --color-error-bg:       #2E1A1A;
  --color-info:           #4A7A9B;
  --color-info-bg:        #1A2430;
  --color-paid:           #4A8C6A;
  --color-paid-bg:        #1A2E24;
  --color-pending:        #C4963A;
  --color-pending-bg:     #2A2010;
  --color-overdue:        #C44A4A;
  --color-overdue-bg:     #2E1A1A;
  --font-display:   'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body:      'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:      'DM Mono', 'Courier New', monospace;
  --text-xs:    0.75rem;
  --text-sm:    0.875rem;
  --text-base:  1rem;
  --text-lg:    1.125rem;
  --text-xl:    1.25rem;
  --text-2xl:   1.5rem;
  --text-3xl:   1.875rem;
  --text-4xl:   2.25rem;
  --text-5xl:   3rem;
  --font-light:    300;
  --font-regular:  400;
  --font-medium:   500;
  --font-semibold: 600;
  --leading-tight:  1.2;
  --leading-snug:   1.35;
  --leading-normal: 1.5;
  --leading-relaxed:1.65;
  --tracking-tight:  -0.02em;
  --tracking-normal:  0em;
  --tracking-wide:    0.04em;
  --tracking-widest:  0.12em;
  --space-1:   0.25rem;
  --space-2:   0.5rem;
  --space-3:   0.75rem;
  --space-4:   1rem;
  --space-5:   1.25rem;
  --space-6:   1.5rem;
  --space-8:   2rem;
  --space-10:  2.5rem;
  --space-12:  3rem;
  --space-16:  4rem;
  --space-20:  5rem;
  --space-24:  6rem;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.6);
  --shadow-xl:   0 16px 40px rgba(0,0,0,0.7);
  --shadow-burgundy: 0 4px 20px rgba(123, 45, 66, 0.35);
  --shadow-gold:     0 4px 20px rgba(196, 150, 58, 0.25);
  --transition-fast:    150ms ease;
  --transition-base:    250ms ease;
  --transition-slow:    400ms ease;
  --transition-spring:  300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  --z-base:     0;
  --z-raised:   10;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  300;
  --z-modal:    400;
  --z-toast:    500;
  --sidebar-width:        240px;
  --sidebar-collapsed:     64px;
  --header-height:         60px;
  --content-max-width:   1200px;
  --card-min-width:       280px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg-surface); }
::-webkit-scrollbar-thumb { background: var(--color-border-accent); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-burgundy); }
::selection { background-color: var(--color-burgundy-muted); color: var(--color-text-primary); }

/* Typography */
.text-display { font-family: var(--font-display); font-size: var(--text-5xl); font-weight: var(--font-light); line-height: var(--leading-tight); letter-spacing: -0.02em; }
.text-heading-1 { font-family: var(--font-display); font-size: var(--text-4xl); font-weight: var(--font-regular); line-height: var(--leading-tight); letter-spacing: -0.01em; }
.text-heading-2 { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: var(--font-regular); line-height: var(--leading-snug); letter-spacing: -0.01em; }
.text-heading-3 { font-family: var(--font-body); font-size: var(--text-xl); font-weight: var(--font-semibold); line-height: var(--leading-snug); }
.section-heading { font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--font-regular); font-style: italic; letter-spacing: 0.02em; color: var(--color-text-secondary); min-width: 0; }
.text-label-upper { font-family: var(--font-body); font-size: var(--text-xs); font-weight: var(--font-semibold); letter-spacing: var(--tracking-widest); text-transform: uppercase; color: var(--color-text-muted); }
.text-numeric { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Card */
.card { background-color: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-6); transition: border-color var(--transition-base), box-shadow var(--transition-base); }
.card:hover { border-color: var(--color-border-accent); box-shadow: var(--shadow-md); }
.card--elevated { background-color: var(--color-bg-elevated); box-shadow: var(--shadow-md); }
.card--accent { border-color: var(--color-burgundy); box-shadow: var(--shadow-burgundy); }
.card--active-left { border-left: 3px solid var(--color-burgundy); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-3) var(--space-5); font-family: var(--font-body); font-size: var(--text-sm); font-weight: var(--font-medium); border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; transition: all var(--transition-base); white-space: nowrap; text-decoration: none; user-select: none; }
.btn:active { transform: scale(0.96) !important; transition: transform 80ms ease; }
.btn--primary { background-color: var(--color-burgundy); color: var(--color-text-primary); border-color: var(--color-burgundy); }
.btn--primary:hover { background-color: var(--color-burgundy-light); box-shadow: var(--shadow-burgundy); transform: translateY(-1px); }
.btn--secondary { background-color: transparent; color: var(--color-text-primary); border-color: var(--color-border); }
.btn--secondary:hover { border-color: var(--color-border-accent); background-color: var(--color-bg-elevated); }
.btn--ghost { background-color: transparent; color: var(--color-text-secondary); border-color: transparent; }
.btn--ghost:hover { background-color: var(--color-bg-overlay); color: var(--color-text-primary); }
.btn--gold { background-color: var(--color-gold); color: var(--color-text-inverse); border-color: var(--color-gold); }
.btn--gold:hover { background-color: var(--color-gold-light); box-shadow: var(--shadow-gold); transform: translateY(-1px); }
.btn--danger { background-color: transparent; color: var(--color-error); border-color: var(--color-error); }
.btn--danger:hover { background-color: var(--color-error-bg); }
.btn--sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.btn--lg { padding: var(--space-4) var(--space-8); font-size: var(--text-base); }
.btn--icon { padding: var(--space-2); width: 36px; height: 36px; }

/* Inputs */
.input { width: 100%; padding: var(--space-3) var(--space-4); background-color: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text-primary); font-family: var(--font-body); font-size: var(--text-sm); transition: border-color var(--transition-fast), box-shadow var(--transition-fast); outline: none; }
.input::placeholder { color: var(--color-text-muted); }
.input:focus { border-color: var(--color-burgundy); box-shadow: 0 0 0 3px rgba(123, 45, 66, 0.2); }
.input:hover:not(:focus) { border-color: var(--color-border-accent); }
.input--error { border-color: var(--color-error) !important; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important; }
.input--valid { border-color: var(--color-success) !important; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1) !important; }
.field-hint { font-size: var(--text-xs); margin-top: var(--space-1); display: block; max-height: 0; overflow: hidden; opacity: 0; transition: max-height 200ms ease, opacity 200ms ease; }
.field-hint--visible { max-height: 40px; opacity: 1; }
.field-hint--error { color: var(--color-error); }
.field-hint--valid { color: var(--color-success); }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.input--shake { animation: shake 350ms ease; }
textarea.input { resize: vertical; min-height: 100px; }
select.input { cursor: pointer; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0748a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right var(--space-4) center; padding-right: 2.5rem; }
.form-label { display: block; font-size: var(--text-xs); font-weight: var(--font-semibold); letter-spacing: var(--tracking-widest); text-transform: uppercase; color: var(--color-text-muted); margin-bottom: var(--space-2); }
.form-group { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-3); border-radius: var(--radius-md); font-size: var(--text-xs); font-weight: var(--font-semibold); letter-spacing: var(--tracking-wide); text-transform: uppercase; }
.badge--paid { background-color: var(--color-paid-bg); color: var(--color-paid); border: 1px solid var(--color-paid); }
.badge--pending { background-color: var(--color-pending-bg); color: var(--color-pending); border: 1px solid var(--color-pending); }
.badge--overdue { background-color: var(--color-overdue-bg); color: var(--color-overdue); border: 1px solid var(--color-overdue); }
.badge--parcial { background-color: var(--color-info-bg); color: var(--color-info); border: 1px solid var(--color-info); }
.badge--restaurant { background-color: var(--color-info-bg); color: var(--color-info); border: 1px solid var(--color-info); }
.badge--wine-shop { background-color: var(--color-burgundy-muted); color: var(--color-burgundy-light); border: 1px solid var(--color-burgundy); }
.badge--hotel { background-color: var(--color-gold-muted); color: var(--color-gold); border: 1px solid var(--color-gold); }
.badge--other { background-color: var(--color-bg-overlay); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.badge--alta { background-color: var(--color-error-bg); color: var(--color-error); border: 1px solid var(--color-error); }
.badge--media { background-color: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning); }
.badge--baja { background-color: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success); }

/* Checkbox task */
.checkbox-task { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border-subtle); cursor: pointer; transition: background-color var(--transition-fast), border-color var(--transition-fast); }
.checkbox-task:hover { background-color: var(--color-bg-elevated); border-color: var(--color-border-accent); }
.checkbox-task.completed { opacity: 0.5; }
.checkbox-task.completed .task-text { text-decoration: line-through; color: var(--color-text-muted); }
.checkbox-custom { width: 18px; height: 18px; border: 2px solid var(--color-border-accent); border-radius: var(--radius-sm); flex-shrink: 0; transition: background-color var(--transition-spring), border-color var(--transition-fast), transform var(--transition-spring); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.checkbox-custom.checked { background-color: var(--color-burgundy); border-color: var(--color-burgundy); transform: scale(1.1); }
.checkbox-custom svg { width: 10px; height: 10px; stroke: var(--color-text-primary); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(0.5); transition: opacity 150ms ease 80ms, transform var(--transition-spring) 80ms; }
.checkbox-custom.checked svg { opacity: 1; transform: scale(1); }
@keyframes checkDraw {
  from { stroke-dashoffset: 20; }
  to   { stroke-dashoffset: 0; }
}
.checkbox-custom.checked svg polyline { stroke-dasharray: 20; stroke-dashoffset: 0; animation: checkDraw 200ms ease 80ms both; }

/* Nav */
.nav-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text-secondary); cursor: pointer; transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-base); border: 1px solid transparent; text-decoration: none; position: relative; overflow: hidden; }
.nav-item:hover { background-color: var(--color-bg-elevated); color: var(--color-text-primary); }
.nav-item:active { transform: scale(0.98); }
.nav-item.active { background-color: var(--color-burgundy-muted); color: var(--color-text-primary); border-color: rgba(123, 45, 66, 0.4); box-shadow: inset 3px 0 0 var(--color-burgundy), 0 0 16px rgba(123, 45, 66, 0.15); }
.nav-item.active .nav-icon { color: var(--color-burgundy-light); }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full); background: var(--color-burgundy); color: var(--color-text-primary); font-size: 10px; font-weight: var(--font-semibold); margin-left: auto; line-height: 1; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--color-border); margin: var(--space-4) 0; }
.divider--gold { border-top-color: var(--color-gold-muted); }

/* Avatar */
.avatar { width: 40px; height: 40px; border-radius: var(--radius-full); background-color: var(--color-burgundy-muted); border: 2px solid var(--color-burgundy); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: var(--text-lg); color: var(--color-burgundy-light); overflow: hidden; flex-shrink: 0; }
.avatar--sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--text-2xl); }

/* Stat card */
.stat-card { background-color: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5) var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); transition: all var(--transition-base); }
.stat-card:hover { border-color: var(--color-border-accent); box-shadow: var(--shadow-md); }
.stat-value { font-family: var(--font-mono); font-size: var(--text-3xl); font-weight: var(--font-semibold); color: var(--color-text-primary); line-height: 1; }
.stat-label { font-size: var(--text-xs); font-weight: var(--font-semibold); letter-spacing: var(--tracking-widest); text-transform: uppercase; color: var(--color-text-muted); }
.stat-card--burgundy .stat-value { color: var(--color-burgundy-light); }
.stat-card--gold .stat-value { color: var(--color-gold); }
.stat-card--success .stat-value { color: var(--color-success); }
.stat-card--warning .stat-value { color: var(--color-warning); }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; padding: var(--space-3) var(--space-4); font-size: var(--text-xs); font-weight: var(--font-semibold); letter-spacing: var(--tracking-widest); text-transform: uppercase; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table th.sortable { cursor: default; user-select: none; }
.table th.sortable::after { content: ''; display: inline-block; margin-left: 6px; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 4px solid currentColor; opacity: 0.3; vertical-align: middle; position: relative; top: -1px; }
.table td { padding: var(--space-4); border-bottom: 1px solid var(--color-border-subtle); color: var(--color-text-primary); transition: background-color var(--transition-fast); }
.table tbody tr:nth-child(even) td { background-color: rgba(255,255,255,0.015); }
.table tbody tr { transition: transform var(--transition-fast); }
.table tbody tr:hover td { background-color: var(--color-bg-surface); }
.table tbody tr:hover .table-row-content { transform: translateX(2px); }
.table-row-content { display: inline-block; transition: transform var(--transition-fast); }
.table tr:last-child td { border-bottom: none; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background-color: rgba(14, 11, 15, 0.85); backdrop-filter: blur(4px); z-index: var(--z-overlay); display: flex; align-items: center; justify-content: center; padding: var(--space-4); overscroll-behavior: contain; }
.modal { background-color: var(--color-bg-elevated); border: 1px solid var(--color-border-accent); border-radius: var(--radius-xl); padding: var(--space-8); width: 100%; max-width: 580px; box-shadow: var(--shadow-xl); z-index: var(--z-modal); max-height: 90vh; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-6); padding-bottom: var(--space-4); border-bottom: 1px solid var(--color-border); }
.modal-title { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--font-medium); letter-spacing: -0.01em; }

/* Search */
.search-bar { position: relative; width: 100%; }
.search-bar .search-icon { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.search-bar .input { padding-left: var(--space-10); }

/* Toast */
#toast-container { display: flex; flex-direction: column-reverse; gap: var(--space-2); align-items: flex-end; }
.toast { background-color: var(--color-bg-elevated); border: 1px solid var(--color-border-accent); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-xl); display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); animation: slideInToast 320ms var(--transition-spring) forwards; max-width: 360px; width: max-content; pointer-events: all; }
@keyframes slideInToast { from { transform: translateX(calc(100% + 24px)); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutToast { from { transform: translateX(0); opacity: 1; } to { transform: translateX(calc(100% + 24px)); opacity: 0; } }
@keyframes toastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast--success { border-left: 3px solid var(--color-success); }
.toast--warning { border-left: 3px solid var(--color-warning); }
.toast--error { border-left: 3px solid var(--color-error); }
.toast--info { border-left: 3px solid var(--color-info); }

/* Chat IA */
.chat-bubble--user { background-color: var(--color-burgundy-muted); border: 1px solid var(--color-burgundy); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg); padding: var(--space-3) var(--space-4); max-width: 75%; align-self: flex-end; }
.chat-bubble--ai { background-color: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm); padding: var(--space-3) var(--space-4); max-width: 80%; align-self: flex-start; }
.chat-input-area { background-color: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
.chat-input-area:focus-within { border-color: var(--color-burgundy); box-shadow: 0 0 0 3px rgba(123, 45, 66, 0.15); }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-bg-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: var(--space-6) var(--space-4);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: var(--z-sticky);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%237B2D42' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.5;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: var(--space-8);
  position: relative;
}
.main-content::before {
  content: '';
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 480px;
  background: radial-gradient(ellipse 80% 40% at 50% -10%, rgba(123, 45, 66, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.main-content > *:not(.modal-backdrop) { position: relative; z-index: 1; }

.page-header { margin-bottom: var(--space-8); display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: var(--text-4xl); font-weight: var(--font-regular); color: var(--color-text-primary); line-height: 1; letter-spacing: -0.02em; }
.page-subtitle { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-2); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-6); }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); }

.ornament-divider { display: flex; align-items: center; gap: var(--space-4); color: var(--color-text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-widest); text-transform: uppercase; }
.ornament-divider::before, .ornament-divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(to right, transparent, var(--color-border-accent)); }

.module-header-gradient { background: linear-gradient(135deg, var(--color-burgundy-muted) 0%, transparent 60%); border-radius: var(--radius-lg); padding: var(--space-6); }

/* Sidebar logo */
.sidebar-logo { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-8); padding: 0 var(--space-2); position: relative; z-index: 1; }
.sidebar-logo-text { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--font-medium); color: var(--color-text-primary); letter-spacing: -0.01em; }
.sidebar-logo-sub { font-size: var(--text-xs); color: var(--color-text-muted); letter-spacing: var(--tracking-widest); text-transform: uppercase; }

.sidebar-nav { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; position: relative; z-index: 1; }
.sidebar-section-label { font-size: var(--text-xs); font-weight: var(--font-semibold); letter-spacing: var(--tracking-widest); text-transform: uppercase; color: var(--color-text-muted); padding: var(--space-2) var(--space-4); margin-top: var(--space-4); margin-bottom: var(--space-1); }

.sidebar-footer { margin-top: auto; padding-top: var(--space-6); border-top: 1px solid var(--color-border); position: relative; z-index: 1; }
.sidebar-user { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-2); }
.sidebar-user-name { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--color-text-primary); }
.sidebar-user-role { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Login page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background-color: var(--color-bg-base); padding: var(--space-4); }
.login-card { width: 100%; max-width: 420px; background-color: var(--color-bg-elevated); border: 1px solid var(--color-border-accent); border-radius: var(--radius-2xl); padding: var(--space-12); box-shadow: var(--shadow-xl); }
.login-logo { text-align: center; margin-bottom: var(--space-8); }
.login-logo-title { font-family: var(--font-display); font-size: var(--text-4xl); font-weight: var(--font-regular); color: var(--color-text-primary); letter-spacing: -0.02em; }
.login-logo-subtitle { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-2); letter-spacing: var(--tracking-wide); }
.login-error { background-color: var(--color-error-bg); border: 1px solid var(--color-error); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); color: var(--color-error); margin-bottom: var(--space-5); }
.login-success { background-color: #0d2e1a; border: 1px solid #2d6a4f; border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); color: #52b788; margin-bottom: var(--space-5); }

/* Dashboard layout */
.dashboard-grid { display: grid; grid-template-columns: 1fr 380px; gap: var(--space-6); align-items: start; }
.tasks-list { display: flex; flex-direction: column; gap: var(--space-2); }
.task-actions { display: flex; gap: var(--space-2); margin-left: auto; flex-shrink: 0; }
.task-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); flex-wrap: wrap; }
.task-meta span { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Note cards */
.note-card { background-color: var(--color-bg-elevated); border: 1px solid var(--color-border-subtle); border-radius: var(--radius-md); padding: var(--space-4); position: relative; }
.note-card-actions { display: flex; gap: var(--space-1); }
.note-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }

/* Resource items */
.resource-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border-subtle); transition: background-color var(--transition-fast); }
.resource-item:hover { background-color: var(--color-bg-elevated); }
.resource-icon { width: 36px; height: 36px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: var(--text-lg); }
.resource-icon--link { background-color: var(--color-info-bg); }
.resource-icon--file { background-color: var(--color-gold-muted); }
.resource-icon--text { background-color: var(--color-bg-overlay); }

/* Bodega card */
.bodega-card { background-color: var(--color-bg-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; transition: all var(--transition-base); }
.bodega-card:hover { border-color: var(--color-border-accent); box-shadow: var(--shadow-md); }
.bodega-card-header { padding: var(--space-6); display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.bodega-card-body { padding: 0 var(--space-6) var(--space-6); }
.bodega-clients-section { border-top: 1px solid var(--color-border); margin-top: var(--space-4); padding-top: var(--space-4); display: none; }
.bodega-clients-section.open { display: block; }
.bodega-toggle { cursor: pointer; font-size: var(--text-xs); color: var(--color-text-muted); display: flex; align-items: center; gap: var(--space-1); margin-top: var(--space-4); }
.bodega-toggle:hover { color: var(--color-gold); }

/* Cliente card */
.cliente-row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border-subtle); transition: all var(--transition-fast); cursor: pointer; }
.cliente-row:hover { background-color: var(--color-bg-elevated); border-color: var(--color-border-accent); }

/* Fila cliente */
.cliente-row--responsive { align-items: center; }
.cliente-row--responsive .cr-info { flex: 1; min-width: 0; }
.cliente-row--responsive .cr-name { font-weight: var(--font-medium); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cliente-row--responsive .cr-sub { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.cliente-row--responsive .cr-badges { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cliente-row--responsive .cr-badges--desktop { flex-shrink: 0; }
.cliente-row--responsive .cr-badges--mobile { display: none; margin-top: var(--space-1); }
.cliente-row--responsive .cr-actions { display: flex; gap: var(--space-1); flex-shrink: 0; }

@media (max-width: 768px) {
  .cliente-row--responsive { align-items: flex-start; }
  .cliente-row--responsive .cr-badges--desktop { display: none; }
  .cliente-row--responsive .cr-badges--mobile { display: flex; }
  .cliente-row--responsive .cr-actions { align-self: flex-start; }
}

/* Cobro card */
.cobro-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.cobro-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.cobro-card-actions { display: flex; align-items: flex-start; gap: var(--space-1); flex-shrink: 0; }
.cobro-pago-btn { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin-top: var(--space-1); }

/* Filters bar */
.filters-bar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-6); }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-12); text-align: center; gap: var(--space-3); }
.empty-state-icon { opacity: 0.2; color: var(--color-text-secondary); }
.empty-state-title { color: var(--color-text-secondary); font-size: var(--text-base); font-weight: var(--font-medium); margin: 0; }
.empty-state-text { color: var(--color-text-muted); font-size: var(--text-sm); margin: 0; max-width: 240px; line-height: var(--leading-relaxed); }

/* Week preview */
.week-preview { display: flex; flex-direction: column; gap: var(--space-2); }
.week-day-group { margin-bottom: var(--space-3); }
.week-day-label { font-size: var(--text-xs); font-weight: var(--font-semibold); letter-spacing: var(--tracking-widest); text-transform: uppercase; color: var(--color-gold); margin-bottom: var(--space-2); }
.week-task-item { font-size: var(--text-sm); color: var(--color-text-secondary); padding: var(--space-2) var(--space-3); border-left: 2px solid var(--color-border-accent); margin-bottom: var(--space-1); }

/* Mobile top bar */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background-color: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: var(--z-sticky);
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}
.mobile-topbar-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--color-text-primary);
  flex: 1;
  letter-spacing: -0.01em;
}
.mobile-hamburger {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background-color var(--transition-fast);
  flex-shrink: 0;
}
.mobile-hamburger:hover { color: var(--color-text-primary); background-color: var(--color-bg-elevated); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-sticky) - 1);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* Responsive */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform var(--transition-base); z-index: var(--z-modal); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: var(--space-4); padding-top: calc(52px + var(--space-4)); max-width: 100vw; overflow-x: hidden; }
  .main-content::before { left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Ami FAB y panel */
  .ami-fab { bottom: 16px; right: 16px; }
  .ami-panel { width: auto !important; left: 16px !important; right: 16px !important; bottom: 72px !important; top: 68px !important; height: auto !important; max-height: none !important; }

  /* Note card tappable en mobile */
  .note-card { cursor: pointer; }

  /* Modal bottom-sheet en mobile */
  .modal-backdrop { align-items: flex-end !important; padding: 0 var(--space-3) !important; }
  .modal { border-radius: var(--radius-xl) var(--radius-xl) var(--radius-lg) var(--radius-lg) !important; max-height: 78vh; max-width: 100% !important; width: 100% !important; padding: var(--space-6) var(--space-4); margin-bottom: 76px; scrollbar-width: none; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .modal::-webkit-scrollbar { display: none; }
}

/* Scrollbar del modal oculta en desktop también */
.modal { scrollbar-width: none; }
.modal::-webkit-scrollbar { display: none; }

  /* Tabla dentro de modal: scroll horizontal contenido */
  .modal .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .modal .table th, .modal .table td { white-space: nowrap; }


  /* Cards no desbordan */
  .card { max-width: 100%; overflow: hidden; }
  .filters-bar { gap: var(--space-2); }
  .filters-bar .input { font-size: var(--text-xs); }
}

/* Utility */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.w-full { width: 100%; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-semibold { font-weight: var(--font-semibold); }
.hidden { display: none; }

/* ── Skeleton loaders ─────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--color-bg-elevated) 25%, var(--color-bg-overlay) 50%, var(--color-bg-elevated) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-md);
}
.skeleton-line { height: 12px; margin-bottom: var(--space-2); }
.skeleton-line--sm  { width: 40%; }
.skeleton-line--md  { width: 65%; }
.skeleton-line--full { width: 100%; }
.skeleton-task { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border-subtle); }
.skeleton-task-check { width: 18px; height: 18px; flex-shrink: 0; border-radius: var(--radius-sm); }
.skeleton-task-body { flex: 1; display: flex; flex-direction: column; gap: var(--space-2); padding-top: 2px; }
.skeleton-note { padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border-subtle); display: flex; flex-direction: column; gap: var(--space-2); }
.skeleton-resource { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--color-border-subtle); }
.skeleton-resource-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--radius-md); }
.skeleton-resource-body { flex: 1; display: flex; flex-direction: column; gap: var(--space-2); }
.skeleton-week-label { height: 10px; width: 80px; margin-bottom: var(--space-2); border-radius: var(--radius-full); }
.skeleton-week-item { height: 32px; width: 100%; margin-bottom: var(--space-1); border-radius: var(--radius-md); }

/* ── Ami flotante ─────────────────────────────────────── */
.ami-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--color-burgundy);
  color: var(--color-text-primary);
  border: 1px solid var(--color-burgundy-light);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  box-shadow: var(--shadow-lg), 0 0 0 0 rgba(123,45,66,0.4);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  animation: fabPulse 3s ease-in-out infinite;
}
.ami-fab:hover { background: var(--color-burgundy-light); transform: translateY(-2px); box-shadow: var(--shadow-xl), 0 0 20px rgba(123,45,66,0.3); animation: none; }
@keyframes fabPulse {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(123,45,66,0.35); }
  50%       { box-shadow: var(--shadow-lg), 0 0 0 8px rgba(123,45,66,0); }
}

.ami-panel {
  position: fixed;
  bottom: 78px;
  right: 24px;
  z-index: 600;
  width: 360px;
  height: 500px;
  display: flex;
  flex-direction: column;
  background: rgba(22, 18, 25, 0.82);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(123,45,66,0.15) inset;
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}
.ami-panel--open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}
.ami-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  flex-shrink: 0;
}
.ami-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: none;
}
.ami-messages::-webkit-scrollbar { display: none; }
.ami-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  flex-shrink: 0;
}
.ami-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  resize: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  padding: 4px 0;
}
.ami-textarea::placeholder { color: var(--color-text-muted); }

/* Typing indicator */
.ami-typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  display: inline-block;
}
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}
.ami-typing-dot:nth-child(1) { animation: typingBounce 1.2s ease infinite 0s; }
.ami-typing-dot:nth-child(2) { animation: typingBounce 1.2s ease infinite 0.2s; }
.ami-typing-dot:nth-child(3) { animation: typingBounce 1.2s ease infinite 0.4s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
