/* Mobile application of installers - module Dolibarr "Bons de pose" */
:root {
	--primary: #263c5c;
	--primary-light: #3d5a85;
	--accent: #1f8a5b;
	--warn: #c77700;
	--danger: #b3261e;
	--bg: #f2f4f7;
	--card: #ffffff;
	--text: #1d2430;
	--muted: #667085;
	--border: #d9dee7;
	--radius: 12px;
	--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; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 16px;
	background: var(--bg);
	color: var(--text);
	min-height: 100vh;
	padding-bottom: calc(24px + var(--safe-bottom));
}

#topbar {
	position: sticky; top: 0; z-index: 10;
	display: flex; align-items: center; gap: 4px;
	background: var(--primary); color: #fff;
	padding: calc(8px + var(--safe-top)) 8px 8px 8px;
	min-height: 56px;
}
#title { flex: 1; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.iconbtn {
	background: transparent; border: 0; color: #fff; font-size: 24px;
	width: 44px; height: 44px; border-radius: 22px; cursor: pointer;
}
.iconbtn:active { background: rgba(255,255,255,.15); }

#offline { background: var(--warn); color: #fff; text-align: center; font-size: 14px; padding: 6px; }

main { max-width: 720px; margin: 0 auto; padding: 12px; }

.card {
	background: var(--card); border-radius: var(--radius);
	box-shadow: 0 1px 3px rgba(16,24,40,.08); margin-bottom: 12px; overflow: hidden;
}
.card-body { padding: 14px; }
.card h2 { font-size: 17px; margin: 0; }
.section-head {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	padding: 14px; cursor: pointer; user-select: none;
}
.section-head .chev { color: var(--muted); transition: transform .2s; }
.section.open .section-head .chev { transform: rotate(90deg); }
.section .section-content { display: none; padding: 0 14px 14px 14px; }
.section.open .section-content { display: block; }
.badge-count { background: var(--bg); color: var(--muted); border-radius: 10px; font-size: 13px; padding: 2px 8px; margin-left: 6px; }

.tabs { display: flex; background: #e4e8ef; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 8px; font-size: 15px; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.sheet-item { display: block; padding: 14px; color: inherit; text-decoration: none; }
.sheet-item + .sheet-item { border-top: 1px solid var(--border); }
.sheet-item .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-item .ref { font-weight: 700; }
.sheet-item .customer { font-size: 17px; margin: 4px 0; }
.meta { color: var(--muted); font-size: 14px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 10px; white-space: nowrap; }
.pill.todo { background: #fff4e0; color: #8a5300; }
.pill.done { background: #e3f5ec; color: #146c43; }
.pill.absent { background: #fdecc8; color: #8a5300; }
.pill.ko { background: #fde8e7; color: var(--danger); }
.pill.mine { background: #e7eefb; color: var(--primary); }

.kv { display: flex; gap: 10px; padding: 6px 0; }
.kv .k { color: var(--muted); min-width: 110px; font-size: 14px; }
.kv .v { flex: 1; white-space: pre-line; }

label.field { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=number], input[type=password], input[type=url], textarea, select {
	width: 100%; font-size: 16px; padding: 11px 12px; border: 1px solid var(--border);
	border-radius: 10px; background: #fff; color: var(--text); font-family: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:disabled, textarea:disabled, select:disabled { background: #f6f7f9; color: var(--muted); }

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	border: 0; border-radius: 10px; padding: 13px 16px; font-size: 16px; font-weight: 600;
	background: var(--primary); color: #fff; cursor: pointer; text-decoration: none;
}
.btn.block { width: 100%; margin-top: 12px; }
.btn.secondary { background: #e4e8ef; color: var(--text); }
.btn.accent { background: var(--accent); }
.btn.warn { background: var(--warn); }
.btn.small { padding: 9px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btnrow .btn { flex: 1; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.seg button {
	flex: 1; min-width: 80px; border: 1px solid var(--border); background: #fff; color: var(--text);
	padding: 10px 6px; border-radius: 10px; font-size: 14px;
}
.seg button.on-ok { background: #e3f5ec; border-color: #7cc5a1; color: #146c43; font-weight: 600; }
.seg button.on-ko { background: #fde8e7; border-color: #ee9a95; color: var(--danger); font-weight: 600; }
.seg button.on-na { background: #eef0f3; border-color: #b8c0cc; font-weight: 600; }
.seg button.on-partial { background: #fff4e0; border-color: #f0c070; color: #8a5300; font-weight: 600; }
.seg button:disabled { opacity: .7; }

.edl-item, .line-item { padding: 12px 0; border-top: 1px solid var(--border); }
.edl-item:first-child, .line-item:first-child { border-top: 0; }
.line-item .lbl { font-weight: 600; }
.line-item .desc { color: var(--muted); font-size: 14px; white-space: pre-line; }
.line-item .qtys { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.line-item .qtys input { max-width: 110px; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; background: #e4e8ef; }

.choice { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; }
.choice input { width: 22px; height: 22px; margin: 0; flex: none; }
.choice.checked { border-color: var(--primary-light); background: #eef3fb; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 12px; background: #fff7e6; border-radius: 10px; font-weight: 600; }
.toggle input { width: 22px; height: 22px; }

.sigwrap { position: relative; margin-top: 6px; }
canvas.sig { width: 100%; height: 200px; border: 2px dashed var(--border); border-radius: 10px; background: #fff; touch-action: none; display: block; }
.sigwrap .hint { position: absolute; left: 0; right: 0; top: 45%; text-align: center; color: #b8c0cc; pointer-events: none; }
.terms { font-size: 13px; color: var(--muted); margin-top: 10px; white-space: pre-line; }

#toast {
	position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%) translateY(150%);
	background: #1d2430; color: #fff; padding: 12px 18px; border-radius: 10px; max-width: 90%;
	transition: transform .25s; z-index: 50; font-size: 15px;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 40; display: flex; align-items: center; justify-content: center; }
#overlay img { max-width: 100%; max-height: 100%; }
.menu-panel { position: fixed; top: calc(56px + var(--safe-top)); right: 8px; background: #fff; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 45; min-width: 220px; overflow: hidden; }
.menu-panel button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 14px 16px; font-size: 16px; }
.menu-panel button + button { border-top: 1px solid var(--border); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 4px solid #d0d6e0; border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.logo { width: 72px; height: 72px; border-radius: 16px; display: block; margin: 20px auto 8px; }
