* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f7fb;
    color: #1d2733;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

a {
    color: #0b5cad;
    text-decoration: none;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid #dfe5ee;
    display: flex;
    justify-content: space-between;
    min-height: 60px;
    padding: 0 28px;
}

.brand {
    color: #162130;
    font-size: 18px;
    font-weight: 700;
}

.nav-links {
    align-items: center;
    display: flex;
    gap: 18px;
}

.page {
    margin: 0 auto;
    max-width: 1120px;
    padding: 28px;
}

.wide-page {
    max-width: none;
    width: 95%;
}

.panel {
    background: #ffffff;
    border: 1px solid #dfe5ee;
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 22px;
}

h1,
h2 {
    margin: 0 0 18px;
}

.section-heading {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-heading h2 {
    margin: 0;
}

.form-grid {
    align-items: end;
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(180px, 1fr) minmax(260px, 2fr) auto;
}

.transaction-filter {
    grid-template-columns: minmax(300px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
}

.transaction-query-filter {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(240px, 1.7fr) repeat(2, minmax(125px, .7fr)) minmax(230px, 1.4fr) repeat(2, minmax(150px, 1fr)) auto;
}

.transaction-query-filter label {
    font-size: 13px;
}

.transaction-query-filter input,
.transaction-query-filter select {
    min-height: 36px;
    padding: 6px 9px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

input,
select {
    border: 1px solid #b9c3d1;
    border-radius: 6px;
    font: inherit;
    min-height: 40px;
    padding: 8px 10px;
}

fieldset {
    border: 1px solid #dfe5ee;
    border-radius: 8px;
    margin: 0;
    padding: 16px;
}

legend {
    color: #334155;
    font-weight: 700;
    padding: 0 6px;
}

.fieldset-tools {
    border-bottom: 1px solid #e6ebf2;
    margin: -4px 0 12px;
    padding-bottom: 10px;
}

button {
    background: #145da0;
    border: 0;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    min-height: 40px;
    padding: 9px 14px;
}

button.secondary {
    background: #66788f;
}

.icon-button {
    align-items: center;
    display: inline-flex;
    font-size: 18px;
    justify-content: center;
    line-height: 1;
    min-height: 36px;
    padding: 0;
    width: 36px;
}

.button-link {
    align-items: center;
    background: #145da0;
    border-radius: 6px;
    color: #ffffff;
    display: inline-flex;
    font-weight: 600;
    min-height: 40px;
    padding: 9px 14px;
}

.button-link.secondary {
    background: #66788f;
}

.link-button {
    background: transparent;
    color: #0b5cad;
    min-height: auto;
    padding: 0;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid #e6ebf2;
    padding: 11px 8px;
    text-align: left;
}

th {
    color: #516174;
    font-size: 13px;
    text-transform: uppercase;
}

.mono {
    font-family: Consolas, Monaco, monospace;
}

.small-text {
    font-size: 13px;
    overflow-wrap: anywhere;
}

.amount {
    text-align: right;
    white-space: nowrap;
}

.hash-copy,
.copy-cell {
    color: #0b5cad;
    cursor: pointer;
    position: relative;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    white-space: nowrap;
}

.hash-copy:hover,
.hash-copy:focus,
.copy-cell:hover,
.copy-cell:focus {
    background: #eef6ff;
    outline: 2px solid #9ec5fe;
    outline-offset: -2px;
}

.copy-cell.copied::after,
.copy-cell.copy-error::after {
    border-radius: 999px;
    color: #ffffff;
    content: "Скопировано";
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    position: absolute;
    right: 6px;
    top: 6px;
    white-space: nowrap;
}

.copy-cell.copied::after {
    background: #17663a;
}

.copy-cell.copy-error::after {
    background: #b42318;
    content: "Ошибка";
}

.error {
    color: #b42318;
    font-size: 13px;
}

.hint {
    color: #5c697a;
    margin-top: 0;
}

.muted {
    color: #64748b;
}

.user-form {
    display: grid;
    gap: 18px;
}

.user-main-fields {
    align-items: start;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.fieldset-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(220px, 1fr) minmax(280px, 2fr);
}

.dictionary-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.checkbox-line {
    align-items: center;
    display: flex;
    gap: 8px;
    min-height: 32px;
}

.checkbox-line input {
    min-height: auto;
}

.checkbox-line label {
    display: inline;
    font-weight: 500;
}

.actions {
    display: flex;
    gap: 10px;
}

.table-form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.table-form select {
    min-width: 210px;
}

.table-actions {
    display: grid;
    gap: 8px;
}

.sync-error {
    max-width: 260px;
    overflow-wrap: anywhere;
}

.transaction-table th,
.transaction-table td {
    padding: 7px 8px;
    vertical-align: middle;
}

.transaction-table {
    min-width: 1280px;
}

.transaction-table thead th {
    background: #f8fafc;
    box-shadow: inset 0 -1px 0 #dfe5ee;
    position: sticky;
    top: 0;
    white-space: nowrap;
    z-index: 3;
}

.transaction-table tbody tr:hover {
    background: #f8fbff;
}

.transaction-table td:first-child {
    color: #475569;
    font-size: 13px;
    white-space: nowrap;
}

.transaction-table-scroll {
    border: 1px solid #dfe5ee;
    border-radius: 8px;
    max-height: 65vh;
    overflow: auto;
}

.table-toolbar {
    align-items: end;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 8px 10px;
}

.table-result-count {
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 4px;
}

.table-options {
    align-items: end;
    display: flex;
    gap: 8px;
}

.table-options label {
    color: #64748b;
    font-size: 11px;
    gap: 2px;
}

.table-options select {
    font-size: 13px;
    min-height: 30px;
    padding: 3px 26px 3px 7px;
}

.table-options .direction-label select {
    min-width: 48px;
}

.compact-button {
    font-size: 12px;
    min-height: 30px;
    padding: 4px 9px;
}

.amount-badge {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    white-space: nowrap;
}

.amount-badge.incoming {
    background: #dcfce7;
    color: #166534;
}

.amount-badge.outgoing {
    background: #fee2e2;
    color: #991b1b;
}

.classification-select {
    background-color: #ffffff;
    border-color: #cbd5e1;
    font-size: 13px;
    min-height: 32px;
    min-width: 145px;
    padding: 4px 26px 4px 7px;
    width: 100%;
}

.classification-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px #dbeafe;
    outline: none;
}

.note-editor {
    min-width: 180px;
    position: relative;
}

.note-editor summary {
    color: #475569;
    cursor: pointer;
    font-size: 12px;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-editor[open] {
    min-width: 240px;
}

.note-editor .note-input {
    margin-top: 6px;
}

.save-row-button {
    align-items: center;
    background: #e0f2fe;
    color: #075985;
    display: inline-flex;
    font-size: 16px;
    justify-content: center;
    min-height: 32px;
    padding: 0;
    width: 32px;
}

.save-row-button:hover {
    background: #bae6fd;
}

.external-link-cell {
    padding-left: 4px !important;
    padding-right: 4px !important;
    text-align: center;
    width: 38px;
}

.external-transaction-link {
    align-items: center;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 5px;
    color: #3730a3;
    display: inline-flex;
    font-size: 17px;
    font-weight: 700;
    height: 30px;
    justify-content: center;
    line-height: 1;
    width: 30px;
}

.external-transaction-link:hover,
.external-transaction-link:focus {
    background: #dbeafe;
    border-color: #93c5fd;
    outline: none;
}

.transaction-export-actions {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 12px;
}

.excel-export-button {
    align-items: center;
    background: #17663a;
    display: inline-flex;
    font-size: 12px;
    gap: 6px;
    min-height: 30px;
    padding: 4px 9px;
}

.excel-export-button:hover {
    background: #11552f;
}

.excel-export-button span {
    background: rgba(255, 255, 255, .16);
    border-radius: 3px;
    font-size: 9px;
    letter-spacing: .02em;
    padding: 3px 4px;
}

.balance-heading {
    align-items: flex-start;
}

.balance-heading h1 {
    margin-bottom: 6px;
}

.balance-heading .hint {
    margin-bottom: 0;
}

.balance-refresh {
    white-space: nowrap;
}

.balance-table-scroll {
    border: 1px solid #dfe5ee;
    border-radius: 8px;
    overflow-x: auto;
}

.balance-table {
    min-width: 1180px;
}

.balance-table th {
    background: #f8fafc;
    white-space: nowrap;
}

.balance-table td {
    vertical-align: middle;
}

.balance-wallet-name {
    font-weight: 700;
}

.balance-address,
.balance-updated,
.resource-value {
    font-size: 13px;
    white-space: nowrap;
}

.balance-token {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.balance-token.stablecoin {
    color: #075985;
}

.balance-status {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    white-space: nowrap;
}

.balance-status-actions {
    align-items: center;
    display: flex;
    gap: 6px;
}

.refresh-row-button {
    align-items: center;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    color: #075985;
    display: inline-flex;
    font-size: 18px;
    height: 30px;
    justify-content: center;
    line-height: 1;
    min-height: 30px;
    padding: 0;
    width: 30px;
}

.refresh-row-button:hover,
.refresh-row-button:focus {
    background: #bae6fd;
    outline: none;
}

.success-status {
    background: #dcfce7;
    color: #166534;
}

.warning-status {
    background: #fef3c7;
    color: #92400e;
}

.error-status {
    background: #fee2e2;
    color: #991b1b;
}

.balance-stale {
    background: #fffbeb;
}

.balance-error {
    color: #92400e;
    font-size: 11px;
    margin-top: 5px;
    max-width: 220px;
}

.balance-footnote {
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
    margin: 12px 0 0;
}

.compact-control {
    min-width: 130px;
    width: 100%;
}

.note-input {
    border: 1px solid #b9c3d1;
    border-radius: 6px;
    font: inherit;
    min-width: 190px;
    padding: 8px 10px;
    resize: vertical;
    width: 100%;
}

.notice {
    border-radius: 6px;
    margin: 0 0 16px;
    padding: 10px 12px;
}

.success {
    background: #e7f6ec;
    color: #17663a;
}

.error-notice {
    background: #fdecec;
    color: #b42318;
}

.pill {
    background: #e8eef7;
    border-radius: 999px;
    display: inline-block;
    font-size: 13px;
    margin: 2px 4px 2px 0;
    padding: 3px 8px;
}

.login-page {
    align-items: center;
    display: flex;
    min-height: 100vh;
    justify-content: center;
    padding: 24px;
}

.pagination {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: center;
    padding-top: 18px;
}

.login-panel {
    background: #ffffff;
    border: 1px solid #dfe5ee;
    border-radius: 8px;
    max-width: 380px;
    padding: 28px;
    width: 100%;
}

.login-panel form {
    display: grid;
    gap: 16px;
}

@media (max-width: 760px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .transaction-filter,
    .transaction-query-filter,
    .user-main-fields,
    .fieldset-grid,
    .dictionary-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-heading,
    .nav-links {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding-bottom: 12px;
        padding-top: 12px;
    }

    .table-toolbar,
    .table-options {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .table-options {
        display: grid;
        grid-template-columns: 1fr 72px 1fr auto;
    }

    .transaction-table-scroll {
        max-height: 70vh;
    }

    .wide-page {
        padding-left: 0;
        padding-right: 0;
        width: 95%;
    }

    .transaction-export-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .excel-export-button {
        justify-content: center;
        width: 100%;
    }

    .balance-heading {
        align-items: stretch;
    }

    .balance-refresh {
        justify-content: center;
    }
}

@media (min-width: 761px) and (max-width: 1200px) {
    .transaction-query-filter {
        grid-template-columns: repeat(3, minmax(160px, 1fr));
    }
}
