/* Apparka Dueño — identidad Apparka MX v1.1, pensado primero para teléfono */

@font-face {
  font-family: 'Inter';
  src: url('./fonts/inter-latin-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('./fonts/ibm-plex-mono-latin-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --forest: #173D35;
  --forest-2: #24504A;
  --forest-line: #3E5F57;
  --lime: #D5E6A1;
  --ivory: #F4F0E8;
  --sand: #F1EEE6;
  --ink: #18231F;
  --muted: #52635B;
  --faint: #7F8C86;
  --border: #CDD5CC;
  --line: #E7E4DC;
  --white: #FFFFFF;
  --ok: #12703C;
  --ok-strong: #2FB36A;
  --ok-tint: #E3F4EA;
  --ok-line: #BFE3CB;
  --warn: #8A5A00;
  --warn-deep: #6B4700;
  --warn-strong: #E39A1B;
  --warn-tint: #FBEFD5;
  --danger: #A52B35;
  --danger-tint: #FCE4E4;
  --danger-line: #F0B9BE;
  --radius: 16px;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font: 400 15px/1.45 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--forest); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-weight: 600; }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
:focus-visible { outline: 3px solid var(--warn-strong); outline-offset: 2px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 0;
  font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--forest); color: var(--ivory); }
.btn-outline { background: var(--white); color: var(--forest); border: 1.5px solid var(--forest); }
.btn-danger-outline { background: var(--white); color: var(--danger); border: 1.5px solid var(--danger); }
.btn-ghost { background: var(--sand); color: var(--ink); }
.btn-link { background: none; color: var(--forest); text-decoration: underline; min-height: 44px; padding: 0 8px; }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn svg, .tab-ico svg, .ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Campos */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.field small { font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea {
  min-height: 48px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--white);
  padding: 10px 12px; font-size: 16px; font-weight: 500;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--forest); outline: none; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-error { margin: 0; min-height: 0; color: var(--danger); font-size: 14px; font-weight: 600; }
.form-error:empty { display: none; }

/* Acceso y carga */
.screen-login, .screen-loading {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
}
.screen-loading { flex-direction: column; gap: 12px; color: var(--muted); }
.login-card {
  width: 100%; max-width: 400px; background: var(--white); border-radius: 20px; padding: 28px 22px;
  box-shadow: 0 10px 30px rgba(24, 35, 31, 0.08); display: flex; flex-direction: column; gap: 14px;
}
.login-logo { height: 40px; width: auto; align-self: flex-start; }
.login-card h1 { font-size: 24px; font-weight: 800; }
.login-card p { margin: 0; }

