/* =========================================================
   Cablevisión Guadalquivir — Técnicos · Design System
   Paleta basada en el logo: dorado + gris oscuro
   ========================================================= */

:root {
  /* Marca */
  --gold: #D4A017;
  --gold-light: #F5D76E;
  --gold-dark: #B8860B;
  --ink: #2D2D2D;
  --ink-soft: #3a3a3a;

  /* Neutros */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --text: #1f2328;
  --text-2: #6b7280;
  --text-3: #9ca3af;

  /* Estados */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --purple: #8b5cf6;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

  /* Geometría */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --header-h: 60px;
  --nav-h: 64px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161719;
    --surface: #1f2123;
    --surface-2: #26282b;
    --border: #34373b;
    --text: #f3f4f6;
    --text-2: #a8adb5;
    --text-3: #7c828b;
    --shadow: 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

.app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- Tipografía ---------- */
h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 600; }
small { font-size: .8rem; }
.muted { color: var(--text-2); }
.tiny { font-size: .75rem; }
.center { text-align: center; }

/* ---------- Layout de pantalla ---------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
  animation: fade-in .25s ease;
}
.screen.no-nav { padding-bottom: var(--safe-bottom); }

.screen-body { padding: 16px; flex: 1; }

@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Header ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex; align-items: center; gap: 12px;
  padding-left: 14px; padding-right: 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.appbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.appbar .back { background: none; border: 0; color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 6px; }
.appbar .actions { display: flex; gap: 6px; align-items: center; }
.appbar .iconbtn { background: rgba(255,255,255,.12); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.appbar .iconbtn svg { width: 20px; height: 20px; }

.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.25); }
.sync-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.25); }
.sync-dot.pending { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,.25); }

/* ---------- Bottom Nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--text-3); font-size: .7rem; font-weight: 600;
  position: relative;
}
.bottom-nav a svg { width: 23px; height: 23px; }
.bottom-nav a.active { color: var(--gold-dark); }
@media (prefers-color-scheme: dark) { .bottom-nav a.active { color: var(--gold); } }
.bottom-nav a .nav-badge {
  position: absolute; top: 6px; right: 50%; transform: translateX(18px);
  background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: .95rem; font-weight: 600;
  padding: 13px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: transform .08s ease, filter .15s ease, background .15s; width: 100%;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--gold); color: #2a2300; }
.btn-primary:hover { filter: brightness(1.04); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-sm { padding: 9px 12px; font-size: .85rem; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 12px;
}
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.card-title svg { width: 18px; height: 18px; color: var(--gold-dark); }

/* ---------- Orden (tarjeta) ---------- */
.order-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 14px; margin-bottom: 12px; cursor: pointer;
  display: flex; gap: 12px; align-items: stretch; transition: box-shadow .15s, transform .08s;
  border-left: 4px solid var(--gold);
}
.order-card:active { transform: scale(.99); }
.order-card .time { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 52px; }
.order-card .time .h { font-weight: 800; font-size: 1.05rem; }
.order-card .time .d { font-size: .68rem; color: var(--text-2); }
.order-card .body { flex: 1; min-width: 0; }
.order-card .body .type { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.order-card .body .client { font-weight: 700; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-card .body .addr { font-size: .82rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-card .chev { align-self: center; color: var(--text-3); }

/* ---------- Badges de estado ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-pending { background: #fff7e6; color: #b45309; }
.badge-progress { background: #e6f0ff; color: #1d4ed8; }
.badge-done { background: #e6f9f0; color: #047857; }
.badge-closed { background: #eef0f2; color: #4b5563; }
.badge-urgent { background: #fde8e8; color: #b91c1c; }
@media (prefers-color-scheme: dark) {
  .badge-pending { background: rgba(245,158,11,.15); color: #fbbf24; }
  .badge-progress { background: rgba(59,130,246,.15); color: #93c5fd; }
  .badge-done { background: rgba(16,185,129,.15); color: #6ee7b7; }
  .badge-closed { background: rgba(156,163,175,.15); color: #cbd5e1; }
  .badge-urgent { background: rgba(239,68,68,.15); color: #fca5a5; }
}

/* Punto de tipo de trabajo */
.type-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, .textarea, select.input {
  width: 100%; font-family: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
.input:focus, .textarea:focus, select.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,160,23,.18); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }

/* ---------- Listas de datos (detalle) ---------- */
.data-row { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.data-row:last-child { border-bottom: 0; }
.data-row .k { color: var(--text-2); font-size: .82rem; min-width: 92px; }
.data-row .v { font-weight: 600; flex: 1; }
.data-row a.v { color: var(--info); text-decoration: none; }

/* ---------- Login ---------- */
.login {
  min-height: 100%; display: flex; flex-direction: column; justify-content: center;
  padding: 28px 24px calc(28px + var(--safe-bottom));
  background: radial-gradient(120% 80% at 50% -10%, #3a3a3a 0%, var(--ink) 55%, #1c1c1c 100%);
  color: #fff;
}
.login .logo-wrap { text-align: center; margin-bottom: 34px; }
.login .logo-wrap svg, .login .logo-wrap img { width: 220px; max-width: 78%; height: auto; }
.login .subtitle { text-align: center; color: #d8d8d8; margin-bottom: 26px; font-size: .92rem; }
.login .field label { color: #cfcfcf; }
.login .input { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.18); color: #fff; }
.login .input::placeholder { color: #9a9a9a; }
.login .input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,160,23,.25); }
.login .remember { display: flex; align-items: center; gap: 9px; color: #cfcfcf; font-size: .88rem; margin: 4px 0 20px; }
.login .demo-note { margin-top: 18px; text-align: center; font-size: .78rem; color: #b9b9b9; line-height: 1.5; }

/* ---------- Agenda ---------- */
.day-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.day-strip::-webkit-scrollbar { display: none; }
.day-pill {
  flex: 0 0 auto; width: 52px; padding: 9px 0; border-radius: 12px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer;
}
.day-pill .dow { font-size: .66rem; text-transform: uppercase; color: var(--text-2); font-weight: 700; }
.day-pill .num { font-size: 1.15rem; font-weight: 800; }
.day-pill .dotline { height: 5px; display: flex; gap: 2px; justify-content: center; margin-top: 3px; }
.day-pill .dotline i { width: 5px; height: 5px; border-radius: 50%; }
.day-pill.active { background: var(--gold); border-color: var(--gold); color: #2a2300; }
.day-pill.active .dow, .day-pill.active .num { color: #2a2300; }
.agenda-date-title { margin: 14px 2px 10px; font-weight: 700; text-transform: capitalize; }

/* ---------- Stats (dashboard) ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow-sm); display: block; text-decoration: none; color: inherit; cursor: pointer; transition: transform .08s, box-shadow .15s; }
a.stat:active { transform: scale(.97); }
a.stat:hover { box-shadow: var(--shadow); }
.stat .n { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat .l { font-size: .72rem; color: var(--text-2); margin-top: 5px; font-weight: 600; }
.stat.gold .n { color: var(--gold-dark); }
.stat.green .n { color: var(--success); }
.stat.blue .n { color: var(--info); }

.greeting { margin-bottom: 16px; }
.greeting h1 { font-size: 1.45rem; }
.greeting p { color: var(--text-2); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 12px; }
.section-head h2 { font-size: 1.05rem; }
.section-head a { color: var(--gold-dark); text-decoration: none; font-size: .85rem; font-weight: 600; }

/* ---------- Fotos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: grid; place-items: center; font-size: 14px; }
.photo-add { aspect-ratio: 1; border: 2px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-2); cursor: pointer; font-size: .72rem; font-weight: 600; }
.photo-add svg { width: 26px; height: 26px; }

/* ---------- Firma ---------- */
.sign-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.sign-canvas { display: block; width: 100%; height: 240px; touch-action: none; background: #fff; }
.sign-hint { text-align: center; color: var(--text-3); font-size: .82rem; padding: 8px; }

/* ---------- Toast ---------- */
.toast-container { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .9rem; font-weight: 500; max-width: 92%; animation: toast-in .25s ease; display: flex; align-items: center; gap: 9px; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast svg { width: 18px; height: 18px; flex: 0 0 auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Offline banner ---------- */
.offline-banner { position: fixed; top: var(--safe-top); left: 0; right: 0; z-index: 90; background: var(--warning); color: #422c00; text-align: center; font-size: .78rem; font-weight: 600; padding: 6px 10px; }

/* ---------- Estados vacíos / carga ---------- */
.empty { text-align: center; color: var(--text-2); padding: 48px 20px; }
.empty svg { width: 56px; height: 56px; opacity: .4; margin-bottom: 12px; }
.empty p { font-size: .9rem; }

.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: var(--radius); height: 86px; margin-bottom: 12px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-family: inherit; font-size: .8rem; color: var(--text); padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.chip:active { background: var(--surface-2); }
.fab-bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 16px calc(14px + var(--safe-bottom)); }
.list-reset { list-style: none; }
.big-ico { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(212,160,23,.14); color: var(--gold-dark); }
.big-ico svg { width: 24px; height: 24px; }
@media (prefers-color-scheme: dark) { .big-ico { color: var(--gold); } }
