:root {
	--ttcls-brand: #D94C14;
	--ttcls-brand-hover: #B83E0F;
	--ttcls-bg: #0F0F10;
	--ttcls-surface: #1A1A1C;
	--ttcls-surface-2: #232326;
	--ttcls-border: #2A2A2E;
	--ttcls-text: #F5F5F5;
	--ttcls-text-muted: #9A9AA0;
	--ttcls-danger: #ef4444;
	--ttcls-radius: 10px;
	--ttcls-radius-lg: 14px;
	--ttcls-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
	--ttcls-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	--ttcls-sidebar-w: 240px;
}

[data-theme="light"] {
	--ttcls-bg: #FFFFFF;
	--ttcls-surface: #F7F7F8;
	--ttcls-surface-2: #EFEFF1;
	--ttcls-border: #E4E4E7;
	--ttcls-text: #18181B;
	--ttcls-text-muted: #71717A;
	--ttcls-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Reset within app */
.ttcls-app,
.ttcls-app *,
.ttcls-app *::before,
.ttcls-app *::after {
	box-sizing: border-box;
}

.ttcls-app {
	font-family: var(--ttcls-font);
	color: var(--ttcls-text);
	background: var(--ttcls-bg);
	min-height: 100vh;
	display: grid;
	grid-template-columns: var(--ttcls-sidebar-w) 1fr;
	font-size: 14px;
	line-height: 1.5;
}

.ttcls-app.is-collapsed {
	grid-template-columns: 1fr;
}
.ttcls-app.is-collapsed .ttcls-sidebar {
	display: none;
}

/* ============ Sidebar ============ */
.ttcls-sidebar {
	background: var(--ttcls-surface);
	border-right: 1px solid var(--ttcls-border);
	padding: 20px 14px;
	display: flex;
	flex-direction: column;
	gap: 22px;
	position: sticky;
	top: 0;
	height: 100vh;
	transition: transform 0.2s ease;
}

.ttcls-brand {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 6px 8px;
}

.ttcls-brand-mark {
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: var(--ttcls-brand);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.ttcls-brand-text {
	display: flex;
	flex-direction: column;
	line-height: 1.15;
}

.ttcls-brand-name {
	font-weight: 700;
	font-size: 16px;
	letter-spacing: -0.01em;
}

.ttcls-brand-sub {
	color: var(--ttcls-text-muted);
	font-size: 11px;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.ttcls-nav {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.ttcls-nav-label {
	color: var(--ttcls-text-muted);
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	padding: 0 10px 6px;
}

.ttcls-nav-link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 10px;
	border-radius: var(--ttcls-radius);
	color: var(--ttcls-text-muted);
	text-decoration: none;
	font-weight: 500;
	transition: background 0.12s ease, color 0.12s ease;
}

.ttcls-nav-link:hover {
	background: var(--ttcls-surface-2);
	color: var(--ttcls-text);
}

.ttcls-nav-link.is-active {
	background: var(--ttcls-surface-2);
	color: var(--ttcls-text);
	box-shadow: inset 3px 0 0 var(--ttcls-brand);
}

.ttcls-sidebar-foot {
	margin-top: auto;
	border-top: 1px solid var(--ttcls-border);
	padding-top: 12px;
}

.ttcls-sidebar-close {
	display: none;
	position: absolute;
	top: 12px;
	right: 12px;
	background: transparent;
	border: 1px solid var(--ttcls-border);
	color: var(--ttcls-text-muted);
	width: 34px;
	height: 34px;
	border-radius: 8px;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.12s ease, color 0.12s ease;
}
.ttcls-sidebar-close:hover {
	background: var(--ttcls-surface-2);
	color: var(--ttcls-text);
}

.ttcls-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	z-index: 40;
	opacity: 0;
	transition: opacity 0.18s ease;
}

/* ============ Main ============ */
.ttcls-main {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ttcls-topbar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 24px;
	background: var(--ttcls-bg);
	border-bottom: 1px solid var(--ttcls-border);
	position: sticky;
	top: 0;
	z-index: 10;
}

.ttcls-topbar-title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	flex: 1;
	letter-spacing: -0.01em;
}

.ttcls-topbar-actions {
	display: flex;
	gap: 6px;
}

.ttcls-content {
	padding: 28px 24px 48px;
	max-width: 1100px;
	width: 100%;
	margin: 0 auto;
}

/* ============ Page header ============ */
.ttcls-page-head {
	margin-bottom: 22px;
}

.ttcls-page-title {
	margin: 0 0 4px;
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.ttcls-page-sub {
	margin: 0;
	color: var(--ttcls-text-muted);
	font-size: 14px;
}

/* ============ Stats ============ */
.ttcls-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 14px;
	margin-bottom: 22px;
}

.ttcls-stat {
	background: var(--ttcls-surface);
	border: 1px solid var(--ttcls-border);
	border-radius: var(--ttcls-radius-lg);
	padding: 18px 20px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ttcls-stat-label {
	color: var(--ttcls-text-muted);
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.ttcls-stat-value {
	font-size: 28px;
	font-weight: 700;
	letter-spacing: -0.02em;
}

/* ============ Card ============ */
.ttcls-card {
	background: var(--ttcls-surface);
	border: 1px solid var(--ttcls-border);
	border-radius: var(--ttcls-radius-lg);
	padding: 20px;
	margin-bottom: 18px;
}

.ttcls-card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
	gap: 12px;
}

.ttcls-card-title {
	margin: 0 0 14px;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -0.01em;
	display: flex;
	align-items: center;
	gap: 8px;
}

.ttcls-card-head .ttcls-card-title {
	margin: 0;
}

.ttcls-card-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 14px;
	padding-top: 14px;
	border-top: 1px solid var(--ttcls-border);
	gap: 12px;
}

/* ============ Form ============ */
.ttcls-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ttcls-input-row {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.ttcls-input {
	flex: 1;
	min-width: 200px;
	background: var(--ttcls-surface-2);
	border: 1px solid var(--ttcls-border);
	color: var(--ttcls-text);
	font-family: inherit;
	font-size: 14px;
	padding: 10px 14px;
	border-radius: var(--ttcls-radius);
	outline: none;
	transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.ttcls-input:focus {
	border-color: var(--ttcls-brand);
	box-shadow: 0 0 0 3px rgba(217, 76, 20, 0.15);
}

.ttcls-form-msg {
	margin: 0;
	font-size: 13px;
	color: var(--ttcls-text-muted);
	min-height: 18px;
}

.ttcls-form-msg.is-error {
	color: var(--ttcls-danger);
}

.ttcls-form-msg.is-success {
	color: #16a34a;
}

/* ============ Buttons ============ */
.ttcls-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	background: var(--ttcls-surface-2);
	border: 1px solid var(--ttcls-border);
	color: var(--ttcls-text);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	padding: 10px 16px;
	border-radius: var(--ttcls-radius);
	cursor: pointer;
	transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
	text-decoration: none;
}

.ttcls-btn:hover { background: var(--ttcls-border); }
.ttcls-btn:active { transform: translateY(1px); }
.ttcls-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ttcls-btn-primary {
	background: var(--ttcls-brand);
	border-color: var(--ttcls-brand);
	color: #fff;
}
.ttcls-btn-primary:hover {
	background: var(--ttcls-brand-hover);
	border-color: var(--ttcls-brand-hover);
}

.ttcls-btn-ghost {
	background: transparent;
}

.ttcls-btn-block {
	width: 100%;
}

.ttcls-link-btn {
	color: var(--ttcls-brand);
	text-decoration: none;
	font-size: 13px;
	font-weight: 600;
}
.ttcls-link-btn:hover { color: var(--ttcls-brand-hover); }

.ttcls-iconbtn {
	background: transparent;
	border: 1px solid transparent;
	color: var(--ttcls-text-muted);
	width: 32px;
	height: 32px;
	border-radius: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
	position: relative;
}
.ttcls-iconbtn:hover {
	background: var(--ttcls-surface-2);
	color: var(--ttcls-text);
	border-color: var(--ttcls-border);
}
.ttcls-iconbtn-danger:hover {
	color: var(--ttcls-danger);
	border-color: var(--ttcls-danger);
}

/* Theme icon swap */
.ttcls-icon-sun { display: none; }
[data-theme="light"] .ttcls-icon-moon { display: none; }
[data-theme="light"] .ttcls-icon-sun { display: block; }

/* ============ Link list (recent) ============ */
.ttcls-link-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
}

.ttcls-link-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 0;
	border-bottom: 1px solid var(--ttcls-border);
	gap: 14px;
}
.ttcls-link-row:last-child { border-bottom: 0; }

