:root {
    --bg: #0d0e12;
    --panel: #181920;
    --panel-2: #20212a;
    --line: #333540;
    --text: #f2f2f5;
    --muted: #a8abb7;
    --red: #980019;
    --red-2: #c21835;
    --green: #2fbf71;
    --amber: #d99a22;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

.app {
    width: min(1420px, calc(100vw - 28px));
    margin: 0 auto;
    padding: 18px 0 32px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(194, 24, 53, .45);
    padding-bottom: 14px;
}

h1, h2, p {
    margin: 0;
}

h1 {
    font-size: 24px;
}

.topbar p {
    color: var(--muted);
    margin-top: 4px;
}

.status {
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 8px 11px;
    white-space: nowrap;
}

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

.topbar-actions form {
    margin: 0;
}

.secondary-button {
    background: var(--panel-2);
    border-color: var(--line);
}

.secondary-link {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--text);
    padding: 0 16px;
    font-weight: 700;
    text-decoration: none;
}

.secondary-link:hover {
    background: #2a2c36;
}

.account-badge {
    color: var(--muted);
    white-space: nowrap;
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.login-shell {
    width: min(420px, 100%);
    margin: auto;
}

.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
}

.login-card > p {
    color: var(--muted);
    margin-top: 8px;
}

.login-card form {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}

.login-card label {
    font-weight: 700;
}

.login-error {
    margin-top: 16px;
    border: 1px solid var(--red-2);
    border-radius: 5px;
    background: rgba(152, 0, 25, .18);
    padding: 10px 12px;
}

.access-message {
    margin: 18px 0;
}

.access-success,
.credential-box {
    margin: 18px 0;
    border: 1px solid rgba(47, 191, 113, .55);
    border-radius: 6px;
    background: rgba(47, 191, 113, .12);
    padding: 12px 14px;
}

.credential-box {
    display: grid;
    gap: 10px;
}

.credential-box code {
    user-select: all;
    overflow-wrap: anywhere;
    color: #fff;
    font-size: 16px;
}

.access-section {
    margin-top: 18px;
}

.access-add-form {
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 14px;
}

.access-table-wrap {
    max-height: none;
}

.access-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.access-actions form {
    margin: 0;
}

.access-actions button {
    height: 34px;
}

.danger-button {
    background: #4b111b;
    border-color: var(--red-2);
}

.access-note {
    color: var(--muted);
    padding: 12px 14px 0;
}

.search-panel,
.panel,
.summary {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 7px;
}

.search-panel {
    margin: 18px 0;
    padding: 14px;
    position: relative;
}

.search-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

input,
button {
    height: 42px;
    border-radius: 5px;
    border: 1px solid var(--line);
    color: var(--text);
    font: inherit;
}

input {
    background: #111219;
    padding: 0 12px;
    outline: none;
}

input:focus {
    border-color: var(--red-2);
}

button {
    background: var(--red);
    border-color: var(--red-2);
    padding: 0 18px;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--red-2);
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.suggestion {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
}

.summary {
    color: var(--muted);
    padding: 10px 12px;
    margin-bottom: 18px;
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
    gap: 18px;
}

.results-grid {
    grid-template-columns: minmax(0, 1fr);
}

.panel {
    min-width: 0;
    overflow: hidden;
}

.panel-head {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: #15161d;
}

.panel-head h2 {
    font-size: 16px;
}

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

.table-wrap {
    max-height: calc(100vh - 240px);
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #292b35;
    vertical-align: top;
}

th {
    color: #fff;
    background: var(--panel-2);
    position: sticky;
    top: 0;
    z-index: 1;
}

td {
    color: #e8e8eb;
}

.hash {
    font-family: Consolas, monospace;
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
}

.related-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    align-content: start;
    gap: 10px;
    max-height: calc(100vh - 240px);
    overflow: auto;
    padding: 12px;
}

.related-card {
    border: 1px solid var(--line);
    background: #14151b;
    border-radius: 6px;
    padding: 11px;
}

.related-card.indirect {
    border-color: rgba(217, 154, 34, .55);
}

.related-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.nick {
    font-weight: 700;
}

.nick-profile {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.score {
    color: #fff;
    background: var(--red);
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
}

.score.high {
    background: var(--green);
}

.score.medium {
    background: var(--amber);
}

.direct-label,
.indirect-label {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    white-space: nowrap;
}

.direct-label {
    border-color: rgba(47, 191, 113, .5);
    color: #8be0b2;
}

.indirect-label {
    border-color: rgba(217, 154, 34, .65);
    color: #f0c36f;
}

.probability {
    margin: 8px 0 10px;
}

.probability-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.probability-top strong {
    color: var(--text);
}

.probability-bar {
    display: block;
    width: 100%;
    height: 7px;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 999px;
    background: #0e0f15;
    border: 1px solid #292b35;
    overflow: hidden;
}

.probability-bar::-webkit-progress-bar {
    background: #0e0f15;
}

.probability-bar::-webkit-progress-value {
    background: var(--red);
}

.probability-bar.medium::-webkit-progress-value {
    background: var(--amber);
}

.probability-bar.high::-webkit-progress-value {
    background: var(--green);
}

.probability-bar.certain::-webkit-progress-value {
    background: #42d98b;
    box-shadow: 0 0 10px rgba(66, 217, 139, .35);
}

.probability-bar::-moz-progress-bar {
    background: var(--red);
}

.probability-bar.medium::-moz-progress-bar {
    background: var(--amber);
}

.probability-bar.high::-moz-progress-bar {
    background: var(--green);
}

.probability-bar.certain::-moz-progress-bar {
    background: #42d98b;
    box-shadow: 0 0 10px rgba(66, 217, 139, .35);
}

.bridge {
    color: #f0c36f;
}

.match {
    color: var(--muted);
    border-top: 1px solid #292b35;
    padding-top: 7px;
    margin-top: 7px;
    font-size: 12px;
}

.empty {
    color: var(--muted);
    padding: 14px;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(194, 24, 53, .35);
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 860px) {
    .app {
        width: calc(100vw - 18px);
        padding-top: 10px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .search-row,
    .grid {
        grid-template-columns: 1fr;
    }

    .table-wrap,
    .related-list {
        max-height: none;
    }

    .app-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .access-add-form {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 520px) {
    .login-page {
        align-items: flex-start;
    }
}
