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

:root {
    --bg: #0f1117;
    --bg2: #161b27;
    --bg3: #1e2436;
    --border: #2a3045;
    --brand: #6366f1;
    --brand-h: #4f52d4;
    --text: #e2e8f0;
    --muted: #64748b;
    --success: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
    --sidebar-w: 220px;
}

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

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: #818cf8;
}

/* ── Layout ── */
.admin-wrap {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--brand);
    letter-spacing: -.5px;
}

.sidebar-logo span {
    color: var(--text);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: .5rem 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: .5rem 1rem .25rem;
    font-size: .65rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1rem;
    color: var(--muted);
    font-weight: 500;
    transition: all .15s;
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    color: var(--text);
    background: var(--bg3);
}

.sidebar-item.active {
    color: var(--brand);
    background: rgba(99, 102, 241, .08);
    border-left-color: var(--brand);
}

.sidebar-item .icon {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
}

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

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 56px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-weight: 700;
    font-size: 1rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .8rem;
    color: var(--muted);
}

.page-body {
    padding: 1.5rem;
    flex: 1;
}

/* ── Cards ── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.25rem;
}

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.stat-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    margin-bottom: .4rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.stat-icon {
    font-size: 1.5rem;
    margin-top: .5rem;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: .65rem 1rem;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

tr:hover td {
    background: rgba(255, 255, 255, .02);
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    border: 1px solid;
}

.badge-blue {
    background: rgba(99, 102, 241, .15);
    color: #818cf8;
    border-color: rgba(99, 102, 241, .3);
}

.badge-green {
    background: rgba(34, 197, 94, .15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, .3);
}

.badge-yellow {
    background: rgba(245, 158, 11, .15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, .3);
}

.badge-red {
    background: rgba(239, 68, 68, .15);
    color: #f87171;
    border-color: rgba(239, 68, 68, .3);
}

.badge-gray {
    background: rgba(100, 116, 139, .15);
    color: #94a3b8;
    border-color: rgba(100, 116, 139, .3);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .15s;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-h);
}

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

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: rgba(239, 68, 68, .15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, .3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, .25);
}

.btn-sm {
    padding: .3rem .7rem;
    font-size: .75rem;
    border-radius: 6px;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    font-size: .75rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: .3rem;
}

input[type=text],
input[type=email],
input[type=tel],
input[type=password],
input[type=datetime-local],
input[type=number],
textarea,
select {
    width: 100%;
    padding: .6rem .8rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: .85rem;
    font-family: inherit;
    transition: border-color .15s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--brand);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ── Kanban ── */
.kanban {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.kanban-col {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.kanban-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .8rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.kanban-body {
    padding: .75rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    min-height: 200px;
}

.kanban-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem;
    cursor: pointer;
    transition: all .15s;
}

.kanban-card:hover {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px var(--brand);
}

.kanban-card-title {
    font-weight: 600;
    font-size: .8rem;
    margin-bottom: .3rem;
}

.kanban-card-meta {
    font-size: .7rem;
    color: var(--muted);
}

/* ── Timeline ── */
.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: .4rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.25rem;
}

.timeline-dot {
    position: absolute;
    left: -1.15rem;
    top: .25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand);
    border: 2px solid var(--bg2);
}

.timeline-body {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem;
}

.timeline-meta {
    font-size: .7rem;
    color: var(--muted);
    margin-bottom: .25rem;
}

/* ── Alerts ── */
.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    border: 1px solid;
    margin-bottom: 1rem;
    font-size: .85rem;
}

.alert-success {
    background: rgba(34, 197, 94, .1);
    border-color: rgba(34, 197, 94, .3);
    color: #4ade80;
}

.alert-error {
    background: rgba(239, 68, 68, .1);
    border-color: rgba(239, 68, 68, .3);
    color: #f87171;
}

/* ── Modals ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    padding: 1.5rem;
}

.modal-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 1.25rem;
}

.modal-footer {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
}

.login-logo {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--brand);
    margin-bottom: .25rem;
}

.login-sub {
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
    margin-bottom: 2rem;
}

/* ── Chat bubbles ── */
.chat-user {
    display: flex;
    justify-content: flex-end;
    margin-bottom: .75rem;
}

.chat-ai {
    display: flex;
    justify-content: flex-start;
    margin-bottom: .75rem;
}

.bubble {
    max-width: 75%;
    padding: .6rem .9rem;
    border-radius: 12px;
    font-size: .85rem;
    line-height: 1.5;
}

.bubble-user {
    background: var(--brand);
    color: #fff;
    border-bottom-right-radius: 3px;
}

.bubble-ai {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 3px;
}