:root {
	--color-primary: #ef5523;
	--color-primary-dark: #d8451a;
	--color-primary-light: #fff1ec;
	--color-text: #16181d;
	--color-text-secondary: #6b7280;
	--color-text-faint: #9ca3af;
	--color-border: #e5e7eb;
	--color-bg: #f6f7f9;
	--color-surface: #ffffff;
	--color-danger: #dc2626;
	--color-danger-light: #fef2f2;
	--shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
	--shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
	--shadow-lg: 0 20px 40px -8px rgba(16, 24, 40, 0.18);
	--radius-sm: 8px;
	--radius-md: 12px;
	--radius-lg: 18px;
	--font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
	box-sizing: border-box;
	font-family: var(--font-sans);
}

body {
	margin: 0;
	background: var(--color-bg);
	color: var(--color-text);
	-webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
	letter-spacing: -0.02em;
}

/* ---------- Topbar ---------- */

.topbar {
	z-index: 999;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	background: rgba(255, 255, 255, 0.9);
	backdrop-filter: saturate(180%) blur(10px);
	-webkit-backdrop-filter: saturate(180%) blur(10px);
	border-bottom: 1px solid var(--color-border);
	height: 64px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 40px;
}

.logo-section {
	display: flex;
	align-items: center;
}

.topbar .logo {
	width: 132px;
}

.topbar .logo img {
	width: 100%;
	height: auto;
	display: block;
}

.om-nav {
	display: flex;
	align-items: center;
	gap: 8px;
}

.om-nav a,
.om-nav button.link-btn {
	color: var(--color-text-secondary);
	text-decoration: none;
	font-size: 13.5px;
	font-weight: 600;
	letter-spacing: 0.2px;
	background: none;
	border: none;
	cursor: pointer;
	padding: 8px 14px;
	border-radius: var(--radius-sm);
	transition: background-color 0.15s ease, color 0.15s ease;
}

.om-nav a:hover,
.om-nav button.link-btn:hover {
	color: var(--color-text);
	background: var(--color-bg);
}

.om-nav a.active {
	color: var(--color-primary);
	background: var(--color-primary-light);
}

.om-nav .nav-divider {
	width: 1px;
	height: 22px;
	background: var(--color-border);
	margin: 0 6px;
}

.user-chip {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-left: 6px;
}

.user-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--color-primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 13px;
	font-weight: 700;
	flex-shrink: 0;
}

.user-name {
	font-size: 13.5px;
	font-weight: 600;
	color: var(--color-text);
}

/* ---------- Buttons ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	border: none;
	outline: none;
	cursor: pointer;
	font-family: var(--font-sans);
	font-weight: 600;
	font-size: 14.5px;
	border-radius: var(--radius-sm);
	padding: 11px 20px;
	transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.btn:active {
	transform: translateY(1px);
}

.btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	pointer-events: none;
}

.btn-primary,
.btn-primary.action-btn button,
.action-btn button {
	background: var(--color-primary);
	color: #fff;
	box-shadow: 0 1px 2px rgba(239, 85, 35, 0.25);
}

.btn-primary:hover,
.action-btn button:hover {
	background: var(--color-primary-dark);
}

.btn-block {
	width: 100%;
}

.btn-ghost {
	background: transparent;
	color: var(--color-text-secondary);
	border: 1px solid var(--color-border);
}

.btn-ghost:hover {
	background: var(--color-bg);
	color: var(--color-text);
}

.btn-danger-text {
	background: none;
	border: none;
	color: var(--color-text-faint);
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	padding: 6px 10px;
	border-radius: var(--radius-sm);
}

.btn-danger-text:hover {
	color: var(--color-danger);
	background: var(--color-danger-light);
}

/* ---------- Auth page ---------- */

.page-shell {
	margin-top: 64px;
	min-height: calc(100vh - 64px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	background:
		radial-gradient(circle at 15% 20%, rgba(239, 85, 35, 0.06), transparent 40%),
		radial-gradient(circle at 85% 80%, rgba(239, 85, 35, 0.05), transparent 40%);
}

.card {
	background: var(--color-surface);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-lg);
	border: 1px solid var(--color-border);
	padding: 44px 40px;
	width: 100%;
	max-width: 400px;
}

