:root {
  --navy: #1f3864;
  --blue: #2e5496;
  --blue-soft: #eaf1fb;
  --green: #1f6e43;
  --green-bg: #d6f0e0;
  --amber: #b8860b;
  --amber-bg: #fdf0cf;
  --red: #c0392b;
  --red-bg: #fbe0dd;
  --ink: #1c2533;
  --muted: #6b7785;
  --line: #e2e7ef;
  --bg: #f4f6fa;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,32,64,.08), 0 6px 24px rgba(16,32,64,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  display: flex;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Sidebar */
.sidebar {
  width: 232px;
  background: var(--navy);
  color: #cdd7ea;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #3a63b0, #2e5496);
  display: grid; place-items: center; font-weight: 800; color: #fff; letter-spacing: .5px;
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; }
.brand-txt strong { color: #fff; font-size: 14px; }
.brand-txt span { font-size: 11px; color: #9fb0d0; }
nav { padding: 8px; flex: 1; }
.nav-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin: 2px 0; border: 0; border-radius: 9px;
  background: transparent; color: #cdd7ea; font-size: 13.5px; cursor: pointer;
  text-align: left; transition: background .12s, color .12s;
}
.nav-btn span { font-size: 15px; width: 18px; text-align: center; }
.nav-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-btn.active { background: var(--blue); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot small { display: block; margin-top: 8px; font-size: 10px; color: #8093b5; line-height: 1.4; word-break: break-all; }

/* Content */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; color: var(--navy); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
#search {
  width: 240px; padding: 9px 13px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 13px; outline: none; background: #fff;
}
#search:focus { border-color: var(--blue); }
.view { padding: 24px; overflow-y: auto; flex: 1; }

/* Buttons */
.primary-btn { background: var(--blue); color: #fff; border: 0; padding: 9px 16px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; }
.primary-btn:hover { background: #25467f; }
.ghost-btn { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 9px 14px; border-radius: 9px; font-size: 13px; cursor: pointer; }
.ghost-btn:hover { background: #f4f6fa; }
.danger-btn { background: #fff; color: var(--red); border: 1px solid #f0c8c3; padding: 9px 14px; border-radius: 9px; font-size: 13px; cursor: pointer; }
.danger-btn:hover { background: var(--red-bg); }
.icon-btn { background: none; border: 0; font-size: 17px; cursor: pointer; color: var(--muted); }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.kpi .num { font-size: 30px; font-weight: 800; color: var(--navy); margin-top: 6px; }
.kpi.green .num { color: var(--green); }
.kpi.amber .num { color: var(--amber); }
.kpi.red .num { color: var(--red); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel h3 { font-size: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--navy); }

/* Tables */
.tbl-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #f7f9fc; text-align: left; padding: 11px 14px; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #eef1f6; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fbfe; cursor: pointer; }
.mono { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--blue); }
.muted { color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: #eef1f6; color: var(--muted); }
.chk { font-size: 15px; }
.chk.yes { color: var(--green); }
.chk.no { color: #cdd3dd; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,32,56,.45); display: grid; place-items: center; z-index: 50; }
.modal-backdrop.hidden { display: none; }
.modal { background: #fff; width: 640px; max-width: 92vw; max-height: 88vh; border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; color: var(--navy); }
.modal-body { padding: 18px 20px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.modal-body.list-body { display: block; padding: 0; }
.modal-body.list-body table { width: 100%; }
.modal-body.list-body .empty { padding: 32px; }
.clickable { cursor: pointer; }
.clickable:hover { background: #f4f6fa; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  font-family: inherit; outline: none; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.field textarea { resize: vertical; min-height: 56px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: 17px; height: 17px; }
.field.check label { font-size: 13px; color: var(--ink); }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); z-index: 60; }
.toast.hidden { display: none; }
.toast.err { background: var(--red); }

/* ===== App shell ===== */
.app { display: flex; width: 100%; height: 100%; }
.app.hidden, .login-screen.hidden { display: none; }
.hidden { display: none !important; }

/* ===== Login ===== */
.login-screen {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, #1f3864, #2e5496); padding: 20px;
}
.login-card {
  background: #fff; width: 360px; max-width: 92vw; border-radius: 16px;
  padding: 34px 30px; box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center;
}
.login-logo {
  width: 60px; height: 60px; border-radius: 15px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #3a63b0, #2e5496); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 24px; letter-spacing: .5px;
}
.login-card h1 { font-size: 18px; color: var(--navy); line-height: 1.25; }
.login-card h1 span { font-size: 13px; color: var(--muted); font-weight: 600; }
.login-sub { color: var(--muted); font-size: 12px; margin: 4px 0 22px; text-transform: uppercase; letter-spacing: .5px; }
.login-field { text-align: left; margin-bottom: 14px; }
.login-field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.login-field input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; outline: none; }
.login-field input:focus { border-color: var(--blue); }
.login-btn { width: 100%; padding: 12px; font-size: 14px; margin-top: 6px; }
.login-error { background: var(--red-bg); color: var(--red); padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }

/* ===== Userbox ===== */
.userbox { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.useravatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.userinfo { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.userinfo strong { color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userinfo small { color: #9fb0d0; font-size: 11px; }
.ghost-btn.sm { width: 100%; padding: 7px 10px; font-size: 12px; margin-top: 6px; text-align: left; }

/* ocultar elementos solo-admin cuando el body no es admin */
body:not(.is-admin) .admin-only { display: none !important; }

/* badge archivado */
.badge.archivado { background: #e7e9ee; color: #6b7785; }
tr.inactivo { opacity: .55; }

/* ===== Archivos en documentos ===== */
.archivos-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.archivo-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px; }
.archivo-ic { font-size: 15px; }
.archivo-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.archivo-size { font-size: 11px; color: var(--muted); }
.mini-btn { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; font-size: 11.5px; cursor: pointer; color: var(--blue); }
.mini-btn:hover { background: var(--blue-soft); }
.mini-btn.danger { color: var(--red); }
.mini-btn.danger:hover { background: var(--red-bg); }
.archivos-upload { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.archivos-upload input[type=file] { font-size: 12px; flex: 1; min-width: 160px; }

/* ===== Grupos de casillas (servicios / agencia) ===== */
.chk-group { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 16px; padding: 6px 0 2px; }
.chkopt { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.chkopt input { width: 16px; height: 16px; flex-shrink: 0; }
@media (max-width: 560px){ .chk-group { grid-template-columns: 1fr; } }

.form-note { background: var(--blue-soft); color: var(--blue); border-radius: 8px; padding: 9px 12px; font-size: 12px; line-height: 1.4; }

/* ================================================== */
/* ===== TIPOGRAFÍA UNIFICADA: 12px en toda la app == */
/* ================================================== */
body { font-size: 12px; }
.brand-txt strong, .brand-txt span,
.nav-btn, .nav-btn span,
.sidebar-foot small, .userinfo strong, .userinfo small, .ghost-btn.sm,
.topbar h1, #viewTitle, #search,
.primary-btn, .ghost-btn, .danger-btn, .icon-btn,
.kpi .label, .kpi .num,
.panel h3, table, thead th, tbody td,
.badge, .chk, .archivo-ic,
.modal-head h2, .field label, .field input, .field select, .field textarea, .field.check label,
.toast, .empty, .muted,
.login-card h1, .login-card h1 span, .login-sub, .login-field label, .login-field input, .login-btn,
.archivo-name, .archivo-size, .mini-btn, .chkopt, .form-note,
.tipoName, .mono { font-size: 12px; }

/* iconos/insignias de navegación un poco mayores para legibilidad */
.nav-btn span { font-size: 14px; }
.kpi .num { font-size: 12px; }

/* ===== Campos de formulario uniformes a 12px ===== */
.field input, .field select, .field textarea,
.login-field input, #search { padding: 8px 10px; line-height: 1.35; }
.field label, .login-field label { margin-bottom: 4px; }
.field.check input { width: 15px; height: 15px; }
.chkopt input { width: 15px; height: 15px; }
thead th { padding: 9px 12px; }
tbody td { padding: 9px 12px; }

/* ================================================== */
/* ===== AJUSTE: 14px general · barra lateral 16px === */
/* ================================================== */
body { font-size: 14px; }
.topbar h1, #viewTitle, #search,
.primary-btn, .ghost-btn, .danger-btn, .icon-btn,
.kpi .label, .kpi .num,
.panel h3, table, thead th, tbody td,
.badge, .chk, .archivo-ic,
.modal-head h2, .field label, .field input, .field select, .field textarea, .field.check label,
.toast, .empty, .muted,
.login-card h1, .login-card h1 span, .login-sub, .login-field label, .login-field input, .login-btn,
.archivo-name, .archivo-size, .mini-btn, .chkopt, .form-note,
.tipoName, .mono { font-size: 14px; }
.kpi .num { font-size: 14px; }

/* Barra lateral a 16px */
.brand-txt strong, .brand-txt span,
.nav-btn, .userinfo strong, .userinfo small,
.sidebar-foot small, .ghost-btn.sm { font-size: 16px; }
.nav-btn span { font-size: 18px; }

/* ===== Próximas Citas: MAYÚSCULAS, negritas, 16px ===== */
#citasPanel th,
#citasPanel td,
#citasPanel td .badge,
#citasPanel td .mono,
#citasPanel td .muted {
  font-size: 16px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
}

/* ===== Clientes en tarjetas ===== */
.cli-group { margin-bottom: 24px; }
.cli-sep { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.cli-sep .letter { width: 34px; height: 34px; border-radius: 9px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px; }
.cli-sep .line { flex: 1; height: 1px; background: var(--line); }
.cli-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.cli-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.cli-card:hover { border-color: var(--blue); box-shadow: 0 6px 18px rgba(16,32,64,.12); transform: translateY(-1px); }
.cli-card.inactivo { opacity: .55; }
.cli-card .cc-name { font-weight: 700; color: var(--navy); font-size: 15px; margin-bottom: 4px; line-height: 1.3; }
.cli-card .cc-id { font-size: 12px; color: var(--blue); font-weight: 600; }
.cli-card .cc-row { font-size: 13px; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1200px){ .cli-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px){ .cli-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px){ .cli-grid { grid-template-columns: 1fr; } }

/* ===== Pestañas de letras (clientes) ===== */
.letter-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.ltab { min-width: 36px; padding: 7px 12px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--navy); cursor: pointer; transition: background .12s, color .12s; }
.ltab:hover { background: var(--blue-soft); }
.ltab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ===== Tarjeta de cliente: servicios y cita ===== */
.cli-card .cc-serv { margin: 8px 0 2px; display: flex; flex-wrap: wrap; gap: 4px; }
.cli-card .cc-cita { color: var(--green); font-size: 13px; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.cli-card .cc-cita.muted { color: var(--muted); }
.cli-card .cc-cita strong { color: var(--navy); }

/* ================================================== */
/* ===== TODO EL SISTEMA A 16px ===================== */
/* ================================================== */
body { font-size: 16px; }
.topbar h1, #viewTitle, #search,
.primary-btn, .ghost-btn, .danger-btn, .icon-btn, .ghost-btn.sm,
.kpi .label, .kpi .num,
.panel h3, table, thead th, tbody td,
.badge, .chk, .archivo-ic,
.modal-head h2, .field label, .field input, .field select, .field textarea, .field.check label,
.toast, .empty, .muted,
.login-card h1, .login-card h1 span, .login-sub, .login-field label, .login-field input, .login-btn,
.archivo-name, .archivo-size, .mini-btn, .chkopt, .form-note,
.tipoName, .mono, .letter-tabs .ltab,
.brand-txt strong, .brand-txt span, .nav-btn, .userinfo strong, .userinfo small, .sidebar-foot small,
.cli-card .cc-name, .cli-card .cc-id, .cli-card .cc-row, .cli-sep .letter { font-size: 16px; }
.nav-btn span { font-size: 18px; }
