:root {
  --primary: #1b213b;
  --secondary: #a21724;
  --tertiary: #4f89b7;
  --dark: #333333;
  --white: #ffffff;
  --bg: #f2f2f4;
  --border: rgba(27,33,59,0.13);
  --muted: #888;
  --success-bg: #e8f5e9;
  --success-text: #2e7d32;
  --warn-bg: #fff3e0;
  --warn-text: #e65100;
  --danger-bg: #ffebee;
  --danger-text: #b71c1c;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--dark); font-size: 15px; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { font-family: 'DM Sans', sans-serif; cursor: pointer; }
input, select, textarea { font-family: 'DM Sans', sans-serif; }

/* ── LAYOUT ── */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; max-width: 480px; margin: 0 auto; background: var(--bg); }

/* ── TOP BAR ── */
.top-bar { background: var(--primary); padding: 12px 18px 16px; position: sticky; top: 0; z-index: 100; }
.top-bar-row { display: flex; align-items: center; gap: 10px; }
.top-bar h1 { font-family: 'Sora', sans-serif; font-size: 19px; font-weight: 700; color: white; }
.top-bar .sub { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 1px; }
.back-btn { display: flex; align-items: center; gap: 6px; color: rgba(255,255,255,0.7); font-size: 13px; background: none; border: none; padding: 0 0 8px; cursor: pointer; }
.avatar-btn { width: 34px; height: 34px; background: rgba(255,255,255,0.12); border-radius: 50%; display: flex; align-items: center; justify-content: center; border: none; color: white; font-size: 13px; font-weight: 600; cursor: pointer; flex-shrink: 0; }

/* ── BOTTOM NAV ── */
.bottom-nav { background: white; border-top: 0.5px solid var(--border); display: flex; position: sticky; bottom: 0; z-index: 100; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 0 14px; border: none; background: none; cursor: pointer; }
.nav-item svg { opacity: 0.45; }
.nav-item span { font-size: 10px; color: var(--muted); font-weight: 500; }
.nav-item.active svg { opacity: 1; }
.nav-item.active span { color: var(--secondary); font-weight: 700; }

/* ── CONTENT ── */
.page-content { flex: 1; overflow-y: auto; padding: 14px; }

/* ── CARDS ── */
.card { background: white; border-radius: 16px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 12px; }
.card-header { background: var(--primary); padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; }
.card-header-title { color: white; font-size: 13px; font-weight: 600; }

