@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

html.tp-app-active,
body.tp-app-active {
	overflow: hidden;
	height: 100%;
	overscroll-behavior: none;
}

#tp-app {
	--tp-ink: #1B2340;
	--tp-ink-soft: #5B6482;
	--tp-paper: #F1F3F6;
	--tp-card: #FFFFFF;
	--tp-accent: #0F6E63;
	--tp-accent-dark: #0B534A;
	--tp-gold: #E0982F;
	--tp-danger: #D64550;
	--tp-border: #E4E6EE;
	--tp-radius: 18px;
	--tp-shadow: 0 4px 18px rgba(27,35,64,.07);

	/* Full-viewport app shell: this deliberately ignores the surrounding
	   theme's width, padding, and content wrappers so the planner always
	   renders edge-to-edge and centered, like a native app, regardless of
	   what page or theme it's embedded in. */
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100vh;
	height: 100dvh;
	z-index: 999999;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-y: contain;
	touch-action: pan-y;

	font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
	color: var(--tp-ink);
	background: var(--tp-paper);
	box-sizing: border-box;
	padding: max(16px, env(safe-area-inset-top)) 0 calc(90px + env(safe-area-inset-bottom));
}

#tp-app *, #tp-app *::before, #tp-app *::after { box-sizing: border-box; }

#tp-app h1, #tp-app h2, #tp-app h3 {
	font-family: 'Space Grotesk', sans-serif;
	margin: 0;
}

#tp-app button, #tp-app input, #tp-app select, #tp-app textarea {
	font-family: inherit;
	font-size: 15px;
}

/* Everything except the FAB and modal lives in this centered column, so
   the app also looks right (like a phone mockup) on wider screens. */
.tp-inner {
	max-width: 480px;
	margin: 0 auto;
	padding: 0 16px;
}

.tp-hidden { display: none !important; }

/* ---------- Gate / login ---------- */

.tp-gate {
	min-height: calc(100vh - 106px);
	min-height: calc(100dvh - 106px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
}

.tp-gate-card {
	background: var(--tp-card);
	border-radius: var(--tp-radius);
	box-shadow: var(--tp-shadow);
	padding: 40px 32px;
	width: 100%;
	max-width: 360px;
	text-align: center;
}

.tp-gate-card .tp-gate-icon {
	font-size: 34px;
	margin-bottom: 6px;
}

.tp-gate-card h1 {
	font-size: 22px;
	margin-bottom: 6px;
}

.tp-gate-card p {
	color: var(--tp-ink-soft);
	font-size: 14px;
	margin: 0 0 20px;
}

.tp-gate-card input[type="password"] {
	width: 100%;
	padding: 13px 14px;
	border: 1.5px solid var(--tp-border);
	border-radius: 12px;
	text-align: center;
	letter-spacing: 2px;
	margin-bottom: 12px;
}

.tp-gate-card input[type="password"]:focus {
	outline: none;
	border-color: var(--tp-accent);
}

.tp-error {
	color: var(--tp-danger);
	font-size: 13px;
	min-height: 18px;
	margin-bottom: 8px;
}

/* ---------- Buttons ---------- */

.tp-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	border: none;
	border-radius: 12px;
	padding: 12px 18px;
	font-weight: 600;
	cursor: pointer;
	transition: transform .08s ease, opacity .15s ease;
	width: 100%;
}

.tp-btn:active { transform: scale(0.98); }

.tp-btn-primary {
	background: var(--tp-accent);
	color: #fff;
}

.tp-btn-primary:hover { background: var(--tp-accent-dark); }

.tp-btn-ghost {
	background: transparent;
	color: var(--tp-ink-soft);
	border: 1.5px solid var(--tp-border);
	width: auto;
}

.tp-btn-danger {
	background: transparent;
	color: var(--tp-danger);
	width: auto;
}

.tp-btn-small {
	padding: 7px 12px;
	font-size: 13px;
	width: auto;
}

/* ---------- Top bar ---------- */

.tp-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 18px;
	gap: 10px;
}

.tp-trip-select-wrap select {
	font-family: 'Space Grotesk', sans-serif;
	font-weight: 600;
	font-size: 19px;
	color: var(--tp-ink);
	background: transparent;
	border: none;
	appearance: none;
	padding-right: 18px;
	cursor: pointer;
}

.tp-trip-dates {
	color: var(--tp-ink-soft);
	font-family: 'IBM Plex Mono', monospace;
	font-size: 12.5px;
	margin-top: 2px;
}

.tp-logout {
	background: transparent;
	border: none;
	color: var(--tp-ink-soft);
	font-size: 13px;
	cursor: pointer;
	text-decoration: underline;
	width: auto;
}

