/* Kapato admin — dark, Inter, brand orange #FF5733 */
* { box-sizing: border-box; margin: 0; }
:root {
	--bg: #0b1220; --surface: #131c2e; --surface2: #1b2740; --inset: #0e1626;
	--text: #e6ecf5; --dim: #7e8ca3; --line: #263450;
	--primary: #ff5733; --primary-soft: rgba(255,87,51,.14);
	--ok: #34d399; --warn: #fbbf24; --err: #f87171; --info: #60a5fa;
	--radius: 12px;
}
body {
	background:
		radial-gradient(1200px 500px at 85% -10%, rgba(255,87,51,.07), transparent 60%),
		radial-gradient(900px 500px at -10% 110%, rgba(96,165,250,.05), transparent 60%),
		var(--bg);
	color: var(--text);
	font: 14px/1.55 'Inter', system-ui, sans-serif;
	min-height: 100vh;
}
body.center { display: flex; align-items: center; justify-content: center; }

[x-cloak] { display: none !important; }

/* ── shell: sidebar + content ───────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
	width: 225px; flex-shrink: 0;
	display: flex; flex-direction: column;
	background: var(--surface);
	border-right: 1px solid var(--line);
	padding: 20px 14px;
	position: sticky; top: 0; height: 100vh;
}
.sidenav { display: flex; flex-direction: column; gap: 3px; margin-top: 26px; flex: 1; }
.navitem {
	display: flex; align-items: center; gap: 11px;
	padding: 10px 13px; border-radius: 9px;
	color: var(--dim); text-decoration: none; font-weight: 600; font-size: 13.5px;
	transition: all .12s;
}
.navitem:hover { color: var(--text); background: rgba(255,255,255,.04); }
.navitem.active { color: var(--primary); background: var(--primary-soft); }
.navico { font-size: 15px; width: 18px; text-align: center; }
.sidefoot { display: flex; flex-direction: column; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--line); }

.brand { font-weight: 800; font-size: 17px; letter-spacing: 1.5px; color: var(--text); text-decoration: none; padding: 0 8px; }
.brand span { color: var(--primary); font-weight: 600; margin-left: 7px; letter-spacing: .5px; }
.brand.big { font-size: 26px; text-align: center; margin-bottom: 18px; display: block; padding: 0; }
.toplink { color: var(--dim); text-decoration: none; font-size: 12.5px; }
.toplink:hover { color: var(--text); }
.bridge { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--dim); }
.bridge .dot { width: 8px; height: 8px; border-radius: 99px; flex-shrink: 0; }
.bridge.up .dot { background: var(--ok); box-shadow: 0 0 8px rgba(52,211,153,.7); }
.bridge.down { color: var(--err); }
.bridge.down .dot { background: var(--err); }

.content { flex: 1; min-width: 0; }
.mobilebar { display: none; }
@media (max-width: 900px) {
	.sidebar {
		position: fixed; z-index: 2000; height: 100vh;
		transform: translateX(-100%); transition: transform .2s;
		box-shadow: 20px 0 60px rgba(0,0,0,.5);
	}
	.sidebar.open { transform: translateX(0); }
	.mobilebar {
		display: flex; align-items: center; gap: 12px;
		padding: 10px 16px; background: var(--surface);
		border-bottom: 1px solid var(--line);
		position: sticky; top: 0; z-index: 1000;
	}
}

/* ── layout ─────────────────────────────────────────────── */
main { max-width: 1120px; margin: 0 auto; padding: 26px 24px 80px; }
.pagehead { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.3px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--dim); font-weight: 700; margin: 20px 0 12px; }
.card h2:first-child, .cardhead h2 { margin-top: 0; }
.count { color: var(--dim); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.crumb { color: var(--dim); text-decoration: none; font-weight: 600; }
.crumb:hover { color: var(--primary); }
.crumb-sep { color: var(--dim); margin: 0 8px; font-weight: 400; }
.loghead { margin-top: 26px; }
.pad { padding: 16px; }

.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 20px;
	box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.cardhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.table-card { padding: 6px; margin-top: 16px; overflow-x: auto; }

.grid-device { display: grid; grid-template-columns: 5fr 6fr; gap: 16px; align-items: start; }
@media (max-width: 940px) { .grid-device { grid-template-columns: 1fr; } }

/* ── maps ───────────────────────────────────────────────── */
.map-card { padding: 6px; }
#fleetmap { height: 340px; border-radius: 8px; }
#map { height: 300px; border-radius: 8px; margin-bottom: 14px; }
.map-empty { display: flex; align-items: center; justify-content: center; background: var(--inset); color: var(--dim); font-size: 13px; text-align: center; padding: 20px; }
.leaflet-container { background: #0e1626; font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface2); color: var(--text); }
.leaflet-popup-content a { color: var(--primary); }
.leaflet-bar a { background: var(--surface2); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--line); }

/* ── tables ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.small th, table.small td { padding: 6px 10px; font-size: 13px; }
th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); }
tr:last-child td { border-bottom: none; }
td a { color: var(--primary); text-decoration: none; }
td a:hover { text-decoration: underline; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: rgba(255,255,255,.025); }
td .mono { letter-spacing: 0; }

.devlink { color: var(--text) !important; font-weight: 700; font-size: 15px; }
.devlink:hover { color: var(--primary) !important; text-decoration: none !important; }

.mono, code { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
code { background: var(--inset); border: 1px solid var(--line); padding: 2px 7px; border-radius: 5px; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.error { color: var(--err); margin-bottom: 12px; font-size: 13px; }

/* ── badges & indicators ────────────────────────────────── */
.badge {
	display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 9px;
	border-radius: 99px; background: var(--surface2); color: var(--dim);
	text-transform: uppercase; letter-spacing: .8px; vertical-align: middle;
}
.badge.big { font-size: 13px; padding: 4px 14px; }
.badge.ok { background: rgba(52,211,153,.14); color: var(--ok); }
.badge.warn { background: rgba(251,191,36,.14); color: var(--warn); }
.badge.err { background: rgba(248,113,113,.14); color: var(--err); }
.badge.mode-search { background: var(--primary-soft); color: var(--primary); }
.badge.mode-normal { background: rgba(52,211,153,.14); color: var(--ok); }
.badge.mode-standby { background: rgba(126,140,163,.18); color: var(--dim); }
.badge.kind-status { color: var(--ok); }
.badge.kind-loc { color: var(--primary); }
.badge.kind-cmd { color: var(--warn); }
.badge.kind-ack { color: var(--info); }
.badge.kind-lwt { color: var(--err); }

.fresh { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 7px; }
.fresh.ok { background: var(--ok); box-shadow: 0 0 6px rgba(52,211,153,.6); }
.fresh.warn { background: var(--warn); }
.fresh.old { background: var(--dim); opacity: .5; }

.batwrap { display: inline-flex; align-items: center; gap: 8px; }
.batbar { display: inline-block; width: 46px; height: 7px; background: var(--inset); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.batbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #ffa07a); border-radius: 99px; }

/* ── device status grid ─────────────────────────────────── */
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 6px; }
.stat { background: var(--inset); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.statlabel { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); margin-bottom: 5px; }
.statval { font-weight: 700; font-size: 14px; }
.cmdline { margin: 5px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── forms & buttons ────────────────────────────────────── */
label { display: block; font-size: 11.5px; color: var(--dim); font-weight: 600; }
input {
	display: block; width: 100%; margin-top: 5px; padding: 9px 12px;
	background: var(--inset); color: var(--text);
	border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 14px 0 8px; }
.row label { flex: 1; }
.row label.narrow { flex: 0 0 96px; }

button {
	padding: 9px 18px; border-radius: 8px; border: 1px solid var(--line);
	background: var(--surface2); color: var(--text); font: inherit; font-weight: 600;
	font-size: 13.5px; cursor: pointer; transition: all .15s;
}
button:hover { border-color: var(--primary); transform: translateY(-1px); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(255,87,51,.35); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--dim); }
button.ghost:hover { color: var(--text); }
button.small { padding: 5px 14px; font-size: 12px; }
button.wide { width: 100%; margin-top: 16px; }
button.chip { padding: 4px 14px; font-size: 12px; border-radius: 99px; font-weight: 600; }
button.chip:hover { transform: none; }
button.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chips { align-items: center; padding: 10px 8px 4px; }

/* ── management pages (users/devices) ───────────────────── */
.subname { color: var(--dim); font-weight: 500; font-size: 16px; margin-left: 6px; }
.strong { font-weight: 600; }
table.mgmt { margin-top: 14px; }
table.mgmt td { vertical-align: middle; }
.addform { background: var(--inset); border: 1px solid var(--line); border-radius: 9px; padding: 14px; margin-top: 14px; }
.chips-inline { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.devchip {
	display: inline-flex; align-items: center; gap: 2px;
	background: var(--primary-soft); border: 1px solid rgba(255,87,51,.25);
	border-radius: 99px; padding: 2px 4px 2px 11px; font-size: 12px; font-weight: 600;
}
.devchip a { color: var(--primary); text-decoration: none; }
.chipx {
	background: none; border: none; color: var(--primary); opacity: .6;
	font-size: 14px; padding: 0 6px; cursor: pointer; font-weight: 700;
}
.chipx:hover { opacity: 1; transform: none; }
.inlineform { display: inline; }
.assignform { display: inline-flex; gap: 6px; align-items: center; }
select {
	padding: 5px 9px; background: var(--inset); color: var(--text);
	border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 12.5px;
}
tr.editrow td { background: var(--inset); border-bottom: 1px solid var(--line); }
tr.editrow .row { margin: 4px 0; align-items: center; }
.actions { display: flex; gap: 6px; align-items: center; }
button.danger { color: var(--err); }
button.danger:hover { border-color: var(--err); color: var(--err); }
tbody { border: none; }

/* ── broker credential page ─────────────────────────────── */
.credcard { max-width: 640px; }
.secret {
	font-size: 21px; letter-spacing: 1px; font-weight: 600;
	background: var(--inset); border: 1px solid var(--primary);
	border-radius: 9px; padding: 14px 18px; margin: 10px 0 14px;
	color: var(--primary); user-select: all;
}
.codeblock {
	background: var(--inset); border: 1px solid var(--line); border-radius: 9px;
	padding: 14px 18px; font-family: ui-monospace, Menlo, monospace;
	font-size: 13px; line-height: 1.7; overflow-x: auto; user-select: all;
}

/* ── login ──────────────────────────────────────────────── */
.login-wrap { width: 340px; }
.card.login { padding: 28px; }
.card.login label { margin: 12px 0; }
.login-wrap .foot { text-align: center; margin-top: 16px; letter-spacing: .5px; }
