/*
 * 세금도구함 도구모음 — 공통 스타일
 * 모바일 우선(320px~), 시스템 폰트, 가로 스크롤 금지.
 */

.tdg-tool {
	--tdg-navy: #17335f;
	--tdg-navy-dark: #0f2340;
	--tdg-green: #1a7f4b;
	--tdg-red: #c0392b;
	--tdg-border: #e2e8f0;
	--tdg-bg-soft: #f7f9fc;
	--tdg-radius: 10px;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
	color: #1f2937;
	background: #fff;
	border: 1px solid var(--tdg-border);
	border-radius: var(--tdg-radius);
	padding: 20px 16px;
	margin: 24px 0;
	max-width: 100%;
	box-sizing: border-box;
	overflow-wrap: break-word;
	line-height: 1.55;
}

.tdg-tool *,
.tdg-tool *::before,
.tdg-tool *::after {
	box-sizing: border-box;
}

.tdg-tool-head {
	margin-bottom: 14px;
}

.tdg-tool-title {
	margin: 0 0 6px;
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--tdg-navy);
	line-height: 1.35;
}

.tdg-tool-desc {
	margin: 0;
	font-size: 0.9rem;
	color: #4b5563;
}

.tdg-noscript {
	background: #fff7ed;
	border: 1px solid #fdba74;
	border-radius: var(--tdg-radius);
	padding: 12px;
	font-size: 0.9rem;
	color: #9a3412;
}

/* ---------- 탭 ---------- */

.tdg-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	border-bottom: 2px solid var(--tdg-border);
	margin-bottom: 16px;
	padding-bottom: 0;
}

.tdg-tab {
	appearance: none;
	background: var(--tdg-bg-soft);
	border: 1px solid var(--tdg-border);
	border-bottom: none;
	border-radius: 8px 8px 0 0;
	color: #4b5563;
	cursor: pointer;
	font-size: 0.9rem;
	font-weight: 600;
	min-height: 44px;
	padding: 10px 14px;
	line-height: 1.2;
}

.tdg-tab[aria-selected="true"] {
	background: var(--tdg-navy);
	border-color: var(--tdg-navy);
	color: #fff;
}

.tdg-tab:focus-visible {
	outline: 2px solid var(--tdg-green);
	outline-offset: 2px;
}

.tdg-tabpanel[hidden] {
	display: none;
}

/* ---------- 폼 ---------- */

.tdg-field {
	margin-bottom: 14px;
}

.tdg-label {
	display: block;
	font-size: 0.9rem;
	font-weight: 600;
	color: #374151;
	margin-bottom: 6px;
}

.tdg-input,
.tdg-select,
.tdg-textarea {
	width: 100%;
	border: 1px solid var(--tdg-border);
	border-radius: var(--tdg-radius);
	padding: 10px 12px;
	font-size: 1rem;
	font-family: inherit;
	color: #1f2937;
	background: #fff;
	min-height: 44px;
}

.tdg-textarea {
	min-height: 120px;
	resize: vertical;
	line-height: 1.6;
}

.tdg-input:focus,
.tdg-select:focus,
.tdg-textarea:focus {
	outline: 2px solid var(--tdg-navy);
	outline-offset: 1px;
	border-color: var(--tdg-navy);
}

.tdg-input[aria-invalid="true"],
.tdg-textarea[aria-invalid="true"] {
	border-color: var(--tdg-red);
}

.tdg-error {
	color: var(--tdg-red);
	font-size: 0.85rem;
	margin: 6px 0 0;
}

.tdg-hint {
	color: #6b7280;
	font-size: 0.82rem;
	margin: 6px 0 0;
}

.tdg-radio-group {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	align-items: center;
}

.tdg-radio-group label,
.tdg-check-group label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 0.92rem;
	color: #374151;
	min-height: 32px;
	cursor: pointer;
}

