/* PartesTec · estilos. Para igualar granjatec.online ajuste solo las variables de :root
   (tipografía en config.php: font_url / font_family). */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --primary: #1f6f43;
  --primary-2: #2e8b57;
  --primary-ink: #ffffff;
  --accent: #f2a900;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --ink: #1d2a22;
  --muted: #66746b;
  --line: #dfe5df;
  --danger: #c62828;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 24, .06), 0 4px 14px rgba(16, 40, 24, .06);
  /* Colores del calendario */
  --c-verde: #2e9e4f;
  --c-rojo: #e0453a;
  --c-azul: #2f74d0;
  --c-naranja: #f08c1a;
  --c-violeta: #8a4fc9;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45;
  color: var(--ink); background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--primary); }
h1 { font-size: 1.35rem; margin: .2em 0 .6em; font-weight: 700; }
h2 { font-size: 1.1rem; margin: 0 0 .8em; font-weight: 600; }
h3 { font-size: .95rem; margin: 1.4em 0 .3em; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; }
.warn-text { color: var(--danger); }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--primary); color: var(--primary-ink);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-size: 1.15rem; letter-spacing: .2px; }
.brand b { color: var(--accent); }
.menu-btn { margin-left: auto; background: none; border: 0; color: inherit; font-size: 1.5rem; padding: 4px 8px; cursor: pointer; }
.nav { display: none; }
.nav a { color: inherit; text-decoration: none; padding: 10px 12px; border-radius: 10px; opacity: .9; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.14); opacity: 1; }
body.nav-open .nav {
  display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0;
  background: var(--primary); padding: 6px 10px 12px; box-shadow: 0 8px 16px rgba(0,0,0,.15);
}
.nav-static { display: flex; margin-left: auto; }
@media (min-width: 860px) {
  .menu-btn { display: none; }
  .nav, body.nav-open .nav { display: flex; flex-direction: row; position: static; margin-left: auto; padding: 0; box-shadow: none; background: none; }
}

.wrap { max-width: 920px; margin: 0 auto; padding: 16px; }

