@font-face {
    font-family: NotoSans;
    src: url('NotoSans-Regular.woff') format('woff');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: NotoSans;
    src: url('NotoSans-Medium.woff') format('woff');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: NotoSans;
    src: url('NotoSans-Bold.woff') format('woff');
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: NotoMono;
    src: url('NotoMono.woff') format('woff');
    font-display: swap;
}

:root {
    --color-bg: #634ea2;
    --color-bg-dark: #322853;
    --color-bg-form: #43356d;
    --color-text: #eee;
    --color-text-dim: #d7d7d7;
    --color-text-dark: #000;
    --color-accent: #f3c523;
    --color-accent-hover: #43acc9;
    --color-accent-dark: #e6514d;
    --color-success: #94c535;

    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;

    --shadow-sm: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.15);
    --shadow-md: 0 0.25rem 1rem rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 0.5rem 2rem rgba(0, 0, 0, 0.3);
}

*,
*:before,
*:after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100%;
    font-family: NotoSans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

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

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    background: var(--color-bg);
}

/* Header */

.app-header {
    flex: 0 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-bg-dark);
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    z-index: 20;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 87.5rem;
    margin: auto;
}

.app-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.03125rem;
}

.title-icon {
    font-size: 1.5rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-refresh {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    min-height: 2.625rem;
    padding: 0.5rem 0.8125rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text);
    transition:
        background 0.15s,
        border-color 0.15s,
        transform 0.1s;
}

.btn-refresh:active {
    transform: translateY(0.0625rem);
}

.refresh-menu {
    position: relative;
}

.refresh-menu-button {
    min-width: 7rem;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
    color: var(--color-text);
}

.refresh-menu-button:hover,
.refresh-menu-button[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
}

.refresh-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 100;
    display: none;
    width: 15rem;
    padding: 0.35rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    background: var(--color-bg-dark);
    box-shadow: var(--shadow-lg);
}

.refresh-menu.open .refresh-menu-dropdown {
    display: block;
}

.refresh-menu-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
}

.refresh-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.refresh-menu-item span {
    font-size: 0.8125rem;
    font-weight: 500;
}

.refresh-menu-item small {
    margin-top: 0.125rem;
    color: var(--color-text-dim);
    font-size: 0.6875rem;
}

.refresh-menu-button.refreshing .refresh-indicator {
    opacity: 1;
    background: var(--color-accent);
    animation: pulse 1.5s ease-in-out infinite;
}

.btn-refresh-latest {
    background: rgba(243, 197, 35, 0.16);
    border-color: rgba(243, 197, 35, 0.45);
    color: var(--color-accent);
}

.btn-refresh-latest:hover {
    background: rgba(243, 197, 35, 0.25);
    border-color: rgba(243, 197, 35, 0.7);
}

.btn-refresh-olympiad {
    background: rgba(148, 197, 53, 0.14);
    border-color: rgba(148, 197, 53, 0.4);
    color: var(--color-success);
}

.btn-refresh-olympiad:hover {
    background: rgba(148, 197, 53, 0.22);
    border-color: rgba(148, 197, 53, 0.65);
}

.btn-refresh-full {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
    color: var(--color-text-dim);
}

.btn-refresh-full:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--color-text);
}

.refresh-icon {
    font-size: 1.1875rem;
    line-height: 1;
    font-weight: 400;
}

.btn-refresh.refreshing .refresh-icon {
    animation: spin-refresh 1s linear infinite;
}

@keyframes spin-refresh {
    to {
        transform: rotate(360deg);
    }
}

.refresh-indicator {
    position: absolute;
    top: 0.3125rem;
    right: 0.3125rem;
    width: 0.5rem;
    height: 0.5rem;
    border: 1px solid var(--color-bg-dark);
    border-radius: 50%;
    opacity: 0;
    background: transparent;
}

.refresh-indicator.active {
    opacity: 1;
    background: var(--color-accent);
    animation: pulse 1.5s ease-in-out infinite;
}

.refresh-indicator.error {
    opacity: 1;
    background: var(--color-accent-dark);
}

@keyframes pulse {
    50% {
        opacity: 0.45;
    }
}

.btn-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.625rem;
    height: 2.625rem;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
    cursor: pointer;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Main layout */

.app-main {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 87.5rem;
    margin: auto;
    padding: var(--spacing-lg);
    gap: var(--spacing-lg);
    overflow: hidden;
}

