/* Palette: warm neutrals + terracotta accent (Claude's visual identity),
   not Sentry's cool blue/gray. Light values live in :root; dark values
   are applied both automatically (via prefers-color-scheme) and via an
   explicit [data-theme] override that the sidebar's theme-toggle button
   sets and which always wins over the OS preference. */
:root {
	--bg: #faf9f5;
	--bg-alt: #f0eee6;
	--fg: #33322e;
	--fg-muted: #7c7a73;
	--border: #e5e2d8;
	--accent: #c15f3c;
	--accent-fg: #ffffff;
	--danger: #c0392b;
	--warning: #b8842e;
	--success: #5b8a3a;
	--code-bg: #f0eee6;
	--row-hover: #ebe8dd;

	--sidebar-bg: var(--bg-alt);
	--sidebar-bg-alt: var(--row-hover);
	--sidebar-border: var(--border);
	--sidebar-fg: var(--fg);
	--sidebar-fg-muted: var(--fg-muted);
	--sidebar-hover-bg: var(--row-hover);
	--sidebar-active-bg: color-mix(in srgb, var(--accent) 16%, transparent);
	--sidebar-active-fg: var(--accent);
	--sidebar-shadow: rgba(60, 50, 40, 0.12);

	font-size: 18px;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #262624;
		--bg-alt: #30302d;
		--fg: #f0eee6;
		--fg-muted: #a8a69e;
		--border: #403f3a;
		--accent: #d97757;
		--accent-fg: #262624;
		--danger: #e5686b;
		--warning: #e0a458;
		--success: #8fbc6d;
		--code-bg: #2b2a27;
		--row-hover: #38372f;
		--sidebar-shadow: rgba(0, 0, 0, 0.4);
	}
}

/* Explicit overrides from the theme-toggle button always win, regardless
   of OS preference (higher specificity than the bare :root above, and
   declared after the media query, so both mechanisms agree it wins). */
:root[data-theme="light"] {
	--bg: #faf9f5;
	--bg-alt: #f0eee6;
	--fg: #33322e;
	--fg-muted: #7c7a73;
	--border: #e5e2d8;
	--accent: #c15f3c;
	--accent-fg: #ffffff;
	--danger: #c0392b;
	--warning: #b8842e;
	--success: #5b8a3a;
	--code-bg: #f0eee6;
	--row-hover: #ebe8dd;
	--sidebar-shadow: rgba(60, 50, 40, 0.12);
}
:root[data-theme="dark"] {
	--bg: #262624;
	--bg-alt: #30302d;
	--fg: #f0eee6;
	--fg-muted: #a8a69e;
	--border: #403f3a;
	--accent: #d97757;
	--accent-fg: #262624;
	--danger: #e5686b;
	--warning: #e0a458;
	--success: #8fbc6d;
	--code-bg: #2b2a27;
	--row-hover: #38372f;
	--sidebar-shadow: rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background: var(--bg);
	color: var(--fg);
	line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.88rem;
}

/* ---- App shell: sidebar (follows the active theme) + scrollable main
   content area. ---- */
.app-shell { display: flex; align-items: flex-start; min-height: 100vh; }

.sidebar {
	width: 240px;
	flex-shrink: 0;
	min-height: 100vh;
	background: var(--sidebar-bg);
	border-right: 1px solid var(--sidebar-border);
	display: flex;
	flex-direction: column;
	padding: 1rem 0.75rem;
	position: sticky;
	top: 0;
	transition: width 0.15s ease;
}
.sidebar-collapse-toggle {
	position: absolute;
	top: 18px;
	right: -11px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--sidebar-bg-alt);
	border: 1px solid var(--sidebar-border);
	color: var(--sidebar-fg-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	z-index: 10;
	box-shadow: 0 1px 3px var(--sidebar-shadow);
}
.sidebar-collapse-toggle:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-fg); }
.sidebar-collapse-toggle svg { transition: transform 0.15s ease; }