.tp-topbar-actions {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-shrink: 0;
}

#tp-refresh-btn {
	text-decoration: none;
	font-size: 17px;
	line-height: 1;
	display: inline-block;
}

#tp-refresh-btn.tp-spin {
	animation: tp-spin 0.6s linear;
}

@keyframes tp-spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

/* ---------- Budget summary ---------- */

.tp-summary {
	background: var(--tp-ink);
	color: #fff;
	border-radius: var(--tp-radius);
	padding: 20px 22px;
	margin-bottom: 18px;
	box-shadow: var(--tp-shadow);
}

.tp-summary-label {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 1.5px;
	opacity: .65;
}

.tp-summary-total {
	font-family: 'IBM Plex Mono', monospace;
	font-size: 30px;
	font-weight: 600;
	margin: 4px 0 12px;
	color: var(--tp-gold);
}

.tp-summary-breakdown {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.tp-summary-chip {
	background: rgba(255,255,255,.08);
	border-radius: 10px;
	padding: 6px 10px;
	font-size: 12.5px;
	display: flex;
	align-items: center;
	gap: 5px;
	font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Filters ---------- */

.tp-filters {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	overflow-y: hidden;
	touch-action: pan-x;
	padding-bottom: 4px;
	margin-bottom: 6px;
	-webkit-overflow-scrolling: touch;
}

.tp-chip {
	flex: 0 0 auto;
	border: 1.5px solid var(--tp-border);
	background: var(--tp-card);
	border-radius: 20px;
	padding: 7px 14px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	white-space: nowrap;
	color: var(--tp-ink-soft);
}

.tp-chip.is-active {
	background: var(--tp-ink);
	border-color: var(--tp-ink);
	color: #fff;
}

.tp-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin: 10px 0 16px;
	flex-wrap: wrap;
}

.tp-toolbar-right {
	display: flex;
	align-items: center;
	gap: 8px;
}

.tp-toolbar input[type="date"],
.tp-toolbar select {
	border: 1.5px solid var(--tp-border);
	border-radius: 10px;
	padding: 7px 10px;
	font-size: 13px;
	background: var(--tp-card);
	color: var(--tp-ink-soft);
}

.tp-clear-date {
	background: transparent;
	border: none;
	color: var(--tp-ink-soft);
	font-size: 12px;
	text-decoration: underline;
	cursor: pointer;
	width: auto;
	padding: 0;
}

/* ---------- Place cards: boarding-pass stubs ---------- */

.tp-places {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.tp-empty {
	text-align: center;
	padding: 50px 20px;
	color: var(--tp-ink-soft);
	background: var(--tp-card);
	border-radius: var(--tp-radius);
}

.tp-empty-icon { font-size: 32px; margin-bottom: 8px; }

.tp-place {
	display: flex;
	align-items: stretch;
	background: var(--tp-card);
	border-radius: var(--tp-radius);
	box-shadow: var(--tp-shadow);
	overflow: hidden;
	position: relative;
	transition: opacity .15s ease;
}

.tp-place.is-visited {
	opacity: .6;
}

.tp-check-btn {
	flex: 0 0 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	padding: 0;
	cursor: pointer;
	width: auto;
}

.tp-check-circle {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: 2px solid var(--tp-border);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 13px;
	font-weight: 700;
	color: transparent;
	background: #fff;
	transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.tp-place.is-visited .tp-check-circle {
	background: var(--tp-accent);
	border-color: var(--tp-accent);
	color: #fff;
}

.tp-visited-tag {
	color: var(--tp-accent);
	font-weight: 600;
}

.tp-place.is-visited .tp-place-name {
	text-decoration: line-through;
	text-decoration-color: var(--tp-ink-soft);
}

.tp-place-main {
	flex: 1;
	padding: 16px 14px 16px 18px;
	min-width: 0;
}

.tp-place-when {
	font-family: 'IBM Plex Mono', monospace;
	font-size: 12.5px;
	color: var(--tp-ink-soft);
	letter-spacing: .3px;
	margin-bottom: 4px;
}

.tp-place-name {
	font-family: 'Space Grotesk', sans-serif;
	font-weight: 600;
	font-size: 17px;
	line-height: 1.25;
	margin-bottom: 4px;
	word-break: break-word;
}

.tp-place-notes {
	font-size: 13px;
	color: var(--tp-ink-soft);
	margin-bottom: 8px;
	line-height: 1.4;
}

.tp-place-meta {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.tp-place-budget {
	font-family: 'IBM Plex Mono', monospace;
	font-weight: 600;
	font-size: 13.5px;
	color: var(--tp-accent-dark);
}

.tp-place-link {
	font-size: 12.5px;
	color: var(--tp-accent);
	text-decoration: none;
}

.tp-place-actions {
	margin-top: 10px;
	display: flex;
	gap: 14px;
}

.tp-place-actions button {
	background: transparent;
	border: none;
	padding: 0;
	font-size: 12.5px;
	color: var(--tp-ink-soft);
	cursor: pointer;
	width: auto;
	text-decoration: underline;
}

.tp-place-actions button.tp-delete-btn { color: var(--tp-danger); }

/* Perforated stub divider */
.tp-place-stub {
	flex: 0 0 84px;
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	color: #fff;
	text-align: center;
	padding: 10px 6px;
}

.tp-place-stub::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 0;
	border-left: 2px dashed rgba(255,255,255,.55);
}

.tp-place-stub::after {
	content: "";
	position: absolute;
	left: -7px;
	top: -7px;
	bottom: -7px;
	width: 14px;
	background:
		radial-gradient(circle 7px at 0 -7px, transparent 7px, var(--tp-paper) 7.5px) top left / 100% 14px repeat-y,
		radial-gradient(circle 7px at 0 0, var(--tp-paper) 7px, transparent 7.5px) 0 0 / 14px 14px repeat-y;
}

.tp-stub-icon { font-size: 20px; }

.tp-stub-name {
	font-family: 'IBM Plex Mono', monospace;
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: .5px;
	line-height: 1.2;
}

/* ---------- Floating add button ---------- */

.tp-fab {
	position: fixed;
	bottom: calc(26px + env(safe-area-inset-bottom));
	right: max(20px, calc(50vw - 240px + 20px));
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background: var(--tp-accent);
	color: #fff;
	font-size: 28px;
	border: none;
	box-shadow: 0 8px 20px rgba(15,110,99,.4);
	cursor: pointer;
	z-index: 1000000;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.tp-fab:active { transform: scale(0.95); }

/* ---------- Modal ---------- */

.tp-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(20,24,40,.55);
	display: flex;
	align-items: flex-end;
	justify-content: center;
	z-index: 1000001;
	padding: 0;
}

@media (min-width: 640px) {
	.tp-modal-overlay { align-items: center; padding: 20px; }
}

.tp-modal {
	background: var(--tp-card);
	width: 100%;
	max-width: 480px;
	max-height: 92vh;
	overflow-y: auto;
	border-radius: 20px 20px 0 0;
	padding: 24px 22px 26px;
}

@media (min-width: 640px) {
	.tp-modal { border-radius: 20px; }
}

.tp-modal h2 {
	font-size: 19px;
	margin-bottom: 16px;
}

.tp-field {
	margin-bottom: 14px;
}

.tp-field label {
	display: block;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--tp-ink-soft);
	margin-bottom: 5px;
}

.tp-field input,
.tp-field select,
.tp-field textarea {
	width: 100%;
	border: 1.5px solid var(--tp-border);
	border-radius: 10px;
	padding: 10px 12px;
	color: var(--tp-ink);
	background: #fff;
}

.tp-field input:focus,
.tp-field select:focus,
.tp-field textarea:focus {
	outline: none;
	border-color: var(--tp-accent);
}

.tp-field-row {
	display: flex;
	gap: 10px;
}

.tp-field-row .tp-field { flex: 1; }

.tp-checkbox-field {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 500;
	color: var(--tp-ink);
	margin-bottom: 4px;
	cursor: pointer;
}

.tp-checkbox-field input[type="checkbox"] {
	width: 18px;
	height: 18px;
	accent-color: var(--tp-accent);
	cursor: pointer;
}

.tp-modal-actions {
	display: flex;
	gap: 10px;
	margin-top: 18px;
}

.tp-modal-actions .tp-btn-ghost { flex: 1; }
.tp-modal-actions .tp-btn-primary { flex: 2; }

/* ---------- Misc states ---------- */

.tp-loading {
	text-align: center;
	padding: 60px 20px;
	color: var(--tp-ink-soft);
}

.tp-no-trips {
	background: var(--tp-card);
	border-radius: var(--tp-radius);
	padding: 40px 24px;
	text-align: center;
	color: var(--tp-ink-soft);
	width: 100%;
	max-width: 380px;
}

@media (max-width: 420px) {
	.tp-place-stub { flex-basis: 68px; }
}

/* ---------- Toast ---------- */

.tp-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translate(-50%, 12px);
	background: var(--tp-ink, #1B2340);
	color: #fff;
	padding: 12px 18px;
	border-radius: 12px;
	font-size: 13.5px;
	box-shadow: 0 8px 24px rgba(0,0,0,.25);
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease;
	z-index: 60;
	max-width: 90%;
	text-align: center;
}

.tp-toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}
