/* MSP Flow - Main Stylesheet */

:root {
    --bg: #0d0d0f;
    --bg-deep: #050506;
    --card: #18181b;
    --card-2: #1f1f23;
    --card-hover: #242428;
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.16);
    --text: #fafafa;
    --muted: #888;
    --dim: #555;
    --orange: #fb923c;
    --pink: #f472b6;
    --red: #ef4444;
    --yellow: #eab308;
    --green: #10b981;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --cyan: #22d3ee;
    --indigo: #6366f1;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
.mono { font-family: 'Geist Mono', 'Courier New', monospace; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============ APP SHELL ============ */
.app {
    display: grid;
    grid-template-columns: 72px 1fr;
    min-height: 100vh;
}

.rail {
    background: #09090b;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.rail .logo {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, var(--orange), var(--pink));
    display: grid; place-items: center;
    font-weight: 800; font-size: 16px; color: #fff;
    margin-bottom: 12px;
}
.rail .rail-btn {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center; font-size: 18px;
    color: var(--muted); cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    text-decoration: none;
}
.rail .rail-btn:hover { background: rgba(255,255,255,0.05); color: #fff; }
.rail .rail-btn.active {
    background: rgba(251,146,60,0.1);
    color: var(--orange);
    border-color: rgba(251,146,60,0.25);
}
.rail .spacer { flex: 1; }
.rail .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    display: grid; place-items: center;
    font-weight: 700; font-size: 13px;
    color: #fff; cursor: pointer;
    text-decoration: none;
}

/* ============ TOPBAR ============ */
.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(13,13,15,0.9);
    backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 50;
}
.crumb {
    font-family: 'Geist Mono', monospace;
    font-size: 11px; color: var(--muted);
    letter-spacing: 0.05em;
}
.crumb .sep { color: var(--dim); margin: 0 6px; }
.crumb .current { color: #fff; }
.search {
    margin-left: auto;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 7px 12px;
    display: flex; align-items: center; gap: 8px;
    width: 280px; font-size: 12px; color: var(--muted);
}
.search input { background: transparent; border: 0; color: var(--text); outline: none; flex: 1; font-size: 12px; }
.search .kbd {
    margin-left: auto;
    font-family: 'Geist Mono', monospace;
    font-size: 10px;
    background: rgba(255,255,255,0.06);
    padding: 2px 6px; border-radius: 4px;
}

.top-action {
    padding: 7px 14px; border-radius: 10px;
    font-size: 12px; font-weight: 600;
    background: linear-gradient(135deg, var(--orange), var(--pink));
    color: #fff; border: 0;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none;
    transition: opacity 0.15s;
}
.top-action:hover { opacity: 0.9; }
.top-action.ghost {
    background: rgba(255,255,255,0.04);
    color: #ddd;
    border: 1px solid var(--border);
}
.top-action.ghost:hover { background: rgba(255,255,255,0.08); }
.top-action.danger { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

/* ============ MAIN CONTENT ============ */
.main { padding: 24px; max-width: 100%; }
.page-head {
    display: flex; align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 20px;
}
.page-head h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-head .meta {
    font-family: 'Geist Mono', monospace;
    font-size: 11px;
    color: var(--dim);
    text-align: right;
}

/* ============ CARDS ============ */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    position: relative;
}
.card h3 {
    font-size: 13px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.1em;
}
.card .stat { font-size: 38px; font-weight: 700; letter-spacing: -0.02em; margin-top: 8px; }

/* ============ PILLS & TAGS ============ */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 100px;
    font-size: 10px; font-weight: 600;
    font-family: 'Geist Mono', monospace;
}
.pill.red { background: rgba(239,68,68,0.12); color: var(--red); }
.pill.yellow { background: rgba(234,179,8,0.12); color: var(--yellow); }
.pill.green { background: rgba(16,185,129,0.12); color: var(--green); }
.pill.blue { background: rgba(59,130,246,0.12); color: var(--blue); }
.pill.purple { background: rgba(139,92,246,0.12); color: var(--purple); }
.pill.cyan { background: rgba(34,211,238,0.12); color: var(--cyan); }
.pill.grey { background: rgba(255,255,255,0.06); color: #aaa; }
.pill.orange { background: rgba(251,146,60,0.12); color: var(--orange); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.blue { background: var(--blue); box-shadow: 0 0 8px var(--blue); }

/* ============ AVATARS ============ */
.avatar-sm {
    width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 600;
    color: #fff; flex-shrink: 0;
}
.avatar-md {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 600;
    color: #fff; flex-shrink: 0;
}

/* ============ WORKSPACE SELECTOR ============ */
.workspace-selector {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 40px 20px;
    background: radial-gradient(ellipse at top, #1a1a1f 0%, #0d0d0f 50%, #050506 100%);
}
.ws-shell {
    max-width: 900px; width: 100%;
    text-align: center;
}
.ws-welcome {
    font-family: 'Geist Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.2em;
    color: var(--muted);
    margin-bottom: 12px;
}
.ws-title {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}
.ws-title .accent {
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.ws-sub {
    color: var(--muted);
    margin-bottom: 40px;
    font-size: 14px;
}
.ws-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 36px;
}
.ws-card {
    background: rgba(24,24,27,0.6);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    color: inherit;
    display: block;
}
.ws-card:hover {
    background: var(--card-hover);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}
.ws-card .ws-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 22px;
    margin: 0 auto 14px;
    color: #fff;
}
.ws-card h3 {
    font-size: 14px; font-weight: 700;
    color: #fff;
    text-transform: none;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}
.ws-card p {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
}
.ws-footer {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    background: rgba(24,24,27,0.6);
    border: 1px solid var(--border);
    border-radius: 100px;
}
.ws-footer .avatar-md {
    background: linear-gradient(135deg, #a855f7, #6366f1);
}
.ws-footer-name {
    font-weight: 600; font-size: 13px;
}
.ws-footer-sub {
    font-size: 11px; color: var(--muted);
    font-family: 'Geist Mono', monospace;
}
.ws-footer form { display: inline; }
.ws-footer a, .ws-footer button {
    color: var(--muted);
    font-size: 12px;
    background: none;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
}
.ws-footer a:hover, .ws-footer button:hover { color: #fff; background: rgba(255,255,255,0.05); }
.ws-footer .ver { font-family: 'Geist Mono', monospace; font-size: 10px; color: var(--dim); }

/* ============ LOGIN PAGE ============ */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(ellipse at top, #1a1a1f 0%, #0d0d0f 50%, #050506 100%);
}
.login-card {
    max-width: 420px;
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 80px rgba(0,0,0,0.4);
}
.login-card .brand {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--orange), var(--pink));
    display: grid; place-items: center;
    font-size: 22px; font-weight: 800;
    margin: 0 auto 20px;
    color: #fff;
}
.login-card h1 {
    text-align: center;
    font-size: 24px; font-weight: 700;
    margin-bottom: 6px;
}
.login-card .sub {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 28px;
}
.login-card .form-field { margin-bottom: 14px; }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 14px;
    display: flex; align-items: center; gap: 10px;
}
.alert.error { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.alert.success { background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.25); color: #6ee7b7; }
.alert.warning { background: rgba(234,179,8,0.08); border: 1px solid rgba(234,179,8,0.25); color: #fde68a; }

/* ============ FORMS ============ */
.form-field { margin-bottom: 16px; }
.form-field label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    font-weight: 600;
    font-family: 'Geist Mono', monospace;
}
.form-field input, .form-field select, .form-field textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none;
    border-color: var(--orange);
}
.form-field .hint { font-size: 11px; color: var(--dim); margin-top: 4px; font-family: 'Geist Mono', monospace; }
.form-field .error { font-size: 11px; color: var(--red); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }

.btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 0;
    font-family: inherit;
    display: inline-flex; align-items: center; gap: 6px;
    text-decoration: none;
    transition: all 0.15s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--orange), var(--pink));
    color: #fff;
}
.btn-primary:hover { opacity: 0.9; }
.btn-ghost {
    background: rgba(255,255,255,0.04);
    color: #ddd;
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: #fff; }
.btn-danger {
    background: rgba(239,68,68,0.1);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-success {
    background: rgba(16,185,129,0.1);
    color: var(--green);
    border: 1px solid rgba(16,185,129,0.3);
}
.btn-block { width: 100%; justify-content: center; }

/* ============ TABLES ============ */
.table-card { padding: 0; overflow: hidden; }
.table-head {
    padding: 16px 20px;
    display: flex; align-items: center;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.table-head h3 {
    color: #fff;
    text-transform: none;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    padding: 10px 18px;
    font-family: 'Geist Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
    background: rgba(255,255,255,0.01);
}
.data-table tbody td {
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .u-main {
    display: flex; align-items: center; gap: 10px;
}
.data-table .u-main .avatar-md {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
}
.data-table .u-main .name { font-weight: 500; font-size: 13px; }
.data-table .u-main .sub { font-size: 11px; color: var(--muted); font-family: 'Geist Mono', monospace; margin-top: 2px; }
.data-table .actions { text-align: right; }
.data-table .actions a, .data-table .actions button {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--muted);
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
}
.data-table .actions a:hover, .data-table .actions button:hover { background: rgba(255,255,255,0.06); color: #fff; }

/* ============ TOOLBARS ============ */
.toolbar {
    display: flex; gap: 10px;
    margin-bottom: 14px;
    align-items: center;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.toolbar input[type="search"],
.toolbar input[type="text"] {
    flex: 1;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    color: #fff;
    font-size: 13px;
}
.toolbar select {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    color: #fff;
    font-size: 13px;
}

/* ============ ADMIN LAYOUT ============ */
.admin-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 18px;
}
.admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.side-nav-card { padding: 14px; }
.side-nav-card h4 {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 10px;
    font-weight: 600;
}
.side-nav-item {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #bbb;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
    transition: background 0.15s;
    text-decoration: none;
}
.side-nav-item:hover { background: rgba(255,255,255,0.04); color: #fff; }
.side-nav-item.active { background: rgba(251,146,60,0.1); color: var(--orange); }
.side-nav-item .count {
    margin-left: auto;
    font-family: 'Geist Mono', monospace;
    font-size: 10px;
    color: var(--muted);
}

/* ============ MARKETPLACE ============ */
.mp-hero {
    background: linear-gradient(135deg, #4338ca 0%, #7c3aed 50%, #db2777 100%);
    border: 0;
    padding: 32px;
    border-radius: 18px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    color: #fff;
}
.mp-hero h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.mp-hero p { font-size: 13px; color: rgba(255,255,255,0.85); margin-top: 6px; max-width: 540px; }
.mp-hero .stat-pill {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 16px 22px;
    border-radius: 14px;
    text-align: center;
}
.mp-hero .stat-pill .n { font-size: 26px; font-weight: 700; }
.mp-hero .stat-pill .l {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.8);
    margin-top: 2px;
}
.mp-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.mp-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: all 0.2s;
    position: relative;
}
.mp-card:hover { border-color: var(--border-strong); }
.mp-card .mp-head {
    display: flex; gap: 14px; align-items: flex-start;
}
.mp-card .mp-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 22px;
    flex-shrink: 0;
    font-weight: 700;
    color: #fff;
}
.mp-card .mp-title { flex: 1; min-width: 0; }
.mp-card .mp-title h4 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.mp-card .mp-title .vendor { font-size: 11px; color: var(--muted); font-family: 'Geist Mono', monospace; }
.mp-card .mp-desc { font-size: 12px; color: #aaa; line-height: 1.55; }
.mp-card .mp-foot {
    display: flex; gap: 8px; align-items: center;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.mp-card .mp-badge {
    position: absolute; top: 12px; right: 12px;
    padding: 3px 8px; border-radius: 100px;
    font-size: 9px; font-weight: 700;
    font-family: 'Geist Mono', monospace;
    background: linear-gradient(135deg, var(--orange), var(--pink));
    color: #fff;
    letter-spacing: 0.05em;
}
.mp-card .mp-badge.core { background: rgba(16,185,129,0.15); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.mp-card .status-line {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ============ EMPTY STATE ============ */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty .icon { font-size: 48px; margin-bottom: 12px; }
.empty h3 { font-size: 18px; color: #fff; margin-bottom: 8px; text-transform: none; letter-spacing: -0.01em; font-weight: 600; }

/* ============ UTIL ============ */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.ml-auto { margin-left: auto; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    .ws-grid { grid-template-columns: repeat(3, 1fr); }
    .mp-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .ws-grid { grid-template-columns: repeat(2, 1fr); }
    .mp-grid { grid-template-columns: 1fr; }
    .app { grid-template-columns: 56px 1fr; }
    .rail { padding: 12px 0; }
    .search { width: auto; flex: 1; }
    .page-head h1 { font-size: 26px; }
    .form-row { grid-template-columns: 1fr; }
}

/* ============ ROLES MATRIX ============ */
.roles-matrix { padding: 0; overflow: hidden; }
.rm-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.rm-head h3 {
    color: #fff;
    text-transform: none;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.matrix-wrap { overflow-x: auto; }
.matrix {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}
.matrix th, .matrix td {
    padding: 10px 14px;
    font-size: 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.matrix th {
    font-family: 'Geist Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.matrix th:first-child, .matrix td:first-child {
    text-align: left;
    font-weight: 500;
    color: #fff;
    font-size: 13px;
}
.matrix td input[type="checkbox"] {
    accent-color: var(--orange);
    cursor: pointer;
    transform: scale(1.1);
}
.matrix .group-row td {
    background: rgba(251,146,60,0.05);
    color: var(--orange);
    font-family: 'Geist Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 8px 16px;
    text-align: left;
}
