:root {
    --primary: #1a1a2e;
    --primary-mid: #16213e;
    --accent: #0f3460;
    --highlight: #e94560;
    --silver: #a8a8b3;
    --silver-light: #f4f4f8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sidebar-w: 250px;
}

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

body {
    font-family: 'Segoe UI', sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    color: #1a1a2e;
}

/* ── Layout ── */
#wrapper {
    display: flex;
    min-height: 100vh;
}

#sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

#content {
    margin-left: var(--sidebar-w);
    padding: 2rem;
    width: 100%;
}

/* ── Sidebar ── */
.sidebar-brand {
    padding: 1.5rem 1.25rem;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    gap: .6rem;
}

.sidebar-brand span {
    color: var(--highlight);
}

.sidebar-nav {
    padding: .75rem 0;
    flex: 1;
}

.nav-section {
    padding: .5rem 1.25rem .25rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, .3);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1.25rem;
    color: rgba(255, 255, 255, .65);
    text-decoration: none;
    font-size: .875rem;
    transition: all .2s;
    margin: 1px 8px;
    border-radius: 6px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.nav-link.active {
    background: var(--highlight);
    color: #fff;
}

.nav-link i {
    width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: rgba(255, 255, 255, .7);
    font-size: .82rem;
    margin-bottom: .6rem;
}

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

.btn-logout {
    display: block;
    color: rgba(255, 255, 255, .4);
    text-decoration: none;
    font-size: .8rem;
    padding: .3rem 0;
    transition: color .2s;
}

.btn-logout:hover {
    color: var(--highlight);
}

/* ── Topbar ── */
.topbar {
    background: #fff;
    padding: 1rem 2rem;
    margin: -2rem -2rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.topbar p {
    font-size: .82rem;
    color: var(--silver);
    margin-top: .1rem;
}

/* ── Cards ── */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    font-size: .95rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.5rem;
}

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

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 4px solid var(--highlight);
}

.stat-card.green {
    border-left-color: var(--success);
}

.stat-card.amber {
    border-left-color: var(--warning);
}

.stat-card.blue {
    border-left-color: #3b82f6;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: .8rem;
    color: var(--silver);
    margin-top: .25rem;
}

.stat-icon {
    font-size: 2rem;
    color: #e0e0e8;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

thead th {
    background: var(--silver-light);
    padding: .75rem 1rem;
    text-align: left;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--silver);
    font-weight: 600;
}

tbody td {
    padding: .85rem 1rem;
    border-bottom: 1px solid #f4f4f8;
    vertical-align: middle;
}

tbody tr:hover {
    background: #fafafa;
}

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

/* ── Badges ── */
.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-purple {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-grey {
    background: #f3f4f6;
    color: #6b7280;
}

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

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

.btn-primary:hover {
    background: #c73652;
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid #ddd;
    color: #444;
}

.btn-outline:hover {
    border-color: var(--highlight);
    color: var(--highlight);
}

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

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

.btn-sm {
    padding: .3rem .75rem;
    font-size: .8rem;
}

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

.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: .4rem;
    color: #444;
}

.form-control,
.form-select {
    width: 100%;
    padding: .55rem .85rem;
    border: 1.5px solid #e0e0e8;
    border-radius: 8px;
    font-size: .875rem;
    color: var(--primary);
    transition: border .2s;
    background: #fff;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--highlight);
}

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

.modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #888;
}

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

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

/* ── Pipeline ── */
.pipeline-bar {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 1.5rem 0;
    position: relative;
}

.pipeline-step {
    flex: 1;
    text-align: center;
    position: relative;
    z-index: 1;
}

.pipeline-bar::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e0e0e8;
}

.p-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e8;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto .4rem;
    font-size: .75rem;
    font-weight: 700;
    color: #999;
}

.p-dot.done {
    background: var(--success);
    color: #fff;
}

.p-dot.current {
    background: var(--highlight);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(233, 69, 96, .2);
}

.p-label {
    font-size: .7rem;
    color: #999;
}

.p-label.done {
    color: var(--success);
    font-weight: 600;
}

.p-label.current {
    color: var(--highlight);
    font-weight: 700;
}

/* ── Notes ── */
.note-item {
    padding: .85rem 1rem;
    border-radius: 8px;
    margin-bottom: .75rem;
    font-size: .875rem;
}

.note-staff {
    background: #f0f4ff;
    border-left: 3px solid #3b82f6;
}

.note-client {
    background: #fff8e1;
    border-left: 3px solid var(--warning);
}

.note-meta {
    font-size: .75rem;
    color: #888;
    margin-bottom: .3rem;
}

/* ── Doc checklist ── */
.doc-row {
    display: flex;
    align-items: center;
    padding: .65rem .85rem;
    border-radius: 8px;
    margin-bottom: .5rem;
    font-size: .875rem;
    background: #fafafa;
    gap: .75rem;
}

.doc-row.received {
    background: #f0fdf4;
}

.doc-row.missing {
    background: #fff5f5;
}

.doc-row.review {
    background: #fffbeb;
}

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .3);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .brand-mark {
    font-size: 2.5rem;
    color: var(--highlight);
}

.login-logo h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin: .5rem 0 .25rem;
}

.login-logo p {
    color: var(--silver);
    font-size: .85rem;
}

/* ── Kanban ── */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-col {
    min-width: 260px;
    background: var(--silver-light);
    border-radius: 10px;
    padding: .75rem;
    flex-shrink: 0;
}

.kanban-col-header {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #666;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kanban-card {
    background: #fff;
    border-radius: 8px;
    padding: .85rem 1rem;
    margin-bottom: .6rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
    font-size: .82rem;
    cursor: pointer;
    border-left: 3px solid var(--highlight);
    transition: box-shadow .2s;
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}

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

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

/* ── Notification bell ── */
.notif-bell {
    position: relative;
    cursor: pointer;
    font-size: 1.2rem;
    color: #666;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background: var(--highlight);
    color: #fff;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ── Progress bar ── */
.progress-bar-wrap {
    background: #e0e0e8;
    border-radius: 10px;
    height: 10px;
    overflow: hidden;
    margin: .5rem 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--success);
    border-radius: 10px;
    transition: width .4s;
}

/* ── Signature canvas ── */
#sign-canvas {
    border: 2px dashed #ccc;
    border-radius: 8px;
    cursor: crosshair;
    width: 100%;
    touch-action: none;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
        transition: transform .3s;
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #content {
        margin-left: 0;
        padding: 1rem;
    }

    .topbar {
        margin: -1rem -1rem 1rem;
        padding: .85rem 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Empty states ── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #aaa;
}

.empty-state i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .75rem;
    color: #ddd;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #888;
    margin-bottom: .4rem;
}

.empty-state p {
    font-size: .85rem;
    color: #bbb;
    max-width: 300px;
    margin: 0 auto;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.btn:disabled {
    opacity: .7;
    cursor: not-allowed;
}