:root {
    --ink: #1b1b3a;
    --paper: #fbfefb;
    --coral: #ff6b6b;
    --mint: #4ecdc4;
    --line: rgba(27, 27, 58, 0.14);
    --soft: #eef4f0;
    --muted: #687172;
    --shadow: 0 18px 55px rgba(27, 27, 58, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(78, 205, 196, 0.09), transparent 32%),
        linear-gradient(180deg, #fbfefb 0%, #f1f5f2 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: 286px minmax(0, 1fr);
    min-height: 100vh;
}

.filter-pane {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    color: var(--paper);
    background: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 22px;
    overflow: auto;
}

.brand {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.brand strong {
    display: block;
    font-size: 20px;
    letter-spacing: 0;
    line-height: 1.05;
    text-transform: uppercase;
}

.brand small {
    display: block;
    margin-top: 5px;
    color: rgba(251, 254, 251, 0.68);
    line-height: 1.25;
}

.screen-tabs,
.filters {
    display: grid;
    gap: 8px;
}

.screen-tab {
    min-height: 42px;
    border: 1px solid rgba(251, 254, 251, 0.12);
    border-radius: 8px;
    color: rgba(251, 254, 251, 0.78);
    background: rgba(251, 254, 251, 0.04);
    text-align: left;
    padding: 0 13px;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.screen-tab:hover,
.screen-tab.is-active {
    color: var(--ink);
    background: var(--mint);
    transform: translateX(2px);
}

.filters {
    padding-top: 8px;
    border-top: 1px solid rgba(251, 254, 251, 0.15);
}

label {
    display: grid;
    gap: 7px;
    font-size: 12px;
    line-height: 1.25;
    color: rgba(251, 254, 251, 0.68);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(27, 27, 58, 0.16);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 11px 12px;
    outline: none;
}

.filter-pane input,
.filter-pane select {
    border-color: rgba(251, 254, 251, 0.14);
    color: var(--paper);
    background: rgba(251, 254, 251, 0.08);
}

.filter-pane option {
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--mint);
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.16);
}

.source-box {
    margin-top: auto;
    border: 1px solid rgba(251, 254, 251, 0.14);
    border-radius: 8px;
    padding: 14px;
    background: rgba(251, 254, 251, 0.06);
}

.source-box span,
.panel-kicker,
.eyebrow,
.metrics span {
    display: block;
    font-size: 11px;
    letter-spacing: 0;
    text-transform: uppercase;
    font-weight: 800;
}

.source-box span {
    color: rgba(251, 254, 251, 0.56);
}

.source-box strong {
    display: block;
    margin-top: 6px;
    color: var(--mint);
}

.workspace {
    min-width: 0;
    padding: 24px;
}

.desk-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow,
.panel-kicker {
    color: var(--coral);
    margin: 0 0 6px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(30px, 4vw, 54px);
    line-height: 0.94;
    max-width: 850px;
}

h2 {
    margin-bottom: 8px;
    font-size: 21px;
    line-height: 1.1;
}

p {
    color: var(--muted);
}

.desk-actions,
.dialog-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.dialog-actions button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 15px;
    font-weight: 800;
}

.primary-button {
    color: var(--paper);
    background: var(--ink);
}

.primary-button:hover {
    background: #2c2c57;
}

.ghost-button,
.dialog-actions button {
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
}

.stretch {
    width: 100%;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow);
}

.metrics article {
    min-width: 0;
    padding: 17px 18px;
    border-right: 1px solid var(--line);
}

.metrics article:last-child {
    border-right: 0;
}

.metrics span {
    color: var(--muted);
}

.metrics strong {
    display: block;
    margin: 8px 0 2px;
    font-size: clamp(24px, 3vw, 38px);
    line-height: 1;
}

.metrics small {
    color: var(--muted);
}

.view {
    display: none;
    animation: rise 220ms ease both;
}

.view.is-visible {
    display: block;
}

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