.sidebar-brand {
	color: var(--sidebar-fg);
	font-weight: 700;
	font-size: 1.15rem;
	padding: 0 0.5rem 1rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark { display: none; color: var(--accent); }

.sidebar-project-switcher { margin-bottom: 0.75rem; position: relative; }
.sidebar-project-switcher summary {
	list-style: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.55rem 0.6rem;
	border-radius: 6px;
	background: var(--sidebar-bg-alt);
	color: var(--sidebar-fg);
	font-weight: 600;
	font-size: 0.92rem;
}
.sidebar-project-switcher summary::-webkit-details-marker { display: none; }
.sidebar-project-switcher summary:hover { background: var(--sidebar-hover-bg); }
.project-avatar {
	display: none;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 5px;
	background: color-mix(in srgb, var(--accent) 20%, transparent);
	color: var(--accent);
	font-size: 0.8rem;
	font-weight: 700;
	flex-shrink: 0;
	text-transform: uppercase;
}
.project-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.switch-chevron { color: var(--sidebar-fg-muted); font-size: 0.85rem; flex-shrink: 0; }
.switcher-menu {
	position: absolute;
	left: 0;
	right: 0;
	z-index: 20;
	background: var(--sidebar-bg-alt);
	border: 1px solid var(--sidebar-border);
	border-radius: 6px;
	margin-top: 0.25rem;
	padding: 0.25rem;
	max-height: 260px;
	overflow-y: auto;
	box-shadow: 0 8px 24px var(--sidebar-shadow);
}
.switcher-menu a { display: block; padding: 0.4rem 0.5rem; border-radius: 4px; color: var(--sidebar-fg); font-size: 0.88rem; }
.switcher-menu a:hover { background: var(--sidebar-hover-bg); text-decoration: none; }
.switcher-all { border-top: 1px solid var(--sidebar-border); margin-top: 0.2rem; padding-top: 0.5rem !important; color: var(--sidebar-fg-muted) !important; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.sidebar-link {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	padding: 0.5rem 0.6rem;
	border-radius: 6px;
	color: var(--sidebar-fg-muted);
	font-size: 0.92rem;
	font-weight: 500;
}
.sidebar-link svg { flex-shrink: 0; }
.sidebar-link:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-fg); text-decoration: none; }
.sidebar-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); }
button.sidebar-link {
	width: 100%;
	border: none;
	background: none;
	cursor: pointer;
	text-align: left;
	font-family: inherit;
}

.sidebar-footer {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	margin-top: auto;
	padding-top: 0.75rem;
	border-top: 1px solid var(--sidebar-border);
}
.sidebar-logout { margin: 0; }
.sidebar-logout button {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	width: 100%;
	padding: 0.5rem 0.6rem;
	border-radius: 6px;
	border: none;
	background: none;
	color: var(--sidebar-fg-muted);
	font-size: 0.92rem;
	font-weight: 500;
	cursor: pointer;
	text-align: left;
	font-family: inherit;
}
.sidebar-logout button:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-fg); }

/* ---- Collapsed sidebar state (toggled via app.js + persisted in
   localStorage; the inline head script applies this class before first
   paint to avoid a flash of the expanded sidebar). ---- */
:root.sidebar-collapsed .sidebar { width: 64px; padding-left: 0.5rem; padding-right: 0.5rem; }
:root.sidebar-collapsed .sidebar-collapse-toggle svg { transform: rotate(180deg); }
:root.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
:root.sidebar-collapsed .brand-text { display: none; }
:root.sidebar-collapsed .brand-mark { display: inline-block; }
:root.sidebar-collapsed .sidebar-project-switcher summary { justify-content: center; padding: 0.5rem; }
:root.sidebar-collapsed .project-avatar { display: inline-flex; }
:root.sidebar-collapsed .project-name-text,
:root.sidebar-collapsed .switch-chevron,
:root.sidebar-collapsed .sidebar-link span,
:root.sidebar-collapsed .sidebar-logout button span {
	display: none;
}
:root.sidebar-collapsed .sidebar-link,
:root.sidebar-collapsed .sidebar-logout button {
	justify-content: center;
}
:root.sidebar-collapsed .switcher-menu {
	left: 100%;
	right: auto;
	top: 0;
	margin-top: 0;
	margin-left: 0.4rem;
	width: 200px;
}