.card-eyebrow {
	font-size: 12.5px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--color-primary);
	margin: 0 0 6px 0;
}

.card h1 {
	margin: 0 0 6px 0;
	font-size: 24px;
	font-weight: 700;
}

.card-subtitle {
	color: var(--color-text-secondary);
	font-size: 14.5px;
	margin: 0 0 28px 0;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 18px;
}

.field label {
	font-size: 13px;
	font-weight: 600;
	color: var(--color-text);
}

.field input {
	padding: 11px 14px;
	border: 1.5px solid var(--color-border);
	border-radius: var(--radius-sm);
	font-size: 15px;
	font-family: var(--font-sans);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	background: var(--color-surface);
	color: var(--color-text);
}

.field input:focus {
	outline: none;
	border-color: var(--color-primary);
	box-shadow: 0 0 0 3px rgba(239, 85, 35, 0.12);
}

.field textarea {
	padding: 11px 14px;
	border: 1.5px solid var(--color-border);
	border-radius: var(--radius-sm);
	font-size: 15px;
	font-family: var(--font-sans);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	background: var(--color-surface);
	color: var(--color-text);
	resize: vertical;
}

.field textarea:focus {
	outline: none;
	border-color: var(--color-primary);
	box-shadow: 0 0 0 3px rgba(239, 85, 35, 0.12);
}

.btn-secondary {
	background: none;
	border: none;
	color: var(--color-primary);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	padding: 0;
	margin-top: 20px;
	text-align: center;
	width: 100%;
}

.btn-secondary:hover {
	text-decoration: underline;
}

.error-msg {
	color: var(--color-danger);
	background: var(--color-danger-light);
	border-radius: var(--radius-sm);
	font-size: 13.5px;
	font-weight: 500;
	padding: 0;
	min-height: 0;
	margin-bottom: 0;
	overflow: hidden;
	max-height: 0;
	transition: max-height 0.2s ease, padding 0.2s ease, margin 0.2s ease;
}

.error-msg:not(:empty) {
	padding: 10px 14px;
	margin-bottom: 18px;
	max-height: 100px;
}

/* ---------- Dashboard ---------- */

.dash-shell {
	margin-top: 64px;
	min-height: calc(100vh - 64px);
	padding: 64px 20px;
}

.dash-header {
	max-width: 780px;
	margin: 0 auto 44px auto;
	text-align: center;
}

.dash-header .card-eyebrow {
	text-align: center;
}

.dash-header h1 {
	font-size: 30px;
	margin: 0 0 8px 0;
}

.dash-header p {
	color: var(--color-text-secondary);
	font-size: 15.5px;
	margin: 0;
}

.tile-row {
	display: flex;
	gap: 24px;
	flex-wrap: wrap;
	justify-content: center;
	max-width: 780px;
	margin: 0 auto;
}

.tile {
	background: var(--color-surface);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
	border: 1px solid var(--color-border);
	padding: 32px;
	width: 300px;
	text-decoration: none;
	color: var(--color-text);
	cursor: pointer;
	transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.tile:hover {
	transform: translateY(-4px);
	box-shadow: var(--shadow-lg);
	border-color: rgba(239, 85, 35, 0.25);
}

.tile-icon {
	width: 46px;
	height: 46px;
	border-radius: var(--radius-md);
	background: var(--color-primary-light);
	color: var(--color-primary);
	display: flex;
	align-items: center;
	justify-content: center;
}

.tile-icon svg {
	width: 24px;
	height: 24px;
}

.tile h2 {
	margin: 0;
	font-size: 17px;
	font-weight: 700;
}

.tile p {
	margin: 0;
	color: var(--color-text-secondary);
	font-size: 14px;
	line-height: 1.5;
}

.tile-cta {
	margin-top: 4px;
	font-size: 13.5px;
	font-weight: 700;
	color: var(--color-primary);
	display: flex;
	align-items: center;
	gap: 4px;
}

/* ---------- Projects page ---------- */

.projects-shell {
	margin-top: 64px;
	max-width: 860px;
	margin-left: auto;
	margin-right: auto;
	padding: 48px 20px 80px;
}

.projects-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	margin-bottom: 28px;
	gap: 20px;
	flex-wrap: wrap;
}

.projects-header h1 {
	margin: 0 0 4px 0;
	font-size: 26px;
}

