:root {
    --bg: #eef2f7;
    --surface: rgba(255, 255, 255, .92);
    --surface-strong: #ffffff;
    --ink: #111827;
    --muted: #667085;
    --line: rgba(17, 24, 39, .11);
    --nav: #171923;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --teal: #0f766e;
    --amber: #b45309;
    --rose: #be123c;
    --green: #15803d;
    --shadow: 0 18px 50px rgba(15, 23, 42, .13);
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, .08);
    --radius: 8px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(135deg, rgba(37, 99, 235, .10), transparent 34%),
        linear-gradient(225deg, rgba(15, 118, 110, .11), transparent 32%),
        var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

a { text-decoration: none; }

.ui-rise {
    animation: ui-rise .38s ease both;
}

@keyframes ui-rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 66px;
    background: rgba(23, 25, 35, .94);
    border-bottom: 1px solid rgba(255, 255, 255, .10);
    box-shadow: 0 14px 38px rgba(15, 23, 42, .22);
    backdrop-filter: blur(16px);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 800;
}

.navbar-brand:hover { color: #fff; }

.brand-mark {
    display: inline-grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #2563eb, #0f766e);
    box-shadow: 0 10px 26px rgba(37, 99, 235, .35);
}

.navbar-toggler {
    color: #fff;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: var(--radius);
    box-shadow: none !important;
}

.app-nav .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: var(--radius);
    color: rgba(255,255,255,.72);
    font-weight: 700;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.app-nav .nav-link:hover,
.app-nav .nav-link.active {
    background: rgba(255,255,255,.11);
    color: #fff;
    transform: translateY(-1px);
}

.app-shell {
    width: min(1480px, calc(100% - 32px));
    margin: 18px auto 34px;
}

.app-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 22px;
    align-items: end;
    min-height: 172px;
    padding: 28px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, rgba(37, 99, 235, .32), transparent 42%),
        linear-gradient(225deg, rgba(180, 83, 9, .30), transparent 40%),
        #151923;
    color: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.eyebrow {
    margin: 0 0 8px;
    color: #9ee7dc;
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.app-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 4.2rem);
    font-weight: 850;
    line-height: 1;
}

.hero-copy {
    max-width: 780px;
    margin: 12px 0 0;
    color: rgba(255,255,255,.72);
}

.hero-actions,
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 104px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid rgba(255,255,255,.72);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.metric-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: var(--radius);
    color: #fff;
    background: var(--primary);
}

.metric-card.tone-green .metric-icon { background: var(--green); }
.metric-card.tone-teal .metric-icon { background: var(--teal); }
.metric-card.tone-amber .metric-icon { background: var(--amber); }

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin-top: 2px;
    color: var(--ink);
    font-size: clamp(1.6rem, 2.8vw, 2.25rem);
    line-height: 1.1;
}

.workspace {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,.78);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.app-tabs {
    display: flex;
    gap: 8px;
    padding: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(248, 250, 252, .78);
}

.app-tabs .nav-link {
    white-space: nowrap;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 800;
}

.app-tabs .nav-link.active {
    background: #171923;
    color: #fff;
    box-shadow: 0 8px 22px rgba(23,25,35,.22);
}

.section-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin-bottom: 16px;
}

.section-toolbar h2 {
    margin: 0;
    font-size: 1.18rem;
    font-weight: 850;
}

.section-toolbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

.search-box {
    display: flex;
    gap: 8px;
    width: min(100%, 520px);
}

.form-control,
.form-select {
    border-color: rgba(17,24,39,.14);
    border-radius: var(--radius);
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(37,99,235,.72);
    box-shadow: 0 0 0 .2rem rgba(37,99,235,.14);
}

.btn {
    border-radius: var(--radius);
    font-weight: 750;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 8px 22px rgba(37,99,235,.20);
}

.btn-primary:hover {
    background: var(--primary-strong);
    border-color: var(--primary-strong);
}

.app-table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-strong);
}

.app-table {
    min-width: 1060px;
    margin: 0;
}

.app-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 14px;
    background: #f8fafc;
    color: #475467;
    border-bottom: 1px solid var(--line);
    font-size: .76rem;
    font-weight: 850;
    text-transform: uppercase;
}

.app-table tbody td {
    padding: 12px 14px;
    border-color: rgba(17,24,39,.08);
}

.app-table tbody tr {
    transition: background .14s ease;
}

.app-table tbody tr:hover {
    background: #f9fbff;
}

.id-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.note-cell {
    max-width: 420px;
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 850;
    background: #eef2f7;
    color: #475467;
}

.status-pill.is-active { background: #dcfce7; color: var(--green); }
.status-pill.is-danger { background: #ffe4e6; color: var(--rose); }
.status-pill.is-info { background: #dbeafe; color: var(--primary-strong); }
.status-pill.is-muted { background: #eef2f7; color: #475467; }

.check-list {
    max-height: 340px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    background: #fafbfc;
}

.drag-handle {
    cursor: grab;
    color: var(--muted);
    font-size: .82rem;
}

.sortable-ghost {
    opacity: .75;
    background: #dbeafe !important;
}

.empty-state {
    padding: 34px;
    text-align: center;
    color: var(--muted);
    background: #fafbfc;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.app-alert { border-radius: var(--radius); }

.modal-content {
    border: 1px solid rgba(17,24,39,.12);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal {
    z-index: 1065;
}

.modal-backdrop {
    z-index: 1055;
}

.modal-dialog {
    pointer-events: auto;
}

.modal-body {
    max-height: calc(100vh - 190px);
    overflow: auto;
}

.app-footer {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto 20px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: .9rem;
}

@media (max-width: 1080px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .app-shell,
    .app-footer {
        width: min(100% - 20px, 1480px);
    }

    .app-hero {
        grid-template-columns: 1fr;
        min-height: auto;
        padding: 22px;
    }

    .hero-actions,
    .section-toolbar,
    .app-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .hero-actions .btn,
    .search-box .btn {
        width: 100%;
    }

    .search-box {
        flex-direction: column;
        width: 100%;
    }

    .workspace {
        padding: 12px;
    }
}

@media (max-width: 560px) {
    .app-shell {
        width: min(100% - 12px, 1480px);
        margin-top: 10px;
    }

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

    .metric-card {
        min-height: 86px;
    }

    .app-hero h1 {
        font-size: 2rem;
    }

    .app-table {
        min-width: 1060px;
    }
}