/* App */
.app { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
.view { max-width: 760px; margin: 0 auto; outline: none; }
.offline-bar { background: var(--warn-tint); color: var(--warn-deep); text-align: center; font-size: 13px; font-weight: 600; padding: 8px 12px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 4px var(--safe-b);
  background: var(--white); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tab-ico { width: 54px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
.tabbar a[aria-current="page"] { color: var(--forest); font-weight: 800; }
.tabbar a[aria-current="page"] .tab-ico { background: var(--lime); }
.tab-dot { position: absolute; top: 6px; right: calc(50% - 22px); width: 10px; height: 10px; border-radius: 50%; background: var(--warn-strong); border: 2px solid var(--white); }

@media (min-width: 900px) {
  .tabbar { top: 0; bottom: auto; height: 64px; padding: 0 max(16px, calc(50vw - 380px)); border-top: 0; border-bottom: 1px solid var(--line); }
  .tabbar a { flex-direction: row; font-size: 14px; gap: 6px; }
  .tab-ico { width: 40px; }
  .app { padding-bottom: 24px; padding-top: 64px; }
}

/* Encabezados de pestaña */
.page-head { background: var(--white); border-bottom: 1px solid var(--line); padding: 18px 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.page-head h1 { font-size: 22px; font-weight: 800; }
.page-head .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.page-body { padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }

.hero { background: var(--forest); color: var(--ivory); padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.hero .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hero-label { font-size: 13px; color: #CFE0D8; }
.hero-amount { font: 700 34px var(--mono); letter-spacing: -0.02em; }
.hero-delta { font-size: 13px; font-weight: 700; color: var(--lime); }
.branch-select {
  min-height: 44px; border-radius: 12px; padding: 0 36px 0 12px; font-weight: 700; font-size: 15px;
  background: rgba(244, 240, 232, 0.1) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23F4F0E8" stroke-width="2.4" stroke-linecap="round"><path d="M6 9l6 6 6-6"/></svg>') no-repeat right 12px center;
  color: var(--ivory); border: 1px solid rgba(244, 240, 232, 0.25); -webkit-appearance: none; appearance: none; max-width: 70%;
}
.branch-select option { color: var(--ink); }
.hero-date { font-size: 13px; color: #CFE0D8; }

/* Tarjetas */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { font-size: 16px; font-weight: 800; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card.is-alert { border: 2px solid var(--warn-strong); }
.card.is-dark { background: var(--forest); color: var(--ivory); border-color: var(--forest); }
.card.is-dark .muted { color: #CFE0D8; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font: 700 24px var(--mono); }
.kpi-value small { font: 600 14px Inter, sans-serif; color: var(--muted); }
.stat { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.stat b { font-size: 15px; color: var(--ink); font-weight: 700; }
.card.is-dark .stat { color: #CFE0D8; }
.card.is-dark .stat b { color: var(--ivory); font-family: var(--mono); font-size: 20px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--ok-strong); }
.bar > i.is-warn { background: var(--warn-strong); }
.bar > i.is-full { background: var(--danger); }
.divider { border-top: 1px solid var(--line); }
.section-title { font-size: 16px; font-weight: 800; margin: 6px 0 0; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

/* Etiquetas */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag-ok { background: var(--ok-tint); color: var(--ok); }
.tag-warn { background: var(--warn-tint); color: var(--warn-deep); }
.tag-danger { background: var(--danger-tint); color: var(--danger); }
.tag-neutral { background: var(--sand); color: #3E4A44; }
.tag-mono { background: var(--sand); font-family: var(--mono); }

/* Listas */
.list { display: flex; flex-direction: column; gap: 8px; }
.row-item {
  background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; min-height: 56px; width: 100%; text-align: left; cursor: pointer; text-decoration: none; color: inherit;
}
button.row-item { font: inherit; }
.row-item .grow { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-item .grow b { font-size: 15px; }
.row-item .grow span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.row-item .plate { font: 700 15px var(--mono); }
.row-item .amount { font: 700 15px var(--mono); white-space: nowrap; }
.chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.chev svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.alert-ico { flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.alert-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.alert-ico.is-danger { background: var(--danger-tint); color: var(--danger); }
.alert-ico.is-warn { background: var(--warn-tint); color: var(--warn); }
.alert-ico.is-ok { background: var(--ok-tint); color: var(--ok); }
.inline-list > * + * { border-top: 1px solid var(--line); padding-top: 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv span:first-child { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }

/* Aprobaciones */
.approval { display: flex; flex-direction: column; gap: 10px; }
.approval + .approval { border-top: 1px solid var(--line); padding-top: 12px; }
.approval p { margin: 0; font-size: 14px; }
.approval .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.approval .note { min-height: 44px; border-radius: 10px; border: 1.5px solid var(--border); padding: 8px 10px; font-size: 15px; }

/* Buscador y segmentos */
.search { display: flex; align-items: center; gap: 10px; min-height: 48px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--ivory); padding: 0 14px; }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; flex-shrink: 0; }
.search input { border: 0; outline: none; background: transparent; font-size: 16px; font-weight: 500; width: 100%; min-height: 44px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; background: var(--sand); border-radius: 12px; padding: 4px; }
.segmented button { min-height: 40px; border-radius: 9px; border: 0; background: transparent; font-weight: 600; font-size: 14px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--forest); color: var(--ivory); font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--white); font-weight: 600; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--forest); color: var(--ivory); border-color: var(--forest); font-weight: 700; }

/* Gráfica */
.chart { display: grid; gap: 6px; align-items: end; height: 130px; }
.chart .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.chart .col i { display: block; width: 100%; border-radius: 6px 6px 2px 2px; background: #9FC3B4; min-height: 2px; }
.chart .col.is-last i { background: var(--forest); }
.chart .col span { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* Interruptores */
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; font-size: 15px; cursor: pointer; }
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 14px; background: var(--border); transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + span { background: var(--forest); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--warn-strong); outline-offset: 2px; }

/* Foto */
.photo { height: 140px; background: #DCE7DF center / cover no-repeat; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--forest-line); font-weight: 600; font-size: 14px; }

/* Hoja de edición */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(24, 35, 31, 0.45); display: flex; justify-content: center; align-items: stretch; }
.sheet-panel { width: 100%; max-width: 640px; background: var(--ivory); display: flex; flex-direction: column; min-height: 0; }
@media (min-width: 700px) { .sheet { align-items: center; padding: 24px; } .sheet-panel { border-radius: 20px; max-height: 92vh; } }
.sheet-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px; background: var(--white); border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 18px; font-weight: 800; }
@media (min-width: 700px) { .sheet-head { border-radius: 20px 20px 0 0; } }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; padding-bottom: calc(24px + var(--safe-b)); }
.sheet-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; position: sticky; bottom: 0; background: var(--ivory); padding-top: 8px; }

/* Horario */
.day-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; align-items: center; }
.day-row select, .day-row input { min-height: 44px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--white); padding: 0 8px; font-size: 15px; }
.day-times { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; grid-column: 2; }
.special-row { display: flex; flex-direction: column; gap: 8px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }

/* Confirmación y avisos */
.confirm { position: fixed; inset: 0; z-index: 60; background: rgba(24, 35, 31, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.confirm-card { width: 100%; max-width: 380px; background: var(--white); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.confirm-card h2 { font-size: 18px; font-weight: 800; }
.confirm-card p { margin: 0; color: var(--muted); }
.confirm-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { max-width: 480px; width: 100%; background: var(--ink); color: var(--ivory); border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); pointer-events: auto; }
.toast.is-error { background: var(--danger); }
.toast.is-ok { background: var(--forest); }
