/* ED Control Horario — app de fichaje (móvil primero). Todo bajo .edch para no chocar con el tema. */

.edch {
	--edch-accent: #6b3a6b;
	--edch-accent-ink: #ffffff;
	--edch-ink: #2a2230;
	--edch-muted: #6f6675;
	--edch-bg: #f4f2f6;
	--edch-surface: #ffffff;
	--edch-line: #e5e0e9;
	--edch-soft: #efeaf2;
	--edch-work: #1d7560;
	--edch-work-soft: #e3f2ed;
	--edch-pause: #a8620c;
	--edch-pause-soft: #fbefdc;
	--edch-danger: #b3261e;
	--edch-danger-soft: #fbe7e5;
	--edch-radius: 14px;
	--edch-radius-lg: 22px;
	--edch-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--edch-font-num: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

	font-family: var(--edch-font);
	font-size: 16px;
	line-height: 1.45;
	color: var(--edch-ink);
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
	box-sizing: border-box;
}
.edch *, .edch *::before, .edch *::after { box-sizing: inherit; }
.edch :where(button, input, select, textarea) { font: inherit; color: inherit; }
.edch :where(h1, h2, h3, p) { margin: 0; }
.edch [hidden] { display: none !important; }

/* Página a pantalla completa */
body.edch-fullscreen { margin: 0; background: #f4f2f6; min-height: 100vh; min-height: 100dvh; }
.edch-shell { min-height: 100vh; min-height: 100dvh; }

/* ------------------------------------------------------------------ */
/* Carga */
.edch-boot { min-height: 60vh; display: flex; gap: 12px; align-items: center; justify-content: center; color: var(--edch-muted); }
.edch-spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--edch-line); border-top-color: var(--edch-accent); animation: edch-spin .8s linear infinite; }
@keyframes edch-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* Botones, campos, tarjetas */
.edch-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; padding: 0 20px; border-radius: var(--edch-radius);
	border: 1px solid var(--edch-line); background: var(--edch-surface); color: var(--edch-ink);
	font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .08s ease, background-color .15s ease;
}
.edch-btn:active { transform: scale(.98); }
.edch-btn:focus-visible, .edch-tab:focus-visible, .edch-link:focus-visible, .edch-day__head:focus-visible, .edch-chip-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--edch-accent) 45%, transparent); outline-offset: 2px; }
.edch-btn--primary { background: var(--edch-accent); border-color: var(--edch-accent); color: var(--edch-accent-ink); }
.edch-btn--ghost { background: transparent; }
.edch-btn--danger { color: var(--edch-danger); border-color: color-mix(in srgb, var(--edch-danger) 35%, var(--edch-line)); }
.edch-btn--small { min-height: 36px; padding: 0 14px; font-size: .9rem; border-radius: 10px; }
.edch-btn--block { width: 100%; }
.edch-btn[disabled] { opacity: .55; cursor: default; }

.edch-link { color: var(--edch-accent); font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; }
.edch-link:hover { text-decoration: underline; }

.edch-card { background: var(--edch-surface); border-radius: var(--edch-radius-lg); padding: 20px; border: 1px solid var(--edch-line); }

.edch-field { display: grid; gap: 6px; margin-bottom: 14px; }
.edch-field > span { font-size: .875rem; font-weight: 600; color: var(--edch-muted); }
.edch-field input, .edch-field select, .edch-field textarea {
	width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
	border: 1px solid var(--edch-line); background: #fff; font-size: 16px;
}
.edch-field textarea { min-height: 88px; resize: vertical; }
.edch-field input:focus, .edch-field select:focus, .edch-field textarea:focus { outline: none; border-color: var(--edch-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--edch-accent) 18%, transparent); }
.edch-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.edch-check { display: flex; gap: 10px; align-items: center; margin: 4px 0 18px; color: var(--edch-muted); font-size: .95rem; }
.edch-check input { width: 20px; height: 20px; accent-color: var(--edch-accent); }

