:root {
    --ink: #171a1d;
    --muted: #60686e;
    --line: #d9dde0;
    --soft-line: #e9ecee;
    --paper: #ffffff;
    --canvas: #f4f6f5;
    --teal: #087c72;
    --teal-dark: #055b54;
    --teal-soft: #e7f4f1;
    --blue: #2767a5;
    --blue-soft: #eaf2f8;
    --amber: #976105;
    --amber-soft: #fff5d9;
    --red: #a43636;
    --red-soft: #fff0ee;
    --green: #2b7650;
    --green-soft: #eaf5ee;
    --shadow: 0 16px 40px rgb(23 26 29 / 12%);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0;
}

button,
input {
    font: inherit;
    letter-spacing: 0;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--blue);
}

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px max(24px, calc((100vw - 1240px) / 2));
    border-bottom: 1px solid var(--line);
    background: rgb(255 255 255 / 96%);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    text-decoration: none;
}

.brand img {
    width: 36px;
    height: 36px;
}

.brand span {
    display: grid;
    line-height: 1.15;
}

.brand strong {
    font-size: 15px;
}

.brand small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.environment,
.local-label {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 3px 9px;
    border: 1px solid #e4b2aa;
    border-radius: 4px;
    color: var(--red);
    background: var(--red-soft);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

.button-primary {
    color: #fff;
    border-color: var(--teal-dark);
    background: var(--teal-dark);
}

.button-primary:not(:disabled):hover {
    background: #044c46;
}

.button-secondary {
    color: var(--ink);
    border-color: var(--line);
    background: var(--paper);
}

.button-secondary:not(:disabled):hover {
    border-color: #aeb5b9;
    background: #fafafa;
}

main {
    width: min(1240px, calc(100% - 48px));
    margin: 0 auto;
    padding: 36px 0 72px;
}

.page-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    padding: 14px 0 28px;
}

.eyebrow,
.section-kicker {
    margin: 0 0 6px;
    color: var(--teal-dark);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    max-width: 760px;
    margin: 0;
    font-size: 32px;
    line-height: 1.2;
}

h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.3;
}

h3 {
    margin: 0;
    font-size: 16px;
    line-height: 1.35;
}

.intro-copy {
    max-width: 720px;
    margin: 10px 0 0;
    color: var(--muted);
}

.wallet-summary {
    max-width: 390px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    text-align: right;
}

.loading-band,
.error-band {
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
}

.error-band {
    color: var(--red);
    border-color: #e4b2aa;
    background: var(--red-soft);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
}

.status-stat {
    display: grid;
    min-height: 116px;
    align-content: center;
    padding: 18px 20px;
    border-right: 1px solid var(--line);
}

.status-stat:last-child {
    border-right: 0;
}

.status-stat span,
.status-stat small {
    color: var(--muted);
    font-size: 12px;
}

.status-stat strong {
    margin: 3px 0 1px;
    font-size: 26px;
    line-height: 1.2;
}

.risk-band,
.availability-band {
    display: grid;
    margin-top: 18px;
    border-radius: 6px;
}

.risk-band {
    grid-template-columns: 36px 1fr;
    gap: 14px;
    padding: 20px;
    border: 1px solid #e5c47e;
    background: var(--amber-soft);
}

.risk-marker {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--amber);
    font-size: 18px;
    font-weight: 850;
}

.risk-band p {
    max-width: 1040px;
    margin: 7px 0 0;
    color: #5b480f;
}

.risk-warning {
    font-weight: 750;
}

.availability-band {
    grid-template-columns: 240px 1fr 1fr;
    gap: 30px;
    align-items: start;
    padding: 22px 0;
    border-bottom: 1px solid var(--line);
}

.availability-band p {
    margin: 2px 0 0;
    color: var(--muted);
}

.runbook,
.proposal-area,
.owners-section {
    padding: 30px 0;
    border-bottom: 1px solid var(--line);
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.local-label {
    color: var(--muted);
    border-color: var(--line);
    background: #f9faf9;
}

.section-note {
    margin: 8px 0 18px;
    color: var(--muted);
}

.checklist {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--line);
}

.check-item {
    display: flex;
    min-height: 92px;
    gap: 11px;
    padding: 15px;
    background: var(--paper);
    cursor: pointer;
}

.check-item input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin: 2px 0 0;
    accent-color: var(--teal);
}

.check-item span {
    display: grid;
    align-content: start;
}