.projects-header p {
	margin: 0;
	color: var(--color-text-secondary);
	font-size: 14.5px;
}

.projects-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 18px;
}

.project-card {
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	padding: 22px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.project-card:hover {
	box-shadow: var(--shadow-md);
	border-color: rgba(239, 85, 35, 0.2);
}

.project-card-icon {
	width: 38px;
	height: 38px;
	border-radius: var(--radius-sm);
	background: var(--color-primary-light);
	color: var(--color-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 15px;
}

.project-card-name {
	font-size: 15.5px;
	font-weight: 700;
	margin: 0;
	word-break: break-word;
}

.project-card-meta {
	font-size: 12.5px;
	color: var(--color-text-faint);
	margin: -8px 0 0 0;
}

.project-card-actions {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: auto;
	padding-top: 10px;
	border-top: 1px solid var(--color-border);
}

.open-link {
	color: var(--color-primary);
	text-decoration: none;
	font-weight: 700;
	font-size: 13.5px;
}

.open-link:hover {
	text-decoration: underline;
}

.empty-state {
	text-align: center;
	padding: 70px 20px;
	color: var(--color-text-secondary);
	background: var(--color-surface);
	border: 1px dashed var(--color-border);
	border-radius: var(--radius-lg);
}

.empty-state .empty-icon {
	font-size: 36px;
	margin-bottom: 14px;
}

.empty-state p {
	margin: 0 0 18px 0;
	font-size: 14.5px;
}

/* ---------- Admin table (Manage Users) ---------- */

table.admin-table {
	width: 100%;
	border-collapse: collapse;
	background: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	overflow: hidden;
	box-shadow: var(--shadow-sm);
}

table.admin-table th,
table.admin-table td {
	text-align: left;
	padding: 12px 18px;
	border-bottom: 1px solid var(--color-border);
	font-size: 14px;
}

table.admin-table th {
	background: var(--color-bg);
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--color-text-faint);
}

table.admin-table tr:last-child td {
	border-bottom: none;
}

table.admin-table select {
	padding: 6px 10px;
	border: 1.5px solid var(--color-border);
	border-radius: var(--radius-sm);
	font-size: 13.5px;
	font-family: var(--font-sans);
	background: var(--color-surface);
	color: var(--color-text);
}

.role-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.role-badge-user {
	background: var(--color-bg);
	color: var(--color-text-secondary);
}

.role-badge-admin {
	background: var(--color-primary-light);
	color: var(--color-primary);
}

.role-badge-super_admin {
	background: #1f2937;
	color: #fff;
}

/* ---------- Modal ---------- */

.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 17, 21, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2000;
	padding: 20px;
}

.modal-overlay[hidden] {
	display: none;
}

.modal-card {
	background: var(--color-surface);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-lg);
	width: 100%;
	max-width: 420px;
	padding: 32px;
}

/* Wider variant for content-heavy modals (e.g. the wiki's document Preview),
   where the default 420px is too cramped to be useful. */
.modal-card-wide {
	max-width: 760px;
	max-height: 85vh;
	overflow-y: auto;
}

.modal-card h2 {
	margin: 0 0 6px 0;
	font-size: 19px;
}

.modal-card p {
	margin: 0 0 20px 0;
	color: var(--color-text-secondary);
	font-size: 14px;
}

.modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 22px;
}

.modal-actions.danger .btn-primary {
	background: var(--color-danger);
	box-shadow: none;
}

.modal-actions.danger .btn-primary:hover {
	background: #b91c1c;
}

/* ---------- In-app dialogs (portal/assets/dialogs.js) ---------- */
.ui-dialog {
	z-index: 3000; /* above every page-specific modal (.modal-overlay is 2000) */
}

.ui-dialog .modal-card {
	max-width: 440px;
}

.ui-dialog-message {
	white-space: pre-line;
	overflow-wrap: anywhere;
}

.ui-dialog .field {
	margin-bottom: 8px;
}

/* Neutral text button next to .btn-danger-text (e.g. "Rename" on project cards) */
.btn-text {
	background: none;
	border: none;
	color: var(--color-text-faint);
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	padding: 6px 10px;
	border-radius: var(--radius-sm);
}

.btn-text:hover {
	color: var(--color-text);
	background: var(--color-bg);
}
