/* Table DB 既定のスタイル。設定画面の「独自 CSS」で上書きできます。 */
.tdb-container {
	--tdb-border: #d0d5dd;
	--tdb-head-bg: #eef1f5;
	--tdb-head-text: #1d2327;
	--tdb-stripe-bg: #f7f8fa;
	--tdb-hover-bg: #e8f0fb;
	--tdb-accent: #2563eb;
	margin: 0 0 1.5em;
}

.tdb-wrap {
	max-width: 100%;
}

.tdb-wrap.tdb-scroll-x {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.tdb-scroll-x .tdb {
	width: max-content;
	min-width: 100%;
}

.tdb {
	width: 100%;
	border-collapse: collapse;
	border-spacing: 0;
	margin: 0;
	font-size: inherit;
	line-height: 1.5;
}

.tdb th,
.tdb td {
	border: 1px solid var(--tdb-border);
	padding: 0.5em 0.75em;
	text-align: left;
	vertical-align: top;
	background: none;
}

.tdb thead th,
.tdb tfoot th {
	background-color: var(--tdb-head-bg);
	color: var(--tdb-head-text);
	font-weight: 700;
	vertical-align: middle;
}

.tdb tbody th {
	font-weight: 700;
}

.tdb.tdb-striped > tbody > tr:nth-child(even) > * {
	background-color: var(--tdb-stripe-bg);
}

/* JavaScript で並べ替えたあとも縞模様がずれないようにする */
.tdb.tdb-striped.tdb-js > tbody > tr > * {
	background-color: transparent;
}

.tdb.tdb-striped.tdb-js > tbody > tr.tdb-even > * {
	background-color: var(--tdb-stripe-bg);
}

.tdb.tdb-hover > tbody > tr:hover > *,
.tdb.tdb-hover.tdb-js > tbody > tr:hover > * {
	background-color: var(--tdb-hover-bg);
}

.tdb img {
	max-width: 100%;
	height: auto;
	vertical-align: middle;
}

.tdb-table-name {
	margin: 0 0 0.5em;
}

.tdb-table-description {
	margin: 0.5em 0;
}

/* 並べ替え */
.tdb th.tdb-sortable {
	cursor: pointer;
	position: relative;
	padding-right: 1.75em;
	user-select: none;
}

.tdb th.tdb-sortable::after {
	content: "";
	position: absolute;
	right: 0.6em;
	top: 50%;
	width: 0;
	height: 0;
	border-left: 0.3em solid transparent;
	border-right: 0.3em solid transparent;
	border-bottom: 0.4em solid currentColor;
	opacity: 0.25;
	transform: translateY(-50%);
}

.tdb th.tdb-sorted-asc::after {
	opacity: 0.85;
}

.tdb th.tdb-sorted-desc::after {
	opacity: 0.85;
	border-bottom: 0;
	border-top: 0.4em solid currentColor;
}

.tdb th.tdb-sortable:focus-visible {
	outline: 2px solid var(--tdb-accent);
	outline-offset: -2px;
}

.tdb tr.tdb-empty td {
	text-align: center;
	color: #646970;
}

/* 表の上下の操作部品 */
.tdb-controls {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.5em 1em;
	margin: 0.5em 0;
	font-size: 0.9em;
}

.tdb-controls-top .tdb-search {
	margin-left: auto;
}

.tdb-controls label {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	margin: 0;
}

.tdb-controls select,
.tdb-controls input[type="search"] {
	font-size: inherit;
	padding: 0.3em 0.5em;
	border: 1px solid var(--tdb-border, #d0d5dd);
	border-radius: 4px;
	background: #fff;
	color: inherit;
}

.tdb-controls input[type="search"] {
	width: 14em;
	max-width: 100%;
}

.tdb-pager {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25em;
	margin-left: auto;
}

.tdb-pager .tdb-page {
	min-width: 2.2em;
	padding: 0.3em 0.6em;
	border: 1px solid var(--tdb-border, #d0d5dd);
	border-radius: 4px;
	background: #fff;
	color: inherit;
	font-size: inherit;
	line-height: 1.4;
	cursor: pointer;
}

.tdb-pager .tdb-page:hover:not(:disabled) {
	border-color: var(--tdb-accent, #2563eb);
}

.tdb-pager .tdb-page.tdb-current {
	background: var(--tdb-accent, #2563eb);
	border-color: var(--tdb-accent, #2563eb);
	color: #fff;
	cursor: default;
}

.tdb-pager .tdb-page:disabled {
	opacity: 0.4;
	cursor: default;
}

.tdb-pager .tdb-ellipsis {
	padding: 0.3em 0.2em;
}

.tdb-edit-link {
	margin: -1em 0 1.5em;
	font-size: 0.8em;
}

.tdb-error {
	padding: 0.5em 0.75em;
	border-left: 4px solid #d63638;
	background: #fcf0f1;
}

@media (max-width: 600px) {
	.tdb-controls-top .tdb-search {
		margin-left: 0;
	}

	.tdb-controls input[type="search"] {
		width: 100%;
	}

	.tdb-controls label.tdb-search {
		flex: 1 1 100%;
	}
}

@media print {
	.tdb-controls,
	.tdb-edit-link {
		display: none;
	}
}
