*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
	/* Stelar brand palette (admin MR !1395) */
	--brand-primary:  #E7343F;
	--brand-logo-red: #D31E2B;
	--brand-dark:     #49545C;

	--brand:      var(--brand-primary);
	--brand-d:    #C42B34;
	--text:       #292927;
	--muted:      #7E7E7E;
	--border:     #E0E0E0;
	--bg:         #F5F5F5;
	--surface:    #ffffff;
	--nav-bg:     rgba(255,255,255,.95);
	--green:      #16a34a;
	--radius:     8px;
	--shadow:     0 4px 16px rgba(0,0,0,.08);
	--sidebar-w:  220px;
	--topbar-h:   52px;
}
[data-theme="dark"] {
	--brand:      #F25862;
	--brand-d:    #E7343F;
	--text:       #F5F5F5;
	--muted:      #7E7E7E;
	--border:     #585857;
	--bg:         #292927;
	--surface:    #292927;
	--nav-bg:     rgba(41,41,39,.95);
	--green:      #4ade80;
	--shadow:     0 4px 16px rgba(0,0,0,.3);
}

body { font-family: 'Rework Text', Verdana, system-ui, -apple-system, sans-serif; color: var(--text); background: var(--bg); line-height: 1.6; transition: background .2s, color .2s; }
h1, h2, h3 { font-family: 'Rework Headline', 'Rework Text', Verdana, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar layout ──────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
	width: var(--sidebar-w); flex-shrink: 0;
	background: var(--surface); border-right: 1px solid var(--border);
	position: fixed; top: 0; left: 0; bottom: 0;
	display: flex; flex-direction: column; z-index: 20;
	overflow-y: auto;
}

.sidebar-logo-wrap {
	padding: 1.1rem 1rem; border-bottom: 1px solid var(--border);
	display: flex; align-items: center;
}
.sidebar-logo { display: inline-flex; text-decoration: none; }
.sidebar-logo img { height: 44px; width: auto; }
.sidebar-logo:hover { text-decoration: none; }
/* Logo keeps its red brand color in dark mode too (no invert). */

.sidebar-nav { padding: .5rem .5rem; flex: 1; }
.nav-section {
	font-size: .68rem; font-weight: 700; text-transform: uppercase;
	letter-spacing: .08em; color: var(--muted);
	padding: .85rem .5rem .3rem;
}
.sidebar-item {
	display: flex; align-items: center; gap: .6rem;
	padding: .5rem .75rem; border-radius: var(--radius);
	font-size: .875rem; color: var(--muted);
	text-decoration: none; transition: background .12s, color .12s;
	margin-bottom: 2px;
}
.sidebar-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sidebar-item.active { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); font-weight: 600; }
.sidebar-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.sidebar-item.active svg { opacity: 1; }

.sidebar-footer {
	padding: .75rem 1rem; border-top: 1px solid var(--border);
	font-size: .75rem; color: var(--muted);
}

