/* ElectriWork (versión web/iPhone). Colores y medidas copiados de la app Android original. */
:root {
  --primary: #4F46E5;
  --primary-pale: #E0E7FF;
  --purple: #7C3AED;
  --green: #16A34A;  --green-pale: #DCFCE7;
  --orange: #F97316; --orange-pale: #FFEDD5;
  --teal: #0D9488;   --teal-pale: #CCFBF1;
  --blue: #2563EB;   --blue-pale: #DBEAFE;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --on-surface: #1E293B;
  --text-primary: #1E293B;
  --danger: #DC2626;
  --surface-variant: #E7E0EC;
  --on-surface-variant: #49454F;
  --card: #E6E0E9;
  --dialog: #ECE6F0;
  --nav-bg: #F3EDF7;
  --nav-indicator: #E8DEF8;
  --on-nav-indicator: #1D192B;
  --outline: #79747E;
  --btn: #4F46E5;
  --on-btn: #FFFFFF;
  --chip-selected: #E8DEF8;
  --snack-bg: #322F35;
  --snack-text: #F5EFF7;
  --grad: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 50%, #EC4899 100%);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --field-bg: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #E0E7FF;
    --bg: #0F172A;
    --surface: #1E293B;
    --on-surface: #F1F5F9;
    --surface-variant: #49454F;
    --on-surface-variant: #CAC4D0;
    --card: #36343B;
    --dialog: #2B2930;
    --nav-bg: #211F26;
    --nav-indicator: #4A4458;
    --on-nav-indicator: #E8DEF8;
    --outline: #938F99;
    --btn: #E0E7FF;
    --on-btn: #1E293B;
    --chip-selected: #4A4458;
    --snack-bg: #E6E0E9;
    --snack-text: #322F35;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--on-surface);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Roboto", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
svg { display: block; fill: currentColor; }

#app { min-height: 100%; }
.screen {
  min-height: 100vh;
  padding: calc(16px + var(--safe-top)) 16px calc(96px + var(--safe-bottom));
}
.screen.no-nav { padding-bottom: calc(24px + var(--safe-bottom)); }
.stack > * + * { margin-top: 12px; }
.stack.s16 > * + * { margin-top: 16px; }
.stack.s16 > .grad-card + .sec { margin-top: 20px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--on-surface-variant); }

/* Tipografía (Type.kt) */
.h-large  { font-weight: 700; font-size: 28px; line-height: 34px; }
.h-medium { font-weight: 700; font-size: 22px; line-height: 28px; }
.h-small  { font-weight: 400; font-size: 24px; line-height: 32px; }
.t-large  { font-weight: 600; font-size: 20px; line-height: 26px; }
.t-medium { font-weight: 600; font-size: 16px; line-height: 22px; }
.b-large  { font-weight: 400; font-size: 16px; line-height: 22px; }
.b-medium { font-weight: 400; font-size: 14px; line-height: 20px; }
.l-large  { font-weight: 500; font-size: 14px; line-height: 18px; }
.l-medium { font-weight: 500; font-size: 12px; line-height: 16px; }

