/* ===== Tema ===== */
:root {
	--bg: #0a0e17;
	--bg-2: #0d1220;
	--panel: #121a2b;
	--panel-2: #0f1626;
	--border: #1e2840;
	--border-strong: #2a3652;
	--text: #e7ecf5;
	--muted: #8b97b0;
	--muted-2: #5c6884;
	--primary: #22c55e;
	--primary-press: #16a34a;
	--primary-ink: #05240f;
	--ready: #22c55e;
	--row-hover: #17203400;
	--input-bg: #0b1120;
	--danger-bg: #3a1620;
	--danger-bd: #7f2a3a;
	--danger-tx: #ffb4c0;
	--shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
:root[data-theme="light"] {
	--bg: #eef2f8;
	--bg-2: #e6ecf5;
	--panel: #ffffff;
	--panel-2: #f6f8fc;
	--border: #dfe5ee;
	--border-strong: #cbd4e2;
	--text: #16203a;
	--muted: #5a677e;
	--muted-2: #8b97ac;
	--primary: #16a34a;
	--primary-press: #12833c;
	--primary-ink: #ffffff;
	--ready: #16a34a;
	--input-bg: #f4f7fb;
	--danger-bg: #fdecef;
	--danger-bd: #f3b7c2;
	--danger-tx: #a1213a;
	--shadow: 0 16px 40px rgba(30, 50, 90, 0.14);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	background: radial-gradient(1200px 600px at 50% -10%, var(--bg-2), var(--bg)) fixed;
	color: var(--text);
	font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
	font-size: 14px;
	-webkit-font-smoothing: antialiased;
}

/* ===== Botões / ícones ===== */
.btn-primary {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--primary);
	color: var(--primary-ink);
	border: none;
	border-radius: 10px;
	padding: 11px 16px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, transform 0.05s, opacity 0.15s;
}
.btn-primary:hover { background: var(--primary-press); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; margin-top: 18px; }

.theme-toggle, .icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: var(--panel);
	border: 1px solid var(--border);
	color: var(--muted);
	cursor: pointer;
	text-decoration: none;
	transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle:hover, .icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* ===== Logo (Medicina Diagnóstica Group) ===== */
.logo { display: inline-flex; align-items: center; }
.logo-mark { flex: none; height: 36px; width: auto; display: block; }
.brand-center .logo-mark { height: 60px; width: auto; max-width: 100%; }

