/* Steele Agency CRM — app shell (sidebar + header) + dashboard.
   Built on main.css's design tokens (--bg/--surface/--fg/--accent/…) and its
   light/dark theming (prefers-color-scheme + [data-theme]). */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-sans); }
a { color: inherit; text-decoration: none; }
.ico { display: block; }

:root {
	--sidebar-w: 244px;
	--topbar-h: 60px;
}

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

.sidebar {
	width: var(--sidebar-w); flex-shrink: 0;
	background: var(--surface); border-right: 1px solid var(--border);
	display: flex; flex-direction: column;
	position: sticky; top: 0; height: 100vh;
	z-index: 40;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content { flex: 1; padding: 26px 30px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; }
.brand-mark {
	width: 32px; height: 32px; border-radius: 9px;
	background: linear-gradient(140deg, var(--accent), #7a4dff);
	color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem;
	box-shadow: 0 4px 14px var(--accent-glow);
}
.brand-name { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }

/* ---------- nav ---------- */
.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; }
.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section + .nav-section { margin-top: 12px; }
.nav-section-label { padding: 6px 11px 4px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); opacity: 0.7; }
.nav-item {
	display: flex; align-items: center; gap: 11px;
	padding: 9px 11px; border-radius: 9px;
	color: var(--fg-muted); font-weight: 500; font-size: 0.9rem;
	position: relative; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--hover); color: var(--fg); }