.app-main { flex: 1; min-width: 0; }

main { max-width: 1150px; margin: 0 auto; padding: 1.75rem 2rem 4rem; }

/* ---- Login page (no sidebar; shown pre-auth) ---- */
.login-page { max-width: none; display: flex; justify-content: center; padding-top: 4rem; }
.login-box { width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 1.5rem; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.03em; }

.card {
	background: var(--bg-alt);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 1.25rem;
	margin-bottom: 1rem;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--fg-muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.02em; }
tbody tr:hover { background: var(--row-hover); }

.badge {
	display: inline-block;
	padding: 0.15rem 0.55rem;
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}
.badge-unresolved { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.badge-resolved { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge-ignored { background: color-mix(in srgb, var(--fg-muted) 18%, transparent); color: var(--fg-muted); }
.level-error, .level-fatal { color: var(--danger); }
.level-warning { color: var(--warning); }
.level-info, .level-debug { color: var(--fg-muted); }

.btn {
	display: inline-block;
	padding: 0.45rem 0.9rem;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--fg);
	cursor: pointer;
	font-size: 0.9rem;
	font-family: inherit;
}
.btn:hover { background: var(--row-hover); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { filter: brightness(1.08); }

.issue-nav { display: flex; gap: 0.5rem; margin-bottom: 1rem; }

/* ---- Issue stream toolbar (Sentry-style search + status tabs) ---- */
.issue-toolbar { margin-bottom: 1rem; }
.search-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.search-input {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0 0.7rem;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--fg-muted);
}
.search-input input {
	flex: 1;
	border: none;
	background: none;
	padding: 0.5rem 0;
	color: var(--fg);
	font-size: 0.92rem;
}
.search-input input:focus { outline: none; }
.search-row select {
	padding: 0.4rem 0.6rem;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--fg);
	font-size: 0.9rem;
}
.tabs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.status-tabs {
	display: inline-flex;
	border: 1px solid var(--border);
	border-radius: 6px;
	overflow: hidden;
}
.status-tab {
	border: none;
	background: var(--bg);
	color: var(--fg-muted);
	padding: 0.4rem 0.8rem;
	font-size: 0.88rem;
	font-weight: 500;
	cursor: pointer;
	font-family: inherit;
	border-right: 1px solid var(--border);
}
.status-tab:last-child { border-right: none; }
.status-tab:hover { background: var(--row-hover); }
.status-tab.active { background: var(--accent); color: var(--accent-fg); }
.compact-input {
	padding: 0.4rem 0.6rem;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--fg);
	font-size: 0.88rem;
	width: 130px;
}

/* ---- Stat tiles ---- */
.stat-row { display: flex; gap: 1rem; margin-bottom: 1.25rem; }
.stat-tile {
	background: var(--bg-alt);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0.85rem 1.1rem;
	min-width: 120px;
}
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--fg); line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 0.15rem; }

