:root {
  --ink: #12302f;
  --ink-2: #1d4644;
  --accent: #e9a23b;
  --accent-soft: #fdf2e1;
  --bg: #f5f4ef;
  --card: #ffffff;
  --line: #e6e3da;
  --muted: #6d7471;
  --ok: #2f8a5b;
  --err: #c0392b;
  --c-trim: #1f6f6b;
  --c-anual: #7b4bb7;
  --c-rec: #e9a23b;
  --c-gest: #d1495b;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; }
h1, h3 { margin: 0; }
h1 { font-size: 24px; }
h3 { font-size: 16px; margin-bottom: 12px; }
a { color: var(--ink-2); cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.error { color: var(--err); min-height: 1em; font-size: 13px; }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 5px 10px; font-size: 13px; }
.btn.full { width: 100%; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.badge { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--ink); display: grid; place-items: center; font-weight: 800; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--ink) 0%, var(--ink-2) 100%); }
.login-card { background: #fff; padding: 36px; border-radius: 20px; width: min(400px, 92vw); display: flex; flex-direction: column; gap: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }

/* layout */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { color: #d8e4e2; padding: 10px 12px; border-radius: 10px; text-decoration: none; display: flex; justify-content: space-between; align-items: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); }
.sidebar nav a.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot .btn { color: #fff; border-color: rgba(255,255,255,.25); }
.me { font-size: 13px; color: #bcd; }
.pill { background: var(--accent); color: var(--ink); border-radius: 99px; font-size: 11px; padding: 2px 8px; font-weight: 700; }

.client-picker { display: flex; flex-direction: column; gap: 8px; }
.picker-head { display: flex; justify-content: space-between; align-items: center; }
.picker-head .btn { color: #fff; border-color: rgba(255,255,255,.25); }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #9bb; }
.client-picker input { background: rgba(255,255,255,.08); border-color: transparent; color: #fff; }
#client-list { list-style: none; margin: 0; padding: 0; max-height: 34vh; overflow-y: auto; }
#client-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 6px; }
#client-list li small { display: block; color: #9bb; font-size: 11px; }
#client-list li:hover { background: rgba(255,255,255,.07); }
#client-list li.active { background: var(--accent); color: var(--ink); }
#client-list li.active small { color: var(--ink-2); }

main { padding: 28px 34px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; }
.topbar p { margin: 4px 0 0; }
.tag { font-size: 12px; padding: 5px 10px; border-radius: 99px; background: #fff; border: 1px solid var(--line); }
.tag.on { color: var(--ok); }
.view { display: flex; flex-direction: column; gap: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h3 { margin: 0; text-transform: capitalize; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat strong { font-size: 22px; }
.stat small { color: var(--muted); }

/* calendar */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar .dow { font-size: 11px; text-align: center; color: var(--muted); font-weight: 700; padding-bottom: 4px; }
.calendar .day { min-height: 64px; border-radius: 8px; background: #faf9f6; padding: 5px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.calendar .day.out { opacity: .35; }
.calendar .day.today { outline: 2px solid var(--accent); }
.calendar .day .n { font-weight: 700; }
.ev { font-size: 10.5px; line-height: 1.25; padding: 2px 4px; border-radius: 4px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.trimestral { background: var(--c-trim); }
.ev.anual { background: var(--c-anual); }
.ev.recordatorio { background: var(--c-rec); color: var(--ink); }
.ev.gestor { background: var(--c-gest); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.dot.trimestral { background: var(--c-trim); } .dot.anual { background: var(--c-anual); } .dot.recordatorio { background: var(--c-rec); } .dot.gestor { background: var(--c-gest); }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input[type=date] { width: 160px; }

.upcoming { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.upcoming li { display: grid; grid-template-columns: 54px 1fr; gap: 12px; align-items: center; }
.upcoming .date { text-align: center; background: var(--accent-soft); border-radius: 10px; padding: 6px 0; line-height: 1.1; }
.upcoming .date b { display: block; font-size: 18px; }
.upcoming .date span { font-size: 11px; text-transform: uppercase; }
.upcoming .model { font-size: 11px; color: var(--muted); }
.upcoming .days { font-size: 12px; font-weight: 600; }
.upcoming .days.soon { color: var(--err); }
.upcoming .del { border: 0; background: none; color: var(--muted); cursor: pointer; }

/* uploader */
.uploader { display: flex; flex-direction: column; gap: 12px; }
.drop { position: relative; border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; background: #fcfbf8; transition: .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop p { margin: 4px 0; }
.file-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.upload-opts { display: grid; grid-template-columns: 1.4fr .7fr .6fr 1.4fr auto; gap: 8px; }
.upload-msg { margin: 0; font-size: 13px; }
.upload-msg.ok { color: var(--ok); } .upload-msg.err { color: var(--err); }

/* docs */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 99px; cursor: pointer; font: inherit; font-size: 13px; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs select { width: auto; margin-left: auto; }
table.docs { width: 100%; border-collapse: collapse; font-size: 14px; }
.docs th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.docs td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.docs td.fn { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: #eef3f2; white-space: nowrap; }
.chip.recibido { background: var(--accent-soft); }

/* chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); padding: 0; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 70%; padding: 10px 14px; border-radius: 14px; background: #f0efe9; white-space: pre-wrap; word-wrap: break-word; }
.msg.mine { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg:not(.mine) { border-bottom-left-radius: 4px; }
.msg .meta { font-size: 11px; opacity: .65; margin-top: 4px; }
.day-sep { align-self: center; font-size: 11px; color: var(--muted); padding: 4px 10px; background: #fff; border: 1px solid var(--line); border-radius: 99px; }
.chat-form { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.chat-form textarea { resize: none; max-height: 140px; }

/* forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }

dialog { border: 0; border-radius: 18px; padding: 26px; width: min(480px, 92vw); }
dialog::backdrop { background: rgba(18,48,47,.5); }
.cred { background: var(--accent-soft); padding: 12px; border-radius: 10px; font-size: 14px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .upload-opts { grid-template-columns: 1fr 1fr; }
  main { padding: 18px; }
  .calendar .day { min-height: 48px; }
  .ev { font-size: 0; height: 6px; padding: 0; }
}

/* auth */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.ok-msg { color: var(--ok); font-size: 13px; margin: 0; }
.pending { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.pending li { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); gap: 8px; }
code { background: #f1efe8; padding: 1px 6px; border-radius: 6px; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--muted); }

/* panel del gestor */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
#gestor-nav { display: flex; flex-direction: column; gap: 4px; }
#gestor-nav a { color: #d8e4e2; padding: 10px 12px; border-radius: 10px; text-decoration: none; cursor: pointer; }
#gestor-nav a:hover { background: rgba(255,255,255,.07); }
#gestor-nav a.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.nav-label { padding: 0 12px 4px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 26px 10px; }
.empty p { margin: 4px 0; }
.empty .btn { margin-top: 12px; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.feed li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 8px; cursor: pointer; }
.feed li:hover b { text-decoration: underline; }
.feed .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #faf9f6; }
@media (max-width: 900px) { .grid-4 { grid-template-columns: 1fr 1fr; } #gestor-nav { flex-direction: row; } }