.nav-item.is-active { background: var(--accent-glow); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 19px; height: 19px; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-item.is-soon { cursor: default; }
.soon-tag {
	font-size: 0.62rem; text-transform: uppercase; letter-spacing: .04em;
	color: var(--fg-muted); background: var(--hover); border-radius: 5px; padding: 2px 6px;
}

/* ---------- sidebar footer ---------- */
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.mini-user { display: flex; align-items: center; gap: 10px; padding: 6px; }
.mini-user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.mu-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mu-role, .mu-email { font-size: 0.75rem; color: var(--fg-muted); }

/* ---------- topbar ---------- */
.topbar {
	height: var(--topbar-h); flex-shrink: 0;
	display: flex; align-items: center; gap: 14px; padding: 0 22px;
	background: color-mix(in srgb, var(--surface) 86%, transparent);
	backdrop-filter: saturate(160%) blur(8px);
	border-bottom: 1px solid var(--border);
	position: sticky; top: 0; z-index: 30;
}
.page-title { font-size: 1.05rem; font-weight: 650; margin: 0 auto 0 0; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
	width: 38px; height: 38px; border: 0; background: transparent; cursor: pointer;
	border-radius: 9px; color: var(--fg-muted);
	display: flex; align-items: center; justify-content: center; position: relative; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn .ico { width: 20px; height: 20px; }
.badge {
	position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px;
	background: var(--accent); color: #fff; font-size: 0.65rem; font-weight: 700;
	border-radius: 9px; display: flex; align-items: center; justify-content: center;
	border: 2px solid var(--surface);
}
.menu-toggle { display: none; }

/* theme toggle icon swap (mirrors main.css theme logic) */
.theme-ico--sun { display: none; }
.theme-ico--moon { display: inline-grid; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-ico--sun { display: inline-grid; }
	:root:not([data-theme="light"]) .theme-ico--moon { display: none; }
}
:root[data-theme="dark"] .theme-ico--sun { display: inline-grid; }
:root[data-theme="dark"] .theme-ico--moon { display: none; }
:root[data-theme="light"] .theme-ico--sun { display: none; }
:root[data-theme="light"] .theme-ico--moon { display: inline-grid; }

/* ---------- profile button ---------- */
.profile-btn {
	display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px;
	border: 0; background: transparent; cursor: pointer; color: var(--fg);
	border-radius: 10px; transition: background .12s;
}
.profile-btn:hover { background: var(--hover); }
.profile-btn .ico { width: 16px; height: 16px; color: var(--fg-muted); }
.profile-name { font-weight: 600; font-size: 0.88rem; }
.avatar {
	width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
	background: linear-gradient(140deg, var(--accent), #7a4dff); color: #fff;
	display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.78rem;
}
.avatar.sm { width: 28px; height: 28px; font-size: 0.72rem; }

/* ---------- dropdowns ---------- */
.dropdown { position: relative; }
.menu {
	position: absolute; right: 0; top: calc(100% + 9px); min-width: 244px;
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius-card); box-shadow: var(--shadow-card);
	padding: 6px; z-index: 50;
	opacity: 0; visibility: hidden; transform: translateY(-6px);
	transition: opacity .14s, transform .14s, visibility .14s;
}
.dropdown.open .menu { opacity: 1; visibility: visible; transform: none; }
.menu--wide { min-width: 328px; }
.menu-head { padding: 8px 10px 6px; font-size: 0.78rem; font-weight: 700; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .04em; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 0.88rem; font-weight: 500; }
.menu-item .ico { width: 17px; height: 17px; color: var(--fg-muted); }
.menu-item:hover { background: var(--hover); }
.menu-item--danger { color: var(--danger); }
.menu-item--danger .ico { color: var(--danger); }
.menu-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-user-meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.notif { display: flex; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 0.85rem; align-items: flex-start; }
.notif:hover { background: var(--hover); }
.notif > span:last-child { display: flex; flex-direction: column; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.notif.is-read .notif-dot { background: var(--border); }
.notif-time { font-size: 0.72rem; color: var(--fg-muted); margin-top: 2px; }
.menu-foot { display: block; text-align: center; padding: 9px; font-size: 0.83rem; font-weight: 600; color: var(--accent); border-top: 1px solid var(--border); margin-top: 4px; }

/* ---------- dashboard ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-h2 { margin: 0 0 3px; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.015em; }
.page-sub { margin: 0; color: var(--fg-muted); font-size: 0.9rem; }
.empty-state { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-card); padding: 48px 24px; text-align: center; color: var(--fg-muted); font-size: 0.92rem; }
.empty-state p { margin: 0; }
.menu-empty { padding: 18px 12px; text-align: center; color: var(--fg-muted); font-size: 0.85rem; }
.btn { border: 0; cursor: pointer; font-family: inherit; font-weight: 600; font-size: 0.88rem; padding: 10px 16px; border-radius: var(--radius-btn); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px var(--accent-glow); }
.btn-primary:hover { filter: brightness(1.05); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 0.8rem; color: var(--fg-muted); font-weight: 500; }
.stat-value { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.02em; }
.stat-of { font-size: 1rem; color: var(--fg-muted); font-weight: 500; }
.stat-trend { font-size: 0.76rem; color: var(--fg-muted); }
.stat-trend.up { color: #16a34a; }
.stat-trend.down { color: var(--danger); }

.panel-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 4px 4px 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.panel-head h3 { margin: 0; font-size: 1rem; font-weight: 650; }
.panel-link { font-size: 0.82rem; font-weight: 600; color: var(--accent); }

.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th { text-align: left; font-weight: 600; color: var(--fg-muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: .03em; padding: 8px 16px; }
.table td { padding: 11px 16px; border-top: 1px solid var(--border); }
.pill { font-size: 0.74rem; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.pill-green { background: rgba(22,163,74,.14); color: #16a34a; }
.pill-blue { background: var(--accent-glow); color: var(--accent); }
.pill-amber { background: rgba(217,119,6,.15); color: #d97706; }

.conn-list { list-style: none; margin: 0; padding: 4px 8px 8px; }
.conn-list li { display: flex; align-items: center; justify-content: space-between; padding: 11px 8px; border-top: 1px solid var(--border); font-size: 0.88rem; }
.conn-list li:first-child { border-top: 0; }
.conn-name { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-green { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.dot-grey { background: var(--border); }
.conn-state { font-size: 0.82rem; color: #16a34a; font-weight: 600; }
.conn-state.muted { color: var(--fg-muted); font-weight: 500; }

/* ---------- responsive ---------- */
.sidebar-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
@media (max-width: 960px) {
	.panel-grid { grid-template-columns: 1fr; }
	.stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
	.menu-toggle { display: grid; }
	.sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; }
	.app.nav-open .sidebar { transform: translateX(0); }
	.profile-name { display: none; }
	.content { padding: 18px 16px; }
}

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-theme { position: fixed; top: 16px; right: 16px; }
.auth-card { width: 100%; max-width: 384px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 32px 30px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; margin-bottom: 24px; }
.auth-title { margin: 0; font-size: 1.4rem; font-weight: 750; letter-spacing: -0.02em; }
.auth-sub { margin: 3px 0 22px; color: var(--fg-muted); font-size: 0.9rem; }
.auth-error, .auth-info { border-radius: var(--radius-input); padding: 10px 13px; font-size: 0.85rem; margin-bottom: 16px; }
.auth-error { background: rgba(192,57,43,.12); color: var(--danger); }
.auth-info { background: var(--accent-glow); color: var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; font-weight: 600; color: var(--fg-muted); }
.field input { font-family: inherit; font-size: 0.95rem; color: var(--fg); background: var(--bg); border: 1px solid var(--input-outline); border-radius: var(--radius-input); padding: 11px 13px; outline: none; transition: border-color .12s, box-shadow .12s; }
.field input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-glow); }
.btn-block { width: 100%; margin-top: 6px; padding: 12px; }

