/* Data surfaces: dense tables (stacked or sticky-scrolling on phones), dialog, drawer, tooltip and charts. */
.table-wrap { position: relative; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-md);
}

.table caption { padding: 0 var(--s5) var(--s3); color: var(--ink-secondary); font-size: var(--text-sm);
    text-align: left; }

.table th {
    padding: 12px 16px;
    border-bottom: 1px solid var(--divider);
    color: var(--ink-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--divider);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur-quick) ease; }
.table tbody tr:hover { background: var(--card-hover); }
.table .is-clickable { cursor: pointer; }
.table .right { text-align: right; }
.table .num { white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: var(--s5); }
.table th:last-child, .table td:last-child { padding-right: var(--s5); }
.table .is-exact { background: var(--mint-wash); box-shadow: inset 3px 0 0 var(--mint); }

@media (min-width: 768px) {
    .table th:first-child, .table td:first-child { padding-left: var(--s6); }
    .table th:last-child, .table td:last-child { padding-right: var(--s6); }
}

.cell-user { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.cell-user .handle { color: var(--ink); font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.cell-user .link-button.handle { text-decoration: none; }
.cell-user .link-button.handle:hover, .cell-user .link-button.handle:focus-visible { text-decoration: underline; }
.cell-time.is-unknown { color: var(--ink-muted); }
.cell-user .name { color: var(--ink-secondary); font-size: var(--text-sm); overflow-wrap: anywhere; }
.cell-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.cell-id { color: var(--ink-secondary); white-space: nowrap; }
.cell-time { color: var(--ink-secondary); white-space: nowrap; }
.exact-tag { margin-left: 6px; }

/* Wide tables keep one line per value and scroll sideways on narrow screens with the first column pinned. */
.table-sticky { min-width: 860px; }
.table-sticky td, .table-sticky .cell-user .handle, .table-sticky .cell-user .name { white-space: nowrap;
    overflow-wrap: normal; }

/* Transaction status cell: badge, the owner-only provider outcome and an open attempt's recheck, stacked. */
.tx-status { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.tx-outcome { color: var(--ink-secondary); font-size: var(--text-xs); }
.tx-outcome code { color: var(--ink); }
.tx-recheck-status { max-width: 240px; white-space: normal; }

@media (max-width: 767px) {
    .table-sticky th:first-child,
    .table-sticky td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--card);
        box-shadow: 1px 0 0 var(--divider);
        font-size: var(--text-sm);
    }

    .table-sticky tbody tr:hover td:first-child { background: var(--card-hover); }
}

/* Users table: rows become cards below 768px. */
@media (max-width: 767px) {
    .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table-stack, .table-stack tbody { display: block; }

    .table-stack tr {
        display: grid;
        padding: var(--s4) var(--s5);
        grid-template-columns: 1fr auto;
        grid-template-areas: "user user" "id badges" "platform platform" "created active" "action action";
        gap: var(--s2) var(--s3);
        border-bottom: 1px solid var(--divider);
    }

    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack td, .table-stack td:first-child, .table-stack td:last-child { padding: 0; border: 0; }
    .table-stack .c-user { grid-area: user; }
    .table-stack .c-id { grid-area: id; align-self: center; }
    .table-stack .c-badges { grid-area: badges; justify-self: end; }
    .table-stack .c-platform { grid-area: platform; }
    .table-stack .c-created { grid-area: created; }
    .table-stack .c-active { grid-area: active; text-align: right; }
    .table-stack .c-action { grid-area: action; text-align: left; }
    .table-stack .c-action .button { width: 100%; }

    .table-stack td[data-label]::before {
        display: block;
        color: var(--ink-muted);
        font-size: var(--text-xs);
        content: attr(data-label);
    }
}

.list-foot {
    display: flex;
    padding: var(--s4) var(--s5);
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    flex-wrap: wrap;
    border-top: 1px solid var(--divider);
    color: var(--ink-secondary);
    font-size: var(--text-sm);
}

@media (min-width: 768px) {
    .list-foot { padding: var(--s4) var(--s6); }
}

/* Totals strip */
.totals { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); }
.total { display: flex; flex-direction: column; gap: 2px; }
.total dt { color: var(--ink-muted); font-size: var(--text-xs); }
.total dd { color: var(--ink); font-size: var(--text-lg); font-weight: var(--weight-book); }

/* Modal dialog and detail drawer (native <dialog>: focus containment, Escape and backdrop). */
.dialog, .drawer {
    padding: 0;
    border: 1px solid var(--card-border-strong);
    background: var(--card);
    color: var(--ink);
}

.dialog {
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    border-radius: var(--radius-hero);
}

.dialog[open] { animation: fade-scale 360ms var(--ease-out); }
.dialog::backdrop, .drawer::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px); }

.dialog-body { display: flex; padding: var(--s6); flex-direction: column; gap: var(--s4); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.dialog-head h2 { font-size: var(--text-xl); font-weight: var(--weight-book); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; }

.close-button {
    display: inline-flex;
    width: 40px;
    height: 40px;
    flex: none;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: var(--wash);
    color: var(--ink);
}

.close-button:hover { background: var(--wash-strong); }

.account-chip {
    display: flex;
    padding: var(--s3) var(--s4);
    align-items: center;
    justify-content: space-between;
    gap: var(--s3);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    background: var(--card);
}

.drawer {
    width: min(460px, 100vw);
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0 0 0 auto;
    border-width: 0 0 0 1px;
    border-radius: var(--radius-hero) 0 0 var(--radius-hero);
}

.drawer[open] { animation: drawer-in 420ms var(--ease-sheet); }

@keyframes drawer-in {
    from { opacity: 0.4; transform: translateX(48px); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 639px) {
    .drawer { border-radius: 0; border-width: 0; }
}

.detail-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.detail-row { display: flex; padding: 12px 0; justify-content: space-between; gap: var(--s4);
    border-bottom: 1px solid var(--divider); }
.detail-row dt { color: var(--ink-secondary); font-size: var(--text-sm); }
.detail-row dd { min-width: 0; color: var(--ink); text-align: right; overflow-wrap: anywhere; }

.tooltip {
    position: fixed;
    z-index: 70;
    max-width: 260px;
    padding: 8px 10px;
    border: 1px solid var(--card-border-strong);
    border-radius: 10px;
    background: var(--card);
    color: var(--ink);
    font-size: var(--text-sm);
    line-height: 1.35;
    pointer-events: none;
    box-shadow: 0 12px 32px rgba(20,50,37,.14);
}

.tooltip strong { display: block; font-size: var(--text-base); font-weight: var(--weight-medium); }
.tooltip .tip-row { display: flex; align-items: center; gap: 6px; color: var(--ink-secondary); }
.tooltip .tip-key { width: 10px; height: 2px; border-radius: 1px; }