.lane-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.lane {
    min-height: 116px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.lane strong {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 18px;
}

.lane strong em {
    color: var(--coral);
    font-size: 26px;
    font-style: normal;
}

.mini-bar {
    height: 8px;
    margin-top: 18px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--soft);
}

.mini-bar i,
.tempo-meter i,
.finance-bar i {
    display: block;
    height: 100%;
    width: var(--value, 0%);
    background: linear-gradient(90deg, var(--mint), var(--coral));
    border-radius: inherit;
    transition: width 260ms ease;
}

.portfolio-layout,
.finance-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 16px;
    align-items: start;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.matter-card {
    min-width: 0;
    min-height: 204px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fff;
    text-align: left;
    color: var(--ink);
    display: grid;
    gap: 12px;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.matter-card:hover,
.matter-card.is-selected {
    transform: translateY(-2px);
    border-color: rgba(78, 205, 196, 0.85);
    box-shadow: 0 16px 38px rgba(27, 27, 58, 0.11);
}

.card-top,
.card-bottom,
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    color: var(--ink);
    background: rgba(78, 205, 196, 0.18);
}

.badge.critical {
    background: rgba(255, 107, 107, 0.2);
}

.badge.watch {
    background: #fff1bb;
}

.matter-card h3 {
    margin: 0;
    font-size: 20px;
    line-height: 1.12;
}

.matter-card p {
    margin: 0;
}

.card-bottom {
    margin-top: auto;
    color: var(--muted);
    font-size: 13px;
}

.drill-panel,
.driver-list,
.create-grid,
.doc-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.drill-panel,
.driver-list {
    position: sticky;
    top: 24px;
    padding: 18px;
}

.drill-panel dl {
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr);
    gap: 9px 12px;
    margin: 18px 0;
}

.drill-panel dt {
    color: var(--muted);
}

.drill-panel dd {
    margin: 0;
    font-weight: 800;
    word-break: break-word;
}

.tempo-meter span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
}

.tempo-meter div {
    height: 12px;
    margin-bottom: 16px;
    border-radius: 99px;
    background: var(--soft);
    overflow: hidden;
}

.create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 20px;
    max-width: 920px;
}

.create-grid label {
    color: var(--muted);
}

.form-copy {
    grid-column: 1 / -1;
    max-width: 620px;
}

.form-status {
    align-self: center;
    margin: 0;
}

.section-head {
    margin: 22px 0 12px;
}

.section-head h2 {
    margin: 0;
}

.section-head > span {
    font-weight: 900;
    color: var(--coral);
}

.doc-list {
    overflow: hidden;
}

.doc-row {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr 120px 120px;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    align-items: center;
}

.doc-row:last-child {
    border-bottom: 0;
}

.doc-row strong,
.doc-row span {
    min-width: 0;
}

.finance-bars,
#driverList {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.finance-bar {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 92px;
    gap: 12px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.finance-bar div {
    height: 12px;
    background: var(--soft);
    border-radius: 99px;
    overflow: hidden;
}

.driver {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.driver:last-child {
    border-bottom: 0;
}

.driver strong {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.driver p {
    margin: 6px 0 0;
    font-size: 14px;
}

dialog {
    width: min(460px, calc(100vw - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 24px 80px rgba(27, 27, 58, 0.28);
}

dialog::backdrop {
    background: rgba(27, 27, 58, 0.42);
}

.dialog-form {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.dialog-form label {
    color: var(--muted);
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .metrics,
    .lane-strip,
    .portfolio-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .portfolio-layout,
    .finance-layout {
        grid-template-columns: 1fr;
    }

    .drill-panel,
    .driver-list {
        position: static;
    }
}

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .filter-pane {
        position: static;
        height: auto;
        padding: 16px;
    }

    .workspace {
        padding: 16px;
    }

    .desk-header {
        display: grid;
    }

    .metrics,
    .lane-strip,
    .portfolio-grid,
    .create-grid {
        grid-template-columns: 1fr;
    }

    .metrics article {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .doc-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .finance-bar {
        grid-template-columns: 1fr;
    }
}