.check-item small {
    margin-bottom: 3px;
    color: var(--teal-dark);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.proposal-heading {
    align-items: center;
}

.phase-filter {
    display: grid;
    grid-template-columns: repeat(4, 86px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--paper);
}

.filter-button {
    min-height: 38px;
    padding: 7px 10px;
    border: 0;
    border-right: 1px solid var(--line);
    color: var(--muted);
    background: var(--paper);
    cursor: pointer;
    font-weight: 700;
}

.filter-button:last-child {
    border-right: 0;
}

.filter-button.active {
    color: #fff;
    background: var(--ink);
}

.phase-legend {
    display: flex;
    gap: 28px;
    margin: 12px 0 22px;
    color: var(--muted);
    font-size: 13px;
}

.phase-legend p {
    margin: 0;
}

.chain-section {
    margin-top: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
}

.chain-header {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(300px, 2fr) auto;
    gap: 20px;
    align-items: center;
    min-height: 68px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line);
    background: #f8faf9;
}

.chain-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chain-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--teal-dark);
    background: var(--paper);
    font-size: 12px;
    font-weight: 850;
}

.chain-meta,
.safe-address {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.safe-threshold {
    min-width: 62px;
    color: var(--teal-dark);
    font-size: 12px;
    font-weight: 800;
    text-align: right;
}

.proposal-row + .proposal-row {
    border-top: 1px solid var(--line);
}

.proposal-summary {
    display: grid;
    grid-template-columns: 86px minmax(260px, 2fr) minmax(150px, 1fr) 110px 190px;
    gap: 16px;
    align-items: center;
    min-height: 98px;
    padding: 16px 18px;
}

.phase-badge,
.status-badge {
    display: inline-flex;
    width: fit-content;
    min-height: 27px;
    align-items: center;
    padding: 3px 8px;
    border: 1px solid #b7d7d2;
    border-radius: 4px;
    color: var(--teal-dark);
    background: var(--teal-soft);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
}

.phase-badge.phase-b {
    color: var(--blue);
    border-color: #b9cee1;
    background: var(--blue-soft);
}

.phase-badge.phase-zero {
    color: #6d4307;
    border-color: #e1c178;
    background: var(--amber-soft);
}

.proposal-title p,
.impact-brief,
.confirmation-cell small {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.impact-brief {
    margin: 0;
}

.confirmation-cell strong {
    display: block;
    font-size: 14px;
}

.status-badge.ready {
    color: var(--green);
    border-color: #b8d7c5;
    background: var(--green-soft);
}

.status-badge.unavailable {
    color: var(--red);
    border-color: #e4b2aa;
    background: var(--red-soft);
}

.row-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.row-actions > div {
    display: grid;
    gap: 4px;
}

.review-link {
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.review-link:hover {
    text-decoration: underline;
}

.detail-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--ink);
    background: var(--paper);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.detail-toggle[aria-expanded="true"] {
    color: #fff;
    border-color: var(--ink);
    background: var(--ink);
    transform: rotate(45deg);
}

.proposal-details {
    display: none;
    padding: 0 18px 20px 120px;
}

.proposal-details.open {
    display: block;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 34px;
    padding-top: 18px;
    border-top: 1px solid var(--soft-line);
}

.detail-block h4 {
    margin: 0 0 9px;
    font-size: 13px;
    text-transform: uppercase;
}

.call-list,
.impact-list,
.route-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.call-list li,
.impact-list li {
    padding: 9px 0;
    border-bottom: 1px solid var(--soft-line);
}

.call-list li:last-child,
.impact-list li:last-child {
    border-bottom: 0;
}

.call-list code,
.hash-code,
.dialog-code {
    color: var(--teal-dark);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
}

.call-list p,
.impact-list p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.transaction-facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    margin: 16px 0 0;
}

.transaction-facts div {
    min-width: 0;
}

.transaction-facts .fact-wide {
    grid-column: 1 / -1;
}

.transaction-facts span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.transaction-facts code {
    display: block;
    margin-top: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.dvn-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.dvn-strip span {
    padding: 3px 7px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    background: #fafafa;
    font-size: 11px;
}

.route-table-wrap {
    margin-top: 14px;
    overflow-x: auto;
}

.route-table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
    font-size: 11px;
}

.route-table th,
.route-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--soft-line);
    text-align: left;
}

.route-table th {
    color: var(--muted);
    font-weight: 800;
}

.owners-section {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
}