/* ---------- Tarjetas y formularios ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
label { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
.field { display: block; }
.lbl { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; min-height: 46px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(46,139,87,.18); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; display: inline-block; margin: 0 6px 0 0; accent-color: var(--primary); }
input[type=file] { padding: 8px; }
input[readonly] { background: var(--bg); }
.check { display: flex; align-items: center; color: var(--ink); }
.invalid, .invalid input, .combo.invalid .combo-in { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(198,40,40,.14) !important; }
.item.invalid { box-shadow: 0 0 0 2px var(--danger) !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.w-half { max-width: 220px; }
.row-form { display: flex; gap: 8px; align-items: center; }
.row-form input, .row-form select { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; word-break: break-all; }
@media (max-width: 520px) { .user-form .grid2 { grid-template-columns: 1fr; } }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-danger-text { color: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 54px; font-size: 1.05rem; margin-bottom: 14px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn-icon { width: 44px; padding: 0; font-size: 1.5rem; }
.btn-dashed { border: 2px dashed var(--line); background: transparent; color: var(--primary); margin-bottom: 14px; }
.x { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.x:hover { color: var(--danger); background: rgba(198,40,40,.08); }

/* ---------- Avisos ---------- */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .95rem; }
.alert-ok { background: #e6f4ea; color: #1e5631; }
.alert-error { background: #fdecea; color: #8e1c1c; }
.alert-warn { background: #fff4e0; color: #7a4b00; }

/* ---------- Login ---------- */
.login-page .wrap { display: flex; min-height: calc(100vh - 60px); align-items: center; justify-content: center; }
.login-box { width: 100%; max-width: 400px; padding: 26px 22px; }
.lang-switch { display: flex; justify-content: center; gap: 6px; margin-top: 16px; }
.lang-switch a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.lang-switch a.on { background: var(--bg); color: var(--primary); font-weight: 600; }

/* ---------- Calendario ---------- */
.cal-head { margin-bottom: 8px; }
.cal-user { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.cal-user select { margin: 0; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 12px; }
.cal-nav h1, .cal-nav h2 { margin: 0; text-align: center; flex: 1; }
.calendar { padding: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow span { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal-day {
  aspect-ratio: 1 / 1; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--bg); color: var(--ink); text-decoration: none;
  border: 2px solid transparent; position: relative;
}
.cal-day b { font-size: 1rem; font-weight: 600; }
.cal-day small { font-size: .66rem; line-height: 1.1; opacity: .95; }
.cal-day.empty { background: none; }
.cal-day.weekend:not([class*=" c-"]) { background: #eceeea; }
.cal-day.future { opacity: .35; }
.cal-day.today { border-color: var(--ink); }
.cal-day[class*=" c-"] { color: #fff; }
.c-verde { background: var(--c-verde) !important; }
.c-rojo { background: var(--c-rojo) !important; }
.c-azul { background: var(--c-azul) !important; }
.c-naranja { background: var(--c-naranja) !important; }
.c-violeta { background: var(--c-violeta) !important; }
a.cal-day:hover { filter: brightness(.95); }
.cal-summary { display: flex; gap: 12px; }
.stat { flex: 1; }
.stat span { display: block; color: var(--muted); font-size: .82rem; }
.stat b { font-size: 1.3rem; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .88rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .dot { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }

/* ---------- Editor de parte ---------- */
.parte-page .wrap { padding-bottom: 110px; }
.parte-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.parte-head h1 { margin: 0; font-size: 1.15rem; }
.parte-head p { margin: 0; font-size: .88rem; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 6px 4px; border-radius: 10px; border: 1px solid var(--line);
  font-size: .85rem; font-weight: 600; color: var(--ink); cursor: pointer; background: #fff;
}
.seg-trabajo input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg-vacaciones input:checked + span { background: var(--c-azul); border-color: var(--c-azul); color: #fff; }
.seg-baja input:checked + span { background: var(--c-violeta); border-color: var(--c-violeta); color: #fff; }
.seg-personal input:checked + span { background: var(--c-naranja); border-color: var(--c-naranja); color: #fff; }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(46,139,87,.3); }

.linea { padding: 0; overflow: visible; border-left: 4px solid var(--primary); }
.linea-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 12px 14px; cursor: pointer; }
.linea-num { font-weight: 700; white-space: nowrap; }
.linea-res { flex: 1; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linea:not(.collapsed) .linea-res { visibility: hidden; }
.dur { font-weight: 700; color: var(--primary); white-space: nowrap; }
.linea-body { padding: 0 14px 14px; }
.linea.collapsed .linea-body { display: none; }

.subs { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.sub { border: 1px solid var(--line); border-radius: 12px; background: #fafbf9; }
.sub-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; }
.sub-title { font-weight: 600; font-size: .95rem; }
.sub-add { margin-left: auto; }
.sub-items:empty { display: none; }
.badge:not(:empty) { background: var(--primary); color: #fff; border-radius: 99px; font-size: .75rem; padding: 1px 8px; }
.sub-items { padding: 0 10px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 10px; margin-bottom: 8px; }
.item-head { display: flex; align-items: center; justify-content: space-between; }
.item-title { font-size: .82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.item .field { margin-bottom: 8px; }

.adj-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.adj-chip { display: flex; align-items: center; gap: 2px; background: var(--bg); border-radius: 10px; padding: 3px 3px 3px 4px; max-width: 100%; }
.adj-link { display: flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; font-size: .82rem; min-width: 0; }
.adj-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.adj-link img { width: 40px; height: 40px; object-fit: cover; border-radius: 7px; }
.adj-ico { font-size: 1.4rem; width: 40px; text-align: center; }
.adj-btns { display: flex; gap: 6px; }
.adj-btns label { margin: 0; color: var(--ink); }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.14); max-height: 280px; overflow-y: auto;
}
.combo-list li { padding: 11px 10px; border-radius: 8px; cursor: pointer; color: var(--ink); font-size: .95rem; }
.combo-list li:hover { background: var(--bg); }
.combo-list li.none { color: var(--muted); cursor: default; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--surface); box-shadow: 0 -4px 16px rgba(0,0,0,.08);
}
.savebar > div { flex: 1; }
.savebar small { display: block; color: var(--muted); font-size: .75rem; }
.total-h { font-size: 1.25rem; }
.total-h.ok { color: var(--c-verde); }
.total-h.ko { color: var(--c-rojo); }
.savebar .btn-primary { min-width: 150px; min-height: 50px; }

.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20,30,24,.45); display: flex; align-items: center; justify-content: center; }
.overlay-box { background: #fff; border-radius: var(--radius); padding: 24px; width: min(320px, 90vw); text-align: center; }
.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--primary); border-radius: 50%; margin: 0 auto 10px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* ---------- Tablas y administración ---------- */
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; margin: -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.off td, .tipo-row.off { opacity: .5; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); white-space: nowrap; }
.tag-admin { background: #fde7c6; }
.tag-encargado { background: #d9ecff; }
.tipos-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.tipo-row { display: flex; gap: 8px; align-items: center; }
.tipo-row input { margin: 0; }
.tipo-row .w-orden { width: 70px; flex: none; }
.tipo-row .check { margin: 0; white-space: nowrap; font-size: .85rem; }
pre.code { background: #1d2a22; color: #e6efe8; padding: 12px; border-radius: 10px; overflow-x: auto; font-size: .8rem; white-space: pre; }
.info-nolab { text-align: center; }

@media (max-width: 380px) {
  .seg span { font-size: .78rem; }
  .wrap { padding: 12px; }
}