/* ---- Issue list (card rows, not a table) ---- */
.issue-list { display: flex; flex-direction: column; gap: 0.4rem; }
.issue-row {
	display: flex;
	align-items: center;
	gap: 1rem;
	background: var(--bg-alt);
	border: 1px solid var(--border);
	border-left: 3px solid var(--border);
	border-radius: 6px;
	padding: 0.7rem 1rem;
	color: var(--fg);
}
.issue-row:hover { background: var(--row-hover); text-decoration: none; }
.issue-row.level-border-fatal, .issue-row.level-border-error { border-left-color: var(--danger); }
.issue-row.level-border-warning { border-left-color: var(--warning); }
.issue-row.level-border-info, .issue-row.level-border-debug { border-left-color: var(--fg-muted); }
.issue-main { flex: 1; min-width: 0; }
.issue-title {
	font-weight: 600;
	font-size: 1rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.issue-culprit {
	font-size: 0.84rem;
	color: var(--fg-muted);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin-top: 0.15rem;
}
.issue-spark { color: var(--accent); flex-shrink: 0; display: flex; align-items: center; opacity: 0.85; }
.issue-meta { display: flex; align-items: center; gap: 0.9rem; flex-shrink: 0; font-size: 0.85rem; }
.issue-count { font-weight: 600; min-width: 2.5ch; text-align: right; }
.issue-time { min-width: 74px; text-align: right; }

.issue-row-wrap { display: flex; align-items: center; gap: 0.6rem; }
.issue-row-wrap .issue-row { flex: 1; min-width: 0; }
.issue-select { flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; }

.bulk-toolbar {
	display: none;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 0.6rem;
	padding: 0.5rem 0.8rem;
	background: var(--bg-alt);
	border: 1px solid var(--border);
	border-radius: 6px;
}
.bulk-toolbar.active { display: flex; }
.bulk-select-all { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.bulk-select-all input { width: 16px; height: 16px; cursor: pointer; }
#bulk-count { color: var(--fg-muted); font-size: 0.85rem; margin-right: 0.4rem; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filters input, .filters select {
	padding: 0.4rem 0.6rem;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--fg);
	font-size: 0.9rem;
}
.filters input[type="text"] { flex: 1; min-width: 180px; }

.form-field { margin-bottom: 1rem; }
.form-field label { display: block; margin-bottom: 0.3rem; font-weight: 600; font-size: 0.9rem; }
.form-field input, .form-field select {
	width: 100%;
	padding: 0.5rem 0.6rem;
	border-radius: 6px;
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--fg);
	font-size: 0.95rem;
}

.muted { color: var(--fg-muted); }
.error-text { color: var(--danger); margin-bottom: 1rem; }
.success-text { color: var(--success); margin-bottom: 1rem; }

.dsn-box {
	background: var(--code-bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 0.75rem;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	word-break: break-all;
	font-size: 0.88rem;
}

.pagination { display: flex; gap: 0.5rem; align-items: center; margin-top: 1rem; }

.frame {
	border: 1px solid var(--border);
	border-radius: 6px;
	margin-bottom: 0.5rem;
	overflow: hidden;
}
.frame-header {
	padding: 0.5rem 0.75rem;
	background: var(--bg-alt);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.85rem;
	display: flex;
	justify-content: space-between;
	gap: 1rem;
}
.frame-in-app { border-left: 3px solid var(--accent); }
.frame-context { background: var(--code-bg); overflow-x: auto; }
.frame-context table { width: 100%; }
.frame-context td { border: none; padding: 0 0.75rem; white-space: pre; }
.frame-context .lineno { color: var(--fg-muted); text-align: right; padding-right: 0.75rem; user-select: none; width: 1%; }
.frame-context .context-line { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.frame-vars { padding: 0.5rem 0.75rem; }
.frame-vars table { width: auto; }
.frame-vars td { border: none; padding: 0.15rem 0.5rem; }

.non-in-app-toggle { color: var(--fg-muted); font-size: 0.85rem; margin: 0.4rem 0; }

.breadcrumb-list { list-style: none; padding: 0; margin: 0; }
.breadcrumb-list li {
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--border);
	display: flex;
	gap: 0.75rem;
	font-size: 0.9rem;
}
.breadcrumb-list .bc-time { color: var(--fg-muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }

.tag-summary { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-pill {
	background: var(--bg-alt);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.2rem 0.6rem;
	font-size: 0.84rem;
}

.actions { display: flex; gap: 0.5rem; margin: 1rem 0; }
