/* Base styles of the standalone app (shell, auth pages, navigation). */
:root {
	--tc-brand: #2563eb;
	--tc-bg: #f3f5f8;
	--tc-ink: #1d2327;
	--tc-line: #d6dae1;
	--tc-muted-ink: #646970;
	--tc-top-h: 56px;
	color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; background: var(--tc-bg); color: var(--tc-ink);
	font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-tap-highlight-color: transparent;
}
a { color: var(--tc-brand); }
h1 { font-size: 1.55em; line-height: 1.25; margin: 0; font-weight: 700; }
h2 { font-size: 1.15em; margin: 1.2em 0 .5em; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; }
input, select, textarea, button { font: inherit; }

/* Shared button + field look (auth pages use them without the app CSS). */
.tc-btn { display: inline-flex; align-items: center; justify-content: center; gap: .35em; min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--tc-line); background: #fff; color: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.tc-btn--primary { background: var(--tc-brand); border-color: var(--tc-brand); color: #fff; }
.tc-btn--big { min-height: 50px; font-size: 1.05em; }
.tc-btn--block { width: 100%; }
.tc-btn[disabled] { opacity: .5; cursor: not-allowed; }
.tc-field { display: block; margin: 0 0 12px; }
.tc-field__label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .92em; }
.tc-field input, .tc-field select, .tc-field textarea { width: 100%; min-height: 44px; padding: 8px 12px; font-size: 16px; border: 1px solid var(--tc-line); border-radius: 8px; background: #fff; color: var(--tc-ink); }
.tc-field input:focus, .tc-field select:focus, .tc-field textarea:focus { outline: 2px solid var(--tc-brand); outline-offset: 1px; border-color: transparent; }
.tc-help { display: block; color: var(--tc-muted-ink); font-size: .85em; margin-top: .25em; }
.tc-grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 600px) { .tc-grid2 { grid-template-columns: 1fr 1fr; } }

/* Auth pages */
.tc-auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.tc-auth--wide .tc-auth__card { max-width: 680px; }
.tc-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; }
.tc-brand img { border-radius: 14px; }
.tc-brand__name { font-weight: 700; font-size: 1.2em; }
.tc-auth__card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--tc-line); border-radius: 14px; padding: 22px 20px; box-shadow: 0 6px 24px rgba(16,24,40,.06); }
.tc-auth__card h1 { font-size: 1.35em; margin-bottom: 14px; }
.tc-auth__links { text-align: center; margin: 14px 0 0; }
.tc-check { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; }
.tc-check input { width: 20px; height: 20px; }
.tc-alert { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 12px; border-radius: 8px; }
.tc-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 10px 12px; border-radius: 8px; }
.tc-checks { list-style: none; padding: 0; margin: 0 0 12px; }
.tc-checks li { padding: 3px 0; }
.tc-checks .is-ok { color: #166534; }
.tc-checks .is-bad { color: #b91c1c; font-weight: 600; }
.tc-code { width: 100%; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; }

/* App shell */
.tc-top {
	position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
	min-height: var(--tc-top-h); padding: 0 16px; padding-top: env(safe-area-inset-top);
	background: #fff; border-bottom: 1px solid var(--tc-line);
}
.tc-top__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--tc-ink); text-decoration: none; white-space: nowrap; }
.tc-top__brand img { border-radius: 7px; }
.tc-nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tc-nav::-webkit-scrollbar { display: none; }
.tc-nav a, .tc-top__user a { padding: 8px 10px; border-radius: 8px; color: var(--tc-ink); text-decoration: none; white-space: nowrap; font-weight: 500; }
.tc-nav a:hover, .tc-top__user a:hover { background: var(--tc-bg); }
.tc-nav a.is-active, .tc-top__user a.is-active { background: color-mix(in srgb, var(--tc-brand) 12%, #fff); color: var(--tc-brand); }
.tc-top__user { display: flex; gap: 2px; margin-left: auto; }
.tc-top__logout { color: var(--tc-muted-ink) !important; }
.tc-main { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 1240px; margin: 0 auto; }
.tc-main--portal { max-width: 800px; }
.tc-wrap .tc-head h1 { font-size: 1.5em; }

/* Phone: brand + user on top row, nav as a bottom tab bar. */
@media (max-width: 860px) {
	.tc-top { flex-wrap: wrap; }
	.tc-top__user a:first-child { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
	.tc-shell:not(.tc-shell--portal) .tc-nav {
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; flex: none;
		background: #fff; border-top: 1px solid var(--tc-line);
		padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around;
	}
	.tc-shell:not(.tc-shell--portal) .tc-nav a { display: flex; flex-direction: column; align-items: center; font-size: 11px; padding: 6px 8px; gap: 1px; }
	.tc-shell:not(.tc-shell--portal) .tc-nav a span { font-size: 18px; line-height: 1; }
	.tc-shell:not(.tc-shell--portal) .tc-main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
	.tc-shell:not(.tc-shell--portal) .tc-sticky { bottom: calc(62px + env(safe-area-inset-bottom)); }
	.tc-main { padding-left: 12px; padding-right: 12px; }
}

/* Sticky bar background matches the page */
.tc-sticky { background: linear-gradient(to top, var(--tc-bg) 70%, rgba(243,245,248,0)) !important; }

#tc-offline { position: fixed; left: 0; right: 0; top: 0; z-index: 200; background: #b45309; color: #fff; text-align: center; padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); font-size: 14px; }
.tc-loading { color: var(--tc-muted-ink); }
