/* ==========================================================================
   Gestión de Obras — sistema de diseño "industrial-premium"
   Sidebar oscuro + panel de trabajo cálido. Amber eléctrico como acento.
   Responsive de verdad: app de escritorio con sidebar / móvil con nav inferior.
   Marca (paleta) entra por config.js → brand.{accent, accentDark, accentSoft, onAccent, sidebar, sidebar2, paper, line, line2, ink}.
   ========================================================================== */
:root {
  --accent: #F49E0B;
  --accent-strong: #E0860A;
  --accent-soft: #FDF3E0;
  --accent-rgb: 244,158,11;   /* se recalcula desde config.brand.accent */
  --on-accent: #1A1206;       /* texto sobre el acento (config.brand.onAccent) */
  --ink: #16181D;
  --ink-2: #22252C;
  --ink-soft: #4B505A;
  --muted: #8A909C;
  --paper: #F7F5F1;
  --card: #FFFFFF;
  --line: #EBE7DF;
  --line-2: #E2DDD3;
  --blue: #2D6BFF;
  --blue-soft: #EAF0FF;
  --ok: #199A5B;
  --ok-soft: #E6F5EC;
  --warn: #C98A00;
  --warn-soft: #FBF1D8;
  --danger: #D64545;
  --danger-soft: #FBE9E9;
  --sidebar: #16181D;
  --sidebar-2: #1F232B;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(20,22,28,.05), 0 1px 3px rgba(20,22,28,.04);
  --shadow: 0 2px 6px rgba(20,22,28,.05), 0 12px 32px rgba(20,22,28,.07);
  --shadow-lg: 0 20px 60px rgba(20,22,28,.16);
  --sbw: 250px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, .num { font-family: var(--font-display); letter-spacing: -.02em; }
a { color: inherit; }
button { font-family: inherit; }

/* ======================= LAYOUT ======================= */
.layout { display: flex; min-height: 100vh; }

/* --- Sidebar (escritorio) --- */
.sidebar {
  width: var(--sbw); flex: 0 0 var(--sbw);
  background: var(--sidebar);
  color: #EDEEF1;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
  display: flex; flex-direction: column;
  padding: 22px 16px calc(18px + var(--safe-bottom));
  border-right: 1px solid #000;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.sidebar .brand .logo { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(145deg, var(--accent), var(--accent-strong)); color: var(--on-accent); display: grid; place-items: center; font-family: var(--font-display); font-weight: 900; font-size: 17px; box-shadow: 0 6px 16px rgba(var(--accent-rgb),.35); }
.sidebar .brand .bn { font-family: var(--font-display); font-weight: 800; font-size: 16px; line-height: 1.1; }
.sidebar .brand .bt { font-size: 11.5px; color: #8C93A1; margin-top: 2px; }
.sidebar .nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.sidebar .nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px; color: #B7BDC9; text-decoration: none; font-weight: 600; font-size: 14.5px; transition: background .12s, color .12s; }
.sidebar .nav a .ic { font-size: 18px; width: 22px; text-align: center; }
.sidebar .nav a:hover { background: var(--sidebar-2); color: #fff; }
.sidebar .nav a.on { background: linear-gradient(100deg, rgba(var(--accent-rgb),.16), rgba(var(--accent-rgb),.06)); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar .foot { margin-top: auto; border-top: 1px solid #2A2E37; padding-top: 12px; }
.sidebar .user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 11px; }
.sidebar .user .av { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.sidebar .user .un { font-weight: 700; font-size: 13.5px; }
.sidebar .user .ur { font-size: 11.5px; color: #8C93A1; }
.sidebar .logout { background: none; border: none; color: #8C93A1; cursor: pointer; font-size: 18px; margin-left: auto; padding: 6px; }
.sidebar .logout:hover { color: #fff; }

/* --- Main --- */
.main { flex: 1 1 auto; margin-left: var(--sbw); min-width: 0; display: flex; flex-direction: column; }
.main-inner { width: 100%; max-width: 1120px; margin: 0 auto; padding: 26px 34px 60px; flex: 1; }

/* --- Topbar móvil (oculta en escritorio) --- */
.mtop { display: none; }

/* --- Bottom nav (móvil) --- */
.bottomnav { display: none; }

/* ======================= CABECERA DE PÁGINA ======================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head .h { font-size: 27px; font-weight: 800; line-height: 1.1; }
.page-head .s { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head .actions { display: flex; gap: 10px; }

/* ======================= KPIs ======================= */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -18px; top: -18px; width: 60px; height: 60px; border-radius: 50%; background: var(--accent-soft); opacity: .7; }
.kpi .k-ic { font-size: 17px; position: relative; }
.kpi .num { font-size: 30px; font-weight: 800; line-height: 1; margin-top: 8px; position: relative; }
.kpi .l { font-size: 12.5px; color: var(--muted); margin-top: 5px; font-weight: 500; position: relative; }
.kpi.alert::after { background: var(--danger-soft); }

/* ======================= GRID DASHBOARD ======================= */
.dash { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel > .p-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel > .p-head .pt { font-family: var(--font-display); font-weight: 800; font-size: 15px; }
.panel > .p-body { padding: 14px 16px; }

/* ---- Navegador de fecha + tira de semana ---- */
.datenav { display: flex; align-items: center; gap: 8px; }
.datenav button { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--card); cursor: pointer; font-size: 15px; color: var(--ink-soft); }
.datenav button:hover { background: var(--paper); }
.datenav .lbl { font-family: var(--font-display); font-weight: 700; font-size: 14px; min-width: 96px; text-align: center; text-transform: capitalize; }
.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 4px 16px 14px; }
.weekstrip .d { text-align: center; padding: 8px 2px; border-radius: 11px; cursor: pointer; border: 1px solid transparent; position: relative; }
.weekstrip .d:hover { background: var(--paper); }
.weekstrip .d.sel { background: var(--ink); color: #fff; }
.weekstrip .d.today:not(.sel) { border-color: var(--accent); }
.weekstrip .d .wd { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.weekstrip .d.sel .wd { color: #C9CDd6; }
.weekstrip .d .dn { font-family: var(--font-display); font-weight: 800; font-size: 16px; margin-top: 1px; }
.weekstrip .d .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin: 3px auto 0; }
.weekstrip .d.sel .dot { background: var(--accent); }

/* ======================= TARJETA DE OBRA ======================= */
.wgroup { margin: 6px 2px 4px; display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 15px; margin-bottom: 11px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .12s ease, border-color .12s;
  cursor: pointer;
}
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.card:active { transform: scale(.995); }
.card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card .title { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.card .meta { color: var(--ink-soft); font-size: 13.5px; margin-top: 3px; }
.card .meta.addr { color: var(--muted); display: flex; align-items: center; gap: 5px; }
.card .foot { display: flex; align-items: center; gap: 9px; margin-top: 11px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.card .foot .who { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-weight: 600; }

.avatar { width: 24px; height: 24px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; flex: 0 0 auto; }

/* ======================= CHIPS ======================= */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.pendiente { background: var(--warn-soft); color: #A97400; }
.chip.curso     { background: var(--blue-soft); color: #2456D6; }
.chip.hecha     { background: var(--ok-soft); color: #147A47; }
.chip.facturada { background: #EEEDEA; color: #6A6E76; }

/* ======================= AVISOS ======================= */
.aviso { display: flex; gap: 12px; padding: 13px 14px; border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--line); margin-bottom: 10px; }
.aviso .ai { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; flex: 0 0 auto; }
.aviso.rojo .ai { background: var(--danger-soft); }
.aviso.ambar .ai { background: var(--warn-soft); }
.aviso.azul .ai { background: var(--blue-soft); }
.aviso .at { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.aviso .as { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.aviso .act { margin-left: auto; align-self: center; font-size: 12.5px; font-weight: 700; color: var(--accent-strong); background: none; border: none; cursor: pointer; white-space: nowrap; }

/* ======================= FILTROS ======================= */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 14px; margin-bottom: 4px; }
.filters button { flex: 0 0 auto; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-soft); font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ======================= LISTAS EN GRID (escritorio) ======================= */
.obras-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.obras-grid .card { margin-bottom: 0; }

/* ======================= BOTONES ======================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 12px 18px; font-size: 14.5px; font-weight: 700; cursor: pointer; font-family: var(--font-body); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px rgba(var(--accent-rgb),.28); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--paper); }
.btn.block { width: 100%; }
.btn.big { padding: 16px; font-size: 15.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* FAB (solo móvil) */
.fab { display: none; }

/* ======================= FORMULARIOS ======================= */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px; max-width: 620px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: 11px; padding: 12px 13px;
  font-size: 15px; font-family: inherit; background: var(--card); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { min-height: 96px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ======================= DETALLE OBRA ======================= */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.parte { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 14px; margin-bottom: 11px; }
.parte .h { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; }
.parte .h .who { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); font-weight: 600; }
.parte .body { font-size: 14px; }
.parte img { width: 100%; border-radius: 10px; margin-top: 9px; }
.parte .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.tag { font-size: 11.5px; background: var(--card); border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 10px; color: var(--ink-soft); }

/* ======================= CAPTURA (pantalla estrella) ======================= */
.capture-hero { background: radial-gradient(120% 120% at 50% 0%, var(--ink-2), var(--ink)); color: #fff; border-radius: var(--radius); padding: 24px 18px; text-align: center; margin-bottom: 18px; box-shadow: var(--shadow); }
.capture-hero .ch-t { font-size: 14px; color: #B7BDC9; margin-bottom: 14px; }
.mic { width: 92px; height: 92px; border-radius: 50%; border: none; margin: 0 auto 14px; display: grid; place-items: center; font-size: 36px; cursor: pointer; background: linear-gradient(145deg, var(--accent), var(--accent-strong)); color: var(--on-accent); box-shadow: 0 10px 30px rgba(var(--accent-rgb),.4); transition: transform .1s; }
.mic:active { transform: scale(.96); }
.mic.rec { background: linear-gradient(145deg, #E8574E, var(--danger)); color: #fff; animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(214,69,69,.5);} 70% { box-shadow: 0 0 0 24px rgba(214,69,69,0);} 100% { box-shadow: 0 0 0 0 rgba(214,69,69,0);} }
.capture-hero .status { font-size: 13.5px; color: #C9CDD6; min-height: 20px; }
.ai-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); padding: 6px 12px; border-radius: 999px; margin-bottom: 12px; }
.ai-badge.thinking { color: var(--blue); background: var(--blue-soft); }
.capture-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.cap-tile { background: var(--card); border: 1px solid var(--line-2); border-radius: 13px; padding: 15px; text-align: center; cursor: pointer; display: block; transition: border-color .12s, background .12s; }
.cap-tile:hover { border-color: var(--accent); }
.cap-tile .ic { font-size: 26px; }
.cap-tile .t { font-size: 13.5px; font-weight: 700; margin-top: 5px; }
.cap-tile .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cap-tile.done { border-color: var(--ok); background: var(--ok-soft); }
.cap-tile.done .s { color: #147A47; font-weight: 700; }
.photo-prev { width: 100%; border-radius: 12px; margin-bottom: 14px; display: block; box-shadow: var(--shadow-sm); }

/* ======================= PRESUPUESTO ======================= */
.line-row { display: grid; grid-template-columns: 1fr 60px 84px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.line-row input { padding: 10px; font-size: 14px; }
.line-row .del { background: none; border: none; color: var(--danger); font-size: 20px; cursor: pointer; }
.total-bar { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; background: var(--ink); color: #fff; border-radius: 13px; font-weight: 700; margin: 12px 0 16px; }
.total-bar .big { font-family: var(--font-display); font-size: 24px; font-weight: 800; }

/* ======================= VARIOS ======================= */
.section-title { font-family: var(--font-display); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 24px 2px 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .ic { font-size: 42px; opacity: .5; display: block; margin-bottom: 6px; }
.back-link { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13.5px; margin-bottom: 14px; cursor: pointer; background: none; border: none; padding: 0; }
.back-link:hover { color: var(--ink); }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 90; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ======================= LOGIN (selector de rol) ======================= */
.login { min-height: 100vh; display: grid; place-items: center; padding: 30px; background:
  radial-gradient(90% 70% at 15% 10%, rgba(var(--accent-rgb),.18), transparent 60%),
  radial-gradient(80% 60% at 90% 100%, rgba(45,107,255,.12), transparent 55%),
  var(--ink); }
.login-box { width: 100%; max-width: 400px; color: #fff; }
.login .logo-big { width: 62px; height: 62px; border-radius: 17px; background: linear-gradient(145deg, var(--accent), var(--accent-strong)); color: var(--on-accent); display: grid; place-items: center; font-family: var(--font-display); font-weight: 900; font-size: 24px; box-shadow: 0 12px 30px rgba(var(--accent-rgb),.4); margin-bottom: 20px; }
.login h1 { font-size: 28px; margin: 0 0 4px; }
.login .lp { color: #9CA2AE; margin: 0 0 30px; }
.role-card { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12); border-radius: 15px; padding: 16px; margin-bottom: 12px; cursor: pointer; display: flex; align-items: center; gap: 14px; color: #fff; text-align: left; width: 100%; transition: background .12s, border-color .12s; }
.role-card:hover { background: rgba(255,255,255,.09); border-color: rgba(var(--accent-rgb),.5); }
.role-card .ic { font-size: 26px; }
.role-card .rt { font-weight: 700; }
.role-card .rs { font-size: 12.5px; color: #9CA2AE; }
.login .demo-note { font-size: 12px; color: #7D828D; text-align: center; margin-top: 20px; }

/* ======================= RESPONSIVE: MÓVIL ======================= */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .main-inner { padding: 0 0 calc(84px + var(--safe-bottom)); max-width: 560px; }

  .mtop { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30;
    padding: calc(12px + var(--safe-top)) 18px 12px; background: var(--ink); color: #fff; }
  .mtop .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(145deg, var(--accent), var(--accent-strong)); color: var(--on-accent); display: grid; place-items: center; font-family: var(--font-display); font-weight: 900; font-size: 14px; }
  .mtop .mt-n { font-family: var(--font-display); font-weight: 800; font-size: 16px; }
  .mtop .mt-s { font-size: 11.5px; color: #9CA2AE; }
  .mtop .logout { margin-left: auto; background: none; border: none; color: #9CA2AE; font-size: 18px; cursor: pointer; }

  .page-content { padding: 18px 16px 0; }
  .page-head { margin-bottom: 18px; }
  .page-head .h { font-size: 22px; }

  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
  .kpi .num { font-size: 26px; }
  .dash { grid-template-columns: 1fr; gap: 16px; }
  .detail-grid { grid-template-columns: 1fr; gap: 16px; }
  .obras-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .form-card { padding: 16px; border-radius: var(--radius-sm); }

  /* nav inferior */
  .bottomnav { display: block; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45; }
  .bottomnav .inner { max-width: 560px; margin: 0 auto; background: var(--card); border-top: 1px solid var(--line); display: flex; padding: 7px 0 calc(7px + var(--safe-bottom)); }
  .bottomnav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 3px; }
  .bottomnav a .ic { font-size: 20px; line-height: 1; }
  .bottomnav a.on { color: var(--accent-strong); }

  /* FAB */
  .fab { display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(80px + var(--safe-bottom)); width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(145deg, var(--accent), var(--accent-strong)); color: var(--on-accent); border: none; font-size: 30px; box-shadow: 0 10px 26px rgba(var(--accent-rgb),.5); cursor: pointer; z-index: 46; }
}

@media (min-width: 901px) {
  .page-content { display: block; }
}

/* ======================= DOCUMENTO (presupuesto / factura) ======================= */
.doc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 30px; max-width: 720px; }
.doc-top { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 2px solid var(--ink); }
.doc-emisor { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; }
.doc-brand { font-family: var(--font-display); font-weight: 800; font-size: 19px; color: var(--ink); margin-bottom: 4px; }
.doc-meta { text-align: right; }
.doc-type { font-family: var(--font-display); font-weight: 900; font-size: 20px; letter-spacing: .04em; color: var(--accent-strong); }
.doc-num { font-weight: 700; font-size: 14px; margin-top: 4px; }
.doc-date { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.doc-cliente { margin: 20px 0; }
.doc-cliente .dc-l { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.doc-cliente .dc-n { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin: 3px 0; }
.doc-cliente .dc-x { font-size: 12.5px; color: var(--ink-soft); }
.doc-table { width: 100%; border-collapse: collapse; margin: 10px 0 4px; }
.doc-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line-2); padding: 8px 6px; }
.doc-table td { padding: 11px 6px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.doc-table .r { text-align: right; white-space: nowrap; }
.doc-tot { margin-top: 14px; margin-left: auto; max-width: 300px; }
.doc-tot .dt-row { display: flex; justify-content: space-between; padding: 7px 6px; font-size: 14px; }
.doc-tot .dt-row.total { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 12px; font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.doc-foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); line-height: 1.6; }

/* Impresión de presupuesto */
/* Documento (presupuesto/factura) en móvil: evitar desbordamiento horizontal
   (el email/URL del emisor y la cabecera no podían encoger). */
@media (max-width: 560px) {
  .doc { padding: 20px 16px; }
  .doc-top { flex-wrap: wrap; gap: 12px; }
  .doc-emisor { min-width: 0; flex: 1 1 200px; overflow-wrap: anywhere; }
  .doc-meta { flex: 0 0 auto; }
  .doc-type { font-size: 18px; }
  .doc-table td { padding: 10px 4px; font-size: 13px; }
  .doc-table th { padding: 8px 4px; }
  .doc-tot { max-width: 100%; }
}

@media print {
  .doc { border: none; box-shadow: none; padding: 0; max-width: 100%; }
  body { background: #fff; }
  .sidebar, .bottomnav, .mtop, .fab, .no-print, .back-link { display: none !important; }
  .main { margin-left: 0; }
  .main-inner { padding: 0; max-width: 100%; }
}

/* ======================= FICHAJE / HORAS ======================= */
.fich { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; margin-bottom: 20px; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.fich .st { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.fich .st .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.fich .st .dot.in { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.fich .big { font-family: var(--font-display); font-size: 28px; font-weight: 800; line-height: 1.05; margin-top: 6px; }
.fich .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.fich .tramos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fich select { margin-top: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--card); font-family: inherit; font-size: 14px; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: 0 6px 16px rgba(214,69,69,.25); }
.btn.fichar { min-width: 160px; padding: 14px 18px; font-size: 15px; }
.hours-wrap { overflow-x: auto; }
.hours { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.hours th, .hours td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.hours th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hours th:first-child, .hours td:first-child { text-align: left; }
.hours td.today, .hours th.today { background: var(--accent-soft); }
.hours td.tot, .hours th.tot { font-weight: 800; color: var(--ink); }
.hours .who { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.frow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.frow:last-child { border-bottom: none; }
.frow .r { display: flex; align-items: center; gap: 10px; }
.frow .open { color: var(--ok); font-weight: 700; }
.frow .del { background: none; border: none; color: var(--danger); font-size: 18px; cursor: pointer; }
.frow .fix { background: none; border: none; color: var(--accent-strong); font-weight: 700; cursor: pointer; font-size: 13px; }
.grid-4 { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 8px; }
@media (max-width: 900px) {
  .fich { grid-template-columns: 1fr; }
  .fich .btn.fichar { width: 100%; }
  .bottomnav a { font-size: 10px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ======================= AYUDA DE LA DEMO (tour + menú) ======================= */
.helpbtn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.08); color: #fff; font-weight: 800; font-size: 14px; cursor: pointer; flex: none; margin-left: auto; }
.helpbtn:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.sidebar .user .helpbtn { margin-left: auto; margin-right: 2px; }
.sidebar .user .helpbtn + .logout { margin-left: 0; }
.mtop .helpbtn { margin-left: auto; margin-right: 8px; }
.mtop .helpbtn + .logout { margin-left: 0; }
.tour-spot { position: fixed; z-index: 9000; border-radius: 14px; pointer-events: none; box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px rgba(10,12,16,.62); transition: left .22s, top .22s, width .22s, height .22s; }
.tour-card { position: fixed; z-index: 9001; width: min(370px, calc(100vw - 24px)); background: var(--card); color: var(--ink); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 16px 18px 14px; }
.tour-card .k { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-strong); font-weight: 800; }
.tour-card .t { font-family: var(--font-display); font-size: 18px; font-weight: 800; margin: 4px 0 6px; letter-spacing: -.01em; }
.tour-card .x { font-size: 14px; color: var(--ink-soft); line-height: 1.5; }
.tour-card .btns { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.tour-card .chk { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 12px; cursor: pointer; }
.btn.sm { padding: 9px 13px; font-size: 13px; border-radius: 10px; }
.tlink { background: none; border: none; color: var(--muted); font-weight: 700; cursor: pointer; font-size: 13px; padding: 8px 6px; }
@media (max-width: 900px) {
  .tour-card.sheet { left: 12px !important; right: 12px; width: auto; top: auto !important; bottom: calc(80px + var(--safe-bottom)); }
  .tour-card.sheet.top { top: calc(12px + var(--safe-top)) !important; bottom: auto; }
}
#help-menu .hm-back { position: fixed; inset: 0; background: rgba(10,12,16,.55); z-index: 9002; }
#help-menu .hm { position: fixed; z-index: 9003; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 24px)); background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 20px; }
#help-menu .hm-t { font-family: var(--font-display); font-size: 19px; font-weight: 800; }
#help-menu .hm-s { font-size: 13px; color: var(--muted); margin: 4px 0 14px; }
#help-menu .hm-i { display: block; width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14.5px; font-weight: 700; cursor: pointer; margin-bottom: 8px; }
#help-menu .hm-i span { color: var(--muted); font-weight: 600; }
#help-menu .hm-i:hover { border-color: var(--accent); }
#help-menu .hm-chk { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--ink-soft); margin: 12px 2px 16px; cursor: pointer; line-height: 1.4; }

/* ======================= NAV CON 6 PESTAÑAS (móvil) ======================= */
@media (max-width: 900px) {
  .bottomnav a { font-size: 9.5px; letter-spacing: -.01em; gap: 2px; padding: 0 2px; }
  .bottomnav a .ic { font-size: 19px; }
}
