/**
 * Hanuman Thai Tax Calculator v1.12.0
 * https://www.construction.co.th | GPL-2.0+
 *
 * ทุกกฎอยู่ใต้ .ttc-wrap จึงไม่ไปชนกับสไตล์ของธีม
 * สีทั้งหมดมาจากหมึกสองสีในโลโก้ น้ำเงินกรมท่ากับเขียว
 */

.ttc-wrap {
	--ttc-navy: #002850;
	--ttc-navy-deep: #001a33;
	--ttc-green: #008068;
	--ttc-green-deep: #00604e;
	--ttc-green-soft: #edf8f4;
	--ttc-ink: #1d2938;
	--ttc-muted: #55677c;
	--ttc-line: #dbe4ec;
	--ttc-surface: #fff;
	--ttc-sunken: #f2f6f9;
	--ttc-radius: 14px;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 14px;
	color: var(--ttc-ink);
	font-size: 15px;
	line-height: 1.6;
	box-sizing: border-box;
}

.ttc-wrap *,
.ttc-wrap *::before,
.ttc-wrap *::after { box-sizing: inherit; }

.ttc-heading {
	margin: 0 0 2px;
	padding: 0;
	border: none;
	background: none;
	font-size: 23px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: -0.01em;
	color: var(--ttc-navy);
}

/* ---------------------------------------------------------------------------
 * การ์ด
 * ------------------------------------------------------------------------ */

.ttc-card {
	padding: 20px 22px;
	border: 1px solid var(--ttc-line);
	border-radius: var(--ttc-radius);
	background: var(--ttc-surface);
	box-shadow: 0 1px 2px rgba(0, 40, 80, .05), 0 10px 26px -20px rgba(0, 26, 51, .55);
}

.ttc-label {
	margin: 0 0 12px;
	padding: 0;
	font-size: 11.5px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--ttc-muted);
}

/* ---------------------------------------------------------------------------
 * ปุ่มเลือกโหมดและอัตรา
 * ------------------------------------------------------------------------ */

.ttc-btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.ttc-mode-btn,
.ttc-wht-btn {
	padding: 9px 17px;
	border: 1px solid var(--ttc-line);
	border-radius: 999px;
	background: var(--ttc-sunken);
	color: #3c4858;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .1s ease;
}

.ttc-mode-btn:hover,
.ttc-wht-btn:hover {
	border-color: var(--ttc-green);
	background: var(--ttc-green-soft);
	color: var(--ttc-green-deep);
}

.ttc-mode-btn:active,
.ttc-wht-btn:active { transform: scale(.97); }

.ttc-mode-btn:focus-visible,
.ttc-wht-btn:focus-visible {
	outline: 2px solid var(--ttc-green);
	outline-offset: 2px;
}

/* โหมดใช้กรมท่า อัตราใช้เขียว สองแถวจึงแยกจากกันได้ด้วยสีโดยไม่ต้องอ่านหัวข้อ */
.ttc-mode-btn.ttc-active {
	background: var(--ttc-navy);
	border-color: var(--ttc-navy);
	color: #fff;
	font-weight: 600;
	box-shadow: 0 2px 8px rgba(0, 40, 80, .24);
}

.ttc-wht-btn.ttc-active {
	background: var(--ttc-green-deep);
	border-color: var(--ttc-green-deep);
	color: #fff;
	font-weight: 600;
	box-shadow: 0 2px 8px rgba(0, 96, 78, .28);
}

.ttc-mode-hint {
	margin: 12px 0 0;
	padding: 0;
	font-size: 12.5px;
	line-height: 1.7;
	color: var(--ttc-muted);
}

/* ---------------------------------------------------------------------------
 * ช่องกรอกจำนวนเงิน
 * ------------------------------------------------------------------------ */

.ttc-input-group { margin-top: 18px; }

.ttc-input-label {
	display: block;
	margin-bottom: 8px;
	font-size: 13.5px;
	font-weight: 600;
	letter-spacing: normal;
	text-transform: none;
	color: var(--ttc-navy);
}

