/* ==========================================================================
   ELECTRON · SOFTWARE PARA ELECTRICISTAS · INTERFAZ VISUAL DE ELECTROGEST PRO
   Misma paleta, tipografía y componentes que /var/www/electricidad-app:
   Blanco Nieve (#ffffff), Slate (#f8fafc, #f1f5f9), Azul Eléctrico (#0284c7, #0ea5e9),
   Ámbar Seguridad (#d97706), Verde (#059669), Rojo (#e11d48)
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Fondo y superficies */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-border-subtle: #edf2f7;

  /* Acentos de energía y marca */
  --color-primary: #0284c7;
  --color-primary-dark: #0369a1;
  --color-primary-light: #0ea5e9;
  --color-primary-soft: #eff6ff;
  --color-primary-line: #bae6fd;

  --color-volt-amber: #d97706;
  --color-volt-amber-btn: #f59e0b;
  --color-amber-soft: #fffbeb;
  --color-amber-line: #fde68a;

  --color-safe-green: #059669;
  --color-green-soft: #ecfdf5;
  --color-green-line: #a7f3d0;

  --color-danger: #e11d48;
  --color-danger-soft: #fff1f2;
  --color-danger-line: #fecdd3;

  --color-purple: #9333ea;
  --color-purple-soft: #faf5ff;

  /* Textos */
  --text-primary: #0f172a;
  --text-strong: #1e293b;
  --text-body: #334155;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --hdr-h: 65px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background-color: var(--color-bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Fondo con gradiente claro y trama fina, igual que ElectroGest */