/* Encabezado degradado */
.grad-card {
  background: var(--grad);
  color: #fff;
  border-radius: 22px;
  padding: 18px;
}
.grad-card .sub { color: rgba(255,255,255,.9); }
.date-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.18);
  border-radius: 50px;
  padding: 8px 16px;
  margin-top: 14px;
}
.date-pill svg { width: 20px; height: 20px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat {
  background: rgba(255,255,255,.16);
  border-radius: 14px;
  padding: 8px;
  display: flex; flex-direction: column; align-items: center;
}
.stat .lbl { display: flex; align-items: center; gap: 3px; color: rgba(255,255,255,.9); }
.stat .lbl svg { width: 12px; height: 12px; }
.stat .val { font-weight: 600; font-size: 20px; line-height: 26px; }

.btn-grad {
  width: 100%;
  background: var(--grad);
  color: #fff;
  border-radius: 16px;
  min-height: 52px;
  padding: 6px 16px;
  font-weight: 600; font-size: 16px; line-height: 22px;
}
.btn-grad.small { border-radius: 14px; min-height: 48px; }
.btn-primary {
  width: 100%;
  background: var(--btn); color: var(--on-btn);
  border-radius: 14px;
  min-height: 52px;
  font-weight: 600; font-size: 16px;
}
.btn-outline {
  border: 1px solid var(--outline);
  color: var(--primary);
  border-radius: 14px;
  min-height: 40px;
  padding: 0 24px;
  font-weight: 500; font-size: 14px;
}
.btn-outline.block { width: 100%; }
.btn-text {
  color: var(--primary);
  min-height: 40px; padding: 0 12px;
  font-weight: 500; font-size: 14px; border-radius: 20px;
}
.btn-text.danger { color: var(--danger); }
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-variant); color: var(--on-surface-variant);
  border-radius: 50px; min-height: 40px; padding: 0 16px;
  font-weight: 500; font-size: 14px;
}
.btn-back svg { width: 18px; height: 18px; }
.icon-btn { width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.danger { color: var(--danger); }
.fab-add {
  width: 40px; height: 40px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.fab-add svg { width: 24px; height: 24px; }

/* Tarjeta de trabajo */
.trabajo-card {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 1px 3px 1px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.3);
}
.trabajo-card .head { display: flex; align-items: center; justify-content: space-between; }
.trabajo-card .head .who { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.trabajo-card .head .who svg { width: 20px; height: 20px; color: var(--primary-fixed, #4F46E5); flex: none; }
.trabajo-card .titulo { font-weight: 700; font-size: 16px; line-height: 22px; overflow-wrap: anywhere; }
.trabajo-card .when { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.trabajo-card .when svg { width: 16px; height: 16px; }
.trabajo-card .when .sp { flex: 1; }
.tags { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.tags.first { margin-top: 12px; }
.tag { border-radius: 10px; padding: 8px 10px; font-weight: 600; font-size: 12px; line-height: 16px; overflow-wrap: anywhere; }
.badge { border-radius: 50px; padding: 4px 12px; font-weight: 700; font-size: 12px; line-height: 16px; display: inline-block; white-space: nowrap; }
.c-green  { color: var(--green);  background: var(--green-pale); }
.c-orange { color: var(--orange); background: var(--orange-pale); }
.c-teal   { color: var(--teal);   background: var(--teal-pale); }
.c-primary{ color: #4F46E5;       background: var(--primary-pale); }
.c-blue   { color: var(--blue);   background: var(--blue-pale); }
.trabajo-card .btn-grad { margin-top: 14px; border-radius: 14px; min-height: 48px; }

/* Barra inferior */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--nav-bg);
  height: calc(80px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; z-index: 20;
}
.nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--on-surface-variant);
}
.nav .ind { width: 64px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.nav .ind svg { width: 24px; height: 24px; }
.nav button.sel .ind { background: var(--nav-indicator); color: var(--on-nav-indicator); }
.nav button.sel { color: var(--on-surface); }
.nav .lbl { font-size: 12px; line-height: 16px; font-weight: 500; }

/* Campos (OutlinedTextField) */
.field { position: relative; margin-top: 12px; --fb: var(--field-bg); }
.dialog .body > .field:first-child { margin-top: 0; }
.row.cols { margin-top: 12px; gap: 8px; align-items: flex-start; }
.row.cols .field { margin-top: 0; }
.field input, .field textarea, .field select {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  background: transparent;
  padding: 16px;
  outline: none;
  font-size: 16px; line-height: 24px;
}
.field input:not([type="date"]):not([type="time"]), .field textarea { -webkit-appearance: none; appearance: none; }
/* iPhone: los selectores de fecha/hora traen su propio aspecto; solo se alinean a la izquierda */
.field input[type="date"], .field input[type="time"] { display: block; text-align: left; -webkit-min-logical-width: calc(100% - 32px); }
.field textarea { resize: none; display: block; }
.field input:focus, .field textarea:focus { border: 2px solid var(--primary); padding: 15px; }
.field label {
  position: absolute; left: 12px; top: 16px;
  padding: 0 4px;
  color: var(--on-surface-variant);
  font-size: 16px; line-height: 24px;
  pointer-events: none;
  background: transparent;
  transition: all .12s ease;
}
.field input:focus + label, .field textarea:focus + label,
.field input:not(:placeholder-shown) + label, .field textarea:not(:placeholder-shown) + label,
.field.float label {
  top: -9px; font-size: 12px; line-height: 16px; background: var(--fb);
}
.field input:focus + label, .field textarea:focus + label { color: var(--primary); }
.field.has-prefix input { padding-left: 32px; }
.field .prefix { position: absolute; left: 16px; top: 16px; line-height: 24px; color: var(--on-surface-variant); opacity: 0; pointer-events: none; }
.field input:focus ~ .prefix, .field input:not(:placeholder-shown) ~ .prefix { opacity: 1; }
.field.has-icon input { padding-right: 52px; }
.field .trail { position: absolute; right: 4px; top: 4px; }
.field input[type="date"], .field input[type="time"] { min-height: 56px; text-align: left; }
.plain-input {
  width: 100%; min-height: 56px; border: 1px solid var(--outline); border-radius: 4px;
  background: transparent; padding: 16px; outline: none; font-size: 16px;
}
.plain-input:focus { border: 2px solid var(--primary); padding: 15px; }
.field-title { font-weight: 500; font-size: 14px; line-height: 18px; margin: 0 0 4px; }
.search { position: relative; }
.search svg { position: absolute; left: 16px; top: 16px; width: 24px; height: 24px; color: var(--on-surface-variant); }
.search input { padding-left: 56px; }

/* Chips */
.chips { display: flex; gap: 8px; }
.chips.eq > * { flex: 1; }
.chip {
  min-height: 32px; border-radius: 8px; border: 1px solid var(--outline);
  padding: 0 16px; font-weight: 500; font-size: 14px; line-height: 18px; color: var(--on-surface-variant);
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
}
.chip.sel { background: var(--chip-selected); border-color: transparent; color: var(--on-surface); }

/* Secciones de detalle */
.sec { border-radius: 20px; padding: 16px; color: var(--text-primary); --field-bg: transparent; }
.sec.green  { background: var(--green-pale); }
.sec.orange { background: var(--orange-pale); }
.sec.teal   { background: var(--teal-pale); }
.sec.variant{ background: var(--surface-variant); --field-bg: var(--surface-variant); }
.sec.blue   { background: var(--primary-pale); }
.sec .muted { color: #475569; }
.sec .sec-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.item-card {
  background: var(--surface); color: var(--on-surface);
  border-radius: 12px; padding: 12px; margin: 8px 0 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 1px 3px 1px rgba(0,0,0,.1);
}
.item-card .top { display: flex; justify-content: space-between; gap: 12px; }
.item-card .actions { display: flex; align-items: center; }
.item-card .actions.end { justify-content: flex-end; }
.item-card .sub { color: var(--on-surface-variant); }
.item-card img.thumb { margin-top: 8px; height: 90px; border-radius: 8px; object-fit: cover; display: block; }
.total-row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.resumen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.res-card { background: var(--surface); color: var(--on-surface); border-radius: 14px; padding: 12px 10px; text-align: center; }
.res-card .v { font-weight: 700; font-size: 16px; line-height: 22px; margin-top: 4px; overflow-wrap: anywhere; }

.back-row { display: flex; align-items: center; gap: 12px; }
.topbar { display: flex; align-items: center; gap: 4px; min-height: 64px; padding: 0 4px; margin: -16px -16px 16px; padding-top: var(--safe-top); }
.topbar .t-title { font-weight: 400; font-size: 22px; line-height: 28px; }
.error-text { color: var(--danger); margin-top: 8px; }

/* Diálogos (AlertDialog) */
#dialogs .overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px 16px;
}
.dialog {
  background: var(--dialog); color: var(--on-surface);
  border-radius: 28px; padding: 24px;
  width: 100%; max-width: 360px; max-height: 88vh; overflow-y: auto;
  --field-bg: var(--dialog);
}
.dialog h2 { margin: 0 0 16px; font-weight: 400; font-size: 24px; line-height: 32px; }
.dialog .body { color: var(--on-surface-variant); font-size: 14px; line-height: 20px; }
.dialog .body.field-body { color: inherit; }
.dialog .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.radio-row { display: flex; align-items: center; gap: 4px; min-height: 48px; color: var(--on-surface); }
.radio-row .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--outline); display: inline-block; position: relative; margin: 14px; flex: none; }
.radio-row.sel .dot { border-color: var(--primary); }
.radio-row.sel .dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--primary); }
.total-line { margin-top: 8px; font-weight: 600; color: var(--teal); }
.photo-prev { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; margin-top: 8px; display: block; }

/* Snackbar */
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + var(--safe-bottom));
  background: var(--snack-bg); color: var(--snack-text);
  border-radius: 4px; padding: 14px 16px; font-size: 14px; line-height: 20px;
  opacity: 0; transform: translateY(8px); transition: all .2s ease; pointer-events: none; z-index: 60;
}
#toast.show { opacity: 1; transform: none; }

/* Logo y splash */
.logo-box { height: 100px; width: 100px; border-radius: 14px; background: var(--surface-variant); display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 500; font-size: 12px; flex: none; }
.logo-img { height: 100px; max-width: 250px; object-fit: contain; display: block; }
.splash {
  position: fixed; inset: 0; background: var(--grad); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.splash .logo { opacity: 0; transform: scale(.85); transition: all .4s ease; color: #fff; }
.splash.in .logo { opacity: 1; transform: none; }
.splash .logo svg { width: 72px; height: 72px; }
.splash .logo img { height: 120px; max-width: 300px; object-fit: contain; display: block; }
.section-title { font-weight: 600; font-size: 20px; line-height: 26px; padding: 8px 0; }
hr.div { border: 0; border-top: 1px solid var(--outline); opacity: .4; margin: 16px 0; }
.empty { padding: 32px 0; text-align: center; color: var(--on-surface-variant); }
.hidden-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