.owner-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.owner-address {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--paper);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.owner-address.connected {
    color: var(--green);
    border-color: #9fcab0;
    background: var(--green-soft);
}

.sign-dialog {
    width: min(650px, calc(100% - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: var(--shadow);
}

.sign-dialog::backdrop {
    background: rgb(23 26 29 / 58%);
}

.sign-dialog form {
    padding: 22px;
}

.dialog-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.icon-button {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--ink);
    background: var(--paper);
    cursor: pointer;
    font-size: 24px;
}

.dialog-summary {
    margin: 16px 0;
    padding: 13px 15px;
    border-left: 3px solid var(--teal);
    background: var(--teal-soft);
}

.dialog-facts {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 8px 14px;
    margin: 18px 0;
}

.dialog-facts dt {
    color: var(--muted);
    font-size: 12px;
}

.dialog-facts dd {
    min-width: 0;
    margin: 0;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.review-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 5px;
    cursor: pointer;
}

.review-check input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    margin: 1px 0 0;
    accent-color: var(--teal);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

.toast {
    position: fixed;
    z-index: 50;
    right: 22px;
    bottom: 22px;
    width: min(430px, calc(100% - 44px));
    padding: 13px 15px;
    border: 1px solid #9fcab0;
    border-radius: 6px;
    color: #174b32;
    background: var(--green-soft);
    box-shadow: var(--shadow);
    font-weight: 700;
}

.toast.error {
    color: var(--red);
    border-color: #e4b2aa;
    background: var(--red-soft);
}

@media (max-width: 1000px) {
    .status-grid {
        grid-template-columns: 1fr 1fr;
    }

    .status-stat:nth-child(2) {
        border-right: 0;
    }

    .status-stat:nth-child(-n + 2) {
        border-bottom: 1px solid var(--line);
    }

    .availability-band {
        grid-template-columns: 1fr 1fr;
    }

    .availability-band > div:first-child {
        grid-column: 1 / -1;
    }

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

    .proposal-summary {
        grid-template-columns: 76px minmax(220px, 1.8fr) 130px 170px;
    }

    .impact-brief {
        display: none;
    }

    .proposal-details {
        padding-left: 94px;
    }
}

@media (max-width: 760px) {
    .topbar {
        position: static;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
    }

    .topbar-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .environment {
        display: none;
    }

    #refreshButton {
        display: none;
    }

    #walletButton {
        max-width: 160px;
        white-space: normal;
    }

    main {
        width: auto;
        max-width: none;
        margin-right: 14px;
        margin-left: 14px;
        padding-top: 18px;
    }

    .page-intro {
        display: block;
        padding-bottom: 20px;
    }

    h1 {
        font-size: 27px;
    }

    .wallet-summary {
        margin-top: 12px;
        text-align: left;
    }

    .status-grid,
    .checklist {
        grid-template-columns: 1fr;
    }

    .status-stat {
        min-height: 94px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .status-stat:nth-child(3) {
        border-bottom: 1px solid var(--line);
    }

    .status-stat:last-child {
        border-bottom: 0;
    }

    .risk-band {
        grid-template-columns: 28px 1fr;
        padding: 16px;
    }

    .risk-marker {
        width: 28px;
        height: 28px;
    }

    .availability-band,
    .owners-section {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .availability-band > div:first-child {
        grid-column: auto;
    }

    .section-heading {
        align-items: flex-start;
    }

    .proposal-heading {
        display: block;
    }

    .phase-filter {
        grid-template-columns: repeat(4, 1fr);
        margin-top: 14px;
    }

    .phase-legend {
        display: block;
    }

    .phase-legend p + p {
        margin-top: 5px;
    }

    .chain-header {
        grid-template-columns: 1fr auto;
        gap: 8px 14px;
    }

    .safe-address {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .proposal-summary {
        grid-template-columns: 72px 1fr auto;
        gap: 12px;
        align-items: start;
        padding: 15px;
    }

    .confirmation-cell {
        grid-column: 2;
    }

    .row-actions {
        grid-column: 2 / -1;
        grid-template-columns: minmax(120px, 1fr) auto;
    }

    .proposal-details {
        padding: 0 15px 18px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .owner-list {
        grid-template-columns: 1fr;
    }

    .dialog-facts {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .dialog-facts dd {
        margin-bottom: 8px;
    }
}

@media (max-width: 520px) {
    .topbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .topbar-actions,
    #walletButton {
        width: 100%;
        max-width: none;
    }
}