.ttc-input-wrap {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 13px 16px;
	border: 1.5px solid var(--ttc-line);
	border-radius: 12px;
	background: var(--ttc-sunken);
	transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.ttc-input-wrap:focus-within {
	border-color: var(--ttc-green);
	background: #fff;
	box-shadow: 0 0 0 4px rgba(0, 128, 104, .13);
}

.ttc-currency {
	flex-shrink: 0;
	font-size: 17px;
	font-weight: 700;
	color: var(--ttc-green-deep);
	user-select: none;
}

.ttc-amount-input {
	flex: 1;
	width: 100%;
	min-width: 0;
	border: none;
	outline: none;
	background: transparent;
	font-family: inherit;
	font-size: 20px;
	font-weight: 600;
	color: var(--ttc-navy);
	font-variant-numeric: tabular-nums;
}

.ttc-amount-input::-webkit-inner-spin-button,
.ttc-amount-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ttc-amount-input[type=number] { -moz-appearance: textfield; }

.ttc-clear-btn {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: #dfe7ee;
	color: #4b5c6d;
	font-family: inherit;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background .15s ease, color .15s ease;
}

.ttc-clear-btn:hover { background: #c9d6e0; color: var(--ttc-navy); }
.ttc-clear-btn:focus-visible { outline: 2px solid var(--ttc-green); outline-offset: 2px; }
.ttc-clear-btn[hidden] { display: none; }

.ttc-wht-hint { margin-top: 12px; }

/* ---------------------------------------------------------------------------
 * กล่องเน้นผลลัพธ์ของโหมดถอดยอด
 * ------------------------------------------------------------------------ */

.ttc-reverse-highlight,
.ttc-expense-highlight,
.ttc-grossup-highlight {
	margin-bottom: 16px;
	padding: 15px 17px;
	border-radius: 12px;
}

.ttc-reverse-highlight {
	border: 1px solid #bcd3e8;
	background: linear-gradient(135deg, #eef5fb, #e8f1f9);
}

.ttc-expense-highlight {
	border: 1px solid #a9ddcd;
	background: linear-gradient(135deg, #f0faf6, #e9f7f1);
}

.ttc-reverse-highlight__label,
.ttc-expense-highlight__label,
.ttc-grossup-highlight__label {
	margin: 0 0 4px;
	padding: 0;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .02em;
}

.ttc-reverse-highlight__label { color: var(--ttc-navy); }
.ttc-expense-highlight__label { color: var(--ttc-green-deep); }

.ttc-reverse-highlight__val,
.ttc-expense-highlight__val,
.ttc-grossup-highlight__val {
	font-size: 25px;
	font-weight: 800;
	letter-spacing: -0.01em;
	font-variant-numeric: tabular-nums;
}

.ttc-reverse-highlight__val { color: var(--ttc-navy); }
.ttc-expense-highlight__val { color: #024c36; }

/* ยอดตั้งต้นในใบเสร็จ — โหมดให้ผู้รับได้เต็มจำนวน */
.ttc-grossup-highlight {
	border: 1px solid #c9b8e8;
	background: linear-gradient(135deg, #f5f1fd, #efeafb);
}

.ttc-grossup-highlight__label { color: #4c2f8f; }
.ttc-grossup-highlight__val   { color: #3b1f78; }

.ttc-grossup-highlight__note {
	margin: 6px 0 0;
	padding: 0;
	font-size: 12px;
	line-height: 1.6;
	color: #5b4a7d;
}

/* ---------------------------------------------------------------------------
 * สวิตช์เปิด/ปิด VAT (เฉพาะโหมดให้ผู้รับได้เต็มจำนวน)
 * ------------------------------------------------------------------------ */

.ttc-vat-switch {
	display: flex;
	align-items: flex-start;
	gap: 11px;
	margin-top: 14px;
	padding: 13px 15px;
	border: 1px solid var(--ttc-line);
	border-radius: 12px;
	background: var(--ttc-sunken);
	cursor: pointer;
}

.ttc-vat-switch:hover { border-color: #b9cddd; }

/* ซ่อน checkbox จริงไว้ แต่ยังโฟกัสด้วยคีย์บอร์ดได้ ตัวที่เห็นคือรางสวิตช์ */
.ttc-vat-switch__input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	margin: 0;
	pointer-events: none;
}

.ttc-vat-switch__track {
	flex: none;
	position: relative;
	width: 40px;
	height: 23px;
	margin-top: 1px;
	border-radius: 999px;
	background: #c3ceda;
	transition: background .18s ease;
}

.ttc-vat-switch__track::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 17px;
	height: 17px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 26, 51, .32);
	transition: transform .18s ease;
}

.ttc-vat-switch__input:checked + .ttc-vat-switch__track { background: var(--ttc-green-deep); }
.ttc-vat-switch__input:checked + .ttc-vat-switch__track::after { transform: translateX(17px); }

.ttc-vat-switch__input:focus-visible + .ttc-vat-switch__track {
	outline: 2px solid var(--ttc-green);
	outline-offset: 2px;
}

.ttc-vat-switch__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.ttc-vat-switch__text strong {
	font-size: 13.5px;
	font-weight: 600;
	color: var(--ttc-navy);
}

.ttc-vat-switch__text em {
	font-style: normal;
	font-size: 12px;
	line-height: 1.6;
	color: var(--ttc-muted);
}

/* ---------------------------------------------------------------------------
 * แถวผลลัพธ์
 * ------------------------------------------------------------------------ */

.ttc-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	padding: 11px 0;
	border-bottom: 1px solid #eef2f6;
	font-size: 14px;
}

.ttc-row-label {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	color: var(--ttc-muted);
}

.ttc-row-val {
	font-weight: 600;
	color: var(--ttc-ink);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.ttc-plus  { color: var(--ttc-green-deep); }
.ttc-minus { color: #b42318; }

.ttc-total-row {
	margin: 6px -22px;
	padding: 13px 22px;
	border-bottom: none;
	border-radius: 10px;
	background: var(--ttc-sunken);
}

.ttc-row-label-strong {
	font-size: 14px;
	font-weight: 700;
	color: var(--ttc-navy);
}

.ttc-row-val-strong {
	font-size: 16px;
	font-weight: 700;
	color: var(--ttc-navy);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.ttc-wht-row.ttc-hidden { display: none; }

.ttc-tag {
	display: inline-block;
	padding: 3px 9px;
	border-radius: 999px;
	background: #e9eef3;
	color: #3c4858;
	font-size: 11px;
	font-weight: 600;
	white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * ยอดสุทธิ
 * ------------------------------------------------------------------------ */

.ttc-net-block { padding-top: 16px; }
.ttc-net-label { margin-bottom: 4px; }

.ttc-net-val {
	margin-top: 4px;
	font-size: 32px;
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1.15;
	word-break: break-all;
	color: var(--ttc-navy);
	font-variant-numeric: tabular-nums;
}

.ttc-net-val--confirm { color: var(--ttc-green-deep); }

/* ---------------------------------------------------------------------------
 * ปุ่มคัดลอกสรุป
 * ------------------------------------------------------------------------ */

.ttc-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 16px;
	padding-top: 14px;
	border-top: 1px dashed var(--ttc-line);
}

.ttc-action-btn {
	padding: 8px 17px;
	border: 1px solid var(--ttc-line);
	border-radius: 999px;
	background: #fff;
	color: var(--ttc-navy);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.ttc-action-btn:hover {
	border-color: var(--ttc-green);
	background: var(--ttc-green-soft);
	color: var(--ttc-green-deep);
}

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

.ttc-action-btn--done {
	border-color: var(--ttc-green-deep);
	background: var(--ttc-green-soft);
	color: var(--ttc-green-deep);
}

/* ---------------------------------------------------------------------------
 * กล่องสูตรและหมายเหตุ
 * ------------------------------------------------------------------------ */

.ttc-formula-card,
.ttc-expense-formula-card,
.ttc-grossup-formula-card,
.ttc-note-card {
	background: var(--ttc-sunken);
	border-color: #e3eaf1;
	box-shadow: none;
}

.ttc-formula-title,
.ttc-note-title {
	margin: 0 0 8px;
	padding: 0;
	font-size: 13px;
	font-weight: 700;
	color: var(--ttc-navy);
}

.ttc-formula-body {
	margin: 0 0 8px;
	font-size: 13px;
	line-height: 1.9;
	color: #3c4858;
}

.ttc-formula-body strong { color: var(--ttc-green-deep); }

.ttc-formula-example,
.ttc-expense-formula-example,
.ttc-grossup-formula-example {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.75;
	color: var(--ttc-muted);
	font-variant-numeric: tabular-nums;
}

.ttc-note-body {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.9;
	color: var(--ttc-muted);
}

/* ---------------------------------------------------------------------------
 * จอแคบ
 * ------------------------------------------------------------------------ */

@media ( max-width: 480px ) {
	.ttc-card { padding: 16px 17px; }
	.ttc-total-row { margin: 6px -17px; padding: 12px 17px; }
	.ttc-heading { font-size: 20px; }
	.ttc-net-val { font-size: 26px; }
	.ttc-reverse-highlight__val, .ttc-expense-highlight__val, .ttc-grossup-highlight__val { font-size: 21px; }
	.ttc-mode-btn, .ttc-wht-btn { font-size: 13px; padding: 8px 14px; }
}

@media ( prefers-reduced-motion: reduce ) {
	.ttc-wrap * { transition: none !important; }
}

/* พิมพ์เฉพาะผลลัพธ์ ไม่ต้องได้ปุ่มควบคุมติดไปด้วย */
@media print {
	.ttc-mode-card, .ttc-wht-card, .ttc-actions, .ttc-note-card, .ttc-vat-switch { display: none !important; }
	.ttc-card { box-shadow: none; border: 1px solid #ccc; }
}
