.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 20px;
}
.card-header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--gap); margin-bottom: 12px; }
.card-header h2 { margin: 0; }

.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	cursor: pointer;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 0.85rem; }
.btn.icon { padding: 2px 8px; font-size: 1.1rem; line-height: 1.2; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 0; }

.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 0.85rem; color: var(--muted); }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
input, select, textarea {
	font: inherit;
	padding: 8px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.table th.sortable { cursor: pointer; user-select: none; }
.table tr:hover td { background: var(--bg); }

.badge {
	display: inline-block;
	padding: 1px 8px;
	border-radius: 999px;
	font-size: 0.75rem;
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--muted);
	margin: 1px 2px 1px 0;
}
.badge.primary { color: var(--primary); border-color: var(--primary); }
.badge.off { text-decoration: line-through; }

.notice { padding: 10px 12px; border-radius: var(--radius); border: 1px solid; font-size: 0.9rem; }
.notice.ok { color: var(--ok); border-color: var(--ok); background: #eef8f1; }
.notice.err { color: var(--danger); border-color: var(--danger); background: #fdf0ee; }

dialog {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 20px;
	width: min(520px, calc(100vw - 32px));
	color: var(--text);
}
dialog::backdrop { background: rgba(20, 30, 40, 0.4); }

.loading { color: var(--muted); padding: 24px 0; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs button {
	font: inherit;
	background: none;
	border: 0;
	border-bottom: 2px solid transparent;
	padding: 8px 12px;
	color: var(--muted);
	cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { font-size: 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; margin-left: 4px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; }
.filters input[type="search"] { min-width: 220px; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; background: var(--bg); color: var(--muted); }
.chip.emergency { background: #fdecea; color: #b71c1c; }
.chip.urgent { background: #fff3e0; color: #b35c00; }
.chip.oncall { background: #fdecea; color: #b71c1c; }
.chip.inpatient { background: #e8f0fe; color: #1a4fa3; }
.overdue { color: var(--danger); font-weight: 600; }
.soon { color: #b35c00; font-weight: 600; }

.table tr.clickable { cursor: pointer; }
.table tr.selected td { background: #e8f0fe; }
.table td.row-actions { white-space: nowrap; text-align: right; }
.table td.nowrap { white-space: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }

.detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.detail dt { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.detail dd { margin: 0; }

.report-body { line-height: 1.5; }
.report-body p { margin: 0 0 8px; }
.report-body table { border-collapse: collapse; }
.report-body td, .report-body th { border: 1px solid var(--border); padding: 4px 8px; }
.tox-tinymce { border-radius: var(--radius) !important; }

/* Dialogs that hold the editor stay out of the browser's top layer, so the
   editor's own popups can stack above them. */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(20, 30, 40, 0.4); z-index: 40; }
dialog.editor-dialog[open] { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; z-index: 50; max-height: 92vh; overflow: auto; }