.search-panel {
    display: flex;
    flex-direction: column;
    flex: 0 0 20rem;
    min-height: 0;
    background: var(--color-bg-dark);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.panel-header {
    flex: 0 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0;
    border: 0;
    background: 0;
    color: var(--color-text);
    font-weight: 600;
    cursor: pointer;
}

.toggle-arrow {
    transition: transform 0.25s;
}

.panel-toggle.collapsed .toggle-arrow {
    transform: rotate(-90deg);
}

.panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--spacing-lg);
}

.panel-body.collapsed {
    display: none;
}

/* Search mode */

.search-mode-toggle {
    display: flex;
    gap: 0.25rem;
    margin-bottom: var(--spacing-lg);
    padding: 0.25rem;
    background: var(--color-bg-form);
    border-radius: var(--radius-md);
}

.mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 2.5rem;
    flex: 1;
    padding: 0.5rem 0.625rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-dim);
    cursor: pointer;
}

.mode-btn.active {
    background: var(--color-accent);
    color: var(--color-text-dark);
    box-shadow: var(--shadow-sm);
}

/* Form */

.search-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    min-width: 0;
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-dim);
}

.form-input {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.625rem 0.875rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    outline: 0;
    background: var(--color-bg-form);
    color: var(--color-text);
}

.form-input:focus {
    border-color: var(--color-accent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.btn-primary,
.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.5rem 1.125rem;
    border: 0;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.btn-primary {
    flex: 1;
    background: var(--color-accent);
    color: var(--color-text-dark);
    font-weight: 600;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text);
}

.loading-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-dim);
    font-size: 0.875rem;
}

.loading-indicator.active {
    display: flex;
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.batch-input {
    min-height: 9.375rem;
    resize: vertical;
    font-family: NotoMono, monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--color-text-dim);
    opacity: 0.7;
}

.batch-stats {
    display: flex;
    gap: var(--spacing-lg);
    font-size: 0.8125rem;
    color: var(--color-text-dim);
}

.panel-footer {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.update-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.update-label {
    font-size: 0.75rem;
    color: var(--color-text-dim);
    opacity: 0.7;
}

.update-time {
    font-size: 0.8125rem;
}

/* Results */

.results-panel {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: rgba(50, 40, 83, 0.45);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    flex: 0 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-bg-dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.results-header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 0;
}

.results-title {
    font-size: clamp(1rem, 0.92rem + 0.4vw, 1.125rem);
}

.results-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    padding: 0.125rem 0.4375rem;
    border-radius: 1.25rem;
    background: var(--color-accent);
    color: var(--color-text-dark);
    font-size: 0.8125rem;
}

.batch-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 1.25rem;
    background: rgba(243, 197, 35, 0.15);
    color: var(--color-accent);
}

.results-header-right {
    display: flex;
    gap: 0.5rem;
}

.btn-export {
    min-height: 2.5rem;
    padding: 0.4375rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
    cursor: pointer;
    transition:
        background 0.15s,
        border-color 0.15s,
        color 0.15s,
        transform 0.1s;
}

.btn-export:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--color-text);
}

.btn-export:active {
    transform: translateY(0.0625rem);
}

.results-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--spacing-lg);
}

/* Result card */