.edch-alert { padding: 12px 14px; border-radius: 12px; font-size: .95rem; margin-bottom: 14px; }
.edch-alert--error { background: var(--edch-danger-soft); color: var(--edch-danger); }
.edch-alert--info { background: var(--edch-soft); color: var(--edch-ink); }
.edch-alert--warn { background: var(--edch-pause-soft); color: #6b3f07; }

/* ------------------------------------------------------------------ */
/* Acceso */
.edch-login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--edch-bg); }
.edch-login__card { width: 100%; max-width: 380px; padding: 28px 24px; }
.edch-login__brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.edch-login__mark { width: 44px; height: 44px; border-radius: 14px; background: var(--edch-accent); position: relative; flex: none; }
.edch-login__mark::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; border: 3px solid #fff; border-right-color: transparent; transform: rotate(45deg); }
.edch-login__title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.edch-login__company { color: var(--edch-muted); font-size: .95rem; }
.edch-login .edch-btn--block { margin-bottom: 16px; }
.edch-login .edch-link { display: block; text-align: center; }
.edch-login p + p { margin-top: 12px; }

/* ------------------------------------------------------------------ */
/* Estructura de la app */
.edch-app { max-width: 540px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); background: var(--edch-bg); }
.edch-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 0 12px; }
.edch-top__hello { font-size: 1.125rem; font-weight: 700; }
.edch-top__sub { font-size: .85rem; color: var(--edch-muted); }
.edch-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--edch-soft); color: var(--edch-accent); font-weight: 700; border: 0; cursor: pointer; }

.edch-view { display: grid; gap: 14px; }
.edch-section-title { font-size: 1.05rem; font-weight: 700; margin: 8px 2px 0; }
.edch-muted { color: var(--edch-muted); }
.edch-small { font-size: .875rem; }

/* Barra inferior */
.edch-tabs {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
	display: grid; grid-template-columns: repeat(5, 1fr);
	max-width: 540px; margin: 0 auto;
	padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
	background: color-mix(in srgb, var(--edch-surface) 92%, transparent);
	backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
	border-top: 1px solid var(--edch-line);
}
@media (min-width: 560px) { .edch-tabs { bottom: 12px; border: 1px solid var(--edch-line); border-radius: 20px; } }
.edch-tab { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--edch-muted); font-size: .72rem; font-weight: 600; cursor: pointer; border-radius: 12px; position: relative; }
.edch-tab svg { width: 24px; height: 24px; }
.edch-tab[aria-current="page"] { color: var(--edch-accent); }
.edch-tab__dot { position: absolute; top: 4px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--edch-danger); }

/* ------------------------------------------------------------------ */
/* Tarjeta de fichaje (el elemento protagonista) */
.edch-punch {
	--state: var(--edch-muted);
	--state-soft: var(--edch-soft);
	border-radius: 28px; padding: 22px 20px 20px; background: var(--edch-surface);
	border: 1px solid var(--edch-line); position: relative; overflow: hidden;
}
.edch-punch::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--state); }
.edch-punch[data-state="working"] { --state: var(--edch-work); --state-soft: var(--edch-work-soft); }
.edch-punch[data-state="paused"]  { --state: var(--edch-pause); --state-soft: var(--edch-pause-soft); }

.edch-punch__status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--state-soft); color: var(--state); font-weight: 700; font-size: .9rem; }
.edch-punch__status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.edch-punch[data-state="working"] .edch-punch__status::before { animation: edch-pulse 1.6s ease-in-out infinite; }
@keyframes edch-pulse { 50% { opacity: .35; } }

.edch-clock { font-family: var(--edch-font-num); font-variant-numeric: tabular-nums; font-size: clamp(3.25rem, 17vw, 4.5rem); font-weight: 700; letter-spacing: -.03em; line-height: 1; margin: 18px 0 6px; }
.edch-clock small { font-size: .42em; font-weight: 600; color: var(--edch-muted); letter-spacing: 0; margin-left: 4px; }
.edch-punch__meta { color: var(--edch-muted); font-size: .95rem; }

