@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap');

:root {
  color-scheme: dark;
  --bg: #070b14;
  --surface: #0d1320;
  --surface-2: #121a2a;
  --surface-3: #182235;
  --line: rgba(148, 163, 184, .14);
  --muted: #8d9bb0;
  --text: #f5f7fb;
  --brand: #36d399;
  --brand-2: #35b8ff;
  --warning: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 24px 70px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html { background: var(--bg); }
body { margin: 0; font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.crm-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); background: radial-gradient(circle at 70% -20%, rgba(53,184,255,.09), transparent 34%), var(--bg); }
.sidebar { min-height: 100vh; padding: 22px 16px; border-right: 1px solid var(--line); background: rgba(9, 14, 25, .9); backdrop-filter: blur(18px); display: flex; flex-direction: column; position: relative; z-index: 20; }
.brand-lockup { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(145deg, var(--brand), var(--brand-2)); color: #04100d; box-shadow: 0 10px 30px rgba(54,211,153,.2); font-size: 18px; }
.brand-title { font-family: Manrope, sans-serif; font-weight: 800; letter-spacing: -.03em; }
.brand-subtitle { color: var(--muted); font-size: 11px; }
.env-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; color: #a7f3d0; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.env-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px rgba(54,211,153,.1); }
.nav-label { padding: 8px 12px; color: #64748b; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.side-nav { display: grid; gap: 5px; }
.nav-btn { width: 100%; min-height: 44px; border: 0; background: transparent; color: #98a5b8; border-radius: 12px; padding: 0 13px; display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 13px; font-weight: 700; text-align: left; transition: .2s ease; }
.nav-btn i { width: 18px; text-align: center; }
.nav-btn:hover { color: white; background: rgba(255,255,255,.04); transform: translateX(2px); }
.nav-btn.active { color: #07130f; background: linear-gradient(135deg, #6ee7b7, #36d399); box-shadow: 0 10px 28px rgba(16,185,129,.18); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 14px; }
.avatar-initial { width: 34px; height: 34px; border-radius: 11px; background: #1e293b; display: grid; place-items: center; color: #a7f3d0; font-weight: 800; }
.user-chip strong { display: block; font-size: 12px; }
.user-chip small { color: var(--muted); font-size: 10px; }

.workspace { min-width: 0; height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 72px; padding: 12px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; background: rgba(7,11,20,.74); backdrop-filter: blur(18px); }
.page-heading h1 { margin: 0; font-family: Manrope, sans-serif; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.page-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.main-area { flex: 1; min-height: 0; }
.mobile-menu { display: none; }

.btn-secondary, .btn-primary, .mode, .icon-btn { min-height: 38px; border-radius: 11px; padding: 0 13px; font-size: 12px; font-weight: 700; cursor: pointer; transition: .18s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-secondary, .mode, .icon-btn { background: rgba(255,255,255,.035); border: 1px solid var(--line); color: #cad3df; }
.btn-secondary:hover, .mode:hover, .icon-btn:hover { background: rgba(255,255,255,.07); color: white; border-color: rgba(148,163,184,.28); }
.btn-primary, .mode.active { border: 1px solid transparent; background: linear-gradient(135deg, #34d399, #10b981); color: #04100d; box-shadow: 0 9px 22px rgba(16,185,129,.16); }
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.icon-btn { width: 38px; padding: 0; }
.field { min-height: 38px; background: #080d17; border: 1px solid var(--line); border-radius: 11px; padding: 9px 11px; color: #e9eef6; outline: none; transition: .18s ease; }
.field::placeholder { color: #59677b; }
.field:focus { border-color: rgba(54,211,153,.72); box-shadow: 0 0 0 3px rgba(54,211,153,.09); }

.inbox-layout { height: 100%; display: grid !important; grid-template-columns: 326px minmax(420px, 1fr) 290px; }
.conversation-sidebar, .customer-panel { background: rgba(13,19,32,.72); }
.conversation-sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.sidebar-search { padding: 14px; border-bottom: 1px solid var(--line); }
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #637187; font-size: 12px; }
.search-wrap .field { width: 100%; padding-left: 34px; }
.channel-row { display: flex; gap: 6px; padding-top: 10px; overflow-x: auto; scrollbar-width: none; }
.channel-pill { white-space: nowrap; border: 1px solid transparent; color: #8492a6; background: transparent; border-radius: 9px; padding: 6px 9px; font-size: 10px; font-weight: 700; cursor: pointer; }
.channel-pill:hover { color: white; background: rgba(255,255,255,.04); }
.channel-pill.active { color: #d1fae5; border-color: rgba(52,211,153,.24); background: rgba(16,185,129,.1); }
.conversation-list { flex: 1; overflow-y: auto; padding: 7px; }
.conversation { padding: 12px; border: 1px solid transparent; border-radius: 13px; cursor: pointer; margin-bottom: 4px; transition: .16s ease; }
.conversation:hover { background: rgba(255,255,255,.035); }
.conversation.active { background: linear-gradient(135deg, rgba(16,185,129,.13), rgba(53,184,255,.05)); border-color: rgba(52,211,153,.18); }
.conversation img, #conversationHeader img { object-fit: cover; background: #1e293b; }
.chat-column { min-width: 0; display: flex; flex-direction: column; background: #090e18; }
.conversation-header { min-height: 72px; padding: 12px 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(13,19,32,.66); }
.message-bg { background-color: #090e18; background-image: radial-gradient(rgba(148,163,184,.1) .7px, transparent .7px); background-size: 19px 19px; }
.message-stream { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: min(72%, 600px); padding: 11px 13px; border-radius: 15px; font-size: 13px; line-height: 1.55; box-shadow: 0 8px 22px rgba(0,0,0,.11); }
.bubble.customer { align-self: flex-start; background: #182235; border-bottom-left-radius: 5px; }
.bubble.agent { align-self: flex-end; background: linear-gradient(135deg, #0d7256, #0b5d49); border-bottom-right-radius: 5px; }
.bubble.internal { align-self: flex-end; background: #5d3a0b; border: 1px solid #8b5a13; }
.meta { font-size: 9px; color: rgba(226,232,240,.58); margin-top: 5px; }
.composer { padding: 13px 16px; border-top: 1px solid var(--line); background: rgba(13,19,32,.86); }
.composer-modes { display: flex; gap: 7px; margin-bottom: 9px; }
.composer form { display: flex; gap: 9px; align-items: end; }
.composer textarea { flex: 1; resize: none; max-height: 130px; }
.customer-panel { border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; }
.customer-panel h3 { font-family: Manrope, sans-serif; }
.order { background: #080d17; border: 1px solid var(--line); border-radius: 12px; padding: 11px; margin-top: 8px; }

.content-page { height: 100%; overflow-y: auto; padding: 24px; }
.page-title-row { display: flex; align-items: end; justify-content: space-between; margin-bottom: 20px; }
.title { margin: 0; font-family: Manrope, sans-serif; font-weight: 800; font-size: 24px; letter-spacing: -.03em; }
.section-kicker { color: var(--brand); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.card { background: linear-gradient(145deg, rgba(18,26,42,.95), rgba(13,19,32,.95)); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: 0 14px 40px rgba(0,0,0,.08); }
.notice { background: linear-gradient(135deg, rgba(29,78,216,.16), rgba(14,116,144,.09)); border: 1px solid rgba(59,130,246,.24); border-radius: 14px; padding: 15px; color: #c8ddff; }
.dialog { width: min(460px, 92vw); padding: 0; background: #101827; color: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(1,4,10,.76); backdrop-filter: blur(5px); }
.toast { position: fixed; right: 22px; bottom: 22px; background: #0b5d49; border: 1px solid rgba(52,211,153,.45); padding: 12px 16px; border-radius: 12px; z-index: 99; box-shadow: var(--shadow); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.1fr); background: var(--bg); }
.auth-visual { position: relative; overflow: hidden; padding: 52px; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(circle at 25% 15%, rgba(54,211,153,.2), transparent 30%), radial-gradient(circle at 85% 70%, rgba(53,184,255,.16), transparent 35%), #0b111d; }
.auth-visual::after { content: ""; position: absolute; inset: 0; opacity: .22; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 38px 38px; mask-image: linear-gradient(to bottom, #000, transparent 85%); }
.auth-copy { position: relative; z-index: 1; max-width: 520px; }
.auth-copy h2 { font-family: Manrope, sans-serif; font-size: clamp(34px, 4vw, 58px); line-height: 1.02; letter-spacing: -.055em; margin: 0 0 20px; }
.auth-copy p { color: #9ba8ba; font-size: 16px; line-height: 1.7; }
.auth-features { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.auth-feature { padding: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 13px; font-size: 11px; color: #bac5d4; }
.auth-feature i { color: var(--brand); margin-bottom: 8px; display: block; }
.auth-form-wrap { display: grid; place-items: center; padding: 34px; }
.auth-card { width: min(440px, 100%); }
.auth-card h1 { font-family: Manrope, sans-serif; font-size: 30px; margin: 8px 0; letter-spacing: -.04em; }
.auth-card .eyebrow { color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.auth-card .lead { color: var(--muted); margin: 0 0 28px; }
.form-label { display: block; margin: 0 0 16px; }
.form-label span { display: block; color: #cbd5e1; font-size: 12px; font-weight: 600; margin-bottom: 7px; }
.form-label .field { width: 100%; min-height: 46px; }
.auth-error { margin-bottom: 18px; border-radius: 12px; background: rgba(190,24,93,.12); border: 1px solid rgba(251,113,133,.25); padding: 12px; color: #fecdd3; font-size: 12px; }

.admin-page { min-height: 100vh; background: radial-gradient(circle at 80% -10%, rgba(53,184,255,.08), transparent 30%), var(--bg); padding: 26px; }
.admin-wrap { max-width: 1180px; margin: auto; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.admin-grid { display: grid; grid-template-columns: 350px minmax(0,1fr); gap: 18px; }
.panel { background: rgba(13,19,32,.9); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 18px 55px rgba(0,0,0,.11); }
.panel-body { padding: 20px; }
.panel-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { margin: 0; font-family: Manrope,sans-serif; font-size: 16px; }
.admin-form { display: grid; gap: 13px; }
.admin-form .field { width: 100%; min-height: 43px; }
.helper { color: var(--muted); font-size: 11px; line-height: 1.55; }
.users-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.users-table th { color: #728096; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; text-align: left; padding: 13px 16px; background: rgba(255,255,255,.018); }
.users-table td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.users-table tbody tr:hover { background: rgba(255,255,255,.018); }
.user-identity { display: flex; align-items: center; gap: 10px; }
.user-identity .avatar-initial { flex: 0 0 auto; }
.user-email { color: var(--muted); margin-top: 2px; font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; }
.admin-actions { display: flex; gap: 6px; }
.table-scroll { overflow-x: auto; }
.admin-tabs { display: flex; gap: 5px; padding: 6px; margin-bottom: 22px; overflow-x: auto; }
.admin-tab { border: 0; background: transparent; color: var(--muted); padding: 10px 13px; border-radius: 11px; white-space: nowrap; font-size: 12px; font-weight: 700; cursor: pointer; }
.admin-tab:hover { color: white; background: rgba(255,255,255,.035); }
.admin-tab.active { color: #07130f; background: var(--brand); }
.admin-section { animation: sectionIn .22s ease; }
.admin-section:not(.hidden) { display: block; min-height: calc(100vh - 220px); }
@keyframes sectionIn { from { opacity: 0; transform: translateY(5px); } }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 0 0 17px; }
.section-heading h2 { font-family: Manrope,sans-serif; font-size: 22px; margin: 3px 0; }
.section-heading p { color: var(--muted); font-size: 12px; margin: 0; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(270px,1fr)); gap: 13px; }
.role-card { background: rgba(13,19,32,.9); border: 1px solid var(--line); border-radius: 16px; padding: 17px; transition: .18s ease; }
.role-card:hover { transform: translateY(-2px); border-color: rgba(54,211,153,.22); }
.role-card-head { display: flex; justify-content: space-between; gap: 12px; }
.role-card h3 { font-family: Manrope,sans-serif; margin: 0; font-size: 15px; }
.role-card p { color: var(--muted); font-size: 11px; line-height: 1.55; min-height: 34px; }
.role-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.mini-pill { background: rgba(255,255,255,.045); border: 1px solid var(--line); color: #b9c4d4; font-size: 9px; border-radius: 999px; padding: 4px 7px; }
.wide-dialog { width: min(760px,94vw); }
.dialog-form { padding: 22px; display: grid; gap: 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.dialog-head h3 { font-family: Manrope,sans-serif; font-size: 20px; margin: 3px 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); padding-top: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.form-grid .form-label { margin: 0; }
.form-grid .full { grid-column: 1/-1; }
.choice-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-columns fieldset,.permission-group { border: 1px solid var(--line); border-radius: 13px; padding: 12px; min-width: 0; }
.choice-columns legend,.permission-group h4 { color: #d9e2ee; font-size: 11px; font-weight: 800; padding: 0 5px; margin: 0 0 8px; }
.choice-list { display: grid; gap: 7px; max-height: 180px; overflow-y: auto; }
.choice { display: flex; align-items: center; gap: 8px; color: #aab6c7; font-size: 11px; cursor: pointer; }
.choice input { accent-color: var(--brand); }
.permission-groups { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; max-height: 390px; overflow-y: auto; }
.permission-group { background: rgba(255,255,255,.015); }
.user-status { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 700; }
.user-status::before { content:""; width:7px; height:7px; border-radius:50%; background:var(--brand); }
.user-status.inactive { color: var(--muted); }
.user-status.inactive::before { background:#64748b; }

@media (max-width: 1180px) {
  .inbox-layout { grid-template-columns: 300px minmax(390px,1fr); }
  .customer-panel { display: none; }
}
@media (max-width: 860px) {
  .crm-shell { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { padding: 18px 10px; }
  .brand-lockup { padding: 0 7px 20px; }
  .brand-lockup > div:last-child, .nav-label, .nav-btn span, .user-chip > div:last-child { display: none; }
  .nav-btn { justify-content: center; padding: 0; }
  .nav-btn:hover { transform: none; }
  .sidebar-bottom .btn-secondary span { display: none; }
  .inbox-layout { grid-template-columns: 280px minmax(360px,1fr); }
  .top-actions #activeAgent { max-width: 130px; }
  .admin-grid { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 650px) {
  .crm-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; transform: translateX(-102%); transition: .22s ease; box-shadow: var(--shadow); }
  body.menu-open .sidebar { transform: translateX(0); }
  .brand-lockup > div:last-child, .nav-label, .nav-btn span, .user-chip > div:last-child { display: block; }
  .nav-btn { justify-content: flex-start; padding: 0 13px; }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 10px 12px; min-height: 64px; }
  .page-heading p, .top-actions .btn-secondary span, .top-actions #activeAgent { display: none; }
  .workspace { height: 100dvh; }
  .inbox-layout { display: flex !important; }
  .conversation-sidebar { width: 100%; }
  .chat-column { display: none; width: 100%; }
  body.chat-open .conversation-sidebar { display: none; }
  body.chat-open .chat-column { display: flex; }
  .conversation-header { padding: 10px; }
  .conversation-header .field { max-width: 112px; }
  .message-stream { padding: 14px; }
  .bubble { max-width: 88%; }
  .composer { padding: 10px; }
  .composer .btn-primary span { display: none; }
  .content-page { padding: 16px; }
  .admin-page { padding: 14px; }
  .admin-header { align-items: flex-start; }
  .section-heading { align-items: flex-start; }
  .form-grid,.choice-columns,.permission-groups { grid-template-columns: 1fr; }
  .auth-form-wrap { padding: 22px; }
}

/* CRM-LRM Design System v1 ------------------------------------------------ */
:root {
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Manrope", var(--font-body);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 18px; --radius-xl: 24px;
  --canvas: #070b14; --canvas-soft: #0a101b;
  --surface-solid: #0d1320; --surface-raised: #121a2a; --surface-subtle: #182235;
  --border: rgba(148,163,184,.16); --border-strong: rgba(148,163,184,.28);
  --text-strong: #f7f9fc; --text-body: #d7deea; --text-muted: #8d9bb0;
  --primary: #36d399; --primary-hover: #4adea8; --primary-contrast: #04100d;
  --info: #38bdf8; --success: #34d399; --warning-ui: #fbbf24; --danger-ui: #fb7185;
  --focus-ring: 0 0 0 3px rgba(54,211,153,.25);
  --elevation-1: 0 8px 28px rgba(0,0,0,.16);
  --elevation-2: 0 24px 70px rgba(0,0,0,.32);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb; --canvas: #f4f7fb; --canvas-soft: #eef3f8;
  --surface: #ffffff; --surface-2: #ffffff; --surface-3: #edf2f7;
  --surface-solid: #ffffff; --surface-raised: #ffffff; --surface-subtle: #edf2f7;
  --line: rgba(51,65,85,.14); --border: rgba(51,65,85,.14); --border-strong: rgba(51,65,85,.25);
  --text: #142033; --text-strong: #101827; --text-body: #334155; --muted: #64748b; --text-muted: #64748b;
  --shadow: 0 24px 70px rgba(15,23,42,.12); --elevation-1: 0 8px 28px rgba(15,23,42,.08); --elevation-2: 0 24px 70px rgba(15,23,42,.14);
}

html { scroll-behavior: smooth; }
body { font-family: var(--font-body); color: var(--text-strong); line-height: 1.5; }
h1,h2,h3,h4,.title,.brand-title { font-family: var(--font-display); text-wrap: balance; }
a { color: inherit; }
::selection { background: rgba(54,211,153,.28); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }

.btn-primary,.btn-secondary,.icon-btn,.mode,.admin-tab,.nav-btn { min-height: 42px; border-radius: var(--radius-md); }
.btn-primary { background: linear-gradient(135deg,var(--primary),#10b981); color: var(--primary-contrast); }
.btn-primary:active,.btn-secondary:active,.icon-btn:active { transform: translateY(1px); }
.field { min-height: 42px; color: var(--text-strong); background: var(--canvas-soft); border-color: var(--border); }
.field:hover { border-color: var(--border-strong); }
.field:focus { border-color: var(--primary); box-shadow: var(--focus-ring); }
.field:invalid:not(:placeholder-shown) { border-color: var(--danger-ui); }
.form-label span { color: var(--text-body); }
.helper,.user-email,.role-card p,.section-heading p { color: var(--text-muted); }

.card,.panel,.role-card,.dialog { background: var(--surface-solid); border-color: var(--border); box-shadow: var(--elevation-1); }
.role-card:hover { border-color: rgba(54,211,153,.42); box-shadow: var(--elevation-1); }
.panel-head,.users-table th { background: color-mix(in srgb,var(--surface-subtle) 38%,transparent); }
.users-table th { color: var(--text-muted); }
.users-table td { border-color: var(--border); color: var(--text-body); }
.users-table tbody tr { transition: background-color .16s ease; }
.users-table tbody tr:hover { background: color-mix(in srgb,var(--primary) 6%,transparent); }
.pagination-bar { min-height:64px;padding:12px 16px;border-top:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:16px;background:var(--surface-solid); }
.pagination-actions { display:flex;align-items:center;gap:9px; }
.page-indicator { min-width:96px;text-align:center;color:var(--text-muted);font-size:11px;font-weight:700; }
.mini-pill { background: var(--surface-subtle); border-color: var(--border); color: var(--text-body); }
.notice { color: var(--text-body); background: color-mix(in srgb,var(--info) 10%,var(--surface-solid)); }
.auth-error { color: var(--danger-ui); background: color-mix(in srgb,var(--danger-ui) 9%,var(--surface-solid)); }
.toast { color: #fff; }

.crm-shell,.admin-page { background: radial-gradient(circle at 78% -10%,rgba(53,184,255,.08),transparent 31%),var(--canvas); }
.sidebar,.topbar,.conversation-sidebar,.customer-panel,.conversation-header,.composer { background: color-mix(in srgb,var(--surface-solid) 91%,transparent); border-color: var(--border); }
.chat-column,.message-bg { background-color: var(--canvas-soft); }
.nav-btn,.channel-pill { color: var(--text-muted); }
.nav-btn:hover,.channel-pill:hover,.admin-tab:hover { color: var(--text-strong); background: color-mix(in srgb,var(--text-strong) 5%,transparent); }
.user-chip,.order { background: var(--canvas-soft); border-color: var(--border); }
.avatar-initial { background: var(--surface-subtle); }
.bubble.customer { background: var(--surface-subtle); color: var(--text-strong); }
.bubble.agent { color: #fff; }
.dialog::backdrop { background: rgba(2,6,23,.66); backdrop-filter: blur(7px); }

.auth-page { background: var(--canvas); }
.auth-form-wrap { background: var(--canvas); position: relative; }
.auth-card { padding: clamp(24px,4vw,40px); border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface-solid); box-shadow: var(--elevation-2); }
.auth-card .lead { color: var(--text-muted); }
.auth-visual { background: radial-gradient(circle at 25% 15%,rgba(54,211,153,.2),transparent 30%),radial-gradient(circle at 85% 70%,rgba(53,184,255,.16),transparent 35%),#0b111d; color:#f7f9fc; }
.theme-floating { position: fixed; z-index: 50; top: 20px; right: 20px; }
.theme-label { display: inline; }

.status-badge { display:inline-flex;align-items:center;gap:6px;border-radius:999px;padding:5px 9px;font-size:11px;font-weight:700;background:var(--surface-subtle); }
.status-badge.success { color:var(--success); }.status-badge.warning { color:var(--warning-ui); }.status-badge.danger { color:var(--danger-ui); }
.skeleton { border-radius:var(--radius-sm);background:linear-gradient(90deg,var(--surface-subtle),var(--surface-raised),var(--surface-subtle));background-size:200% 100%;animation:skeleton 1.4s infinite; }
@keyframes skeleton { to { background-position:-200% 0; } }

@media (max-width: 760px) {
  .admin-header { flex-direction: column; }
  .admin-actions { width:100%; flex-wrap:wrap; }
  .admin-actions > * { flex:1 1 auto; }
  .admin-tabs { position:sticky;top:0;z-index:10;background:var(--surface-solid);box-shadow:var(--elevation-1); }
  .section-heading { flex-direction:column;align-items:stretch; }
  .section-heading .btn-primary { width:100%; }
  .users-table { min-width:760px; }
  .table-scroll { border-radius:var(--radius-lg); }
  .dialog { max-height:92dvh;overflow:auto; }
  .theme-label { display:none; }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration:.01ms !important;animation-iteration-count:1 !important;scroll-behavior:auto !important;transition-duration:.01ms !important; }
}

/* Product shell v5: scalable enterprise interface ------------------------ */
:root {
  --primary: #5b7cfa; --primary-hover: #7490ff; --primary-contrast: #ffffff;
  --accent: #22c7a9; --canvas: #080b12; --canvas-soft: #0c111b;
  --surface-solid: #111722; --surface-raised: #151d2b; --surface-subtle: #1b2535;
  --focus-ring: 0 0 0 3px rgba(91,124,250,.28);
}
:root[data-theme="light"] { --primary:#315ee7;--primary-hover:#244fcf;--accent:#087f6a;--canvas:#f3f5f9;--canvas-soft:#e9edf4;--surface-subtle:#edf1f7; }

.crm-shell { grid-template-columns: 272px minmax(0,1fr); background:var(--canvas); }
.sidebar { padding:18px 14px; background:var(--surface-solid); border-right:1px solid var(--border); }
.brand-lockup { padding:2px 8px 17px; }
.brand { width:38px;height:38px;border-radius:10px;background:var(--text-strong);color:var(--surface-solid);box-shadow:none; }
.brand-title { font-size:14px;letter-spacing:-.02em; }
.brand-subtitle { font-size:10px; }
.env-badge { color:var(--accent); }
.env-badge::before { background:var(--accent);box-shadow:none; }
.workspace-switcher { display:grid;grid-template-columns:32px minmax(0,1fr) 12px;align-items:center;gap:9px;margin:0 4px 20px;padding:10px;border:1px solid var(--border);border-radius:12px;background:var(--canvas-soft); }
.workspace-switcher strong,.workspace-switcher small { display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.workspace-switcher strong { font-size:11px; }.workspace-switcher small { color:var(--text-muted);font-size:9px;margin-top:1px; }
.workspace-switcher>i { color:var(--text-muted);font-size:9px; }
.workspace-mark { width:32px;height:32px;display:grid;place-items:center;border-radius:9px;background:rgba(91,124,250,.14);color:#8da2ff;font-size:10px;font-weight:800; }
.nav-label { padding:5px 12px 7px;color:var(--text-muted);font-size:9px;letter-spacing:.11em; }
.nav-label-spaced { margin-top:19px; }
.side-nav { gap:3px; }
.nav-btn,.module-nav { min-height:40px;border:0;border-radius:9px;padding:0 11px;display:grid;grid-template-columns:20px minmax(0,1fr) auto;align-items:center;gap:9px;text-align:left;font-size:11px;font-weight:650; }
.nav-btn { color:var(--text-muted);background:transparent;cursor:pointer; }
.nav-btn i,.module-nav i { text-align:center;font-size:12px; }
.nav-btn:hover { transform:none;background:var(--surface-subtle); }
.nav-btn.active { color:#fff;background:#315ee7;box-shadow:0 6px 18px rgba(49,94,231,.22); }
.module-nav { color:color-mix(in srgb,var(--text-muted) 72%,transparent);background:transparent;cursor:default; }
.module-nav small { padding:2px 5px;border:1px solid var(--border);border-radius:5px;font-size:7px;text-transform:uppercase;letter-spacing:.05em; }
.future-modules { opacity:.78; }
.sidebar-bottom { gap:7px;padding-top:18px; }
.user-chip { border-radius:10px;padding:9px;background:transparent; }
.topbar { min-height:68px;padding:10px 20px;background:var(--surface-solid);backdrop-filter:none; }
.page-heading h1 { font-size:16px; }.page-heading p { font-size:10px; }
.top-actions { gap:7px; }.top-actions .field { max-width:190px; }
.btn-primary { background:var(--primary);box-shadow:none; }.btn-primary:hover { background:var(--primary-hover);filter:none; }
.btn-secondary,.icon-btn,.mode { background:var(--surface-raised); }
.field { background:var(--canvas-soft); }

.inbox-layout { grid-template-columns:340px minmax(420px,1fr) 304px;gap:0; }
.conversation-sidebar,.customer-panel,.conversation-header,.composer { background:var(--surface-solid); }
.sidebar-search { padding:13px; }.conversation-list { padding:8px; }
.conversation { padding:12px;border-radius:10px;margin-bottom:3px; }
.conversation:hover { background:var(--surface-raised); }
.conversation.active { background:rgba(91,124,250,.11);border-color:rgba(91,124,250,.22); }
.channel-pill { border-radius:7px;padding:5px 8px; }.channel-pill.active { color:#aab8ff;border-color:rgba(91,124,250,.25);background:rgba(91,124,250,.1); }
.chat-column,.message-bg { background-color:var(--canvas-soft); }
.message-bg { background-image:radial-gradient(rgba(148,163,184,.08) .65px,transparent .65px);background-size:18px 18px; }
.conversation-header { min-height:68px; }.message-stream { padding:24px; }
.bubble { border-radius:13px;box-shadow:none;border:1px solid var(--border); }
.bubble.customer { background:var(--surface-solid); }.bubble.agent { background:#315ee7;border-color:#315ee7; }
.composer { padding:12px 16px; }.customer-panel { padding:20px; }
.order { border-radius:10px; }

.admin-page { background:var(--canvas);padding:32px; }
.admin-wrap { max-width:1320px; }.admin-header { margin-bottom:26px;padding-bottom:22px;border-bottom:1px solid var(--border); }
.admin-tabs { border-radius:13px;padding:5px;box-shadow:none; }
.admin-tab { border-radius:8px; }.admin-tab.active { background:var(--primary);color:#fff; }
.panel,.role-card { border-radius:14px;box-shadow:none; }.role-card { padding:19px; }
.section-heading { margin:28px 0 18px; }.section-heading h2 { font-size:21px; }
.users-table th { height:44px; }.users-table td { height:60px; }
.dialog { border-radius:16px; }.dialog-head { position:sticky;top:0;background:var(--surface-solid);z-index:2;padding-bottom:8px; }

.auth-page { grid-template-columns:minmax(560px,1.15fr) minmax(440px,.85fr); }
.auth-visual { padding:42px 48px;background:linear-gradient(145deg,#0c1220 0%,#101a31 58%,#142a35 100%); }
.auth-visual::after { opacity:.12;background-size:48px 48px; }
.auth-copy { max-width:660px; }
.auth-copy h2 { max-width:640px;font-size:clamp(42px,5vw,70px);line-height:1.02;letter-spacing:-.06em;margin:24px 0 22px; }
.auth-copy p { max-width:590px;color:#aab5c8;font-size:16px; }
.product-chip { display:inline-flex;align-items:center;gap:8px;padding:7px 10px;border:1px solid rgba(255,255,255,.13);border-radius:999px;background:rgba(255,255,255,.05);font-size:10px;font-weight:700;color:#dbe4f3; }
.product-chip i { color:#8da2ff; }
.auth-proof { display:grid;grid-template-columns:repeat(3,1fr);gap:1px;margin-top:38px;overflow:hidden;border:1px solid rgba(255,255,255,.1);border-radius:14px;background:rgba(255,255,255,.1); }
.auth-proof>div { padding:17px;background:rgba(10,16,29,.82); }.auth-proof strong,.auth-proof span { display:block; }.auth-proof strong { font-family:var(--font-display);font-size:19px; }.auth-proof span { margin-top:3px;color:#8492a8;font-size:9px; }
.auth-footer { position:relative;z-index:1;display:flex;justify-content:space-between;color:#77859b;font-size:9px; }
.auth-footer i { color:#42d4b5;margin-right:5px; }
.auth-form-wrap { padding:clamp(28px,5vw,72px); }
.auth-card { width:min(430px,100%);padding:0;border:0;background:transparent;box-shadow:none; }
.auth-card-icon { width:46px;height:46px;display:grid;place-items:center;margin-bottom:24px;border-radius:13px;background:rgba(91,124,250,.12);color:#8298ff;font-size:17px; }
.auth-card h1 { font-size:38px;margin:8px 0 9px; }.auth-card .lead { margin-bottom:32px; }
.auth-card .field { min-height:50px;border-radius:10px;background:var(--surface-solid); }.auth-card .btn-primary { min-height:50px!important;border-radius:10px; }
.theme-floating { background:color-mix(in srgb,var(--surface-solid) 88%,transparent);backdrop-filter:blur(12px); }

@media (max-width:1180px) { .crm-shell{grid-template-columns:248px minmax(0,1fr)}.inbox-layout{grid-template-columns:310px minmax(390px,1fr)} }
@media (max-width:860px) { .workspace-switcher,.future-modules,.nav-label-spaced{display:none}.auth-page{grid-template-columns:1fr}.auth-visual{display:none}.auth-card{padding:30px;border:1px solid var(--border);background:var(--surface-solid);box-shadow:var(--elevation-1)} }
@media (max-width:650px) { .crm-shell{display:block}.workspace-switcher,.future-modules,.nav-label-spaced{display:grid}.admin-page{padding:14px}.auth-card{padding:24px}.auth-card h1{font-size:30px}.top-actions .theme-label{display:none} }
@media (max-width:520px) { .pagination-bar{align-items:stretch;flex-direction:column}.pagination-actions{display:grid;grid-template-columns:1fr auto 1fr}.pagination-actions .btn-secondary{padding:0 9px} }