.result-card {
    margin-bottom: var(--spacing-md);
    border-radius: var(--radius-md);
    background: var(--color-bg-dark);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.card-number {
    font-weight: 700;
}

.card-status {
    font-size: clamp(0.75rem, 0.73rem + 0.12vw, 0.8125rem);
}

.card-source {
    margin-left: auto;
    font-size: clamp(0.6875rem, 0.68rem + 0.08vw, 0.75rem);
    color: var(--color-text-dim);
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-body {
    padding: var(--spacing-md);
}

.card-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-row {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    width: max-content;
    max-width: 100%;
}

.field-label {
    font-size: clamp(0.8125rem, 0.78rem + 0.2vw, 0.875rem);
    color: var(--color-text-dim);
    flex: 0 0 auto;
    padding-top: 0.3125rem;
}

.field-value {
    min-width: 0;
    max-width: 100%;
}

.field-value code {
    display: inline-block;
    width: max-content;
    max-width: 100%;
    padding: 0.375rem 0.5625rem;
    border-radius: 0.375rem;
    background: rgba(48, 50, 69, 0.8);
    font-family: NotoMono, monospace;
    font-size: clamp(0.875rem, 0.82rem + 0.35vw, 1rem);
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: normal;
    cursor: pointer;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: var(--spacing-md);
}

.btn-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.4375rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(243, 197, 35, 0.12);
    color: var(--color-accent);
    text-decoration: none;
}

.not-found-text {
    margin-top: 0.3125rem;
    color: var(--color-text-dim);
    font-size: clamp(0.75rem, 0.73rem + 0.12vw, 0.8125rem);
}

/* Empty / placeholder */

.results-placeholder,
.results-empty {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    color: var(--color-text-dim);
    padding: 2.5rem;
}

.placeholder-icon,
.empty-icon {
    font-size: 2.625rem;
}

.results-placeholder h3,
.results-empty h3 {
    color: var(--color-text);
}

/* Navigation */

.nav-controls {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    display: none;
    gap: 0.5rem;
    z-index: 30;
}

.nav-controls.visible {
    display: flex;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 50%;
    background: var(--color-bg-dark);
    color: var(--color-text);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    font-size: 1.5rem;
}

/* Toast */

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    z-index: 9999;
    padding: 1.25rem 2rem;
    border-radius: 0.75rem;
    background: rgba(20, 23, 28, 0.9);
    backdrop-filter: blur(0.75rem);
    -webkit-backdrop-filter: blur(0.75rem);
    color: var(--color-text);
    box-shadow: 0 0.5rem 2.5rem rgba(0, 0, 0, 0.5);
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
    opacity: 0;
    font-size: 1.125rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: NotoSans, -apple-system, BlinkMacSystemFont, sans-serif;
}

.toast-in {
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast-out {
    animation: toastOut 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* Desktop */

@media (min-width: 64.0625rem) {
    .search-panel {
        width: 20rem;
    }
}

/* Tablet */

@media (max-width: 64rem) {
    .app-main {
        padding: 1rem;
        gap: 1rem;
    }

    .search-panel {
        flex-basis: 17.5rem;
    }
}

/* Mobile */

@media (max-width: 48rem) {
    .app-header {
        padding: 0.625rem 0.75rem;
    }

    .header-content {
        gap: 0.75rem;
    }

    .app-title {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 1.0625rem;
    }

    .header-actions {
        flex: 0 0 auto;
    }

    .title-icon {
        font-size: 1.25rem;
    }

    .btn-icon {
        width: 2.625rem;
        height: 2.625rem;
    }

    .app-main {
        display: flex;
        flex-direction: column;
        padding: 0.625rem;
        gap: 0.625rem;
        overflow: hidden;
    }

    .search-panel {
        flex: 0 0 auto;
        width: 100%;
        max-height: 48vh;
        border-radius: 0.875rem;
    }

    .search-panel.collapsed {
        max-height: none;
    }

    .panel-header {
        padding: 0.6875rem 0.875rem;
    }

    .panel-body {
        padding: 0.875rem;
    }

    .panel-body.collapsed {
        display: none;
    }

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

    .results-panel {
        flex: 1;
        min-height: 0;
        border-radius: 0.875rem;
    }

    .results-header {
        padding: 0.625rem 0.75rem;
    }

    .results-title {
        font-size: 1rem;
    }

    .results-list {
        padding: 0.625rem;
    }

    .field-row {
        width: max-content;
        max-width: 100%;
        gap: 0.625rem;
    }

    .field-label {
        padding-top: 0.25rem;
    }

    .field-value code {
        font-size: 0.875rem;
    }

    .card-source {
        max-width: 35%;
    }

    .nav-controls {
        right: 0.75rem;
        bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .nav-btn {
        width: 2.625rem;
        height: 2.625rem;
    }

    .results-list {
        padding-bottom: 4.375rem;
    }

    .btn-export {
        min-height: 2.5rem;
    }

    .panel-footer {
        margin-top: 0.875rem;
    }

    .toast {
        font-size: 0.9375rem;
        padding: 0.875rem 1.25rem;
        max-width: 85vw;
        border-radius: 0.625rem;
    }
}

/* Small mobile */

/* Consolidated layout rules */
.results-placeholder .placeholder-text-desktop {
    display: block
}

.results-placeholder .placeholder-text-mobile {
    display: none
}

@media (min-width:769px) {
    .search-panel {
        align-self: stretch;
        height: auto;
        max-height: none
    }

    .search-panel .panel-body {
        flex: 1 1 auto;
        max-height: none;
        overflow-y: auto
    }
}

/* Keep the search and results headers as one compact continuous row. */
.panel-header,
.results-header {
    height: 4.5rem;
    min-height: 4.5rem;
    display: flex;
    align-items: center;
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-md);
}

.results-header {
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .12)
}

.app-main.sidebar-collapsed .results-header {
    padding-left: 4.5rem
}

.has-input-clear {
    position: relative
}

.has-input-clear .form-input {
    padding-right: 2.5rem
}

.input-clear {
    position: absolute;
    right: .45rem;
    bottom: .38rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-dim);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: background .15s, color .15s, opacity .15s
}