.edch-progress { height: 8px; border-radius: 99px; background: var(--edch-soft); margin: 16px 0 6px; overflow: hidden; }
.edch-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--state); transition: width .4s ease; }
.edch-progress-label { display: flex; justify-content: space-between; font-size: .85rem; color: var(--edch-muted); }

.edch-punch__actions { display: grid; gap: 10px; margin-top: 20px; }
.edch-punch__actions--two { grid-template-columns: 1fr 1fr; }
.edch-punch__actions .edch-btn { min-height: 60px; font-size: 1.05rem; border-radius: 18px; }
.edch-btn--in { background: var(--edch-accent); border-color: var(--edch-accent); color: var(--edch-accent-ink); min-height: 72px !important; font-size: 1.2rem !important; }
.edch-btn--out { background: var(--edch-ink); border-color: var(--edch-ink); color: #fff; }
.edch-btn--resume { background: var(--edch-work); border-color: var(--edch-work); color: #fff; }

/* Avisos */
.edch-banner { display: grid; gap: 10px; padding: 14px 16px; border-radius: 16px; background: var(--edch-surface); border: 1px solid var(--edch-line); }
.edch-banner--warn { background: var(--edch-pause-soft); border-color: transparent; color: #5c3605; }
.edch-banner--info { background: var(--edch-soft); border-color: transparent; }
.edch-banner--test { background: #e8f0fb; border-color: transparent; color: #1d3b66; }
.edch-banner strong { display: block; font-weight: 700; }
.edch-banner__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Línea de tiempo de hoy */
.edch-timeline { list-style: none; margin: 0; padding: 0; }
.edch-timeline li { display: grid; grid-template-columns: 56px 14px 1fr; align-items: center; gap: 10px; padding: 9px 0; }
.edch-timeline li + li { border-top: 1px dashed var(--edch-line); }
.edch-timeline time { font-family: var(--edch-font-num); font-variant-numeric: tabular-nums; font-weight: 700; }
.edch-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--edch-muted); }
.edch-dot--in { background: var(--edch-work); }
.edch-dot--out { background: var(--edch-ink); }
.edch-dot--break_start, .edch-dot--break_end { background: var(--edch-pause); }
.edch-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--edch-soft); color: var(--edch-muted); margin-left: 6px; }
.edch-tag--warn { background: var(--edch-pause-soft); color: #6b3f07; }
.edch-tag--danger { background: var(--edch-danger-soft); color: var(--edch-danger); }
.edch-tag--ok { background: var(--edch-work-soft); color: var(--edch-work); }

.edch-empty { padding: 18px; text-align: center; color: var(--edch-muted); }

/* ------------------------------------------------------------------ */
/* Registro mensual */
.edch-monthbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.edch-monthbar h2 { font-size: 1.15rem; font-weight: 700; }
.edch-iconbtn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--edch-line); background: var(--edch-surface); cursor: pointer; }
.edch-iconbtn[disabled] { opacity: .35; cursor: default; }
.edch-iconbtn svg { width: 20px; height: 20px; }

.edch-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.edch-stat { background: var(--edch-surface); border: 1px solid var(--edch-line); border-radius: 16px; padding: 12px; }
.edch-stat__value { font-family: var(--edch-font-num); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.35rem; }
.edch-stat__label { font-size: .8rem; color: var(--edch-muted); }
.edch-pos { color: var(--edch-work); }
.edch-neg { color: var(--edch-danger); }