/* ── TABLA ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.data-table thead tr { background: var(--primary); }
.data-table thead th { padding: 9px 10px; text-align: left; color: white; font-size: 11px; font-weight: 600; }
.data-table thead th:first-child { padding-left: 14px; }
.data-table tbody tr { border-bottom: 0.5px solid var(--border); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody td { padding: 9px 10px; color: var(--dark); }
.data-table tbody td:first-child { padding-left: 14px; }
.data-table tbody tr.urgent { background: #fff8f8; }
.table-legend { padding: 8px 14px; border-top: 0.5px solid var(--border); display: flex; gap: 14px; background: #fafafa; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-danger { background: #b71c1c; }
.dot-warn { background: #e65100; }
.dot-ok { background: #2e7d32; }

/* ── BADGES ── */
.badge { font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.badge-ok { background: var(--success-bg); color: var(--success-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-admin { background: rgba(162,23,36,0.15); color: var(--secondary); border: 1px solid rgba(162,23,36,0.3); }

/* ── FORMS ── */
.form-card { background: white; border-radius: 16px; border: 1px solid var(--border); padding: 16px; margin-bottom: 12px; }
.form-card h3 { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 14px; }
.field-group { margin-bottom: 13px; }
.field-group:last-child { margin-bottom: 0; }
.field-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; display: block; }
.field-input, .field-select { width: 100%; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--dark); background: #fafafa; outline: none; transition: border-color 0.2s; -webkit-appearance: none; }
.field-input:focus, .field-select:focus { border-color: var(--tertiary); background: white; }

/* ── BUTTONS ── */
.btn { border: none; border-radius: 12px; padding: 13px 20px; font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity 0.15s, transform 0.1s; }
.btn:active { transform: scale(0.98); opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--secondary); color: white; }
.btn-secondary { background: var(--primary); color: white; }
.btn-outline { background: white; color: var(--primary); border: 1.5px solid var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }

/* ── BOTTOM ACTIONS ── */
.bottom-actions { padding: 12px 16px; background: white; border-top: 0.5px solid var(--border); display: flex; gap: 10px; position: sticky; bottom: 60px; }

/* ── ALERT BANNER ── */
.alert-banner { background: var(--warn-bg); border-left: 4px solid var(--warn-text); padding: 12px 14px; border-radius: 10px; display: flex; align-items: center; gap: 10px; margin-bottom: 12px; cursor: pointer; }
.alert-banner .alert-text { font-size: 13px; color: var(--warn-text); font-weight: 600; }
.alert-banner .alert-sub { font-size: 11px; color: #bf360c; margin-top: 1px; }

/* ── SECTION TITLE ── */
.section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }

/* ── SEARCH ── */
.search-bar { display: flex; align-items: center; background: white; border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; gap: 8px; margin-bottom: 12px; }
.search-bar input { border: none; background: transparent; font-size: 14px; color: var(--dark); flex: 1; outline: none; font-family: 'DM Sans', sans-serif; }

/* ── TOGGLE ── */
.view-toggle { display: flex; background: #e4e4e8; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.view-toggle button { flex: 1; padding: 7px; border: none; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; background: transparent; color: var(--muted); }
.view-toggle button.active { background: var(--primary); color: white; }

/* ── CLIENT CARD (list view) ── */
.client-card { background: white; border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: background 0.15s; }
.client-card:active { background: #f8f8f8; }
.client-avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--primary); display: flex; align-items: center; justify-content: center; color: white; font-size: 13px; font-weight: 700; flex-shrink: 0; font-family: 'Sora', sans-serif; }
.client-avatar.urgent { background: var(--secondary); }

/* ── LEVANTADA / NUEVA ── */
.fecha-box { flex: 1; border-radius: 10px; padding: 11px; }
.fecha-box.levantada { background: #fff5f5; border: 1.5px solid #ffcdd2; }
.fecha-box.nueva { background: #f1f8f1; border: 1.5px solid #c8e6c9; }
.fecha-box-label { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; margin-bottom: 7px; }
.fecha-box.levantada .fecha-box-label { color: var(--secondary); }
.fecha-box.nueva .fecha-box-label { color: #2e7d32; }
.fecha-box input { width: 100%; border-radius: 8px; padding: 7px 8px; font-size: 12px; color: var(--dark); background: white; outline: none; font-family: 'DM Sans', sans-serif; }
.fecha-box.levantada input { border: 1px solid #ffcdd2; }
.fecha-box.nueva input { border: 1px solid #c8e6c9; }

/* ── HISTORIAL ── */
.hist-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.hist-row:last-child { border-bottom: none; padding-bottom: 0; }
.hist-dot { width: 8px; height: 8px; background: var(--tertiary); border-radius: 50%; margin-top: 5px; flex-shrink: 0; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet { background: white; border-radius: 22px 22px 0 0; width: 100%; max-width: 480px; padding: 20px 20px 36px; transform: translateY(100%); transition: transform 0.3s ease; }
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 18px; }
.modal-title { font-family: 'Sora', sans-serif; font-size: 17px; font-weight: 700; color: var(--dark); margin-bottom: 16px; }

/* ── TOAST ── */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--primary); color: white; padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 500; z-index: 300; opacity: 0; transition: all 0.3s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state svg { opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── SPINNER ── */
.spinner { border: 2px solid var(--border); border-top-color: var(--secondary); border-radius: 50%; width: 24px; height: 24px; animation: spin 0.7s linear infinite; margin: 32px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ANIMATIONS ── */
@keyframes fadeUp { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }
.fade-up { animation: fadeUp 0.3s ease both; }
