/* T-58: the phone view (www/m.html, m.js). Waggles green, light or dark as the phone is set; fits 320 px and large text. */
:root {
	--bg: #f4f7f5; --surface: #ffffff; --text: #17251d; --muted: #5b6b62; --line: #dfe6e1;
	--primary: #12382a; --on-primary: #ffffff; --mint: #e3f3ea; --accent: #1f6b4a;
	--good-bg: #e3f5ea; --good: #1d6b40; --warn-bg: #fdf1dc; --warn: #8a5300; --bad-bg: #fdecea; --bad: #a3271b;
	--info-bg: #e5eefb; --info: #2459a6; --shadow: 0 1px 2px rgba(0, 0, 0, .06);
	--nav-h: 64px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #111613; --surface: #1b211d; --text: #e7eee9; --muted: #a3b2a9; --line: #2e3832;
		--primary: #a6d8bd; --on-primary: #0e2a1e; --mint: #20342a; --accent: #a6d8bd;
		--good-bg: #183224; --good: #8fd6ac; --warn-bg: #3a2c14; --warn: #f2c179; --bad-bg: #3d1d1a; --bad: #f2a299;
		--info-bg: #17263b; --info: #9cc1f5; --shadow: none; color-scheme: dark;
	}
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-text-size-adjust: 100%; overflow-x: hidden; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
	padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 10px; min-height: 56px; }
.top h1 { margin: 0; font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .back { border: 0; background: none; padding: 6px; margin-left: -6px; display: flex; cursor: pointer; }
.chip { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--mint); color: var(--accent); white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center;
	font-weight: 700; font-size: 14px; border: 0; flex: none; }

main { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.stack > * + * { margin-top: 12px; }
h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
h2:first-child { margin-top: 4px; }
.hello { font-size: 22px; font-weight: 700; margin: 0; }
.sub { color: var(--muted); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
button.card, a.card { display: block; width: 100%; text-align: left; text-decoration: none; color: inherit; cursor: pointer; }
.row { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.row .grow { flex: 1 1 9em; min-width: 0; } /* a long name takes the line; the pill or amount goes under it */
.title { font-weight: 600; overflow-wrap: anywhere; }
.amount { font-weight: 700; white-space: nowrap; }
.right { text-align: right; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; text-decoration: none; color: inherit; display: block; }
.tile .k { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; overflow-wrap: anywhere; }
.tile .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.up { color: var(--good); } .down { color: var(--bad); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.t-good { background: var(--good-bg); color: var(--good); } .t-warn { background: var(--warn-bg); color: var(--warn); }
.t-bad { background: var(--bad-bg); color: var(--bad); } .t-info { background: var(--info-bg); color: var(--info); }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.count { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 10px 16px; border-radius: 10px;
	border: 0; background: var(--primary); color: var(--on-primary); font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn[disabled] { opacity: .55; }
.btns { display: flex; gap: 10px; } .btns > * { flex: 1; }
.btn.small { min-height: 40px; font-size: 15px; }

.search { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.chips button.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }

table.lines { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lines td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lines td + td { padding-left: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 15px; }
.kv .total { font-weight: 700; font-size: 17px; border-top: 1px solid var(--line); padding-top: 6px; }

nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line);
	display: flex; padding-bottom: env(safe-area-inset-bottom); }
nav.bottom a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 10px;
	font-size: 12px; color: var(--muted); text-decoration: none; position: relative; }
nav.bottom a .ic { width: min(56px, 100%); height: 30px; border-radius: 15px; display: grid; place-items: center; }
nav.bottom a.on { color: var(--accent); font-weight: 700; }
nav.bottom a.on .ic { background: var(--mint); }
/* whole labels on a small phone with large text: smaller letters, never cut (as the sales app's menu) */
nav.bottom a span.lbl { max-width: 100%; white-space: nowrap; font-size: clamp(9px, 3.3vw, 12px); letter-spacing: -.01em; }
nav.bottom .badge { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
	background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); width: 100%; max-width: 720px; margin: 0 auto; border-radius: 16px 16px 0 0;
	padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto; }
.sheet h3 { margin: 0 0 6px; font-size: 18px; }
textarea, .field { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 30;
	background: #263029; color: #fff; padding: 12px 14px; border-radius: 10px; font-size: 15px; max-width: 688px; margin: 0 auto; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.spin { text-align: center; color: var(--muted); padding: 28px; }

.login { min-height: 100vh; display: flex; flex-direction: column; }
.login .band { background: #12382a; color: #fff; padding: calc(44px + env(safe-area-inset-top)) 24px 28px; }
.login .band h1 { margin: 0 0 6px; font-size: 26px; }
.login .band p { margin: 0; color: #c2ecd3; }
.login form { padding: 8px 24px 32px; max-width: 480px; }
