:root {
  --navy: #001f3f; --navy-2: #0b2d52; --gold: #bca474; --gold-soft: #f3ecdc; --ink: #333333; --bg: #fdfdfd;
  --line: #e4e1da; --muted: #6b6b6b; --ok: #2e7d4f; --warn: #b7791f; --bad: #b03a2e;
  --serif: 'Century', 'Century Schoolbook', Georgia, serif; --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); font-size: 14px; }
h1, h2, h3 { font-family: var(--serif); color: var(--navy); font-weight: 600; }
h1 { font-size: 24px; margin: 0 0 4px; } h2 { font-size: 18px; margin: 24px 0 10px; } h3 { font-size: 15px; margin: 16px 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .error { color: var(--bad); min-height: 1em; }
a { color: var(--navy); }

.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #dfe6ee; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 20px 20px 16px; font-family: var(--serif); font-size: 22px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand small { display: block; color: var(--gold); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
nav { padding: 8px 0; flex: 1; }
nav .grupo { font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); padding: 14px 20px 4px; }
nav a { display: flex; justify-content: space-between; padding: 7px 20px; color: #dfe6ee; text-decoration: none; border-left: 3px solid transparent; }
nav a:hover { background: var(--navy-2); }
nav a.active { background: var(--navy-2); border-left-color: var(--gold); color: #fff; }
nav .badge { background: var(--gold); color: var(--navy); border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.link { background: none; border: 0; color: var(--gold); cursor: pointer; padding: 0; margin-top: 4px; }

main { min-width: 0; }
.topbar { display: flex; gap: 12px; align-items: center; padding: 12px 28px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.topbar input { flex: 1; max-width: 560px; }
#menu-toggle { display: none; }
#view { padding: 24px 28px 80px; max-width: 1280px; }

input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; color: var(--ink); }
.btn { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: 600; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.icon-btn { background: none; border: 0; font-size: 20px; cursor: pointer; color: inherit; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 16px 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.card .num { font-family: var(--serif); font-size: 26px; color: var(--navy); }
.card .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.panel h3:first-child, .panel h2:first-child { margin-top: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

table.t { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #faf8f3; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; } .t tr.click:hover td { background: var(--gold-soft); }
.num-r { text-align: right; font-variant-numeric: tabular-nums; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; background: #eef1f5; color: var(--navy); }
.tag.gold { background: var(--gold-soft); color: #7a6431; } .tag.ok { background: #e3f2e9; color: var(--ok); }
.tag.warn { background: #fdf1dc; color: var(--warn); } .tag.bad { background: #f8e3e0; color: var(--bad); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; font: inherit; color: var(--muted); }
.tabs button.on { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.list-item { padding: 9px 0; border-bottom: 1px solid var(--line); } .list-item:last-child { border-bottom: 0; }
.small { font-size: 12px; }

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.kcol { min-width: 230px; background: #f6f4ef; border-radius: 10px; padding: 10px; }
.kcol h4 { margin: 2px 4px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--navy); display: flex; justify-content: space-between; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; font-size: 13px; }
.kcard b { color: var(--navy); } .kcol.over { outline: 2px dashed var(--gold); }

.login { min-height: 100vh; display: grid; place-items: center; background: var(--navy); }
.login-card { background: #fff; padding: 32px; border-radius: 12px; width: 360px; border-top: 4px solid var(--gold); }
.brand-big { font-family: var(--serif); font-size: 28px; color: var(--navy); } .brand-big span { color: var(--gold); }

.modal { position: fixed; inset: 0; background: rgba(0,20,40,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: #fff; border-radius: 12px; padding: 22px 24px; width: 640px; max-width: 100%; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-x { position: absolute; top: 10px; right: 12px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; border-left: 4px solid var(--gold); }
.toast.bad { border-left-color: var(--bad); }

.ai-toggle { position: fixed; right: 24px; bottom: 24px; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--gold); color: var(--navy); font-size: 22px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.2); z-index: 30; }
.ai-panel { position: fixed; right: 24px; bottom: 90px; width: 380px; max-width: calc(100vw - 32px); height: 520px; max-height: 70vh; background: #fff; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; z-index: 31; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.ai-head { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 12px 12px 0 0; display: flex; justify-content: space-between; align-items: center; font-family: var(--serif); }
.ai-log { flex: 1; overflow-y: auto; padding: 12px; }
.msg { padding: 8px 11px; border-radius: 10px; margin-bottom: 8px; max-width: 88%; white-space: pre-wrap; }
.msg.bot { background: #f3f1ec; } .msg.yo { background: var(--navy); color: #fff; margin-left: auto; }
.ai-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
code.url { display: block; background: #f6f4ef; padding: 10px; border-radius: 6px; word-break: break-all; margin: 8px 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 250px; z-index: 40; transition: left .2s; }
  .sidebar.open { left: 0; }
  #menu-toggle { display: block; color: var(--navy); }
  #view { padding: 16px; } .cols, .grid2, .grid3 { grid-template-columns: 1fr; }
  .t { display: block; overflow-x: auto; }
}
@media print { .sidebar, .topbar, .ai-toggle, .ai-panel, .noprint { display: none !important; } .layout { display: block; } }

/* Panel del equipo */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 12px 0 6px; }
.stat { background: #f6f3ec; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.stat .n { font-size: 22px; font-weight: 600; }
.stat .n.ok { color: var(--ok); } .stat .n.bad { color: var(--bad, #b3261e); }

/* Notificaciones judiciales */
.notif.nueva { border-left: 4px solid var(--gold); }
.notif.leida { opacity: .85; }
.providencia.corta { max-height: 9.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }

/* Filtros de selección múltiple */
.msel { position: relative; flex: 1; min-width: 170px; }
.msel > summary { list-style: none; cursor: pointer; padding: 8px 30px 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.msel > summary::-webkit-details-marker { display: none; }
.msel > summary::after { content: '▾'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: #666; }
.msel.activo > summary { border-color: var(--gold); background: #fbf7ec; font-weight: 600; }
.msel-pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 100%; max-height: 340px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; }
.msel-pop label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; white-space: nowrap; margin: 0; }
.msel-pop label:hover { background: #f4f1ea; }
.msel-pop input { width: auto; margin: 0; }
.msel-acc { display: flex; justify-content: space-between; gap: 12px; padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 13px; }

/* Términos detectados en providencias */
.terminos-det { margin-top: 8px; display: grid; gap: 6px; }
.termino { padding: 8px 10px; border-radius: 6px; background: #fbf7ec; border: 1px solid #ecdfb8; }
.termino.ok { background: #eef7ef; border-color: #cfe6d2; }
.termino.muted { background: transparent; border: 0; padding: 0 2px; }

/* Gastos y caja chica */
.barra-fila { display: grid; grid-template-columns: minmax(120px, 38%) 1fr auto; gap: 10px; align-items: center; margin: 6px 0; font-size: 14px; }
.barra-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra { background: #f1ede3; border-radius: 4px; height: 10px; overflow: hidden; }
.barra i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.stat.alerta { border-color: #e7c27a; background: #fdf6e7; } .stat.mal { border-color: #e3a49b; background: #fbecea; }