:root {
  --ink: #1f2123;
  --ink-2: #5b6066;
  --ink-3: #8a8f95;
  --line: #e6e6e3;
  --bg: #f4f4f3;
  --card: #ffffff;
  --side: #292b2d;
  --side-ink: #d9dadb;
  --accent: #292b2d;
  --red: #c0392b;
  --red-bg: #fdecea;
  --green: #2e7d4f;
  --green-bg: #e6f4ec;
  --amber: #8a6100;
  --amber-bg: #fdf3d8;
  --grey-bg: #ececea;
  --radius: 14px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.serif { font-family: var(--serif); font-weight: 400; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--side); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 18px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card .logo { height: 34px; display: block; margin-bottom: 6px; }
.login-card .brand-sub { font-size: 11px; letter-spacing: .14em; color: var(--ink-3); margin-bottom: 26px; }
.login-card h1 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin-bottom: 18px; }
.login-help { margin-top: 18px; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.brand-text { font-weight: 700; letter-spacing: .08em; font-size: 20px; }

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
  color: var(--ink); width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 11px 12px; font-size: 16px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #9aa0a6; box-shadow: 0 0 0 3px rgba(41,43,45,.08); }
textarea { min-height: 96px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 14px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { background: #f8f8f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3a3d40; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; padding: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; }
.error-msg { background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.ok-msg { background: var(--green-bg); color: var(--green); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.dropzone { display: block; border: 1.5px dashed #c9cbcd; border-radius: 12px; padding: 22px; text-align: center; color: var(--ink-2); cursor: pointer; background: #fff; }
.dropzone strong { display: block; color: var(--ink); margin: 6px 0 2px; font-size: 14px; }
.dropzone input { display: none; }
.file-list { list-style: none; padding: 0; margin: 10px 0 0; }
.file-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; padding: 6px 10px; background: var(--grey-bg); border-radius: 8px; margin-bottom: 6px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.check-row:last-child { border-bottom: 0; }
.check-row input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
.fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 14px; background: #fff; }
.fieldset legend { font-size: 12.5px; font-weight: 600; padding: 0 4px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 22px 14px 14px; position: sticky; top: 0; height: 100vh; }
.side .logo { height: 30px; filter: brightness(0) invert(1); display: block; }
.side .brand-sub { font-size: 10.5px; letter-spacing: .14em; color: #9da1a5; margin: 8px 4px 26px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 0; color: var(--side-ink); padding: 11px 12px; border-radius: 10px; font-size: 14.5px; text-align: left; margin-bottom: 2px; }
.nav button:hover { background: rgba(255,255,255,.06); }
.nav button.active { background: #fff; color: var(--ink); font-weight: 600; }
.side .me { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; display: flex; align-items: center; gap: 10px; position: relative; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e7e7e5; color: var(--ink); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.side .me .avatar { background: #f1f1ef; }
.me-name { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.me-role { font-size: 11.5px; color: #9da1a5; }
.me .icon-btn { margin-left: auto; background: transparent; border: 0; color: #fff; }
.menu-pop { position: absolute; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 6px; min-width: 200px; z-index: 50; }
.menu-pop button { display: flex; width: 100%; gap: 10px; align-items: center; background: none; border: 0; padding: 9px 10px; border-radius: 8px; font-size: 14px; text-align: left; }
.menu-pop button:hover { background: var(--bg); }
.menu-pop button.danger { color: var(--red); }
.side .menu-pop { bottom: 54px; left: 0; right: 0; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(244,244,243,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 14px 28px; display: flex; align-items: center; gap: 12px; }
.topbar .eyebrow { font-size: 10.5px; letter-spacing: .14em; color: var(--ink-3); font-weight: 700; }
.topbar h1 { font-size: 20px; font-weight: 500; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; position: relative; }
.topbar .actions .menu-pop { top: 46px; right: 0; }
.content { padding: 26px 28px 80px; max-width: 1180px; }
.mobile-nav { display: none; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-head .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.link-btn { background: none; border: 0; font-weight: 600; font-size: 13px; padding: 4px; }
.welcome { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.welcome .date { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.welcome h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; margin: 6px 0 4px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { display: flex; gap: 14px; align-items: center; padding: 18px; }
.stat .ic { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--grey-bg); flex: none; }
.stat .ic.amber { background: var(--amber-bg); color: var(--amber); }
.stat .ic.blue { background: #e8eef8; color: #2d5aa0; }
.stat b { font-size: 24px; display: block; }
.stat span { font-size: 12.5px; color: var(--ink-2); }
.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.grid-2.even { grid-template-columns: 1fr 1fr; }

.work-row { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.work-row:last-child { border-bottom: 0; }
.work-row:hover { background: #fafaf9; }
.letter { width: 36px; height: 36px; border-radius: 9px; background: var(--grey-bg); display: grid; place-items: center; font-family: var(--serif); font-size: 16px; flex: none; }
.work-row .info { min-width: 0; flex: 1.2; }
.work-row .info b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-row .info small { color: var(--ink-2); font-size: 12px; }
.progress { flex: 1; min-width: 110px; }
.progress .lbl { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); margin-bottom: 5px; }
.progress .lbl b { color: var(--ink); }
.bar { height: 5px; background: var(--grey-bg); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--grey-bg); white-space: nowrap; }
.pill.Pendiente { background: var(--amber-bg); color: var(--amber); }
.pill.Finalizada { background: var(--green-bg); color: var(--green); }
.pill.overdue { background: var(--red-bg); color: var(--red); }
.pill.role-admin { background: #e8eef8; color: #2d5aa0; }
.pill.off { background: #f1f1f1; color: #888; }

.task-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-row input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--accent); flex: none; margin: 0; }
.task-row .t { flex: 1; min-width: 0; }
.task-row .t b { font-size: 13.5px; font-weight: 600; display: block; }
.task-row .t small { font-size: 11.5px; color: var(--ink-2); }
.task-row.done .t b { color: var(--ink-2); }

.report { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; }
.report:last-child { border-bottom: 0; }
.report .body { flex: 1; min-width: 0; }
.report .head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.report .head b { font-size: 14px; }
.report .meta { font-size: 12px; color: var(--ink-2); margin: 2px 0 6px; }
.report p { margin: 0; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attachment-link { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-decoration: none; }
.empty { padding: 34px 18px; text-align: center; color: var(--ink-2); font-size: 14px; }
.empty b { display: block; color: var(--ink); margin: 6px 0 2px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 220px)); gap: 12px; padding: 0 18px 18px; }
.filters label.field { margin: 0; }

.hero { background: var(--side); color: #fff; border-radius: var(--radius); padding: 22px 24px; display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.hero .letter { background: rgba(255,255,255,.95); color: var(--ink); width: 48px; height: 48px; font-size: 22px; }
.hero h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; }
.hero small { color: #c4c6c8; }
.hero .pct { margin-left: auto; text-align: right; }
.hero .pct b { font-size: 28px; display: block; }
.hero .icon-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); }
.back { background: none; border: 0; color: var(--ink-2); font-size: 13.5px; margin-bottom: 14px; padding: 0; }

.worker-hero { background: var(--side); color: #fff; border-radius: 18px; padding: 24px 22px; margin-bottom: 14px; }
.worker-hero .date { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #b8babd; }
.worker-hero h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 6px 0 4px; }
.worker-hero p { margin: 0 0 16px; color: #d0d2d4; font-size: 14px; }
.worker-hero label span { color: #fff; }
.worker-hero select { font-weight: 600; }
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.big-action { display: flex; align-items: center; gap: 14px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; }
.big-action .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--grey-bg); display: grid; place-items: center; flex: none; }
.big-action b { display: block; font-size: 15px; }
.big-action small { color: var(--ink-2); font-size: 12.5px; }
.big-action .chev { margin-left: auto; }
.worker-content { max-width: 720px; margin: 0 auto; padding: 18px 16px 60px; }
.worker-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--side); color: #fff; position: relative; }
.worker-top .logo { height: 24px; filter: brightness(0) invert(1); }
.worker-top .menu-pop { top: 52px; right: 10px; }
.worker-top .icon-btn { background: transparent; border-color: rgba(255,255,255,.25); color: #fff; }
.last-report { font-size: 13px; color: var(--ink-2); text-align: center; margin-top: 14px; }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; padding: 18px; }
.person { border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-align: center; position: relative; }
.person .avatar { margin: 0 auto 10px; width: 46px; height: 46px; }
.person b { display: block; font-size: 15px; }
.person .u { font-size: 12.5px; color: var(--ink-2); margin: 3px 0 8px; }
.person .seen { font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.person .row-actions { position: absolute; top: 10px; right: 10px; }
.person.inactive { opacity: .6; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; padding: 14px 18px; }
.photo-grid button { border: 0; padding: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: var(--grey-bg); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

.doc-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.doc-item:last-child { border-bottom: 0; }
.doc-item .t { flex: 1; min-width: 0; }
.doc-item .t b { font-size: 14px; display: block; }
.doc-item .t small { font-size: 12px; color: var(--ink-2); }

.hours-total { padding: 18px; }
.hours-total b { font-size: 30px; display: block; font-family: var(--serif); font-weight: 400; }
.hours-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; margin-top: 14px; align-items: start; }
.hours-cards { display: grid; gap: 10px; }
details.worker-hours { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
details.worker-hours summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
details.worker-hours summary::-webkit-details-marker { display: none; }
details.worker-hours summary .h { margin-left: auto; font-weight: 700; font-size: 17px; }
details.worker-hours .inner { border-top: 1px solid var(--line); padding: 10px 16px 14px; font-size: 13.5px; }
.hour-line { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.hour-line:last-child { border-bottom: 0; }
.hour-sub { font-weight: 700; margin: 10px 0 4px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }

/* ---------- drawer, modales ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20,21,22,.45); z-index: 100; display: flex; justify-content: flex-end; }
.drawer { background: #fff; width: 100%; max-width: 460px; height: 100%; overflow-y: auto; padding: 22px 22px 30px; display: flex; flex-direction: column; animation: slidein .18s ease-out; }
@keyframes slidein { from { transform: translateX(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.drawer .eyebrow { font-size: 10.5px; letter-spacing: .14em; color: var(--ink-3); font-weight: 700; }
.drawer h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 4px 0 20px; }
.drawer .close { position: absolute; right: 18px; top: 18px; }
.drawer-head { position: relative; }
.drawer-foot { display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }
.overlay.center { justify-content: center; align-items: center; padding: 20px; }
.confirm-box { background: #fff; border-radius: 16px; padding: 22px; max-width: 400px; width: 100%; }
.confirm-box h3 { font-size: 17px; margin-bottom: 8px; }
.confirm-box p { color: var(--ink-2); margin: 0 0 18px; font-size: 14px; line-height: 1.45; }
.confirm-box .row { display: flex; justify-content: flex-end; gap: 10px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; background: var(--grey-bg); border-radius: 10px; padding: 14px; text-align: center; letter-spacing: .03em; margin: 6px 0 14px; user-select: all; }
.photo-viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 120; display: flex; align-items: center; justify-content: center; }
.photo-viewer img { max-width: 92vw; max-height: 82vh; border-radius: 6px; }
.photo-viewer figcaption { color: #ddd; text-align: center; font-size: 13px; margin-top: 10px; }
.photo-viewer .pv-btn { position: absolute; background: rgba(255,255,255,.12); border: 0; color: #fff; width: 46px; height: 46px; border-radius: 50%; font-size: 22px; }
.pv-close { top: 16px; right: 16px; }
.pv-prev { left: 16px; top: 50%; }
.pv-next { right: 16px; top: 50%; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--side); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 200; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--red); }

.budget-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.budget-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.budget-item:last-child { border-bottom: 0; }
.budget-item input[type=checkbox] { margin-top: 10px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.budget-item textarea { min-height: 40px; font-size: 14px; padding: 7px 9px; }
.budget-chapter { background: var(--grey-bg); font-size: 12px; font-weight: 700; padding: 6px 10px; text-transform: uppercase; letter-spacing: .04em; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { min-height: 60vh; display: grid; place-items: center; color: var(--ink-2); }

/* ---------- móvil ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 18px; }
  .content { padding: 16px 14px 96px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .grid-2, .grid-2.even, .hours-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .welcome { flex-direction: column; align-items: flex-start; }
  .welcome h2 { font-size: 27px; }
  .work-row { flex-wrap: wrap; padding: 12px 14px; }
  .work-row .progress { order: 5; flex-basis: 100%; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 40; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .mobile-nav button { flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; padding: 6px 2px; color: var(--ink-2); }
  .mobile-nav button.active { color: var(--ink); font-weight: 700; }
  .hero { flex-wrap: wrap; padding: 18px; }
  .hero h2 { font-size: 23px; }
  .big-actions { grid-template-columns: 1fr; }
  .drawer { max-width: 100%; padding: 18px 16px 24px; }
  table.data th, table.data td { padding: 10px; }
  .hide-mobile { display: none; }
}