.input-clear.visible {
    opacity: .75;
    pointer-events: auto
}

.input-clear:hover {
    background: rgba(255, 255, 255, .1);
    color: var(--color-text)
}

.search-highlight {
    padding: 0;
    background: transparent;
    color: var(--color-success);
    font-weight: 700
}

.nav-btn {
    background: var(--color-bg-dark);
    border: 1px solid rgba(243, 197, 35, .42);
    color: var(--color-accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .22)
}

.nav-btn:hover {
    background: rgba(243, 197, 35, .18);
    border-color: rgba(243, 197, 35, .68);
    color: var(--color-text);
    transform: translateY(-1px)
}

.nav-btn:active {
    background: rgba(243, 197, 35, .24);
    transform: translateY(1px)
}

/* Compact FIO row: each name part stays independently copyable; full-name copy stays next to it. */
.fio-group {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    min-width: 0
}

.fio-label {
    flex: 0 0 auto
}

.fio-value {
    display: flex !important;
    align-items: center;
    justify-content: flex-start !important;
    gap: .35rem;
    width: auto !important;
    max-width: 100%;
    min-width: 0;
    flex: 0 1 auto;
    flex-wrap: wrap
}

.fio-value .copyable {
    cursor: pointer
}

.copy-full-name {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2rem;
    width: 2rem;
    height: 2rem;
    margin-left: .15rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: .5rem;
    background: rgba(255, 255, 255, .05);
    color: var(--color-text-dim);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .1s
}

.copy-full-name:hover {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(243, 197, 35, .45);
    color: var(--color-accent)
}

.copy-full-name:active {
    transform: translateY(1px)
}

.copy-full-name svg {
    pointer-events: none
}

.db-info,
.refresh-history-block {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(255, 255, 255, .05)
}

.db-info-title {
    margin-bottom: .5rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--color-text-dim);
    opacity: .85;
    text-transform: uppercase;
    letter-spacing: .025em
}

.db-info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem
}

.db-info-grid>div {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0
}

.db-info-grid span {
    font-size: .68rem;
    color: var(--color-text-dim);
    opacity: .7
}

.db-info-grid strong {
    font-size: .8rem;
    color: var(--color-text)
}

.refresh-history {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    max-height: 10rem;
    overflow-y: auto;
    padding-right: .15rem
}

.history-row {
    padding: .45rem .5rem;
    border-radius: .45rem;
    background: rgba(255, 255, 255, .035)
}

.history-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem
}

.history-operation {
    font-size: .72rem;
    color: var(--color-text)
}

.history-status {
    font-size: .66rem;
    font-weight: 600
}

.history-status.success {
    color: var(--color-success)
}

.history-status.error {
    color: var(--color-accent-dark)
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .55rem;
    margin-top: .15rem;
    font-size: .62rem;
    color: var(--color-text-dim);
    opacity: .7
}

.history-empty {
    font-size: .68rem;
    line-height: 1.35;
    color: var(--color-text-dim);
    opacity: .65
}

@media (max-width:768px) {
    .results-placeholder .placeholder-text-desktop {
        display: none
    }

    .results-placeholder .placeholder-text-mobile {
        display: block
    }

    .db-info-grid {
        gap: .35rem
    }

    .db-info-grid strong {
        font-size: .74rem
    }

    .refresh-history {
        max-height: 8rem
    }

    .fio-group {
        gap: .5rem
    }

    .fio-value {
        max-width: 100%;
    }

    .copy-full-name {
        width: 1.9rem;
        height: 1.9rem;
        flex-basis: 1.9rem
    }
}

/* Desktop layout polish: align the header with the same content grid as the main area. */
:root {
    --content-max-width: 87.5rem;
    --content-inline-padding: var(--spacing-lg);
}