body {
  background-image:
    radial-gradient(ellipse 70% 40% at 50% -10%, rgba(2, 132, 199, 0.05), transparent 70%),
    linear-gradient(to right, rgba(15, 23, 42, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { color: var(--text-primary); font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ==========================================================================
   UTILIDADES
   ========================================================================== */
.mono { font-family: var(--font-mono); }
.ico { display: inline-block; flex: none; vertical-align: middle; }
[data-ico] { display: inline-flex; align-items: center; }
.tnum { font-variant-numeric: tabular-nums; }
.c-ink { color: var(--text-primary); }
.c-primary { color: var(--color-primary); }
.c-amber { color: var(--color-volt-amber); }
.c-green { color: var(--color-safe-green); }
.c-danger { color: var(--color-danger); }
.c-muted { color: var(--text-muted); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; line-height: 1.4;
}
.badge-volt { background: #eff6ff; color: #0284c7; border: 1px solid #bae6fd; }
.badge-verifactu { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.badge-amber { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.badge-danger { background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3; }
.badge-purple { background: #faf5ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.badge-gray { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-xs { font-size: 10px; padding: 1px 7px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-md);
  font-weight: 600; font-size: 13px; cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition-fast);
  white-space: nowrap; user-select: none; background: none; line-height: 1.4;
}
.btn-primary { background: #0284c7; color: #ffffff; border-color: #0369a1; box-shadow: 0 1px 3px rgba(2, 132, 199, 0.25); }
.btn-primary:hover { background: #0369a1; box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3); transform: translateY(-1px); }
.btn-volt { background: #f59e0b; color: #ffffff; font-weight: 700; border-color: #d97706; box-shadow: 0 1px 3px rgba(245, 158, 11, 0.25); }
.btn-volt:hover { background: #d97706; box-shadow: 0 4px 10px rgba(245, 158, 11, 0.35); transform: translateY(-1px); }
.btn-success { background: #059669; color: #ffffff; border-color: #047857; }
.btn-success:hover { background: #047857; box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25); }
.btn-outline { background: #ffffff; border-color: var(--color-border); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--color-primary); }
.btn-danger { background: #fff1f2; border-color: #fecdd3; color: #e11d48; }
.btn-danger:hover { background: #ffe4e6; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: var(--radius-sm); gap: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: var(--radius-sm); gap: 5px; }
.btn-icon { padding: 5px 7px; color: var(--text-muted); }
.btn-icon:hover { color: #e11d48; border-color: #fecdd3; background: #fff1f2; }
.btn.armed, .btn-icon.armed { background: #e11d48 !important; border-color: #be123c !important; color: #ffffff !important; font-size: 11px; font-weight: 700; padding-inline: 9px; }

/* Tarjetas */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm); min-width: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.card:hover { border-color: #cbd5e1; box-shadow: var(--shadow-md); }
.card-glow-volt { border-top: 3px solid #0284c7; }
.card-glow-amber { border-top: 3px solid #f59e0b; }
.card-glow-verifactu { border-top: 3px solid #059669; }
.card-glow-danger { border-top: 3px solid #e11d48; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head > div { min-width: 0; }
.card-title { font-size: 15px; font-weight: 700; color: #0f172a; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; max-width: 80ch; }
.card-sub b { color: var(--text-primary); font-weight: 700; }

/* Formularios */
.form-label {
  display: block; font-size: 12px; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em;
}
.input, .select, .textarea {
  width: 100%; background: #ffffff; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: 9px 13px; color: var(--text-primary); transition: all var(--transition-fast);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03); min-width: 0;
}
.input:hover, .select:hover, .textarea:hover { border-color: #cbd5e1; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15); }
.input::placeholder, .textarea::placeholder { color: #94a3b8; }
.select { cursor: pointer; }
.textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
.input-sm, .select-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.input.num { text-align: right; font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.input.w-xxs { width: 58px; }
.input.w-xs { width: 72px; }
.input.w-sm { width: 92px; }
.input.w-md { width: 112px; }
.input.big { font-family: var(--font-sans); font-size: 22px; font-weight: 800; padding: 6px 12px; width: 130px; }
.unit-in { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.unit { color: var(--text-muted); font-size: 11px; font-weight: 600; }

/* Interruptor (toggle) */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; vertical-align: middle; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background-color: #cbd5e1; transition: .3s; border-radius: 22px; }
.toggle-slider:before {
  position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background-color: #0284c7; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }
.toggle-switch input:focus-visible + .toggle-slider { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ==========================================================================
   ESTRUCTURA: CABECERA, BARRA LATERAL Y ÁREA DE TRABAJO
   ========================================================================== */
.app-container { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  background: #ffffff; border-bottom: 1px solid var(--color-border);
  padding: 12px 24px; min-height: var(--hdr-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 40; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.hdr-left, .hdr-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  display: flex; align-items: center; justify-content: center; color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25); border: 1px solid rgba(0, 0, 0, 0.08);
}
.brand-text { min-width: 0; }
.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-name { font-weight: 800; font-size: 18px; color: #0f172a; letter-spacing: -0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-badge { font-size: 10px; padding: 1px 7px; }
.brand-sub { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.brand-sub-k { font-weight: 600; color: #334155; }
.brand-sub-v { color: var(--color-primary); font-weight: 600; }
.hdr-pill { padding: 5px 12px; }
.hdr-note { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.app-main-layout { display: flex; flex: 1; }

.app-sidebar {
  width: 260px; background: #ffffff; border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; justify-content: space-between; gap: 20px;
  padding: 16px 12px; height: calc(100vh - var(--hdr-h)); position: sticky; top: var(--hdr-h);
  align-self: flex-start; flex-shrink: 0; overflow-y: auto;
}
.side-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
  padding: 0 10px 8px 10px; font-weight: 700;
}
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: var(--radius-md);
  background: transparent; color: var(--text-secondary); border: 1px solid transparent;
  cursor: pointer; font-size: 13px; font-weight: 500; transition: all var(--transition-fast); text-align: left; width: 100%;
}
.nav-item:hover { background: #f8fafc; color: var(--text-primary); }
.nav-item .nav-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-item .ico { color: var(--text-muted); }
.nav-item[aria-current="page"] { background: #eff6ff; color: var(--color-primary); border-color: #bae6fd; font-weight: 700; }
.nav-item[aria-current="page"] .ico { color: var(--color-primary); }
.nav-item .badge { font-size: 10px; padding: 1px 6px; }

.plan-card {
  margin-top: auto; flex-shrink: 0; padding: 14px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #cbd5e1; border-radius: 14px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: #0f172a; }
.plan-title .ico { color: #0284c7; }
.plan-tag { font-size: 9px; padding: 1px 6px; font-weight: 800; border-radius: 6px; background: #e0f2fe; color: #0284c7; }
.plan-text { font-size: 11px; color: #64748b; line-height: 1.45; }

.app-content-area { flex: 1; padding: 24px 32px 48px; max-width: 1400px; margin: 0 auto; width: 100%; min-width: 0; }

/* ==========================================================================
   VISTAS
   ========================================================================== */
.view { display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.page-head > div:first-child { min-width: 0; }
.page-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-title h2 { font-size: 20px; color: #0f172a; }
.page-lede { font-size: 12px; color: var(--text-muted); max-width: 90ch; margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Tarjetas de métricas */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.kpi-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; letter-spacing: 0.02em; }
.kpi-ico { padding: 5px; border-radius: 6px; display: inline-flex; }
.ib-volt { background: #eff6ff; color: #0284c7; }
.ib-amber { background: #fffbeb; color: #d97706; }
.ib-green { background: #ecfdf5; color: #059669; }
.ib-purple { background: #faf5ff; color: #9333ea; }
.ib-danger { background: #fff1f2; color: #e11d48; }
.kpi-value { font-size: 26px; font-weight: 800; color: #0f172a; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.kpi-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--color-border); font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }

/* Ecuación de mano de obra */
.eq-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1.15fr); gap: 12px; align-items: stretch; }
.eq-term { background: #f8fafc; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.eq-term.res { background: #fffbeb; border-color: #fde68a; }
.eq-term .kpi-value { font-size: 24px; }
.eq-op { align-self: center; width: 32px; height: 32px; border-radius: 50%; background: #f1f5f9; border: 1px solid var(--color-border); display: grid; place-items: center; font-weight: 800; color: var(--text-muted); font-size: 16px; }

/* Columnas y bloques */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.section-title { font-size: 16px; }

/* Tablas */
.table-wrap { overflow-x: auto; min-width: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl thead tr { border-bottom: 2px solid var(--color-border); text-align: left; color: #475569; background: #f8fafc; }
.tbl th { padding: 10px; font-weight: 700; white-space: nowrap; text-align: left; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--color-border); vertical-align: middle; color: var(--text-body); }
.tbl tbody tr { transition: background var(--transition-fast); }
.tbl tbody tr:hover { background: #fbfdff; }
.tbl tfoot tr { background: #f8fafc; }
.tbl tfoot th, .tbl tfoot td { padding: 10px; font-weight: 800; color: #0f172a; border-bottom: 0; border-top: 2px solid var(--color-border); }
.tbl .r, .tbl th.r { text-align: right; }
.tbl .c, .tbl th.c { text-align: center; }
.tbl .act { width: 1%; white-space: nowrap; text-align: right; }
.tbl .act > * + * { margin-left: 6px; }
.tbl .money { font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .money-strong { font-weight: 800; color: #0f172a; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .pvp { font-weight: 800; color: #d97706; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .dimmed { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .date { color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .ink { font-weight: 700; color: #0f172a; }
.tbl td.empty { text-align: center; color: var(--text-muted); padding: 22px 10px; }
.tbl tr.flash td { background: #eff6ff; }
.tbl tr.editing td { background: #fffbeb; }
.tbl tr.out td { color: #94a3b8; }
.tbl tr.out td .money, .tbl tr.out td .money-strong { color: #94a3b8; }
.code { font-family: var(--font-mono); font-weight: 800; color: var(--color-primary); font-size: 12px; white-space: nowrap; }
.code + .ink, .code + .badge { margin-left: 6px; }
.tbl-db { min-width: 820px; }
.tbl-mat { min-width: 760px; }
.tbl-fx { min-width: 450px; }
.tbl-fx td:first-child { min-width: 120px; }
.tbl-fx th, .tbl-fx td { padding-left: 6px; padding-right: 6px; }
.tbl-fx .input.num.w-sm { width: 80px; }
.tbl-lines { min-width: 680px; }
.tbl-lines td { vertical-align: top; }
.tbl-lines td.top-pad { padding-top: 15px; }

/* Cajas suaves (resúmenes y desgloses) */
.soft-box { background: #f8fafc; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px 14px; }
.soft-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.soft-row + .soft-row { margin-top: 6px; }
.soft-row .lbl { font-size: 12px; color: var(--text-muted); }
.soft-row .val { font-size: 18px; font-weight: 800; color: #0f172a; font-variant-numeric: tabular-nums; white-space: nowrap; }
.perday { margin-top: 14px; }

/* Barra de búsqueda y filtros */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.search-wrap { position: relative; flex: 1; min-width: 240px; }
.search-wrap .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-wrap .input { padding-left: 32px; font-size: 12px; }
.toolbar .select { width: auto; min-width: 170px; font-size: 12px; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }

/* Pestañas segmentadas */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: #f1f5f9; border: 1px solid var(--color-border); border-radius: 12px; align-self: flex-start; max-width: 100%; overflow-x: auto; }
.seg button { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: transparent; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-secondary); cursor: pointer; white-space: nowrap; transition: all var(--transition-fast); }
.seg button:hover { color: var(--text-primary); }
.seg button[aria-selected="true"] { background: #ffffff; color: var(--color-primary); font-weight: 700; border-color: var(--color-border); box-shadow: var(--shadow-sm); }
.seg .count { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: #e2e8f0; color: #475569; }
.seg button[aria-selected="true"] .count { background: #e0f2fe; color: #0284c7; }

/* Formularios en rejilla */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px 14px; align-items: start; }
.form-grid .fg-check, .form-grid .form-actions { align-self: end; }
.fg .input, .fg .select { min-height: 40px; }
.fg { min-width: 0; }
.fg .form-label { margin-bottom: 6px; }
.fg .input, .fg .select { font-size: 13px; }
.fg .pay { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 6px; }
.fg-check { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-secondary); padding-bottom: 9px; cursor: pointer; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (min-width: 760px) { .fg.wide { grid-column: span 2; } }

/* Chips de resumen */
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 12px; }
.stat { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: #f8fafc; border: 1px solid var(--color-border); font-size: 12px; color: var(--text-secondary); }
.stat b { color: #0f172a; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat.warn { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.stat.warn b { color: #d97706; }
.pay-cell { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.pay-cell small { color: var(--text-muted); font-size: 10px; font-family: var(--font-mono); }

/* Material y tarifas */
.tarifas { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.tarifa { display: flex; flex-direction: column; gap: 12px; }
.t-head { display: flex; align-items: center; gap: 10px; }
.t-num { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: #eff6ff; border: 1px solid #bae6fd; color: #0284c7; font-family: var(--font-mono); font-weight: 800; font-size: 13px; }
.t-name { font-size: 15px; font-weight: 700; padding: 7px 11px; }
.add-comp { border-style: dashed; color: var(--text-secondary); font-size: 12px; background: #ffffff; }
.t-time { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.t-time .unit { text-transform: none; letter-spacing: 0; }
.bd .soft-row .lbl { font-size: 12px; color: var(--text-secondary); }
.bd .soft-row .v { font-weight: 700; color: #0f172a; font-size: 13px; font-variant-numeric: tabular-nums; }
.bd .bt { border-top: 1px solid var(--color-border-strong); margin-top: 8px; padding-top: 8px; }
.bd .bt .lbl { font-weight: 700; color: #0f172a; font-size: 13px; }
.bd .bt .v { font-size: 20px; font-weight: 800; color: #d97706; }

/* Presupuestos */
.pres-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.doc-id { display: flex; align-items: center; gap: 12px; }
.doc-ico { padding: 8px; border-radius: 10px; background: #fffbeb; color: #d97706; display: inline-flex; }
.doc-kicker { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.doc-num { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--font-mono); font-weight: 800; font-size: 18px; color: var(--color-primary); }
.doc-num .badge { font-family: var(--font-sans); }
.doc-date { width: 170px; }
.client-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) minmax(0, 1.2fr); gap: 12px; margin-bottom: 18px; }
.desc-cell { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }
.add-line { margin-top: 12px; }
.obs { margin-top: 16px; }
.totals-box { margin-top: 16px; margin-left: auto; width: min(100%, 340px); }
.totals-box .soft-row .lbl { font-size: 12px; color: var(--text-secondary); }
.totals-box .soft-row .v { font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }
.totals-box .grand { border-top: 1px solid var(--color-border-strong); margin-top: 8px; padding-top: 8px; }
.totals-box .grand .lbl { font-weight: 800; color: #0f172a; font-size: 14px; }
.totals-box .grand .v { font-size: 20px; font-weight: 800; color: #d97706; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.side-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.saved-list { display: flex; flex-direction: column; gap: 10px; }
.saved-item { padding: 12px; border-radius: var(--radius-md); background: #f8fafc; border: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 8px; }
.saved-item.open { background: #eff6ff; border-color: #bae6fd; }
.sv-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sv-top-r { display: flex; align-items: center; gap: 8px; }
.sv-num { font-family: var(--font-mono); font-weight: 800; color: var(--color-primary); }
.sv-date { font-size: 11px; color: var(--text-muted); }
.sv-mid { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sv-cli { font-weight: 700; font-size: 13px; color: #0f172a; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-total { font-weight: 800; font-size: 15px; color: #0f172a; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sv-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.empty-note { font-size: 12px; color: var(--text-muted); }
details.emisor > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
details.emisor > summary::-webkit-details-marker { display: none; }
details.emisor > summary::after { content: "+"; font-weight: 800; color: var(--text-muted); font-size: 16px; }
details.emisor[open] > summary::after { content: "−"; }
details.emisor .fields { display: grid; gap: 12px; margin-top: 14px; }

/* Beneficio */
.tax-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tax-cell { background: #f8fafc; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tax-cell.hl-amber { background: #fffbeb; border-color: #fde68a; }
.tax-cell.hl-green { background: #ecfdf5; border-color: #a7f3d0; }
.tax-cell .kpi-value { font-size: 22px; }
.tax-cell .kpi-label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--radius-md); font-size: 12px; margin-top: 14px; }
.notice-amber { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.notice-green { background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; }
.notice b { font-weight: 800; }
.notice .btn { margin-left: auto; }
.fine { font-size: 11px; color: var(--text-muted); margin-top: 12px; max-width: 100ch; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; font-weight: 600; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-s1 { background: #0284c7; }
.sw-s2 { background: #f59e0b; }
.chart { position: relative; width: 100%; min-width: 0; margin: 4px 0 16px; }
.chart svg { display: block; max-width: 100%; }
.gl { stroke: #edf2f7; stroke-width: 1; shape-rendering: crispEdges; }
.base { stroke: #cbd5e1; stroke-width: 1; shape-rendering: crispEdges; }
.tk { fill: #64748b; font-family: var(--font-sans); font-size: 11px; font-weight: 500; }
.s1 { fill: #0284c7; }
.s2 { fill: #f59e0b; }
.hit { fill: transparent; cursor: crosshair; }
.hl { fill: transparent; }
.grp.hover .hl { fill: #f1f5f9; }
.tip { position: absolute; top: 4px; pointer-events: none; background: #ffffff; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px 12px; font-size: 12px; box-shadow: var(--shadow-lg); min-width: 200px; z-index: 2; }
.tip .t-t { font-weight: 800; margin-bottom: 6px; text-transform: capitalize; color: #0f172a; }
.tip .t-r { display: flex; justify-content: space-between; gap: 16px; color: var(--text-secondary); }
.tip .t-r span:last-child { font-weight: 700; color: #0f172a; font-variant-numeric: tabular-nums; }
.tip .t-sum { border-top: 1px solid var(--color-border); margin-top: 6px; padding-top: 6px; font-weight: 800; }

/* Aviso flotante */
.toast {
  position: fixed; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: min(440px, calc(100vw - 32px)); background: #ffffff; color: #0f172a;
  border: 1px solid var(--color-border); border-left: 4px solid #0284c7; border-radius: var(--radius-md);
  padding: 12px 16px; font-size: 13px; font-weight: 600; z-index: 999; box-shadow: var(--shadow-lg);
  animation: toastIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.alert { border-left-color: #e11d48; background: #fff1f2; color: #9f1239; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   ADAPTACIÓN A PANTALLAS PEQUEÑAS
   ========================================================================== */
@media (max-width: 1360px) {
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1180px) {
  .pres-layout { grid-template-columns: minmax(0, 1fr); }
  .hdr-note { display: none; }
}
@media (max-width: 1000px) {
  .hdr-pill { display: none; }
}
@media (max-width: 900px) {
  .app-sidebar { width: 220px; padding: 12px 8px; }
  .app-content-area { padding: 16px 20px 40px; }
  .eq-grid { grid-template-columns: minmax(0, 1fr); }
  .eq-op { justify-self: start; margin-left: 12px; }
}
@media (max-width: 760px) {
  .client-grid { grid-template-columns: minmax(0, 1fr); }
  .tax-grid { grid-template-columns: minmax(0, 1fr); }
  .brand-sub { display: none; }
}
@media (max-width: 680px) {
  .app-header { padding: 10px 16px; }
  .app-main-layout { flex-direction: column; }
  .app-sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--color-border); padding: 10px 16px; }
  .side-label, .plan-card { display: none; }
  .side-nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .nav-item { width: auto; flex: none; white-space: nowrap; }
  .app-content-area { padding: 16px 16px 40px; }
  .hdr-right .btn span:last-child { display: none; }
  .kpi-value { font-size: 22px; }
  .search-wrap { min-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ==========================================================================
   ELECTRON EN PRODUCCIÓN: ACCESO, GUARDADO, MIS DATOS Y ADMINISTRACIÓN
   ========================================================================== */
[hidden] { display: none !important; }
.ink { font-weight: 700; color: #0f172a; }

/* Estado del guardado en la cabecera */
.save-state { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px; font-size: 11px; font-weight: 700; color: var(--text-secondary); background: #f8fafc; border: 1px solid var(--color-border); white-space: nowrap; }
.save-state .dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: none; }
.save-state[data-estado="guardado"] { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.save-state[data-estado="guardado"] .dot { background: #059669; }
.save-state[data-estado="pendiente"] .dot, .save-state[data-estado="guardando"] .dot, .save-state[data-estado="cargando"] .dot { background: #0284c7; animation: latido 1s ease-in-out infinite; }
.save-state[data-estado="sinConexion"], .save-state[data-estado="error"] { color: #9f1239; background: #fff1f2; border-color: #fecdd3; }
.save-state[data-estado="sinConexion"] .dot, .save-state[data-estado="error"] .dot { background: #e11d48; }
@keyframes latido { 50% { opacity: 0.35; } }

.user-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 5px 11px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); background: #ffffff; font-size: 12px; font-weight: 700; color: var(--text-primary); cursor: pointer; box-shadow: var(--shadow-sm); }
.user-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip:hover { border-color: #cbd5e1; color: var(--color-primary); }
.user-chip .ico { color: var(--color-primary); }

/* Carga, errores y avisos */
.loading-view { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 40vh; color: var(--text-muted); font-weight: 600; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #bae6fd; border-top-color: #0284c7; animation: giro 0.8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.load-error { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; color: #e11d48; }
.load-error > div { flex: 1; min-width: 200px; }
.form-error { color: #be123c; background: #fff1f2; border: 1px solid #fecdd3; border-radius: var(--radius-md); padding: 8px 12px; font-size: 12px; font-weight: 600; }
.notice.no-top { margin-top: 0; margin-bottom: 0; }
.lic-aviso { margin: 0 0 20px; }

/* Mis datos */
.welcome .steps { margin: 0 0 0 20px; display: grid; gap: 8px; font-size: 13px; color: var(--text-body); }
.welcome .steps b { color: #0f172a; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--color-primary); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.empresa-grid { margin-bottom: 18px; }
.logo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--color-border); }
.logo-box { width: 160px; height: 80px; border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md); background: #f8fafc; display: grid; place-items: center; color: var(--text-faint); overflow: hidden; flex: none; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-info .form-label { margin-bottom: 2px; }
.logo-info .form-actions { margin-top: 8px; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.acc-actions { margin-top: 14px; }
.soft-row .ink { font-size: 13px; }
.emisor-mini { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; min-width: 0; }
.emisor-mini img { max-width: 72px; max-height: 40px; object-fit: contain; }
.emisor-mini .dimmed { color: var(--text-muted); font-size: 12px; }
.emisor-card .notice { margin-bottom: 12px; }

/* Diálogos */
.dialog { border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 22px; width: min(540px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow-lg); color: var(--text-primary); margin: auto; background: #ffffff; }
.dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.dialog > form { display: flex; flex-direction: column; gap: 14px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-actions { justify-content: flex-end; margin-top: 4px; }
.dialog .form-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.dialog .fine { margin-top: 0; }
.cred-box { font-family: var(--font-mono); font-size: 12px; background: #f8fafc; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 12px 14px; white-space: pre-wrap; word-break: break-word; color: #0f172a; user-select: all; }

/* Pantalla de acceso */
.auth-page { display: flex; min-height: 100vh; }
.auth-wrap { margin: auto; width: min(420px, calc(100vw - 32px)); padding: 32px 0; display: flex; flex-direction: column; gap: 20px; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; }
.auth-brand .brand-logo { width: 48px; height: 48px; border-radius: 12px; }
.auth-brand .brand-name { font-size: 24px; }
.auth-card { display: flex; flex-direction: column; gap: 12px; padding: 26px; }
.auth-title { font-size: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.auth-btn { width: 100%; padding: 11px 16px; font-size: 14px; }
.auth-card .notice { margin-top: 0; }
.auth-card .fine { margin-top: 4px; }
.auth-foot { text-align: center; font-size: 11px; color: var(--text-faint); }

/* Administración */
.admin-main { padding: 24px 32px 48px; max-width: 1400px; margin: 0 auto; width: 100%; }
.admin-login { width: min(420px, 100%); margin: 8vh auto 0; }
.tbl-admin { min-width: 1080px; }
.tbl-admin td { vertical-align: top; }
.tbl-admin .dimmed { font-size: 11px; white-space: normal; }
.tbl-admin .act { white-space: normal; }
.admin-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; width: 300px; margin-left: auto; }
.tbl .act > .admin-acts + * { margin-left: 0; }

@media (max-width: 760px) {
  .save-state .txt { display: none; }
  .save-state { padding: 6px; }
  .user-chip { display: none; }
}
@media (max-width: 680px) {
  .admin-main { padding: 16px; }
  .logo-box { width: 120px; height: 64px; }
}