.tdg-check-group {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.tdg-radio-group input[type="radio"],
.tdg-check-group input[type="checkbox"] {
	width: 18px;
	height: 18px;
	accent-color: var(--tdg-navy);
	margin: 0;
	flex: none;
}

fieldset.tdg-fieldset {
	border: 1px solid var(--tdg-border);
	border-radius: var(--tdg-radius);
	padding: 10px 14px 12px;
	margin: 0 0 14px;
	min-width: 0;
}

fieldset.tdg-fieldset legend {
	font-size: 0.88rem;
	font-weight: 600;
	color: #374151;
	padding: 0 6px;
}

/* ---------- 버튼 ---------- */

.tdg-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 14px 0;
}

.tdg-btn {
	appearance: none;
	border: 1px solid var(--tdg-navy);
	background: var(--tdg-navy);
	color: #fff;
	border-radius: var(--tdg-radius);
	font-size: 0.95rem;
	font-weight: 600;
	font-family: inherit;
	padding: 10px 18px;
	min-height: 44px;
	min-width: 44px;
	cursor: pointer;
	line-height: 1.2;
}

.tdg-btn:hover {
	background: var(--tdg-navy-dark);
	border-color: var(--tdg-navy-dark);
}

.tdg-btn:focus-visible {
	outline: 2px solid var(--tdg-green);
	outline-offset: 2px;
}

.tdg-btn--ghost {
	background: #fff;
	color: var(--tdg-navy);
}

.tdg-btn--ghost:hover {
	background: var(--tdg-bg-soft);
	color: var(--tdg-navy-dark);
}

.tdg-btn--green {
	background: var(--tdg-green);
	border-color: var(--tdg-green);
}

.tdg-btn--green:hover {
	background: #14653c;
	border-color: #14653c;
}

.tdg-btn--small {
	padding: 6px 10px;
	min-height: 36px;
	font-size: 0.85rem;
}

.tdg-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ---------- 결과 영역 ---------- */

.tdg-result {
	background: var(--tdg-bg-soft);
	border: 1px solid var(--tdg-border);
	border-left: 4px solid var(--tdg-navy);
	border-radius: var(--tdg-radius);
	padding: 14px 16px;
	margin: 14px 0;
}

.tdg-result[hidden] {
	display: none;
}

.tdg-result-title {
	margin: 0 0 10px;
	font-size: 1rem;
	font-weight: 700;
	color: var(--tdg-navy);
}

.tdg-result-rows {
	margin: 0;
}

.tdg-result-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	padding: 6px 0;
	border-bottom: 1px dashed var(--tdg-border);
	flex-wrap: wrap;
}

.tdg-result-row:last-child {
	border-bottom: none;
}

.tdg-result-row dt {
	font-size: 0.9rem;
	color: #4b5563;
	margin: 0;
}

.tdg-result-row dd {
	font-size: 1.05rem;
	font-weight: 700;
	color: #111827;
	margin: 0;
	font-variant-numeric: tabular-nums;
}

.tdg-result-row--total dd {
	color: var(--tdg-navy);
	font-size: 1.15rem;
}

.tdg-formula {
	font-size: 0.82rem;
	color: #6b7280;
	margin: 10px 0 0;
}

/* ---------- 표 ---------- */

.tdg-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin: 12px 0;
	border: 1px solid var(--tdg-border);
	border-radius: var(--tdg-radius);
}

.tdg-table {
	border-collapse: collapse;
	width: 100%;
	min-width: 480px;
	font-size: 0.9rem;
	background: #fff;
}