.edch-days { display: grid; gap: 8px; }
.edch-day { background: var(--edch-surface); border: 1px solid var(--edch-line); border-radius: 16px; }
.edch-day__head { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 12px 14px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 16px; }
.edch-day__date { font-weight: 700; text-transform: capitalize; }
.edch-day__times { grid-column: 1; font-family: var(--edch-font-num); font-variant-numeric: tabular-nums; color: var(--edch-muted); font-size: .9rem; }
.edch-day__worked { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-family: var(--edch-font-num); font-variant-numeric: tabular-nums; font-weight: 700; }
.edch-day__worked small { display: block; font-weight: 500; font-size: .78rem; color: var(--edch-muted); }
.edch-day__body { padding: 0 14px 14px; border-top: 1px solid var(--edch-line); }
.edch-day--today { border-color: color-mix(in srgb, var(--edch-accent) 40%, var(--edch-line)); }
.edch-day--rest .edch-day__date { color: var(--edch-muted); font-weight: 600; }

.edch-entry { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.edch-entry + .edch-entry { border-top: 1px dashed var(--edch-line); }
.edch-entry time { font-family: var(--edch-font-num); font-variant-numeric: tabular-nums; font-weight: 700; min-width: 48px; }
.edch-entry__label { flex: 1; }
.edch-chip-btn { border: 1px solid var(--edch-line); background: var(--edch-surface); border-radius: 999px; padding: 6px 12px; font-size: .85rem; font-weight: 600; cursor: pointer; color: var(--edch-accent); }

.edch-list { display: grid; gap: 8px; }
.edch-item { background: var(--edch-surface); border: 1px solid var(--edch-line); border-radius: 16px; padding: 12px 14px; display: grid; gap: 4px; }
.edch-item__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.edch-item__title { font-weight: 700; }

/* Horario semanal */
.edch-week { width: 100%; border-collapse: collapse; }
.edch-week th, .edch-week td { text-align: left; padding: 10px 0; border-bottom: 1px solid var(--edch-line); vertical-align: top; }
.edch-week tr:last-child th, .edch-week tr:last-child td { border-bottom: 0; }
.edch-week th { font-weight: 600; width: 34%; }
.edch-week td { font-family: var(--edch-font-num); font-variant-numeric: tabular-nums; }
.edch-week td.edch-week__off { color: var(--edch-muted); font-family: var(--edch-font); }
.edch-week td:last-child { text-align: right; color: var(--edch-muted); }
.edch-week__today th, .edch-week__today td { color: var(--edch-accent); font-weight: 700; }

/* Hoja inferior (formularios) */
.edch-sheet { position: fixed; inset: 0; z-index: 100; display: grid; align-items: end; justify-items: center; }
.edch-sheet__backdrop { position: absolute; inset: 0; background: rgba(32, 22, 38, .42); animation: edch-fade .18s ease; }
.edch-sheet__panel { position: relative; width: 100%; max-width: 540px; max-height: 92vh; overflow: auto; background: var(--edch-surface); border-radius: 24px 24px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); animation: edch-up .22s ease; }
@media (min-width: 560px) { .edch-sheet { align-items: center; } .edch-sheet__panel { border-radius: 24px; } }
.edch-sheet__grip { width: 40px; height: 4px; border-radius: 4px; background: var(--edch-line); margin: 0 auto 14px; }
.edch-sheet__title { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.edch-sheet__text { color: var(--edch-muted); margin-bottom: 16px; }
.edch-sheet__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
@keyframes edch-fade { from { opacity: 0; } }
@keyframes edch-up { from { transform: translateY(24px); opacity: .6; } }

/* Mensajes */
.edch-toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120; max-width: calc(100% - 32px); width: max-content; padding: 12px 16px; border-radius: 14px; background: var(--edch-ink); color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgba(30, 20, 36, .25); animation: edch-up .2s ease; }
.edch-toast--error { background: var(--edch-danger); }

.edch-profile dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.edch-profile dt { color: var(--edch-muted); }
.edch-profile dd { margin: 0; font-weight: 600; word-break: break-word; }

@media (prefers-reduced-motion: reduce) {
	.edch *, .edch *::before, .edch *::after { animation: none !important; transition: none !important; }
}
