/*
 * Wise Caretaker - phone app styles.
 * Warm paper background, deep green ink, one orange call to action.
 * Thumb-sized targets (min 48px), one column, nothing hidden behind menus.
 */

:root
{
	--ink: #16302b;
	--ink-2: #2c4a43;
	--muted: #6b7a75;
	--paper: #f5f2ea;
	--card: #ffffff;
	--line: #e4dfd3;
	--accent: #e8743a;
	--accent-ink: #ffffff;
	--teal: #1f6f5c;
	--teal-soft: #e3f0ec;
	--danger: #c8453b;
	--radius: 18px;
	--shadow: 0 1px 2px rgba(22, 48, 43, .06), 0 4px 14px rgba(22, 48, 43, .06);

	--st-open: #2f6fdb;
	--st-awaiting_approval: #b97c06;
	--st-approved: #1f8a70;
	--st-in_progress: #7a4fd6;
	--st-done: #2e9e4f;
	--st-closed: #8a948f;
	--st-rejected: #c8453b;
	--st-cancelled: #8a948f;

	--safe-top: env(safe-area-inset-top, 0px);
	--safe-bottom: env(safe-area-inset-bottom, 0px);
}

*
{
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html, body
{
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

#app
{
	max-width: 560px;
	margin: 0 auto;
	min-height: 100dvh;
	padding-bottom: calc(96px + var(--safe-bottom));
}

h1, h2, h3
{
	margin: 0;
	line-height: 1.2;
	letter-spacing: -.01em;
}

h1 { font-size: 28px; font-weight: 750; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 650; }

p { margin: 0; }

a { color: var(--teal); }

.ic { flex: none; display: block; }

.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

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

.topbar
{
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: calc(10px + var(--safe-top)) 14px 10px;
	background: rgba(245, 242, 234, .92);
	backdrop-filter: saturate(1.4) blur(10px);
	-webkit-backdrop-filter: saturate(1.4) blur(10px);
}

.topbar .title
{
	flex: 1;
	min-width: 0;
	font-weight: 700;
	font-size: 17px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.iconbtn
{
	width: 44px;
	height: 44px;
	border-radius: 14px;
	border: 0;
	background: transparent;
	color: var(--ink);
	display: grid;
	place-items: center;
	cursor: pointer;
}

.iconbtn:active { background: rgba(22, 48, 43, .08); }

.page { padding: 6px 16px 24px; }

/* ---------- Hero (welcome / home) ---------- */

.hero
{
	margin: 8px 16px 18px;
	padding: 22px 20px;
	border-radius: 24px;
	background: var(--ink);
	color: #fff;
	position: relative;
	overflow: hidden;
}

.hero::after
{
	/* A soft roof-line motif - the building behind every request. */
	content: "";
	position: absolute;
	right: -30px;
	bottom: -40px;
	width: 180px;
	height: 180px;
	border: 26px solid rgba(255, 255, 255, .06);
	transform: rotate(45deg);
	border-radius: 18px;
}

.hero .kicker
{
	font-size: 13px;
	letter-spacing: .06em;
	text-transform: uppercase;
	opacity: .7;
	margin-bottom: 6px;
}

.hero .where
{
	margin-top: 14px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px 6px 8px;
	border-radius: 999px;
	background: rgba(255, 255, 255, .12);
	font-size: 14px;
}

.brand
{
	display: flex;
	align-items: center;
	gap: 10px;
	padding: calc(18px + var(--safe-top)) 20px 6px;
	font-weight: 750;
	font-size: 15px;
	color: var(--ink-2);
}

.brand .logo
{
	width: 30px;
	height: 30px;
	border-radius: 9px;
	background: var(--accent);
	color: #fff;
	display: grid;
	place-items: center;
}

/* ---------- Cards and lists ---------- */

.card
{
	background: var(--card);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px;
}

.section-head
{
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin: 26px 2px 10px;
}

.list { display: grid; gap: 10px; }

.tcard
{
	display: flex;
	gap: 12px;
	align-items: stretch;
	background: var(--card);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 12px;
	cursor: pointer;
	color: inherit;
	text-decoration: none;
	position: relative;
}

.tcard:active { transform: scale(.99); }

.tcard.urgent { box-shadow: inset 4px 0 0 var(--danger), var(--shadow); }

.tcard .thumb
{
	width: 64px;
	height: 64px;
	border-radius: 13px;
	background: var(--teal-soft);
	color: var(--teal);
	display: grid;
	place-items: center;
	flex: none;
	overflow: hidden;
}

.tcard .thumb img { width: 100%; height: 100%; object-fit: cover; }

.tcard .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tcard .ttl { font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tcard .meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tcard .foot { margin-top: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.dot-sep::before { content: "·"; margin-right: 6px; }

.status
{
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12.5px;
	font-weight: 650;
	padding: 3px 9px 3px 8px;
	border-radius: 999px;
	color: var(--c);
	background: color-mix(in srgb, var(--c) 12%, white);
	white-space: nowrap;
}

.status::before
{
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--c);
}

.badge
{
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	font-weight: 700;
	padding: 2px 8px;
	border-radius: 999px;
	background: #fde9e7;
	color: var(--danger);
}

.badge.soft { background: var(--teal-soft); color: var(--teal); }

.empty
{
	padding: 30px 20px;
	text-align: center;
	color: var(--muted);
	border: 1.5px dashed var(--line);
	border-radius: var(--radius);
}

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

.btn
{
	appearance: none;
	border: 0;
	min-height: 50px;
	padding: 0 18px;
	border-radius: 15px;
	font: inherit;
	font-weight: 650;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	cursor: pointer;
	background: var(--card);
	color: var(--ink);
	box-shadow: inset 0 0 0 1.5px var(--line);
	text-decoration: none;
	transition: transform .08s ease;
}

.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px rgba(232, 116, 58, .28); }
.btn.dark { background: var(--ink); color: #fff; box-shadow: none; }
.btn.teal { background: var(--teal); color: #fff; box-shadow: none; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--teal); }
.btn.small { min-height: 38px; padding: 0 12px; border-radius: 12px; font-size: 14px; }

.cta
{
	display: flex;
	align-items: center;
	gap: 16px;
	width: 100%;
	border: 0;
	text-align: left;
	padding: 20px;
	border-radius: 22px;
	background: var(--accent);
	color: #fff;
	font: inherit;
	cursor: pointer;
	box-shadow: 0 10px 24px rgba(232, 116, 58, .3);
}

.cta .big { font-size: 20px; font-weight: 750; }
.cta .sub { opacity: .9; font-size: 14px; }

.cta .plus
{
	width: 54px;
	height: 54px;
	border-radius: 16px;
	background: rgba(255, 255, 255, .2);
	display: grid;
	place-items: center;
	flex: none;
}

.bottom-bar
{
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 6;
	padding: 12px 16px calc(12px + var(--safe-bottom));
	background: linear-gradient(to top, var(--paper) 70%, rgba(245, 242, 234, 0));
}

.bottom-bar > div { max-width: 528px; margin: 0 auto; display: flex; gap: 10px; flex-wrap: wrap; }
.bottom-bar .btn { flex: 1 1 140px; }

.fab
{
	position: fixed;
	right: max(18px, calc(50% - 262px));
	bottom: calc(22px + var(--safe-bottom));
	width: 60px;
	height: 60px;
	border-radius: 20px;
	border: 0;
	background: var(--accent);
	color: #fff;
	display: grid;
	place-items: center;
	box-shadow: 0 10px 24px rgba(232, 116, 58, .35);
	cursor: pointer;
	z-index: 6;
}

/* ---------- Forms ---------- */

label.fld { display: block; }
label.fld > span { display: block; font-size: 14px; font-weight: 600; margin: 0 2px 6px; }
label.fld > small { display: block; color: var(--muted); font-size: 13px; margin: 6px 2px 0; }

input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], select, textarea
{
	width: 100%;
	font: inherit;
	font-size: 17px; /* >= 16px stops iOS zooming into the field */
	color: var(--ink);
	background: var(--card);
	border: 1.5px solid var(--line);
	border-radius: 14px;
	padding: 13px 14px;
	outline: none;
	transition: border-color .15s;
}

textarea { min-height: 96px; resize: vertical; }

input:focus, select:focus, textarea:focus { border-color: var(--teal); }

.field-err { color: var(--danger); font-size: 14px; margin-top: 8px; }

.seg
{
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	gap: 6px;
	padding: 5px;
	border-radius: 16px;
	background: #ebe6da;
}

.seg button
{
	border: 0;
	min-height: 46px;
	border-radius: 12px;
	font: inherit;
	font-weight: 600;
	font-size: 15px;
	background: transparent;
	color: var(--ink-2);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 0 8px;
}

.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.cat
{
	border: 0;
	background: var(--card);
	box-shadow: inset 0 0 0 1.5px var(--line);
	border-radius: 16px;
	min-height: 84px;
	padding: 10px 4px;
	font: inherit;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--ink-2);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 7px;
	cursor: pointer;
	line-height: 1.15;
	text-align: center;
}

.cat.on { background: var(--ink); color: #fff; box-shadow: none; }

.step-label
{
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 24px 2px 10px;
	font-weight: 700;
}

.step-label .n
{
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--ink);
	color: #fff;
	font-size: 13px;
	display: grid;
	place-items: center;
}

.shots { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }

.shot-add
{
	flex: none;
	width: 124px;
	height: 124px;
	border-radius: 18px;
	border: 2px dashed #cfc7b6;
	background: transparent;
	color: var(--ink-2);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	cursor: pointer;
}

.shot-add.main { border-color: var(--accent); color: var(--accent); background: #fdf1ea; }

.shot
{
	flex: none;
	width: 124px;
	height: 124px;
	border-radius: 18px;
	position: relative;
	overflow: hidden;
	background: var(--teal-soft);
	display: grid;
	place-items: center;
	color: var(--teal);
}

.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot .fname { position: absolute; left: 8px; right: 8px; bottom: 8px; font-size: 12px; color: var(--ink); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.shot .rm
{
	position: absolute;
	top: 6px;
	right: 6px;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: 0;
	background: rgba(22, 48, 43, .7);
	color: #fff;
	display: grid;
	place-items: center;
	cursor: pointer;
}

.switch-row
{
	width: 100%;
	font: inherit;
	color: inherit;
	border: 0;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	border-radius: 16px;
	background: var(--card);
	box-shadow: inset 0 0 0 1.5px var(--line);
	cursor: pointer;
}

.switch-row.on { box-shadow: inset 0 0 0 2px var(--danger); background: #fff6f5; }

.switch
{
	width: 50px;
	height: 30px;
	border-radius: 999px;
	background: #d9d3c5;
	position: relative;
	flex: none;
	transition: background .15s;
}

.switch::after
{
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
	transition: transform .15s;
}

.on > .switch, .switch.on { background: var(--danger); }
.on > .switch::after, .switch.on::after { transform: translateX(20px); }

.notice
{
	border-radius: 16px;
	padding: 14px;
	background: #fff8e8;
	box-shadow: inset 0 0 0 1.5px #f1dfae;
}

.notice h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: #8a5d00; }

.mini
{
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 0;
	border-top: 1px solid #f1e6c8;
}

.mini:first-of-type { border-top: 0; }
.mini img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; }

/* ---------- Ticket detail ---------- */

.detail-head { padding: 4px 18px 0; }
.detail-head .status { margin-bottom: 10px; }

.progress
{
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 4px;
	margin: 18px 16px 4px;
}

.progress .p
{
	font-size: 12px;
	color: var(--muted);
	font-weight: 600;
}

.progress .p::before
{
	content: "";
	display: block;
	height: 5px;
	border-radius: 999px;
	background: #e2dccd;
	margin-bottom: 7px;
}

.progress .p.on { color: var(--ink); }
.progress .p.on::before { background: var(--teal); }

.explain
{
	margin: 14px 16px 0;
	padding: 14px 16px;
	border-radius: 16px;
	background: var(--teal-soft);
	color: var(--ink-2);
	display: flex;
	gap: 10px;
	align-items: flex-start;
}

.gallery
{
	display: flex;
	gap: 10px;
	overflow-x: auto;
	padding: 14px 16px 4px;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.gallery a
{
	flex: none;
	scroll-snap-align: start;
	border-radius: 18px;
	overflow: hidden;
	background: var(--teal-soft);
}

.gallery img { display: block; height: 220px; max-width: 86vw; object-fit: cover; }

.gallery .one img { width: calc(min(560px, 100vw) - 32px); max-width: none; height: 260px; }

.facts { display: grid; gap: 12px; }

.fact { display: flex; gap: 12px; align-items: center; }

.fact .ic-wrap
{
	width: 38px;
	height: 38px;
	border-radius: 12px;
	background: var(--paper);
	display: grid;
	place-items: center;
	color: var(--ink-2);
	flex: none;
}

.timeline { position: relative; padding-left: 22px; }

.timeline::before
{
	content: "";
	position: absolute;
	left: 6px;
	top: 6px;
	bottom: 6px;
	width: 2px;
	background: var(--line);
}

.ev { position: relative; padding: 0 0 16px; }

.ev::before
{
	content: "";
	position: absolute;
	left: -21px;
	top: 5px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--c, var(--muted));
	box-shadow: 0 0 0 3px var(--paper);
}

.ev .who { font-size: 14px; }
.ev .when { font-size: 12.5px; color: var(--muted); }

.bubble
{
	margin-top: 6px;
	padding: 10px 13px;
	border-radius: 4px 16px 16px 16px;
	background: var(--card);
	box-shadow: var(--shadow);
	white-space: pre-wrap;
	word-wrap: break-word;
}

.bubble.internal { background: #fff8e8; box-shadow: inset 0 0 0 1.5px #f1dfae; }
.ev-files { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ev-files img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; display: block; }

.filechip
{
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	border-radius: 12px;
	background: var(--card);
	box-shadow: inset 0 0 0 1.5px var(--line);
	font-size: 14px;
	color: var(--ink);
	text-decoration: none;
	max-width: 100%;
}

.composer
{
	display: flex;
	gap: 8px;
	align-items: flex-end;
	margin-top: 6px;
}

.composer textarea { min-height: 50px; height: 50px; padding: 12px 14px; }

/* ---------- Tabs (housekeeper queue) ---------- */

.tabs
{
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 4px 16px 10px;
	scrollbar-width: none;
	position: sticky;
	top: calc(64px + var(--safe-top));
	z-index: 4;
	background: var(--paper);
}

.tab
{
	flex: none;
	border: 0;
	min-height: 40px;
	padding: 0 14px;
	border-radius: 999px;
	font: inherit;
	font-size: 15px;
	font-weight: 650;
	background: #ebe6da;
	color: var(--ink-2);
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
}

.tab.on { background: var(--ink); color: #fff; }

.tab .n
{
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 999px;
	font-size: 12.5px;
	background: rgba(22, 48, 43, .12);
	display: grid;
	place-items: center;
}

.tab.on .n { background: var(--accent); color: #fff; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 12px; scrollbar-width: none; }

.chip
{
	flex: none;
	border: 0;
	min-height: 34px;
	padding: 0 12px;
	border-radius: 999px;
	font: inherit;
	font-size: 14px;
	background: transparent;
	box-shadow: inset 0 0 0 1.5px var(--line);
	color: var(--ink-2);
	cursor: pointer;
}

.chip.on { background: var(--teal-soft); box-shadow: inset 0 0 0 1.5px var(--teal); color: var(--teal); font-weight: 650; }

/* ---------- Bottom sheet dialogs ---------- */

.sheet-backdrop
{
	position: fixed;
	inset: 0;
	z-index: 20;
	background: rgba(22, 48, 43, .4);
	display: flex;
	align-items: flex-end;
	justify-content: center;
	animation: fade .15s ease;
}

.sheet
{
	width: 100%;
	max-width: 560px;
	max-height: 92dvh;
	overflow: auto;
	background: var(--paper);
	border-radius: 26px 26px 0 0;
	padding: 10px 18px calc(18px + var(--safe-bottom));
	animation: rise .2s cubic-bezier(.2, .8, .2, 1);
}

.sheet .grab { width: 44px; height: 5px; border-radius: 999px; background: #d3ccbc; margin: 2px auto 14px; }
.sheet h2 { margin-bottom: 14px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet .actions .btn { flex: 1; }

@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#toast
{
	position: fixed;
	left: 50%;
	bottom: calc(100px + var(--safe-bottom));
	transform: translate(-50%, 20px);
	background: var(--ink);
	color: #fff;
	padding: 12px 18px;
	border-radius: 14px;
	font-weight: 600;
	font-size: 15px;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s, transform .2s;
	z-index: 30;
	max-width: calc(100vw - 40px);
	display: flex;
	gap: 8px;
	align-items: center;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

.spinner
{
	width: 28px;
	height: 28px;
	border: 3px solid var(--line);
	border-top-color: var(--teal);
	border-radius: 50%;
	animation: spin .8s linear infinite;
	margin: 60px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.lang-pick { display: flex; gap: 6px; flex-wrap: wrap; }

/* Image viewer */
.viewer
{
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .92);
	z-index: 40;
	display: grid;
	place-items: center;
	animation: fade .15s;
}

.viewer img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.viewer .iconbtn { position: absolute; top: calc(10px + var(--safe-top)); right: 10px; color: #fff; }

.ic.inline { display: inline-block; vertical-align: -3px; }
.mini .thumb { width: 44px; height: 44px; border-radius: 10px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex: none; }