.ttcls-link-main {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	flex: 1;
}

.ttcls-link-short {
	color: var(--ttcls-brand);
	font-weight: 600;
	text-decoration: none;
	font-size: 14px;
}
.ttcls-link-short:hover { text-decoration: underline; }

.ttcls-link-dest {
	color: var(--ttcls-text-muted);
	font-size: 12.5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.ttcls-link-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.ttcls-badge {
	background: var(--ttcls-surface-2);
	color: var(--ttcls-text-muted);
	font-size: 12px;
	font-weight: 600;
	padding: 4px 10px;
	border-radius: 999px;
	border: 1px solid var(--ttcls-border);
	white-space: nowrap;
}

.ttcls-empty {
	color: var(--ttcls-text-muted);
	padding: 18px 4px;
	text-align: center;
	font-size: 13px;
}

/* ============ Table ============ */
.ttcls-table-wrap {
	overflow-x: auto;
	margin: 0 -4px;
}

.ttcls-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13.5px;
}

.ttcls-table th,
.ttcls-table td {
	padding: 12px 10px;
	text-align: left;
	border-bottom: 1px solid var(--ttcls-border);
	vertical-align: middle;
}

.ttcls-table th {
	color: var(--ttcls-text-muted);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.ttcls-table .ttcls-num { text-align: right; }
.ttcls-table .ttcls-actions-col { text-align: right; width: 110px; }

.ttcls-table tbody tr:hover { background: var(--ttcls-surface-2); }

.ttcls-table .ttcls-link-short { font-size: 13.5px; }
.ttcls-table .ttcls-cell-dest {
	max-width: 320px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--ttcls-text-muted);
}