@media (min-width:769px) {
    .app-header {
        padding-left: var(--content-inline-padding);
        padding-right: var(--content-inline-padding);
        padding-top: .625rem;
        padding-bottom: .625rem;
    }

    .header-content {
        max-width: none;
        margin: 0;
    }

    .btn-refresh,
    .btn-icon {
        min-height: 2.375rem;
    }

    .btn-icon {
        width: 2.375rem;
        height: 2.375rem;
    }
}

@media (min-width:769px) and (max-width:64rem) {
    :root {
        --content-inline-padding: 1rem
    }
}

/* Desktop result cards: keep the same one-column field layout as mobile. */
@media (min-width:769px) {
    .results-list {
        padding: 1rem 1rem 1.5rem;
    }

    .result-card {
        margin-bottom: .75rem;
    }

    .card-header {
        padding: .5rem .875rem;
        justify-content: flex-start;
        gap: .75rem;
    }

    .card-body {
        padding: .875rem 1rem 1rem;
    }

    .card-fields {
        display: flex;
        flex-direction: column;
        gap: .5rem;
    }

    .field-row {
        display: grid;
        grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr);
        align-items: center;
        width: 100%;
        max-width: 100%;
        gap: .75rem;
        padding: .2rem .35rem;
        margin: -.2rem -.35rem;
        border-radius: .4rem;
        transition: none;
    }

    /* Hover belongs to the copyable value badge, not to the whole field row. */
    .field-row:hover {
        background: transparent !important;
        transform: none !important;
        box-shadow: none !important;
    }

    .field-label {
        padding-top: 0;
        line-height: 1.35;
    }

    .field-value {
        min-width: 0;
        max-width: 100%;
    }

    .field-value code {
        max-width: 100%;
    }

    .card-actions {
        margin-top: .875rem;
    }

    /* For found records the source replaces the redundant "Найдено" label. */
    .card-header .card-status.status-found {
        display: none;
    }

    .card-source {
        margin-left: 0;
        color: var(--color-accent);
        font-weight: 600;
    }
}

/* Use one shared grid boundary for every result field, including the compact FIO row. */
.result-card.found .fio-row {
    display: grid !important;
    grid-template-columns: minmax(6.5rem, max-content) max-content auto !important;
    align-items: center;
    gap: .75rem;
    width: max-content !important;
    max-width: 100% !important;
}

.result-card.found .fio-row>.field-label {
    grid-column: 1;
    min-width: 0;
}

.result-card.found .fio-row>.fio-values {
    grid-column: 2;
    min-width: 0;
    max-width: 100%;
    width: auto;
    flex: none;
}

.result-card.found .fio-row>.fio-copy-btn {
    grid-column: 3;
}

/* Keep the same alignment on narrow screens. */
@media (max-width:768px) {
    .result-card.found .fio-row {
        grid-template-columns: minmax(6.5rem, max-content) max-content auto !important;
        gap: .5rem;
        width: max-content !important;
        max-width: 100% !important;
    }
}


/* Mobile header: title on its own row, action buttons on the row below. */
@media (max-width:768px) {
    .app-header {
        height: auto !important;
        min-height: 0 !important;
        padding: .75rem .75rem .65rem !important;
    }

    .app-header .header-content {
        width: 100%;
        max-width: none;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: .65rem;
    }

    .app-header .app-title {
        margin: 0;
        width: 100%;
        line-height: 1.05;
    }

    .app-header .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 3rem;
        align-items: stretch;
        gap: .5rem;
    }

    .app-header .header-actions .btn-refresh,
    .app-header .header-actions .btn-icon {
        width: 100%;
        min-width: 0;
        min-height: 2.75rem;
        height: 2.75rem;
    }

    .app-header .header-actions .btn-icon {
        width: 2.75rem;
        justify-self: end;
    }

    .app-header .header-actions .refresh-label-short {
        white-space: nowrap;
    }

    /* Keep the buttons compact enough for narrow phones. */
    .app-header .refresh-icon {
        flex: 0 0 auto;
    }
}

/* Mobile source badge: show the current source without letting it collide with the card header. */
@media (max-width:768px) {
    .card-header {
        min-width: 0;
        gap: .45rem;
    }

    .card-header .card-source-group {
        min-width: 0;
        max-width: calc(100vw - 8rem);
    }

    .card-header .card-source-item {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: .78rem;
        line-height: 1.2;
        padding: .18rem .4rem;
    }

    .card-header .card-source-item::before {
        font-size: .78rem;
    }
}