/* ===== Login ===== */
.login-top {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding-top: 40px;
}
.pill {
	background: rgba(34, 197, 94, 0.14);
	color: var(--primary);
	border: 1px solid rgba(34, 197, 94, 0.35);
	padding: 5px 14px;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 600;
}
.login-wrap {
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: 60px 20px 40px;
}
.card {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 16px;
	box-shadow: var(--shadow);
}
.login-card { width: 100%; max-width: 430px; padding: 32px 30px 30px; }
.brand-center { display: flex; justify-content: center; margin-bottom: 22px; }
.field-label { display: block; margin: 16px 0 7px; font-weight: 600; font-size: 13.5px; }
.req { color: #ef4767; }

.input {
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--input-bg);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0 12px;
	transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus-within {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}
.input .ico { color: var(--muted-2); flex: none; }
.input input {
	flex: 1;
	background: transparent;
	border: none;
	outline: none;
	color: var(--text);
	font-size: 14.5px;
	padding: 12px 0;
}
.input input::placeholder { color: var(--muted-2); }
.eye { background: none; border: none; color: var(--muted-2); cursor: pointer; padding: 4px; display: flex; }
.eye:hover { color: var(--text); }

.alert {
	background: var(--danger-bg);
	border: 1px solid var(--danger-bd);
	color: var(--danger-tx);
	padding: 10px 12px;
	border-radius: 10px;
	font-size: 13.5px;
	margin-bottom: 6px;
}

/* ===== Topbar (home) ===== */
.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 22px;
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 10;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar {
	width: 38px; height: 38px;
	border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: linear-gradient(135deg, #2b3a55, #1c2740);
	border: 1px solid var(--border-strong);
	color: var(--text);
	font-weight: 700;
	font-size: 13px;
}

/* ===== Conteúdo / toolbar ===== */
.content { padding: 20px 22px 40px; max-width: 1200px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.search { flex: 1; max-width: 360px; }
.search input { padding: 10px 0; }
.select-wrap { min-width: 220px; }
.select-wrap select {
	flex: 1;
	background: transparent;
	border: none;
	outline: none;
	color: var(--text);
	font-size: 14px;
	padding: 11px 0;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}
.select-wrap select option { background: var(--panel); color: var(--text); }

.modalidade-tag {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 8px;
	font-size: 12px;
	font-weight: 600;
	background: rgba(109, 179, 242, 0.14);
	color: #6db3f2;
	border: 1px solid rgba(109, 179, 242, 0.32);
	white-space: nowrap;
}
.det-title .modalidade-tag { margin-left: 8px; vertical-align: middle; font-size: 12.5px; }
.vazio-filtro { text-align: center; color: var(--muted); padding: 24px; }

/* ===== Grid ===== */
.table-wrap {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 14px;
	overflow-x: auto;
}
table.grid { width: 100%; border-collapse: collapse; min-width: 780px; }
.grid thead th {
	text-align: left;
	color: var(--muted);
	font-weight: 600;
	font-size: 12.5px;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
.grid tbody td {
	padding: 13px 16px;
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr.linha:hover { background: var(--panel-2); }
.grid tbody tr.linha.sel-on { background: rgba(34, 197, 94, 0.08); }
.col-check { width: 44px; text-align: center; }
.col-laudo { width: 80px; text-align: center; }
.mono { font-variant-numeric: tabular-nums; font-weight: 600; }
.empty td { text-align: center; color: var(--muted); padding: 40px 16px; }

.resumo { max-width: 420px; }
.resumo .qtd { display: block; font-weight: 600; }
.resumo .lista {
	display: block;
	color: var(--muted);
	font-size: 12.5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 420px;
}

.badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 700;
	border: 1px solid transparent;
}
.badge.pronto { background: rgba(34, 197, 94, 0.16); color: var(--ready); border-color: rgba(34, 197, 94, 0.4); }
.badge.parcial { background: rgba(234, 179, 8, 0.16); color: #eab308; border-color: rgba(234, 179, 8, 0.4); }
.badge.pendente { background: rgba(120, 130, 150, 0.16); color: var(--muted); border-color: var(--border-strong); }
.frac { color: var(--muted-2); font-size: 12px; margin-left: 8px; font-variant-numeric: tabular-nums; }

.laudo-btn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 36px; height: 36px;
	border-radius: 50%;
	text-decoration: none;
}
.laudo-btn.ready { color: var(--ready); background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.35); }
.laudo-btn.ready:hover { background: rgba(34, 197, 94, 0.22); }
.laudo-btn.dicom { color: #6db3f2; background: rgba(109, 179, 242, 0.12); border: 1px solid rgba(109, 179, 242, 0.35); }
.laudo-btn.dicom:hover { background: rgba(109, 179, 242, 0.22); }
.laudo-btn.muted { color: var(--muted-2); background: var(--panel-2); border: 1px solid var(--border); cursor: default; }

/* checkbox */
input[type="checkbox"] {
	width: 17px; height: 17px;
	accent-color: var(--primary);
	cursor: pointer;
}
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.4; }

/* ===== Linha clicável (home) ===== */
.grid tbody tr.click { cursor: pointer; }
.chevron { color: var(--muted-2); display: inline-flex; }
.grid tbody tr.click:hover .chevron { color: var(--primary); }

/* ===== Detalhe do atendimento ===== */
.voltar {
	display: inline-flex; align-items: center; gap: 6px;
	color: var(--muted); text-decoration: none;
	font-weight: 600; font-size: 13px; margin-bottom: 14px;
}
.voltar:hover { color: var(--text); }
.det-head { margin-bottom: 16px; }
.det-title { font-size: 18px; font-weight: 700; }
.det-title .mono { color: var(--primary); }
.det-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.medico { color: var(--muted); font-size: 13px; white-space: nowrap; }

.btn-ghost {
	display: inline-flex; align-items: center; gap: 8px;
	background: var(--panel); color: var(--text);
	border: 1px solid var(--border); border-radius: 10px;
	padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
	transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}
.btn-ghost:hover { border-color: var(--border-strong); background: var(--panel-2); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.toolbar .spacer { flex: 1; }

@media (max-width: 640px) {
	.resumo .lista { max-width: 220px; }
	.search { max-width: none; }
	.toolbar { flex-wrap: wrap; }
	.toolbar .spacer { display: none; }
}

/* ===== Balcão (sessão de funcionário) ===== */
.pill-func {
	background: rgba(109, 179, 242, 0.14);
	color: #6db3f2;
	border-color: rgba(109, 179, 242, 0.35);
}
.link-alt {
	display: block;
	text-align: center;
	margin-top: 16px;
	color: var(--muted);
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
}
.link-alt:hover { color: var(--primary); }

/* Chip com o funcionário logado, no topo */
.chip-func {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	max-width: 260px;
	padding: 5px 12px 5px 5px;
	border-radius: 999px;
	background: var(--panel-2);
	border: 1px solid var(--border);
}
.chip-ini {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px; height: 26px;
	border-radius: 50%;
	background: linear-gradient(135deg, #2b3a55, #1c2740);
	color: var(--text);
	font-size: 11px;
	font-weight: 700;
	flex: none;
}
.chip-nome {
	font-size: 12.5px;
	font-weight: 600;
	color: var(--muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* Faixa lembrando de quem são os exames abertos */
.faixa-paciente {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 22px;
	background: rgba(109, 179, 242, 0.09);
	border-bottom: 1px solid var(--border);
	font-size: 13.5px;
	color: var(--muted);
}
.faixa-paciente strong { color: var(--text); }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

/* Busca de paciente */
.search-lg { max-width: 520px; }
.aviso-truncado {
	margin: 0 0 14px;
	padding: 10px 14px;
	border-radius: 10px;
	background: rgba(234, 179, 8, 0.12);
	border: 1px solid rgba(234, 179, 8, 0.35);
	color: #eab308;
	font-size: 13px;
}

/* Coluna de controle de impressão */
.col-impressao { white-space: nowrap; }
.muted { color: var(--muted); }
.desfazer {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px; height: 28px;
	margin-left: 6px;
	vertical-align: middle;
	border-radius: 8px;
	background: transparent;
	border: 1px solid var(--border);
	color: var(--muted-2);
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.desfazer:hover {
	color: var(--danger-tx);
	border-color: var(--danger-bd);
	background: var(--danger-bg);
}