/* ============ Search ============ */
.ttcls-search {
	position: relative;
	flex: 1;
	max-width: 360px;
	display: flex;
	align-items: center;
}

.ttcls-search svg {
	position: absolute;
	left: 12px;
	color: var(--ttcls-text-muted);
	pointer-events: none;
}

.ttcls-search .ttcls-input {
	padding-left: 36px;
}

/* ============ Pager ============ */
.ttcls-pager {
	display: flex;
	gap: 8px;
}

.ttcls-pager-info {
	color: var(--ttcls-text-muted);
	font-size: 13px;
}

/* ============ Toast ============ */
.ttcls-toast {
	position: fixed;
	bottom: 24px;
	right: 24px;
	background: var(--ttcls-surface);
	border: 1px solid var(--ttcls-border);
	color: var(--ttcls-text);
	padding: 10px 16px;
	border-radius: var(--ttcls-radius);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	font-size: 13px;
	font-weight: 500;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.18s ease, transform 0.18s ease;
	z-index: 1000;
	pointer-events: none;
}
.ttcls-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

/* ============ Standalone body ============ */
body.ttcls-standalone {
	margin: 0;
	padding: 0;
	background: var(--ttcls-bg, #0F0F10);
	font-family: var(--ttcls-font);
}

/* ============ Login ============ */
.ttcls-login-shell {
	font-family: var(--ttcls-font);
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	padding: 40px 20px;
	color: var(--ttcls-text);
	background:
		radial-gradient(1200px 600px at 80% -10%, rgba(217, 76, 20, 0.18), transparent 60%),
		radial-gradient(900px 500px at -10% 110%, rgba(217, 76, 20, 0.10), transparent 55%),
		var(--ttcls-bg);
	box-sizing: border-box;
}

.ttcls-login-shell *,
.ttcls-login-shell *::before,
.ttcls-login-shell *::after { box-sizing: border-box; }

.ttcls-login-card {
	background: var(--ttcls-surface);
	border: 1px solid var(--ttcls-border);
	border-radius: var(--ttcls-radius-lg);
	padding: 32px;
	max-width: 420px;
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 22px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.ttcls-login-brand {
	display: flex;
	align-items: center;
	gap: 14px;
}

.ttcls-login-title {
	margin: 0 0 4px;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.ttcls-login-sub {
	margin: 0;
	color: var(--ttcls-text-muted);
	font-size: 13px;
	line-height: 1.45;
}

/* Form fields */
.ttcls-login-form { gap: 14px; }

.ttcls-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ttcls-field-label {
	font-size: 12px;
	font-weight: 600;
	color: var(--ttcls-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.ttcls-pw-wrap {
	position: relative;
	display: flex;
	align-items: center;
}

.ttcls-pw-wrap .ttcls-input {
	padding-right: 42px;
	width: 100%;
}

.ttcls-pw-toggle {
	position: absolute;
	right: 6px;
	top: 50%;
	transform: translateY(-50%);
	background: transparent;
	border: 0;
	color: var(--ttcls-text-muted);
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border-radius: 6px;
	transition: background 0.12s ease, color 0.12s ease;
}
.ttcls-pw-toggle:hover { background: var(--ttcls-surface-2); color: var(--ttcls-text); }

.ttcls-pw-toggle .ttcls-icon-eye-off { display: none; }
.ttcls-pw-toggle.is-on .ttcls-icon-eye { display: none; }
.ttcls-pw-toggle.is-on .ttcls-icon-eye-off { display: block; }

.ttcls-login-foot {
	text-align: center;
	font-size: 13px;
}
.ttcls-login-foot a {
	color: var(--ttcls-text-muted);
	text-decoration: none;
}
.ttcls-login-foot a:hover {
	color: var(--ttcls-brand);
	text-decoration: underline;
}

/* ============ Mobile ============ */
@media (max-width: 768px) {
	.ttcls-app {
		grid-template-columns: 1fr;
	}
	.ttcls-sidebar {
		position: fixed;
		left: 0;
		top: 0;
		width: var(--ttcls-sidebar-w);
		z-index: 50;
		transform: translateX(-100%);
		box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
	}
	.ttcls-app.is-collapsed .ttcls-sidebar {
		display: flex;
	}
	.ttcls-app.is-open .ttcls-sidebar {
		transform: translateX(0);
	}
	.ttcls-sidebar-close {
		display: inline-flex;
	}
	.ttcls-app.is-open .ttcls-backdrop {
		display: block;
		opacity: 1;
	}
	body.ttcls-no-scroll {
		overflow: hidden;
	}
	.ttcls-content {
		padding: 18px 16px 40px;
	}
}
