/* CallSave – přehled hovorů */
:root {
	--bg: #f5f6fa;
	--surface: #ffffff;
	--surface-2: #f0f2f7;
	--border: #e3e6ee;
	--text: #141826;
	--muted: #646b80;
	--primary: #5b4ff0;
	--primary-2: #8b5cf6;
	--primary-soft: #ecebfe;
	--ok: #13a36e;
	--ok-soft: #e3f6ee;
	--bad: #e0384f;
	--bad-soft: #fde8eb;
	--warn: #c77a07;
	--warn-soft: #fdf1dc;
	--out: #2f7fd6;
	--out-soft: #e3effc;
	--shadow: 0 1px 2px rgba(20, 24, 38, .05), 0 4px 16px rgba(20, 24, 38, .05);
	--shadow-lg: 0 12px 32px rgba(20, 24, 38, .12);
	--radius: 16px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0d0f17;
		--surface: #161925;
		--surface-2: #1d2130;
		--border: #272c3d;
		--text: #e9ebf3;
		--muted: #949bb2;
		--primary: #8c83ff;
		--primary-2: #b18cff;
		--primary-soft: #262447;
		--ok: #3bcf93;
		--ok-soft: #133226;
		--bad: #ff6b7f;
		--bad-soft: #3a1a22;
		--warn: #f2b13c;
		--warn-soft: #3a2c12;
		--out: #6fb1ff;
		--out-soft: #15283f;
		--shadow: 0 1px 2px rgba(0, 0, 0, .3);
		--shadow-lg: 0 12px 32px rgba(0, 0, 0, .4);
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	-webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- horní lišta ---------- */
.topbar {
	position: sticky; top: 0; z-index: 1000;
	background: color-mix(in srgb, var(--surface) 82%, transparent);
	backdrop-filter: saturate(1.6) blur(14px);
	border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 24px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.logo {
	width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff;
	background: linear-gradient(135deg, var(--primary), var(--primary-2));
	box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 35%, transparent);
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); font-weight: 550; padding: 7px 12px; border-radius: 9px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.logout { color: var(--muted); display: flex; align-items: center; gap: 6px; font-size: 14px; }

main.wrap { padding-top: 30px; padding-bottom: 60px; }

/* ---------- typografie ---------- */
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -.02em; font-weight: 750; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }

/* ---------- karty a statistiky ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 550; display: flex; align-items: center; gap: 7px; }
.stat .value { font-size: 30px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); display: inline-block; }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.dot.ok { background: var(--ok); }

/* ---------- telefony ---------- */
.devices { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.device {
	display: block; color: inherit; padding: 20px; position: relative; overflow: hidden;
	transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.device:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); text-decoration: none; }
.device-head { display: flex; gap: 14px; align-items: center; }
.avatar {
	width: 46px; height: 46px; flex: none; border-radius: 14px; display: grid; place-items: center;
	font-weight: 750; font-size: 17px; color: #fff;
	background: linear-gradient(135deg, hsl(var(--h) 75% 58%), hsl(calc(var(--h) + 40) 75% 52%));
}
.avatar.lg { width: 60px; height: 60px; border-radius: 18px; font-size: 22px; }
.device-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.device-sub { color: var(--muted); font-size: 13px; }
.online { display: inline-flex; align-items: center; gap: 5px; }
.online::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .5; }
.online.on::before { background: var(--ok); opacity: 1; box-shadow: 0 0 0 3px var(--ok-soft); }

.device-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 14px; }
.device-stats div { background: var(--surface-2); border-radius: 11px; padding: 9px 12px; }
.device-stats b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.device-stats span { font-size: 12px; color: var(--muted); }
.device-last { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; border-top: 1px dashed var(--border); padding-top: 12px; }
.device-last .num { font-weight: 600; }