.tdg-table th,
.tdg-table td {
	border-bottom: 1px solid var(--tdg-border);
	padding: 8px 10px;
	text-align: right;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.tdg-table th {
	background: var(--tdg-bg-soft);
	color: #374151;
	font-weight: 600;
	text-align: center;
}

.tdg-table td:first-child,
.tdg-table th:first-child {
	text-align: left;
}

.tdg-table tr.tdg-row-total td {
	background: #eef2f8;
	font-weight: 700;
	color: var(--tdg-navy);
	border-top: 2px solid var(--tdg-navy);
}

.tdg-table tr.tdg-row-error td {
	color: var(--tdg-red);
	background: #fdf2f2;
}

/* ---------- 안내/뱃지 ---------- */

.tdg-notice {
	background: var(--tdg-bg-soft);
	border: 1px solid var(--tdg-border);
	border-radius: var(--tdg-radius);
	color: #4b5563;
	font-size: 0.83rem;
	padding: 10px 14px;
	margin: 12px 0 0;
}

.tdg-notice p {
	margin: 0 0 6px;
}

.tdg-notice p:last-child {
	margin-bottom: 0;
}

.tdg-privacy {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	background: #f0faf4;
	border: 1px solid #bbe5cc;
	border-radius: var(--tdg-radius);
	color: #14532d;
	font-size: 0.88rem;
	font-weight: 600;
	padding: 10px 14px;
	margin: 0 0 14px;
}

.tdg-badge {
	display: inline-block;
	border-radius: 999px;
	font-size: 0.82rem;
	font-weight: 700;
	padding: 4px 12px;
	vertical-align: middle;
}

.tdg-badge--good {
	background: #e7f6ee;
	color: var(--tdg-green);
	border: 1px solid #b9e2cb;
}

.tdg-badge--warn {
	background: #fef6e7;
	color: #92600a;
	border: 1px solid #f2d9a4;
}

.tdg-badge--na {
	background: #f1f2f4;
	color: #4b5563;
	border: 1px solid #d5d9de;
}

.tdg-copied {
	color: var(--tdg-green);
	font-size: 0.85rem;
	margin-left: 6px;
}

/* ---------- 진행 바 ---------- */

.tdg-progress {
	background: var(--tdg-border);
	border-radius: 999px;
	height: 10px;
	overflow: hidden;
	margin: 10px 0;
}

.tdg-progress-bar {
	background: var(--tdg-green);
	height: 100%;
	width: 0;
	transition: width 0.2s ease;
}

/* ---------- 영수증 PDF ---------- */

.tdg-dropzone {
	border: 2px dashed var(--tdg-border);
	border-radius: var(--tdg-radius);
	background: var(--tdg-bg-soft);
	color: #4b5563;
	cursor: pointer;
	font-size: 0.92rem;
	padding: 26px 14px;
	text-align: center;
	margin-bottom: 14px;
}

.tdg-dropzone.tdg-dragover {
	border-color: var(--tdg-navy);
	background: #eef2f8;
	color: var(--tdg-navy);
}

.tdg-dropzone:focus-visible {
	outline: 2px solid var(--tdg-navy);
	outline-offset: 2px;
}

.tdg-thumbs {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 10px;
	list-style: none;
	margin: 0 0 14px;
	padding: 0;
}

.tdg-thumb {
	border: 1px solid var(--tdg-border);
	border-radius: var(--tdg-radius);
	background: #fff;
	padding: 8px;
	text-align: center;
	cursor: grab;
}

.tdg-thumb.tdg-drag-src {
	opacity: 0.4;
}

.tdg-thumb.tdg-drag-over {
	border-color: var(--tdg-navy);
	box-shadow: 0 0 0 2px var(--tdg-navy) inset;
}

.tdg-thumb img {
	width: 100%;
	height: 90px;
	object-fit: contain;
	display: block;
	background: var(--tdg-bg-soft);
	border-radius: 6px;
	max-width: 100%;
}

.tdg-thumb-name {
	display: block;
	font-size: 0.72rem;
	color: #6b7280;
	margin: 6px 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tdg-thumb-btns {
	display: flex;
	justify-content: center;
	gap: 4px;
	flex-wrap: wrap;
}

.tdg-icon-btn {
	appearance: none;
	background: #fff;
	border: 1px solid var(--tdg-border);
	border-radius: 8px;
	color: #374151;
	cursor: pointer;
	font-size: 0.85rem;
	min-width: 32px;
	min-height: 32px;
	padding: 4px 6px;
	line-height: 1;
}

.tdg-icon-btn:hover {
	border-color: var(--tdg-navy);
	color: var(--tdg-navy);
}

.tdg-icon-btn:focus-visible {
	outline: 2px solid var(--tdg-green);
	outline-offset: 1px;
}

.tdg-preview-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 35, 64, 0.82);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	padding: 20px;
}

