/* =========================================================================
   Eurofiestas TPV
   ========================================================================= */

.ef-tpv-root,
.ef-tpv-root * {
	box-sizing: border-box;
}

.ef-tpv-root {
	--ink: #102a35;
	--ink-2: #1b3d4a;
	--bg: #eaeeef;
	--card: #ffffff;
	--text: #102a35;
	--muted: #5c6e75;
	--line: #dee5e7;
	--in: #1c8a5b;
	--in-bg: #e6f4ec;
	--out: #c0463b;
	--out-bg: #fae9e7;
	--accent: #f2a33c;
	--accent-ink: #6e430f;
	--radius: 14px;
	--shadow: 0 1px 2px rgba(16, 42, 53, .06), 0 6px 18px rgba(16, 42, 53, .08);

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--text);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
	max-width: 640px;
	margin: 0 auto;
	min-height: 100%;
	position: relative;
}

.ef-num {
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
}

/* Standalone: app ocupa toda la pantalla */
body.ef-tpv-standalone {
	margin: 0;
	background: var(--bg, #eaeeef);
}
body.ef-tpv-standalone .ef-tpv-root {
	min-height: 100vh;
	min-height: 100dvh;
}

/* -------------------------------------------------------- Barra superior */
.ef-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 14px 16px;
	background: var(--ink);
	color: #fff;
	position: sticky;
	top: 0;
	z-index: 20;
}
.ef-brand {
	display: flex;
	align-items: center;
	gap: 9px;
	font-weight: 700;
	letter-spacing: .2px;
	font-size: 16px;
}
.ef-brand .ef-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 0 3px rgba(242, 163, 60, .25);
}
.ef-pill {
	font-size: 12px;
	font-weight: 600;
	padding: 5px 10px;
	border-radius: 999px;
	white-space: nowrap;
}
.ef-pill.is-open {
	background: rgba(28, 138, 91, .2);
	color: #b8f0d4;
}
.ef-pill.is-closed {
	background: rgba(255, 255, 255, .12);
	color: #cdd7da;
}

/* ---------------------------------------------------------------- Layout */
.ef-main {
	padding: 16px 16px 96px;
}
.ef-card {
	background: var(--card);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 18px;
	margin-bottom: 14px;
}
.ef-section-label {
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .8px;
	text-transform: uppercase;
	color: var(--muted);
	margin: 6px 2px 10px;
}

/* ----------------------------------------------------------- Hero saldo */
.ef-hero {
	background: var(--ink);
	color: #fff;
	border-radius: var(--radius);
	padding: 22px 20px;
	margin-bottom: 14px;
	box-shadow: var(--shadow);
}
.ef-hero .ef-hero-label {
	font-size: 12px;
	letter-spacing: .9px;
	text-transform: uppercase;
	color: #9fb4bb;
	font-weight: 600;
}
.ef-hero .ef-hero-amount {
	font-size: 44px;
	line-height: 1.05;
	font-weight: 800;
	margin: 6px 0 2px;
	letter-spacing: -1px;
}
.ef-hero .ef-hero-sub {
	font-size: 13px;
	color: #9fb4bb;
}

/* ------------------------------------------------------------ Arqueo box */
.ef-arqueo {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1px;
	background: var(--line);
	border-radius: 12px;
	overflow: hidden;
	border: 1px solid var(--line);
}
.ef-arqueo .ef-aq {
	background: #fff;
	padding: 12px 14px;
}
.ef-arqueo .ef-aq .k {
	font-size: 12px;
	color: var(--muted);
	font-weight: 600;
}
.ef-arqueo .ef-aq .v {
	font-size: 18px;
	font-weight: 700;
	margin-top: 2px;
}
.ef-aq .v.in { color: var(--in); }
.ef-aq .v.out { color: var(--out); }
.ef-arqueo .ef-aq.full {
	grid-column: 1 / -1;
	background: #f6f9f9;
}