.empty { text-align: center; padding: 56px 24px; }
.empty .icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty h2 { margin-bottom: 6px; }
.empty code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* ---------- filtr ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; margin-bottom: 14px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; flex-wrap: wrap; }
.segmented a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 550; font-size: 13.5px; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.toolbar form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; justify-content: flex-end; }

input[type=text], input[type=search], input[type=date], input[type=password] {
	font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
	border-radius: 10px; padding: 8px 12px; outline: none; min-width: 0;
	transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
input[type=search] { width: 220px; }

.btn {
	font: inherit; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 7px;
	padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
	color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }

/* ---------- tabulka hovorů ---------- */
.table-wrap { overflow-x: auto; }
table.calls { width: 100%; border-collapse: collapse; }
.calls th {
	text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
	font-weight: 650; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.calls td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.calls tr:last-child td { border-bottom: 0; }
.calls tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.calls .who { display: flex; align-items: center; gap: 12px; min-width: 210px; }
.calls .num { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); }
.calls .name { font-size: 13px; color: var(--muted); }
.calls .time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.calls .right { text-align: right; }
.day-row td { background: var(--surface-2); font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 7px 16px; text-transform: uppercase; letter-spacing: .04em; }

.call-icon { width: 36px; height: 36px; flex: none; border-radius: 11px; display: grid; place-items: center; }
.call-icon.in { background: var(--ok-soft); color: var(--ok); }
.call-icon.missed { background: var(--bad-soft); color: var(--bad); }
.call-icon.out { background: var(--out-soft); color: var(--out); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.in { background: var(--ok-soft); color: var(--ok); }
.pill.missed { background: var(--bad-soft); color: var(--bad); }
.pill.out { background: var(--out-soft); color: var(--out); }
.pill.unknown { background: var(--warn-soft); color: var(--warn); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

.loc { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span.cur { min-width: 34px; text-align: center; padding: 6px 10px; border-radius: 9px; font-weight: 600; font-size: 14px; }
.pagination a { color: var(--muted); }
.pagination a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.pagination span.cur { background: var(--primary-soft); color: var(--primary); }

/* ---------- detail telefonu ---------- */
.device-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.device-hero .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; color: var(--muted); font-size: 13.5px; }
.device-hero .meta span { display: inline-flex; align-items: center; gap: 5px; }
.hero-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
details.rename summary { list-style: none; cursor: pointer; }
details.rename summary::-webkit-details-marker { display: none; }
details.rename[open] summary { display: none; }
details.rename form { display: flex; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 18px; }
#map { height: 340px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); z-index: 1; }

.flash { padding: 12px 16px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); font-weight: 600; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.danger-zone { margin-top: 26px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; }

/* ---------- přihlášení ---------- */
.login-page {
	min-height: 100vh; display: grid; place-items: center; padding: 20px;
	background:
		radial-gradient(1000px 600px at 10% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 60%),
		radial-gradient(800px 500px at 110% 110%, color-mix(in srgb, var(--primary-2) 22%, transparent), transparent 60%),
		var(--bg);
}
.login { width: 100%; max-width: 380px; padding: 34px 30px 30px; box-shadow: var(--shadow-lg); }
.login .logo { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 18px; }
.login h1 { font-size: 24px; }
.login p { margin: 6px 0 22px; }
.login label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.login input { width: 100%; padding: 11px 14px; font-size: 16px; }
.login .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 14px; font-size: 15px; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; margin-bottom: 14px; }

/* ---------- mobil ---------- */
@media (max-width: 860px) {
	.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.toolbar form { justify-content: flex-start; }
	input[type=search] { width: 100%; flex: 1 1 100%; }
	.hide-sm { display: none; }
	.calls td, .calls th { padding: 10px 12px; }
	.calls .who { min-width: 0; }
}
@media (max-width: 520px) {
	.wrap { padding: 0 14px; }
	.topbar .wrap { gap: 12px; }
	.brand span { display: none; }
	.devices { grid-template-columns: 1fr; }
	.stat .value { font-size: 24px; }
	.hide-xs { display: none; }
}
