/*
 * Wise Caretaker - manager web styles. Same palette as the phone app,
 * laid out for a desk: sidebar, wide tables, a detail drawer on the right.
 */

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

	--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;
}

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
a { color: var(--teal); }
.ic { flex: none; display: block; }
.ic.inline { display: inline-block; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.right { margin-left: auto; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side
{
	background: var(--ink);
	color: #e8efec;
	padding: 18px 12px;
	display: flex;
	flex-direction: column;
	gap: 4px;
	position: sticky;
	top: 0;
	height: 100vh;
}

.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px; font-weight: 750; font-size: 15px; color: #fff; }
.side .org { padding: 0 8px 18px 50px; font-size: 12.5px; opacity: .65; margin-top: -2px; }

.logo
{
	width: 32px;
	height: 32px;
	border-radius: 10px;
	background: var(--accent);
	color: #fff;
	display: grid;
	place-items: center;
	flex: none;
}

.nav
{
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-radius: 11px;
	color: inherit;
	text-decoration: none;
	font-weight: 600;
	opacity: .78;
}

.nav:hover { background: rgba(255, 255, 255, .06); opacity: 1; }
.nav.on { background: rgba(255, 255, 255, .12); opacity: 1; }

.nav .cnt
{
	margin-left: auto;
	min-width: 22px;
	height: 22px;
	padding: 0 7px;
	border-radius: 999px;
	background: var(--accent);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	display: grid;
	place-items: center;
}

.side .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 13px; }
.side .foot select { background: transparent; color: inherit; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; padding: 5px 6px; font: inherit; width: 100%; margin: 8px 0; }
.side .foot select option { color: var(--ink); }
.side .foot button { background: none; border: 0; color: inherit; opacity: .75; cursor: pointer; font: inherit; padding: 4px 0; display: flex; align-items: center; gap: 8px; }

.main { padding: 26px 32px 60px; min-width: 0; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

/* ---------- Cards, KPIs ---------- */

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card > h2 { margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.mono, .table a, .manual { font-variant-ligatures: none; font-feature-settings: "calt" 0; }
.two { grid-template-columns: 1.4fr 1fr; }

.kpi
{
	background: var(--card);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px 18px;
	text-decoration: none;
	color: inherit;
	display: block;
	position: relative;
	overflow: hidden;
}

.kpi .v { font-size: 32px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-weight: 600; font-size: 13.5px; }
.kpi .ic-wrap { position: absolute; right: 14px; top: 14px; color: var(--muted); opacity: .5; }
.kpi.hot { background: var(--ink); color: #fff; }
.kpi.hot .l { color: rgba(255, 255, 255, .75); }
.kpi.hot .ic-wrap { color: var(--accent); opacity: 1; }
.kpi.hot .v { color: #ffd2b8; }
a.kpi:hover { box-shadow: 0 0 0 2px var(--teal), var(--shadow); }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars div { flex: 1; background: var(--teal-soft); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars div.today { background: var(--accent); }
.bars div:hover { background: var(--teal); }

.hbar { display: grid; grid-template-columns: 130px 1fr 36px; gap: 10px; align-items: center; margin: 8px 0; }
.hbar .track { height: 10px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.hbar .fill { height: 100%; background: var(--teal); border-radius: 999px; }

/* ---------- Tables ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr.click { cursor: pointer; }
/* The dashboard's per-building table sits in the narrower column: its long
   headers wrap instead of pushing the last column out of the card, and the
   building name stays on one line (22 Nov 2026). */
.table-card { overflow-x: auto; }
.btable th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
.btable td:first-child .t1 { white-space: nowrap; }
.table tr.click:hover td { background: #faf8f3; }
.table tr.sel td { background: var(--teal-soft); }
.table tr.urgent td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table .thumb { width: 42px; height: 42px; border-radius: 10px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; overflow: hidden; flex: none; }
.table .thumb img { width: 100%; height: 100%; object-fit: cover; }
.table .t1 { font-weight: 650; }
.table-card { padding: 4px 6px; overflow-x: auto; }

.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); white-space: nowrap; }
.badge.soft { background: var(--teal-soft); color: var(--teal); }
.badge.amber { background: #fff1cf; color: #8a5d00; }
.badge.gray { background: var(--line-2); color: var(--muted); }

/* ---------- Controls ---------- */

.btn
{
	appearance: none;
	border: 0;
	min-height: 38px;
	padding: 0 14px;
	border-radius: 11px;
	font: inherit;
	font-weight: 650;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	cursor: pointer;
	background: var(--card);
	color: var(--ink);
	box-shadow: inset 0 0 0 1.5px var(--line);
	text-decoration: none;
	white-space: nowrap;
}

.btn:hover { box-shadow: inset 0 0 0 1.5px #cfc8b8; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: none; }
.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.sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 9px; }

input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea
{
	font: inherit;
	color: var(--ink);
	background: var(--card);
	border: 1.5px solid var(--line);
	border-radius: 10px;
	padding: 8px 11px;
	outline: none;
	min-height: 38px;
}

input:focus, select:focus, textarea:focus { border-color: var(--teal); }
textarea { width: 100%; min-height: 80px; resize: vertical; }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: #ebe6da; }
.seg button { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink-2); padding: 6px 12px; border-radius: 9px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg .n { font-size: 12px; color: var(--muted); }

.fld { display: block; margin-bottom: 14px; }
.fld > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.fld input, .fld select, .fld textarea { width: 100%; }
.fld small { display: block; color: var(--muted); margin-top: 5px; }

.checks { display: flex; flex-direction: column; gap: 8px; }
.checks label { display: flex; gap: 8px; align-items: center; cursor: pointer; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- Drawer ---------- */

.drawer-back { position: fixed; inset: 0; background: rgba(22, 48, 43, .25); z-index: 10; animation: fade .15s; }

.drawer
{
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(560px, 100vw);
	background: var(--paper);
	z-index: 11;
	overflow: auto;
	box-shadow: -10px 0 40px rgba(22, 48, 43, .15);
	animation: slide .2s cubic-bezier(.2, .8, .2, 1);
	display: flex;
	flex-direction: column;
}

.drawer .dh { padding: 18px 22px 10px; display: flex; gap: 10px; align-items: flex-start; position: sticky; top: 0; background: var(--paper); z-index: 2; }
.drawer .db { padding: 0 22px 20px; flex: 1; }
.drawer .df { padding: 14px 22px; border-top: 1px solid var(--line); background: var(--card); display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; }

.iconbtn { width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.iconbtn:hover { background: rgba(22, 48, 43, .07); }

.gallery { display: flex; gap: 8px; overflow-x: auto; margin: 14px 0; }
.gallery img { height: 170px; border-radius: 12px; display: block; cursor: zoom-in; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.facts .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.timeline { position: relative; padding-left: 20px; margin-top: 10px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.ev { position: relative; padding-bottom: 14px; }
.ev::before { content: ""; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); box-shadow: 0 0 0 3px var(--paper); }
.ev .when { font-size: 12px; color: var(--muted); }
.bubble { margin-top: 5px; padding: 9px 12px; border-radius: 4px 12px 12px 12px; 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: 6px; margin-top: 6px; flex-wrap: wrap; }
.ev-files img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; cursor: zoom-in; display: block; }
.filechip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--ink); text-decoration: none; font-size: 13px; }

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

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

.modal-back { position: fixed; inset: 0; background: rgba(22, 48, 43, .35); z-index: 20; display: grid; place-items: center; animation: fade .15s; padding: 20px; }
.modal { background: var(--paper); border-radius: 18px; width: min(480px, 100%); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .2); animation: pop .18s; }
.modal h2 { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.err { color: var(--danger); margin-top: 8px; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; display: flex; gap: 8px; align-items: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.spinner { width: 26px; height: 26px; 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); } }

.viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); z-index: 50; display: grid; place-items: center; cursor: zoom-out; }
.viewer img { max-width: 96vw; max-height: 96vh; }

/* ---------- Login ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.login .box { background: var(--paper); border-radius: 22px; padding: 30px; width: min(400px, 100%); }

/* ---------- Building page ---------- */

.qr-mini { width: 56px; height: 56px; image-rendering: pixelated; border-radius: 6px; background: #fff; padding: 3px; box-shadow: inset 0 0 0 1px var(--line); }
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.unit { background: var(--paper); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.unit:hover { box-shadow: inset 0 0 0 1.5px var(--teal); }
.unit b { font-size: 15px; }

.bcard { display: block; text-decoration: none; color: inherit; }
.bcard:hover { box-shadow: 0 0 0 2px var(--teal), var(--shadow); }

@media (max-width: 900px)
{
	.shell { grid-template-columns: 1fr; }
	.side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
	.side .org, .side .foot { display: none; }
	.two { grid-template-columns: 1fr; }
	.main { padding: 18px 14px 40px; }
}