/* ---------- table row actions + buttons ---------- */
.muted, .table td.muted { color: var(--fg-muted); }
.row-actions { text-align: right; width: 1%; white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.row-actions .icon-btn { display: inline-flex; vertical-align: middle; }
.pill-row { display: flex; flex-wrap: wrap; gap: 5px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.field .select { font-family: inherit; font-size: 0.95rem; color: var(--fg); background: var(--bg); border: 1px solid var(--input-outline); border-radius: var(--radius-input); padding: 10px 12px; outline: none; cursor: pointer; }
.field .select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-glow); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.btn-sm { padding: 9px 13px; font-size: 0.82rem; }
.pw-row { display: flex; gap: 8px; align-items: stretch; }
.pw-row input { flex: 1; min-width: 0; }
.pw-cell { display: flex; align-items: center; gap: 5px; }
.pw-dots { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85rem; letter-spacing: 0.02em; }
.icon-btn.copied { color: #16a34a; }
.table td.small { font-size: 0.82rem; line-height: 1.3; }
.cell-sub { font-size: 0.72rem; color: var(--fg-muted); margin-top: 1px; }
.status-form { margin: 0; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer; font-family: inherit; font-size: 0.74rem; font-weight: 600; padding: 4px 11px; border-radius: 20px; }
.status-pill .status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-pill.is-active { background: rgba(22,163,74,.14); color: #16a34a; }
.status-pill.is-active .status-dot { background: #16a34a; }
.status-pill.is-inactive { background: var(--hover); color: var(--fg-muted); }
.status-pill.is-inactive .status-dot { background: var(--fg-muted); }
.check-field { display: flex; align-items: center; gap: 9px; font-size: 0.9rem; font-weight: 500; color: var(--fg); cursor: pointer; }
.check-field input { width: 16px; height: 16px; accent-color: var(--accent); }
.access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-input); padding: 13px 14px; max-height: 240px; overflow-y: auto; }
.access-group { display: flex; flex-direction: column; gap: 6px; }
.access-group-label { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); }
.access-item { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 500; color: var(--fg); cursor: pointer; }
.access-item input { width: 15px; height: 15px; accent-color: var(--accent); flex-shrink: 0; }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ico { width: 17px; height: 17px; }
.icon-btn.danger:hover { background: rgba(192,57,43,.12); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--hover); color: var(--fg); }

/* ---------- modal (native <dialog>) ---------- */
dialog.modal { position: fixed; inset: 0; margin: auto; height: fit-content; max-height: calc(100vh - 40px); width: calc(100% - 32px); max-width: 420px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-card); padding: 0; overflow: auto; }
dialog.modal::backdrop { background: rgba(0,0,0,.45); }
.modal-form { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-form h3 { margin: 0 0 2px; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