.tdg-preview-overlay img {
	max-width: 100%;
	max-height: 85vh;
	border-radius: 8px;
	background: #fff;
}

.tdg-preview-close {
	position: absolute;
	top: 16px;
	right: 16px;
}

/* ---------- 체크리스트 ---------- */

.tdg-cl-cat {
	margin: 16px 0 6px;
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--tdg-navy);
	border-bottom: 1px solid var(--tdg-border);
	padding-bottom: 4px;
}

.tdg-cl-item {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 8px 4px;
	font-size: 0.93rem;
	color: #374151;
	cursor: pointer;
	border-radius: 6px;
}

.tdg-cl-item:hover {
	background: var(--tdg-bg-soft);
}

.tdg-cl-item input[type="checkbox"] {
	width: 20px;
	height: 20px;
	accent-color: var(--tdg-green);
	margin-top: 2px;
	flex: none;
}

.tdg-cl-item.tdg-done span {
	color: #9ca3af;
	text-decoration: line-through;
}

/* ---------- D-Day ---------- */

.tdg-dday-list {
	list-style: none;
	margin: 14px 0;
	padding: 0;
}

.tdg-dday-item {
	display: flex;
	align-items: center;
	gap: 10px;
	border: 1px solid var(--tdg-border);
	border-radius: var(--tdg-radius);
	padding: 10px 14px;
	margin-bottom: 8px;
	flex-wrap: wrap;
}

.tdg-dday-name {
	font-weight: 600;
	color: #1f2937;
	flex: 1 1 120px;
	min-width: 0;
	overflow-wrap: anywhere;
}

.tdg-dday-date {
	color: #6b7280;
	font-size: 0.85rem;
	white-space: nowrap;
}

.tdg-dday-count {
	font-weight: 700;
	color: var(--tdg-navy);
	font-size: 1rem;
	white-space: nowrap;
	min-width: 64px;
	text-align: right;
}

.tdg-dday-item.tdg-past {
	background: #f4f5f7;
}

.tdg-dday-item.tdg-past .tdg-dday-name,
.tdg-dday-item.tdg-past .tdg-dday-count {
	color: #9ca3af;
}

.tdg-dday-item.tdg-today .tdg-dday-count {
	color: var(--tdg-green);
}

.tdg-empty {
	border: 1px dashed var(--tdg-border);
	border-radius: var(--tdg-radius);
	color: #6b7280;
	font-size: 0.9rem;
	padding: 22px 14px;
	text-align: center;
}

/* ---------- 증빙 판정 ---------- */

.tdg-q {
	margin-bottom: 4px;
}

.tdg-q[hidden] {
	display: none;
}

.tdg-ev-list {
	margin: 6px 0 0;
	padding-left: 20px;
	font-size: 0.9rem;
	color: #374151;
}

.tdg-ev-list li {
	margin-bottom: 4px;
}

.tdg-basis {
	border-top: 1px dashed var(--tdg-border);
	margin-top: 12px;
	padding-top: 10px;
	font-size: 0.78rem;
	color: #6b7280;
}

/* ---------- 반응형 ---------- */

@media (min-width: 600px) {
	.tdg-tool {
		padding: 24px;
	}

	.tdg-check-group--cols {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 4px 16px;
	}
}

/* ---------- 인쇄 ---------- */

@media print {
	body.tdg-print-mode * {
		visibility: hidden !important;
	}

	body.tdg-print-mode .tdg-printing,
	body.tdg-print-mode .tdg-printing * {
		visibility: visible !important;
	}

	body.tdg-print-mode .tdg-printing {
		position: absolute !important;
		left: 0 !important;
		top: 0 !important;
		width: 100% !important;
		margin: 0 !important;
		border: none !important;
	}

	.tdg-printing .tdg-actions,
	.tdg-printing .tdg-tabs,
	.tdg-printing .tdg-btn,
	.tdg-printing .tdg-icon-btn,
	.tdg-printing .tdg-print-hide {
		display: none !important;
	}

	.tdg-printing .tdg-table {
		min-width: 0 !important;
	}
}