/* -------------------------------------------------------------- Botones */
.ef-btn {
	appearance: none;
	border: 0;
	border-radius: 12px;
	font-size: 16px;
	font-weight: 700;
	padding: 15px 16px;
	cursor: pointer;
	width: 100%;
	font-family: inherit;
	transition: transform .04s ease, filter .15s ease;
	color: #fff;
}
.ef-btn:active { transform: translateY(1px); }
.ef-btn:focus-visible { outline: 3px solid rgba(16,42,53,.35); outline-offset: 2px; }
.ef-btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.ef-btn.ink { background: var(--ink); }
.ef-btn.accent { background: var(--accent); color: var(--accent-ink); }
.ef-btn.in { background: var(--in); }
.ef-btn.out { background: var(--out); }
.ef-btn[disabled] { opacity: .5; cursor: not-allowed; }

.ef-actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-bottom: 14px;
}
.ef-actions .ef-btn { padding: 18px 12px; font-size: 17px; }

/* --------------------------------------------------------- Movimientos */
.ef-mov-list { list-style: none; margin: 0; padding: 0; }
.ef-mov-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 2px;
	border-bottom: 1px solid var(--line);
}
.ef-mov-row:last-child { border-bottom: 0; }
.ef-mov-ico {
	width: 34px;
	height: 34px;
	border-radius: 9px;
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	font-weight: 800;
	font-size: 18px;
}
.ef-mov-ico.in { background: var(--in-bg); color: var(--in); }
.ef-mov-ico.out { background: var(--out-bg); color: var(--out); }
.ef-mov-body { flex: 1 1 auto; min-width: 0; }
.ef-mov-body .c {
	font-weight: 600;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.ef-mov-body .t { font-size: 12px; color: var(--muted); margin-top: 1px; }
.ef-mov-amount { font-weight: 800; font-size: 16px; white-space: nowrap; }
.ef-mov-amount.in { color: var(--in); }
.ef-mov-amount.out { color: var(--out); }
.ef-mov-del {
	border: 0;
	background: transparent;
	color: var(--muted);
	font-size: 20px;
	line-height: 1;
	padding: 4px 6px;
	cursor: pointer;
	border-radius: 8px;
}
.ef-mov-del:hover { background: var(--out-bg); color: var(--out); }

.ef-empty {
	text-align: center;
	color: var(--muted);
	padding: 26px 10px;
	font-size: 14px;
}

/* ------------------------------------------------------------- Formulario */
.ef-field { margin-bottom: 14px; }
.ef-field label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--muted);
	margin-bottom: 6px;
}
.ef-input, .ef-textarea, .ef-select {
	width: 100%;
	font-size: 16px;
	font-family: inherit;
	padding: 13px 14px;
	border: 1px solid var(--line);
	border-radius: 11px;
	background: #fff;
	color: var(--text);
}
.ef-input:focus, .ef-textarea:focus, .ef-select:focus {
	outline: 0;
	border-color: var(--ink-2);
	box-shadow: 0 0 0 3px rgba(27, 61, 74, .15);
}
.ef-input.amount {
	font-size: 26px;
	font-weight: 800;
	text-align: right;
	letter-spacing: -.5px;
}
.ef-textarea { resize: vertical; min-height: 60px; }
.ef-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* -------------------------------------------------------- Segmented control */
.ef-seg {
	display: flex;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 11px;
	padding: 4px;
	gap: 4px;
	margin-bottom: 12px;
}
.ef-seg button {
	flex: 1;
	border: 0;
	background: transparent;
	padding: 9px 6px;
	font-size: 14px;
	font-weight: 600;
	color: var(--muted);
	border-radius: 8px;
	cursor: pointer;
	font-family: inherit;
}
.ef-seg button.active { background: var(--ink); color: #fff; }

/* ----------------------------------------------------------- Histórico */
.ef-hist-filter {
	display: flex;
	gap: 8px;
	margin-bottom: 14px;
}
.ef-hist-filter .ef-input { flex: 1; }
.ef-hist-filter .ef-btn { width: auto; padding: 13px 18px; }

.ef-summary {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-bottom: 14px;
}
.ef-summary .s {
	background: #fff;
	border-radius: 12px;
	padding: 14px;
	box-shadow: var(--shadow);
}
.ef-summary .s .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.ef-summary .s .v { font-size: 22px; font-weight: 800; margin-top: 3px; }
.ef-summary .s .v.in { color: var(--in); }
.ef-summary .s .v.out { color: var(--out); }

.ef-caja-card { cursor: pointer; }
.ef-caja-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.ef-caja-head .when { font-weight: 700; font-size: 15px; }
.ef-tag {
	font-size: 11px;
	font-weight: 700;
	padding: 3px 9px;
	border-radius: 999px;
	text-transform: uppercase;
	letter-spacing: .4px;
}
.ef-tag.abierta { background: var(--in-bg); color: var(--in); }
.ef-tag.cerrada { background: #eef1f2; color: var(--muted); }
.ef-caja-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin-top: 12px;
}
.ef-caja-grid .g .k { font-size: 11px; color: var(--muted); }
.ef-caja-grid .g .v { font-weight: 700; font-size: 15px; margin-top: 1px; }
.ef-caja-grid .g .v.in { color: var(--in); }
.ef-caja-grid .g .v.out { color: var(--out); }
.ef-dif {
	margin-top: 10px;
	font-size: 13px;
	font-weight: 600;
	padding: 8px 10px;
	border-radius: 9px;
	background: #f6f9f9;
}
.ef-dif.ok { color: var(--in); background: var(--in-bg); }
.ef-dif.bad { color: var(--out); background: var(--out-bg); }
.ef-detalle { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 6px; }

/* ----------------------------------------------------------- Bottom nav */
.ef-nav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 30;
	display: flex;
	background: #fff;
	border-top: 1px solid var(--line);
	max-width: 640px;
	margin: 0 auto;
	padding-bottom: env(safe-area-inset-bottom);
}
.ef-nav button {
	flex: 1;
	border: 0;
	background: transparent;
	padding: 11px 6px 10px;
	font-size: 12px;
	font-weight: 600;
	color: var(--muted);
	cursor: pointer;
	font-family: inherit;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
}
.ef-nav button .ic { font-size: 20px; line-height: 1; }
.ef-nav button.active { color: var(--ink); }