/* ── Top bar ─────────────────────────────────── */
.topbar {
	position: fixed; top: 0;
	left: var(--sidebar-w); right: 0;
	height: var(--topbar-h);
	background: var(--nav-bg); backdrop-filter: blur(6px);
	border-bottom: 1px solid var(--border);
	display: flex; align-items: center; justify-content: flex-end;
	padding: 0 1.5rem; gap: .75rem; z-index: 10;
}
.topbar-email {
	font-size: .82rem; color: var(--muted);
	max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-pill {
	background: var(--brand); color: #fff; padding: .35rem 1rem;
	border-radius: 999px; font-size: .82rem; font-weight: 600;
	border: none; cursor: pointer; text-decoration: none;
}
.nav-pill:hover { background: var(--brand-d); text-decoration: none; }
.nav-pill-outline { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.nav-pill-outline:hover { background: var(--bg); color: var(--text); }

/* theme toggle */
.theme-btn {
	background: none; border: 1px solid var(--border); border-radius: 999px;
	width: 2rem; height: 2rem; cursor: pointer; color: var(--muted);
	display: flex; align-items: center; justify-content: center;
	font-size: 1rem; transition: background .15s, color .15s; flex-shrink: 0;
}
.theme-btn:hover { background: var(--bg); color: var(--text); }
.theme-btn .icon-sun  { display: none; }
.theme-btn .icon-moon { display: block; }
[data-theme="dark"] .theme-btn .icon-sun  { display: block; }
[data-theme="dark"] .theme-btn .icon-moon { display: none; }

/* ── App body ────────────────────────────────── */
.app-body { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }
.app-content {
	margin-top: var(--topbar-h); flex: 1;
	background: var(--bg); padding: 2rem;
	min-height: calc(100vh - var(--topbar-h));
}

/* ── Flash messages ──────────────────────────── */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.flash.info    { background: #fde4dc; color: var(--brand-d); }
.flash.success { background: #dcfce7; color: #15803d; }
.flash.warning { background: #fef9c3; color: #854d0e; }
.flash.error   { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .flash.info    { background: #1e3a5f; color: #f39869; }
[data-theme="dark"] .flash.success { background: #14532d; color: #86efac; }
[data-theme="dark"] .flash.warning { background: #422006; color: #fde68a; }
[data-theme="dark"] .flash.error   { background: #450a0a; color: #fca5a5; }

/* ── Workspace selector ─────────────────────── */
.workspace-selector { position: relative; padding: .5rem .75rem .25rem; }
.workspace-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .4rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .45rem .65rem; font-size: .82rem; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.workspace-btn:hover { border-color: var(--brand); }
.workspace-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-dropdown { display: none; position: absolute; left: .75rem; right: .75rem; top: calc(100% - .25rem); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); z-index: 100; padding: .35rem 0; }
.ws-dropdown.open { display: block; }
.ws-dropdown-header { font-size: .72rem; color: var(--muted); padding: .3rem .75rem .15rem; text-transform: uppercase; letter-spacing: .04em; }
.ws-dropdown-sep { height: 1px; background: var(--border); margin: .3rem 0; }
.ws-item { display: flex; align-items: center; gap: .5rem; padding: .4rem .75rem; font-size: .82rem; color: var(--text); cursor: pointer; text-decoration: none; }
.ws-item:hover { background: var(--bg); text-decoration: none; }
.ws-item-active { font-weight: 700; color: var(--brand); }
.ws-check { color: var(--brand); width: 14px; flex-shrink: 0; }
.ws-item-new { color: var(--brand); font-weight: 600; }

.impersonate-bar { background: #fef3c7; border: 1px solid #f59e0b; border-radius: 8px; padding: .6rem 1rem; margin-bottom: 1.25rem; display: flex; align-items: center; justify-content: space-between; font-size: .85rem; color: #78350f; }
.impersonate-bar a { color: #92400e; font-weight: 600; white-space: nowrap; }
[data-theme="dark"] .impersonate-bar { background: #422006; border-color: #b45309; color: #fde68a; }
[data-theme="dark"] .impersonate-bar a { color: #fcd34d; }

/* ── Auth layout (login page) ────────────────── */
.auth-shell {
	min-height: 100vh; display: flex; align-items: center; justify-content: center;
	background: var(--bg); padding: 1.5rem;
}
.login-page { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.login-logo { display: inline-flex; text-decoration: none; }
.login-logo img { height: 48px; width: auto; }
.login-logo:hover { text-decoration: none; }
/* Logo keeps its red brand color in dark mode too (no invert) — consistent
   with the sidebar logo; the white brightness/invert variant read as a
   different brand on the login screen. */

.login-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.login-card h1 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.lf-group { margin-bottom: .9rem; }
.lf-group label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .3rem; color: var(--text); }
.lf-group input {
	width: 100%; padding: .55rem .75rem; border: 1px solid var(--border);
	border-radius: 6px; font-size: .9rem; background: var(--bg); color: var(--text);
	transition: border-color .15s;
}
.lf-group input:focus { outline: none; border-color: var(--brand); }
.login-card button {
	width: 100%; margin-top: .5rem; padding: .65rem;
	background: var(--brand); color: #fff;
	border: none; border-radius: 6px; font-size: .9rem; font-weight: 600;
	cursor: pointer; transition: background .15s;
}
.login-card button:hover { background: var(--brand-d); }

.auth-flash { margin-bottom: 1rem; width: 100%; max-width: 380px; }

.auth-theme {
	position: fixed; top: 1rem; right: 1rem;
}