/* ------------------------------------------------------------ Modal/sheet */
.ef-modal-back {
	position: fixed;
	inset: 0;
	background: rgba(16, 42, 53, .5);
	z-index: 50;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}
.ef-modal {
	background: #fff;
	width: 100%;
	max-width: 640px;
	border-radius: 18px 18px 0 0;
	padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
	animation: ef-up .18s ease;
	max-height: 92vh;
	overflow-y: auto;
}
@keyframes ef-up { from { transform: translateY(20px); opacity: .6; } to { transform: none; opacity: 1; } }
.ef-modal-title {
	font-size: 18px;
	font-weight: 800;
	margin: 0 0 14px;
	display: flex;
	align-items: center;
	gap: 9px;
}
.ef-modal-title .badge {
	width: 28px; height: 28px; border-radius: 8px;
	display: grid; place-items: center; font-size: 18px; font-weight: 800;
}
.ef-modal-title .badge.in { background: var(--in-bg); color: var(--in); }
.ef-modal-title .badge.out { background: var(--out-bg); color: var(--out); }
.ef-modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.ef-modal-actions .ef-btn { flex: 1; }

.ef-cierre-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 14px;
}
.ef-cierre-table td {
	padding: 9px 2px;
	border-bottom: 1px solid var(--line);
	font-size: 15px;
}
.ef-cierre-table td:last-child { text-align: right; font-weight: 700; }
.ef-cierre-table tr.total td { font-size: 17px; font-weight: 800; border-bottom: 0; }
.ef-cierre-table td .in { color: var(--in); }
.ef-cierre-table td .out { color: var(--out); }
.ef-dif-live {
	margin-top: 12px;
	padding: 12px 14px;
	border-radius: 11px;
	font-weight: 700;
	text-align: center;
	background: #f6f9f9;
}
.ef-dif-live.ok { background: var(--in-bg); color: var(--in); }
.ef-dif-live.bad { background: var(--out-bg); color: var(--out); }

/* -------------------------------------------------------------- Estados */
.ef-gate, .ef-loading {
	padding: 60px 24px;
	text-align: center;
	color: var(--muted);
}
.ef-gate h2 { color: var(--text); margin-bottom: 8px; }
.ef-gate .ef-btn { max-width: 260px; margin: 14px auto 0; }

.ef-toast {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	bottom: 84px;
	background: var(--ink);
	color: #fff;
	padding: 11px 18px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	z-index: 80;
	box-shadow: var(--shadow);
	animation: ef-up .18s ease;
	max-width: 90%;
	text-align: center;
}
.ef-toast.err { background: var(--out); }

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

@media (min-width: 560px) {
	.ef-hero .ef-hero-amount { font-size: 52px; }
}

@media (prefers-reduced-motion: reduce) {
	.ef-modal, .ef-toast { animation: none; }
	.ef-spinner { animation-duration: 1.4s; }
}

/* ----------------------------------------------------------- Acceso PIN */
.ef-top-right { display: flex; align-items: center; gap: 8px; }
.ef-lock {
	border: 0;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	width: 32px;
	height: 32px;
	border-radius: 9px;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
}
.ef-lock:active { transform: translateY(1px); }

.ef-pin-wrap {
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 18px;
	background: var(--ink);
}
.ef-pin-card {
	background: #fff;
	border-radius: 20px;
	padding: 26px 22px 22px;
	width: 100%;
	max-width: 340px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
	text-align: center;
}
.ef-pin-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--muted);
	margin-bottom: 16px;
}
.ef-pin-dots {
	display: flex;
	gap: 12px;
	justify-content: center;
	margin-bottom: 6px;
	min-height: 20px;
}
.ef-pin-dot {
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 2px solid var(--line);
	background: transparent;
	transition: background .12s ease, border-color .12s ease;
}
.ef-pin-dot.filled { background: var(--ink); border-color: var(--ink); }
.ef-pin-err {
	color: var(--out);
	font-size: 13px;
	font-weight: 600;
	margin: 10px 0 0;
	min-height: 16px;
}
.ef-pad {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
	margin-top: 20px;
}
.ef-key {
	appearance: none;
	border: 1px solid var(--line);
	background: #fff;
	border-radius: 14px;
	font-size: 24px;
	font-weight: 600;
	color: var(--text);
	padding: 16px 0;
	cursor: pointer;
	font-family: inherit;
	font-variant-numeric: tabular-nums;
	transition: transform .04s ease, background .12s ease;
}
.ef-key:active { transform: translateY(1px); background: var(--bg); }
.ef-key.ghost { border-color: transparent; color: var(--muted); font-size: 22px; }
.ef-key.ok { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: 26px; }
.ef-key:focus-visible { outline: 3px solid rgba(16, 42, 53, .3); outline-offset: 2px; }

/* ------------------------------------------------------ Histórico / PDF */
.ef-back-main {
	margin-bottom: 12px;
}
.ef-print-btn {
	margin-bottom: 14px;
}
.ef-print-header {
	display: none;
}

@media print {
	body.ef-tpv-printing * {
		visibility: hidden !important;
	}
	body.ef-tpv-printing #ef-tpv-app,
	body.ef-tpv-printing #ef-tpv-app * {
		visibility: visible !important;
	}
	body.ef-tpv-printing #ef-tpv-app {
		position: absolute !important;
		left: 0 !important;
		top: 0 !important;
		width: 100% !important;
		max-width: none !important;
		min-height: auto !important;
		margin: 0 !important;
		background: #fff !important;
		color: #000 !important;
		box-shadow: none !important;
	}
	body.ef-tpv-printing .ef-topbar,
	body.ef-tpv-printing .ef-nav,
	body.ef-tpv-printing .ef-no-print,
	body.ef-tpv-printing .ef-toast {
		display: none !important;
	}
	body.ef-tpv-printing .ef-main {
		padding: 0 !important;
	}
	body.ef-tpv-printing .ef-print-header {
		display: block !important;
		margin: 0 0 14px !important;
		padding: 0 0 12px !important;
		border-bottom: 1px solid #ccc !important;
	}
	body.ef-tpv-printing .ef-print-header h1 {
		font-size: 22px !important;
		margin: 0 0 4px !important;
		color: #000 !important;
	}
	body.ef-tpv-printing .ef-print-header p {
		font-size: 13px !important;
		margin: 0 !important;
		color: #333 !important;
	}
	body.ef-tpv-printing .ef-card,
	body.ef-tpv-printing .ef-summary .s {
		box-shadow: none !important;
		border: 1px solid #ddd !important;
		break-inside: avoid !important;
		page-break-inside: avoid !important;
	}
	body.ef-tpv-printing .ef-caja-card {
		cursor: default !important;
	}
	body.ef-tpv-printing .ef-summary {
		grid-template-columns: repeat(4, 1fr) !important;
	}
}
