/* =============================================================
 * SMARTPATENT — PROFESSIONAL DARK DESIGN SYSTEM v2
 * Dark + Glassmorphism + Accent Blue
 * Responsive: 320 / 480 / 768 / 1024 / 1280px
 * ============================================================= */

:root {
    /* Backgrounds */
    --bg-primary:    #080a12;
    --bg-secondary:  #0e1018;
    --bg-tertiary:   #141720;
    --bg-elevated:   #1a1e2e;

    /* Borders */
    --border-color:  rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);
    --border-focus:  #4f8bff;

    /* Text */
    --text-primary:   #f0f4ff;
    --text-secondary: #8b96b0;
    --text-muted:     #4a5368;

    /* Accent */
    --accent:        #4f8bff;
    --accent-hover:  #3a75f0;
    --accent-glow:   rgba(79, 139, 255, 0.18);
    --accent-subtle: rgba(79, 139, 255, 0.08);

    /* Status */
    --status-active-bg:   rgba(34, 197, 94, 0.12);
    --status-active-text: #4ade80;
    --status-active-border: rgba(34, 197, 94, 0.35);

    --status-pending-bg:   rgba(245, 158, 11, 0.12);
    --status-pending-text: #fbbf24;
    --status-pending-border: rgba(245, 158, 11, 0.35);

    --status-applied-bg:   rgba(167, 139, 250, 0.12);
    --status-applied-text: #c4b5fd;
    --status-applied-border: rgba(167, 139, 250, 0.35);

    --status-expired-bg:   rgba(100, 116, 139, 0.10);
    --status-expired-text: #64748b;
    --status-expired-border: rgba(100, 116, 139, 0.25);

    /* Glass effect */
    --glass-bg:          rgba(255, 255, 255, 0.04);
    --glass-border:      rgba(255, 255, 255, 0.08);
    --dropdown-bg:       #1a1d2e;
    --subs-item-bg:      rgba(255, 255, 255, 0.06);
    --subs-item-bg-hover:rgba(255, 255, 255, 0.10);

    /* Shadows */
    --shadow-card:   0 2px 12px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-color);
    --shadow-hover:  0 4px 20px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-strong), 0 0 16px var(--accent-glow);
    --shadow-modal:  0 24px 64px rgba(0, 0, 0, 0.7);

    /* Radius */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;

    /* Modal backdrop */
    --modal-backdrop: rgba(7, 9, 18, 0.88);

    /* Fonts */
    --font-heading: 'Plus Jakarta Sans', 'Outfit', sans-serif;
    --font-pixel:   'Press Start 2P', 'VT323', monospace;
    --font-body:    'Inter', sans-serif;

    /* Transitions */
    --transition-fast: 0.12s ease;
    --transition-med:  0.22s ease;
}

/* Light Theme */
body.light-theme {
    --bg-primary:    #f4f6fb;
    --bg-secondary:  #ffffff;
    --bg-tertiary:   #edf0f7;
    --bg-elevated:   #ffffff;

    --border-color:  rgba(15, 23, 42, 0.10);
    --border-strong: rgba(15, 23, 42, 0.22);
    --border-focus:  #2563eb;

    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-muted:     #94a3b8;

    --accent:        #2563eb;
    --accent-hover:  #1d4ed8;
    --accent-glow:   rgba(37, 99, 235, 0.15);
    --accent-subtle: rgba(37, 99, 235, 0.06);

    --glass-bg:          rgba(255, 255, 255, 0.7);
    --glass-border:      rgba(15, 23, 42, 0.08);
    --dropdown-bg:       #ffffff;
    --subs-item-bg:      rgba(15, 23, 42, 0.04);
    --subs-item-bg-hover:rgba(15, 23, 42, 0.07);

    --shadow-card:   0 1px 8px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--border-color);
    --shadow-hover:  0 4px 16px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--border-strong);
    --shadow-modal:  0 24px 64px rgba(15, 23, 42, 0.25);

    --modal-backdrop: rgba(15, 23, 42, 0.6);

    --status-active-bg:   rgba(22, 163, 74, 0.08);
    --status-active-text: #16a34a;
    --status-active-border: rgba(22, 163, 74, 0.25);

    --status-pending-bg:   rgba(217, 119, 6, 0.08);
    --status-pending-text: #b45309;
    --status-pending-border: rgba(217, 119, 6, 0.25);

    --status-applied-bg:   rgba(124, 58, 237, 0.08);
    --status-applied-text: #7c3aed;
    --status-applied-border: rgba(124, 58, 237, 0.25);

    --status-expired-bg:   rgba(100, 116, 139, 0.08);
    --status-expired-text: #64748b;
    --status-expired-border: rgba(100, 116, 139, 0.20);
}

/* =============================================================
 * RESET & BASE
 * ============================================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent horizontal scroll at root level */
html {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    line-height: 1.55;
    transition: background-color var(--transition-med), color var(--transition-med);
    font-size: 16px;
}

/* Background gradient blobs */
body::before {
    content: "";
    position: fixed;
    top: -10vh;
    right: -10vw;
    left: auto;
    width: 70vw;
    height: 70vh;
    background: radial-gradient(ellipse at center, rgba(79, 139, 255, 0.09) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: "";
    position: fixed;
    bottom: 0;
    left: -10vw;
    width: 60vw;
    height: 60vh;
    background: radial-gradient(ellipse at center, rgba(139, 92, 246, 0.06) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
}

body.light-theme::before {
    background: radial-gradient(ellipse at center, rgba(37, 99, 235, 0.05) 0%, transparent 65%);
}

body.light-theme::after {
    background: radial-gradient(ellipse at center, rgba(139, 92, 246, 0.03) 0%, transparent 65%);
}

/* =============================================================
 * HEADER
 * ============================================================= */
.main-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(8, 10, 18, 0.75);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 1px 0 rgba(79, 139, 255, 0.1), 0 4px 24px rgba(0, 0, 0, 0.3);
}

body.light-theme .main-header {
    background: rgba(244, 246, 251, 0.8);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 1px 0 rgba(37, 99, 235, 0.08), 0 4px 24px rgba(15, 23, 42, 0.06);
}

.header-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.85rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-icon {
    width: 20px;
    height: 20px;
    color: var(--accent);
    flex-shrink: 0;
}

.logo-text {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
}

/* Short word in the chunky display pixel font — Press Start 2P is wide,
   so it only works at this size for 3 letters, not the full wordmark */
.logo-bit {
    font-family: 'Press Start 2P', var(--font-pixel);
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

/* Longer word in the thinner terminal pixel font — reads cleanly at a larger size */
.logo-patent {
    font-family: 'VT323', var(--font-pixel);
    font-weight: 400;
    font-size: 1.55rem;
    letter-spacing: 0.5px;
    line-height: 1;
    color: var(--accent);
    text-shadow: 0 0 12px rgba(79, 139, 255, 0.5);
}

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

.theme-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.theme-btn svg { width: 16px; height: 16px; }

body.dark-theme .sun-icon  { display: block; }
body.dark-theme .moon-icon { display: none; }
body.light-theme .sun-icon  { display: none; }
body.light-theme .moon-icon { display: block; }

/* Glow background elements (decorative) */
/* Contained within viewport — no overflow-x bleed */
.glow-bg {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
    opacity: 0.22;
    max-width: 50vw;
    overflow: hidden;
}
.glow-bg.bg-1 {
    width: 480px; height: 480px;
    background: radial-gradient(circle, rgba(79,139,255,0.28) 0%, transparent 70%);
    top: -120px;
    right: 0;           /* flush — no negative right */
    transform: translateX(30%);  /* partial bleed via transform (doesn't cause scroll) */
}
.glow-bg.bg-2 {
    width: 360px; height: 360px;
    background: radial-gradient(circle, rgba(139,92,246,0.14) 0%, transparent 70%);
    bottom: 8%;
    left: 0;
    transform: translateX(-30%); /* partial bleed via transform */
}
body.light-theme .glow-bg { opacity: 0.10; }

/* =============================================================
 * APP CONTAINER & HERO
 * ============================================================= */
.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 3.5rem 2rem 6rem;
    position: relative;
    z-index: 1;
}

.hero-section {
    text-align: center;
    margin-bottom: 3rem;
}

.hero-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(1.75rem, 4vw, 2.85rem);
    margin-bottom: 0.85rem;
    letter-spacing: -0.5px;
    line-height: 1.15;
}

.hero-title-accent {
    color: var(--accent);
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 1.5vw, 1.05rem);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Hero badge */
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.85rem;
    background: rgba(79, 139, 255, 0.08);
    border: 1px solid rgba(79, 139, 255, 0.2);
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.02em;
    margin-bottom: 1rem;
    font-family: var(--font-heading);
}

body.light-theme .hero-badge {
    background: rgba(37, 99, 235, 0.06);
    border-color: rgba(37, 99, 235, 0.18);
}

/* Hero gradient text */
.hero-gradient-text {
    background: linear-gradient(135deg, #4f8bff 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =============================================================
 * SEARCH CARD
 * ============================================================= */
.search-card-container {
    margin-bottom: 2.5rem;
}

.search-card {
    background: rgba(14, 16, 24, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: 0 0 0 1px rgba(79, 139, 255, 0.05), 0 8px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.light-theme .search-card {
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.04), 0 8px 40px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Tabs */
.search-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.tab-btn.active {
    background: rgba(79, 139, 255, 0.1);
    color: var(--accent);
    box-shadow: 0 0 0 1px rgba(79, 139, 255, 0.2);
    text-shadow: 0 0 12px rgba(79, 139, 255, 0.3);
}

body.light-theme .tab-btn.active {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
    text-shadow: none;
}

.tab-icon { width: 16px; height: 16px; flex-shrink: 0; }

/* Search Input Row */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

#search-input {
    width: 100%;
    padding: 1rem 3.5rem 1rem 3rem;
    background: rgba(8, 10, 18, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.02rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    outline: none;
}

#search-input::placeholder { color: var(--text-muted); }

#search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 139, 255, 0.15), 0 0 30px rgba(79, 139, 255, 0.08);
    background: rgba(8, 10, 18, 0.9);
}

body.light-theme #search-input {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(15, 23, 42, 0.12);
}

body.light-theme #search-input:focus {
    background: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-input-wrapper:focus-within .search-icon {
    color: var(--accent);
    transition: color 0.2s ease;
}

.clear-btn {
    position: absolute;
    right: 0.85rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.clear-btn:hover { color: var(--text-primary); }
.clear-btn svg { width: 16px; height: 16px; }

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.7rem 1.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.btn:active { opacity: 0.85; transform: translateY(1px); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-secondary { background: var(--bg-tertiary); }

.btn-icon, .btn-icon-right { width: 16px; height: 16px; }

/* =============================================================
 * FILTERS PANEL
 * ============================================================= */
.filters-panel {
    border-top: 1px solid var(--border-color);
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
}

.filters-row--dates {
    gap: 0.75rem;
}

.filters-row--patent-extra {
    gap: 0.75rem;
}

.filter-group {
    flex: 1 1 200px;
    min-width: 0;
    background: rgba(20, 23, 32, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-group:focus-within {
    border-color: rgba(79, 139, 255, 0.25);
    box-shadow: 0 0 0 3px rgba(79, 139, 255, 0.06);
}

body.light-theme .filter-group {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(15, 23, 42, 0.08);
}

body.light-theme .filter-group:focus-within {
    border-color: rgba(37, 99, 235, 0.25);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.06);
}

.filter-group--wide {
    flex: 2 1 300px;
}

.filter-label {
    display: block;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

/* Legacy: filter-group label without .filter-label */
.filter-group label:not(.filter-label):not(.checkbox-label) {
    display: block;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

/* Handled by .filter-label above */

.filter-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Quick Class Tags */
.quick-class-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.quick-class-tag {
    background: rgba(79, 139, 255, 0.07);
    border: 1px solid rgba(79, 139, 255, 0.18);
    color: var(--text-secondary);
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    padding: 0.22rem 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    line-height: 1.5;
}

.quick-class-tag:hover {
    background: rgba(79, 139, 255, 0.14);
    border-color: rgba(79, 139, 255, 0.4);
    color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79, 139, 255, 0.08);
}

.quick-class-tag.selected {
    background: rgba(79, 139, 255, 0.18);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79, 139, 255, 0.12);
}

body.light-theme .quick-class-tag {
    background: rgba(37, 99, 235, 0.05);
    border-color: rgba(37, 99, 235, 0.18);
}

body.light-theme .quick-class-tag:hover,
body.light-theme .quick-class-tag.selected {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.45);
}

/* Status Checkboxes */
.status-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: color var(--transition-fast);
}

.checkbox-label:hover { color: var(--text-primary); }

.checkbox-label input {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: var(--bg-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.checkbox-label input:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-label input:checked::after {
    content: "";
    position: absolute;
    width: 9px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translate(0, -1px);
}

/* =============================================================
 * INVENTION TYPE & PRESETS
 * ============================================================= */
/* .invention-type-row removed — filter-groups now live inside .filters-row */

#filter-invention-type {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#filter-invention-type:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.patent-presets {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
    flex-wrap: wrap;
}

.presets-label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preset-btn {
    background: var(--accent-subtle);
    border: 1px solid rgba(79, 139, 255, 0.25);
    color: var(--accent);
    padding: 0.3rem 0.7rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    border-radius: 99px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.preset-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Checkbox row for international */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

/* =============================================================
 * STATS BAR & STATES
 * ============================================================= */
.results-section { position: relative; }

.search-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
}

.stats-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.text-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.42rem 0.8rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.text-link-btn:hover {
    background: var(--accent-subtle);
    border-color: rgba(79, 139, 255, 0.3);
    color: var(--accent);
}

/* "Сбросить все" is a secondary/destructive action — keep it visually quieter
   than the export/compare actions, separated by a divider */
#reset-search-btn {
    background: none;
    border: none;
    border-left: 1px solid var(--border-color);
    border-radius: 0;
    padding: 0.42rem 0 0.42rem 0.85rem;
    margin-left: 0.2rem;
    text-decoration: underline;
    text-decoration-color: transparent;
}

#reset-search-btn:hover {
    background: none;
    text-decoration-color: currentColor;
    color: var(--accent);
}

/* Loader */
.loader-container {
    text-align: center;
    padding: 4rem 1rem;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-container p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Empty & Error States */
.empty-container, .error-container {
    text-align: center;
    padding: 4rem 2rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
}

/* Error container — glassmorphism + red glow + entrance animation */
.error-container {
    border: 1px solid rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.03);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.06), 0 8px 32px rgba(0,0,0,0.25);
    animation: errorSlideIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes errorSlideIn {
    from { opacity: 0; transform: translateY(18px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Animated icon wrapper with pulse rings */
.error-icon-wrap {
    position: relative;
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.error-pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1.5px solid rgba(239, 68, 68, 0.35);
    animation: errorPulse 2.2s ease-out infinite;
}

.error-pulse-ring--delay { animation-delay: 1.1s; }

@keyframes errorPulse {
    0%   { transform: scale(0.8);  opacity: 1; }
    100% { transform: scale(1.65); opacity: 0; }
}

.empty-icon, .error-icon {
    width: 44px;
    height: 44px;
    color: var(--text-muted);
}

.error-icon {
    width: 34px;
    height: 34px;
    color: #ef4444;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.6));
    position: relative;
    z-index: 1;
}

/* Error HTTP status badge */
.error-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.5rem;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.28);
    color: #f87171;
    font-family: var(--font-mono, monospace);
}
.error-badge:empty { display: none; }

.empty-container h3, .error-container h3 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.35rem;
}

.error-container h3 { color: #fca5a5; }
body.light-theme .error-container h3 { color: #dc2626; }

.empty-container p, .error-container p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.55;
    max-width: 420px;
}

/* Auto-retry countdown pill */
.error-retry-countdown {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    padding: 0.28rem 0.75rem;
    border-radius: 99px;
    margin-top: 0.1rem;
}

.error-retry-countdown svg {
    animation: spinSlow 1.4s linear infinite;
    flex-shrink: 0;
    color: var(--accent);
}

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

/* Retry button */
.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(239, 68, 68, 0.09);
    border: 1px solid rgba(239, 68, 68, 0.32);
    color: #f87171;
    padding: 0.5rem 1.3rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    margin-top: 0.25rem;
}

.btn-retry:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

body.light-theme .error-container {
    background: rgba(254, 242, 242, 0.7);
    border-color: rgba(239, 68, 68, 0.22);
    box-shadow: 0 4px 24px rgba(239, 68, 68, 0.08);
}

body.light-theme .btn-retry { background: rgba(239,68,68,0.06); color: #dc2626; }
body.light-theme .btn-retry:hover { background: rgba(239,68,68,0.12); }

/* Respect motion preferences */
@media (prefers-reduced-motion: reduce) {
    .error-container { animation: none; }
    .error-pulse-ring { animation: none; opacity: 0.4; }
    .error-retry-countdown svg { animation: none; }
}

.example-searches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.example-searches span {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.example-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.6rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    border-radius: 99px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.example-btn:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

/* =============================================================
 * RESULTS GRID & CARDS
 * ============================================================= */
.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.25,0.46,0.45,0.94), box-shadow 0.22s ease, border-color 0.22s ease;
    overflow: hidden;
}

/* Dark mode: subtle gradient glass look */
body:not(.light-theme) .result-card {
    background: linear-gradient(145deg, rgba(20,23,34,0.92) 0%, rgba(14,16,24,0.96) 100%);
    border-color: rgba(255,255,255,0.07);
    box-shadow: 0 2px 14px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* Light mode: clean white card */
body.light-theme .result-card {
    background: #ffffff;
    border-color: rgba(15,23,42,0.09);
    box-shadow: 0 1px 8px rgba(15,23,42,0.07), 0 0 0 1px rgba(15,23,42,0.05);
}

.result-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent) 0%, rgba(167,139,250,0.7) 60%, transparent 100%);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.result-card:hover {
    border-color: rgba(79, 139, 255, 0.25);
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 14px 44px rgba(0,0,0,0.45), 0 0 0 1px rgba(79,139,255,0.2), 0 0 28px rgba(79,139,255,0.09);
}

body.light-theme .result-card:hover {
    border-color: rgba(37,99,235,0.3);
    box-shadow: 0 8px 32px rgba(15,23,42,0.12), 0 0 0 1px rgba(37,99,235,0.2), 0 0 20px rgba(37,99,235,0.06);
}

.result-card:hover::before { opacity: 1; }

.result-card:active { transform: translateY(-1px) scale(1); }

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header-left,
.card-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.doc-number {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.2rem 0.55rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.72rem;
    border-radius: 99px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
    flex-shrink: 0;
}

.status-badge.active {
    background: var(--status-active-bg);
    color: var(--status-active-text);
    border-color: var(--status-active-border);
}

.status-badge.pending {
    background: var(--status-pending-bg);
    color: var(--status-pending-text);
    border-color: var(--status-pending-border);
}

.status-badge.applied {
    background: var(--status-applied-bg);
    color: var(--status-applied-text);
    border-color: var(--status-applied-border);
}

.status-badge.expired {
    background: var(--status-expired-bg);
    color: var(--status-expired-text);
    border-color: var(--status-expired-border);
    text-decoration: line-through;
    opacity: 0.75;
}

/* Trademark Card */
.tm-card-body {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    flex-grow: 1;
    margin-bottom: 0.85rem;
}

.tm-logo-preview {
    width: 76px;
    height: 76px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.tm-logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.tm-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.18rem;
    line-height: 1.22;
    margin-bottom: 0.35rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tm-info { flex-grow: 1; min-width: 0; }
.patent-info { flex-grow: 1; margin-bottom: 0.85rem; }

/* Patent Card */
.patent-body-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex-grow: 1;
    margin-bottom: 0.85rem;
}

.patent-logo-preview {
    width: 80px;
    height: 80px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem;
    flex-shrink: 0;
}

.patent-logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.patent-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.35;
    margin-bottom: 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.owner-name {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.patent-reg-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.patent-abstract-snippet {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-top: 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card Footer */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    margin-top: auto;
    gap: 0.5rem;
}

.class-tags {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.class-tag {
    background: var(--accent-subtle);
    border: 1px solid rgba(79, 139, 255, 0.2);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    white-space: nowrap;
}

body.light-theme .class-tag {
    background: rgba(37, 99, 235, 0.06);
    border-color: rgba(37, 99, 235, 0.15);
}

.similarity-score {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.similarity-val {
    background: var(--accent-subtle);
    border: 1px solid rgba(79,139,255,0.28);
    color: var(--accent);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.85rem;
    padding: 0.18rem 0.6rem;
    border-radius: 8px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

body:not(.light-theme) .similarity-val {
    background: linear-gradient(135deg, rgba(79,139,255,0.14) 0%, rgba(167,139,250,0.12) 100%);
}

.patent-date-chip {
    background: rgba(139,92,246,0.08);
    border: 1px solid rgba(139,92,246,0.2);
    color: #7c3aed;
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 5px;
    white-space: nowrap;
}

body:not(.light-theme) .patent-date-chip {
    color: rgba(167,139,250,0.85);
    background: rgba(167,139,250,0.1);
    border-color: rgba(167,139,250,0.2);
}

/* Country Badge */
.country-badge {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    text-transform: uppercase;
}

/* Card Loading State */
.result-card.loading { pointer-events: none; }
.result-card.loading > * { filter: blur(2px); opacity: 0.5; }

.result-card.loading::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 26px; height: 26px;
    margin-top: -13px; margin-left: -13px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    z-index: 10;
}

/* Favorite Button */
.favorite-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 22px; height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 0.35rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.favorite-btn:hover { color: #fbbf24; }
.favorite-btn.active { color: #fbbf24; }
.favorite-btn svg { width: 14px; height: 14px; }
.favorite-btn.active svg { fill: currentColor; }

/* Compare Checkbox */
.compare-checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    background: var(--bg-tertiary);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.compare-checkbox:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.compare-checkbox:checked::after {
    content: "";
    position: absolute;
    top: 1px; left: 1px;
    width: 8px; height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
}

/* =============================================================
 * SEARCH HISTORY
 * ============================================================= */
.search-history {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.history-label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.history-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.history-tag {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.2rem 0.5rem;
    font-family: var(--font-body);
    font-size: 0.78rem;
    border-radius: 99px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-tag:hover {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
}

.history-clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.history-clear-btn:hover { color: var(--text-primary); }
.history-clear-btn svg { width: 14px; height: 14px; }

/* =============================================================
 * MODAL — DETAIL VIEW
 * ============================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-backdrop);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    overscroll-behavior: contain;
    touch-action: none;
}

.modal-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 820px;
    max-height: 92vh;
    max-height: 92dvh; /* accounts for mobile browser chrome resizing the visible viewport */
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.modal-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.modal-doc-type {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.4rem;
    line-height: 1.25;
}

.close-modal-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.close-modal-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.close-modal-btn svg { width: 16px; height: 16px; }

/* Modal Body */
.modal-body {
    padding: 1.5rem 1.75rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-layout {
    display: flex;
    gap: 2rem;
}

.modal-visual-area {
    width: 160px; height: 160px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    padding: 0.5rem;
}

.modal-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-details-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.details-section h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

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

.details-table th, .details-table td {
    padding: 0.45rem 0.25rem;
    text-align: left;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-color);
}

.details-table tr:last-child th,
.details-table tr:last-child td {
    border-bottom: none;
}

.details-table th {
    width: 42%;
    font-weight: 500;
    color: var(--text-muted);
}

.details-table td {
    color: var(--text-primary);
    font-weight: 600;
}

.mktu-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.25rem;
}

.modal-abstract-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
}

.modal-abstract-section h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.abstract-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    text-align: justify;
}

/* Modal Footer */
.modal-footer {
    padding: 1.1rem 1.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* =============================================================
 * FAVORITES HEADER BUTTON
 * ============================================================= */
.favorites-header-btn {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}

.favorites-header-btn:hover {
    background: var(--bg-elevated);
    color: #fbbf24;
    border-color: var(--border-strong);
}

.favorites-icon { width: 16px; height: 16px; }

.favorites-badge {
    position: absolute;
    top: -5px; right: -5px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.65rem;
    width: 17px; height: 17px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-primary);
}

/* =============================================================
 * FAVORITES MODAL
 * ============================================================= */
.favorites-modal-card { max-width: 720px; }

.favorites-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.favorites-table thead th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-strong);
}

.favorites-table tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.favorites-table tbody tr:hover td {
    background: var(--bg-tertiary);
}

.remove-fav-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0;
    transition: all var(--transition-fast);
}

.remove-fav-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* =============================================================
 * COMPARE VIEW
 * ============================================================= */
.compare-modal-card { max-width: 960px; }

.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.compare-col {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    min-width: 140px;
}

.compare-col-header {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    max-width: 260px;
}

.compare-row {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.compare-row strong {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
}

/* Export CSV button */
.export-csv-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.45rem 0.9rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.export-csv-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

/* =============================================================
 * ACCESSIBILITY
 * ============================================================= */
:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

/* =============================================================
 * RESPONSIVE — TABLET (≤ 1024px) — 2 колонки
 * ============================================================= */
@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .app-container {
        padding: 2.5rem 1.5rem 5rem;
    }

}


/* =============================================================
 * RESPONSIVE — MODAL STACK (≤ 820px)
 * ============================================================= */
@media (max-width: 820px) {
    .modal-layout {
        flex-direction: column;
        align-items: center;
        gap: 1.25rem;
    }

    .modal-visual-area {
        width: 100%;
        max-width: 180px;
        height: 180px;
    }
}

/* =============================================================
 * RESPONSIVE — MOBILE (≤ 768px) — 1 колонка
 * ============================================================= */
@media (max-width: 768px) {
    .app-container {
        padding: 2rem 1rem 4rem;
    }

    .search-card {
        padding: 1.25rem;
    }

    .filters-row {
        flex-direction: column;
    }

    /* No scale on touch — avoids jank on tap */
    .result-card:hover { transform: translateY(-2px); }
    .result-card:active { transform: none; }

    .filter-group,
    .filter-group--wide {
        flex: 1 1 100%;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-actions button {
        width: 100%;
        min-height: 48px;
    }

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

    .modal-overlay {
        padding: 0.5rem;
        align-items: flex-end;
    }

    .modal-card {
        max-height: 96vh;
        max-height: 96dvh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .modal-header, .modal-footer {
        padding: 0.85rem 1.1rem;
    }

    .modal-body {
        padding: 1rem 1.1rem;
    }

    .search-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* =============================================================
 * RESPONSIVE — SMALL MOBILE (≤ 480px)
 * ============================================================= */
@media (max-width: 480px) {
    .header-container {
        padding: 0.7rem 1rem;
    }

    .logo-bit {
        font-size: 0.68rem;
    }

    .logo-patent {
        font-size: 1.25rem;
    }

    .theme-btn, .favorites-header-btn {
        width: 34px;
        height: 34px;
    }

    /* Hero */
    .hero-section { margin-bottom: 1.75rem; }

    /* Tabs — horizontal scroll */
    .search-tabs {
        overflow-x: auto;
        padding: 4px;
    }

    .tab-btn {
        font-size: 0.88rem;
        padding: 0.55rem 0.75rem;
        flex-shrink: 0;
    }

    /* Cards — mobile-first touch-friendly */
    .result-card {
        padding: 0.9rem;
        border-radius: 14px;
        /* Disable scale on mobile to avoid layout shift */
        transition: box-shadow 0.2s ease, border-color 0.2s ease;
    }
    .result-card:hover { transform: none; }

    .card-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.55rem;
    }

    /* Larger touch targets for interactive elements */
    .compare-checkbox {
        width: 20px; height: 20px;
        cursor: pointer;
    }
    .favorite-btn {
        min-width: 40px; min-height: 40px;
        display: flex; align-items: center; justify-content: center;
    }

    .tm-card-body { gap: 0.75rem; }

    .tm-logo-preview {
        width: 58px; height: 58px;
        border-radius: 10px;
    }

    .tm-name { font-size: 1.05rem; }
    .owner-name { font-size: 0.8rem; }

    .patent-body-wrapper {
        gap: 0.75rem;
    }

    .patent-logo-preview { width: 80px; height: 80px; }
    .patent-title { font-size: 0.95rem; }
    .patent-abstract-snippet { -webkit-line-clamp: 2; line-clamp: 2; }

    .card-footer {
        padding-top: 0.6rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .class-tags { max-width: 100%; }
    .similarity-val { font-size: 0.82rem; padding: 0.15rem 0.5rem; }

    /* Details table → stacked list */
    .details-table tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 0.6rem;
    }

    .details-table th,
    .details-table td {
        width: 100% !important;
        display: block;
        border-bottom: none;
        padding: 0.1rem 0;
    }

    .details-table th { font-size: 0.78rem; }

    .details-table td {
        padding-bottom: 0.35rem;
        border-bottom: 1px dashed var(--border-color);
    }

    /* Modal footer stack */
    .modal-footer {
        flex-direction: column;
        gap: 0.75rem;
    }

    .modal-footer button { width: 100%; min-height: 44px; }

    /* Empty/error padding */
    .empty-container, .error-container {
        padding: 2.5rem 1rem;
    }

    /* Compare modal */
    .compare-grid { grid-template-columns: 1fr 1fr; }
}

/* =============================================================
 * MISSING / EXTRA CLASSES (HTML compatibility)
 * ============================================================= */

/* Filter inputs */
.date-range-wrapper input,
#filter-classes,
#filter-date-from,
#filter-date-to,
#filter-reg-date-from,
#filter-reg-date-to {
    width: 100%;
    padding: 0.55rem 0.7rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#filter-classes:focus,
#filter-date-from:focus,
#filter-date-to:focus,
#filter-reg-date-from:focus,
#filter-reg-date-to:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Date range */
.date-range-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-range-wrapper input { flex: 1; }

.date-separator {
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 1rem;
}

/* Helper text below inputs */
.input-helper {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* Quick class tags (HTML uses .quick-tags, JS creates .quick-class-tag) */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

/* Checkbox group (HTML uses .checkbox-group) */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

/* Sort select */
.sort-select {
    padding: 0.4rem 0.65rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.82rem;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.sort-select:focus { border-color: var(--border-focus); }

/* Filters panel collapse */
.filters-panel.collapsed { display: none; }

/* Presets container */
.presets-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Modal title wrapper */
.modal-title-wrapper { flex: 1; min-width: 0; }

/* Search form */
.search-form { display: flex; flex-direction: column; gap: 1rem; }

/* Compare table & abstracts */
.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.compare-table th, .compare-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.compare-table th {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.compare-abstracts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

/* =============================================================
 * LIGHTBOX — fullscreen image viewer
 * ============================================================= */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.93);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.18s ease-out both;
}

.lightbox.active {
    display: flex;
}

/* Viewport: fills remaining space, centers image */
.lightbox-viewport {
    position: relative;
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
    touch-action: none; /* handled manually for pinch */
}

.lightbox-viewport.zoomed {
    cursor: grab;
}

.lightbox-viewport.zoomed:active {
    cursor: grabbing;
}

/* The image itself */
.lightbox-img {
    display: block;
    max-width: 92vw;
    max-height: 82vh;
    object-fit: contain;
    -webkit-user-select: none;
    user-select: none;
    transform-origin: center center;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    border-radius: var(--radius-sm);
}

/* Close button */
.lightbox-close {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

/* Prev / Next nav buttons */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
    opacity: 0.7;
}

.lightbox-nav:hover { background: rgba(255, 255, 255, 0.25); opacity: 1; }
.lightbox-nav:active { transform: translateY(-50%) scale(0.93); }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

/* Hide nav when only 1 image */
.lightbox.single .lightbox-nav { display: none; }

/* Counter badge */
.lightbox-counter {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 12px;
    border-radius: 20px;
    pointer-events: none;
    white-space: nowrap;
}

.lightbox.single .lightbox-counter { display: none; }

/* Keyboard hint — desktop only, fades out */
.lightbox-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.72rem;
    pointer-events: none;
    white-space: nowrap;
    text-align: center;
}

/* Zoom level indicator */
.lightbox-zoom-badge {
    position: absolute;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.lightbox-zoom-badge.visible { opacity: 1; }

/* Mobile: hide keyboard hint */
@media (hover: none), (max-width: 768px) {
    .lightbox-hint { display: none; }
    .lightbox-nav { width: 44px; height: 44px; font-size: 1.6rem; }
    .lightbox-prev { left: 6px; }
    .lightbox-next { right: 6px; }
}

/* =============================================================
 * IMAGE GALLERY (patent drawings carousel)
 * ============================================================= */

/* When gallery is active: modal-layout stacks vertically, visual-area expands */
.modal-layout.has-gallery {
    flex-direction: column;
    gap: 1.25rem;
}

.modal-visual-area.has-gallery {
    width: 100%;
    max-width: none;
    height: auto;
    background: transparent;
    border: none;
    padding: 0;
}

/* Gallery root */
.gallery {
    position: relative;
    width: 100%;
    -webkit-user-select: none;
    user-select: none;
}

/* Viewport: clips the sliding track */
.gallery-viewport {
    overflow: hidden;
    border-radius: var(--radius-md);
    background: #ffffff;
    border: 1px solid var(--border-color);
    position: relative;
}

/* Sliding track */
.gallery-track {
    display: flex;
    transition: transform 0.38s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.gallery-track.is-dragging {
    transition: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Each slide */
.gallery-slide {
    flex-shrink: 0;
    width: 100%;
    min-height: 220px;
    max-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    box-sizing: border-box;
}

.gallery-viewport {
    cursor: grab;
}

.gallery-viewport.is-dragging {
    cursor: grabbing;
}

.gallery-slide img {
    max-width: 100%;
    max-height: 340px;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    object-fit: contain;
    display: block;
}

/* Prev / Next arrow buttons */
.gallery-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, opacity 0.15s;
    opacity: 0;
    -webkit-tap-highlight-color: transparent;
}

.gallery:hover .gallery-btn,
.gallery-btn:focus-visible {
    opacity: 1;
}

/* Touch devices: hide arrows — swipe is the interaction */
@media (hover: none) {
    .gallery-btn { display: none; }
}

.gallery-slide:hover img {
    transform: scale(1.03);
}

.gallery-prev { left: 6px; }
.gallery-next { right: 6px; }
.gallery-btn:hover { background: rgba(0, 0, 0, 0.82); }
.gallery-btn:active { transform: translateY(-50%) scale(0.93); }

/* Counter badge (top-right corner) */
.gallery-counter {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 4;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    pointer-events: none;
}

/* Dot indicators */
.gallery-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 0 4px;
}

.gallery-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: none;
    background: var(--border-color);
    cursor: pointer;
    padding: 0;
    transition: width 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-radius 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.gallery-dot.active {
    width: 22px;
    border-radius: 3px;
    background: var(--accent);
}

/* Thumbnail strip */
.gallery-thumbs {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.gallery-thumbs::-webkit-scrollbar { height: 3px; }
.gallery-thumbs::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }
.gallery-thumbs::-webkit-scrollbar-track { background: transparent; }

.gallery-thumb {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    background: #fff;
    padding: 0;
    transition: border-color 0.15s, opacity 0.15s;
    opacity: 0.65;
    -webkit-tap-highlight-color: transparent;
}

.gallery-thumb.active {
    border-color: var(--accent);
    opacity: 1;
}

.gallery-thumb:hover { opacity: 1; }

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Multi-image badge on result cards */
.patent-img-count {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 8px;
    pointer-events: none;
}

.patent-logo-preview {
    position: relative;
}

/* Chart container */
.chart-container {
    margin-bottom: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    overflow: hidden;
}

#year-chart {
    display: block;
    width: 100%;
}

/* Compare modal */
.compare-modal-card { max-width: 960px; }

/* =============================================================
 * ANIMATIONS & MICRO-INTERACTIONS
 * ============================================================= */

/* --- Keyframes --- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUpModal {
    from { opacity: 0; transform: translateY(40px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position: 600px 0; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.93); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes popIn {
    0%   { opacity: 0; transform: scale(0.6); }
    65%  { transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes floatUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes heartBeat {
    0%   { transform: scale(1); }
    25%  { transform: scale(1.35); }
    50%  { transform: scale(0.9); }
    75%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}


/* --- Card entrance: stagger via nth-child --- */
.result-card {
    animation: fadeUp 0.32s ease-out both;
}

.result-card:nth-child(1)  { animation-delay: 0.03s; }
.result-card:nth-child(2)  { animation-delay: 0.07s; }
.result-card:nth-child(3)  { animation-delay: 0.11s; }
.result-card:nth-child(4)  { animation-delay: 0.15s; }
.result-card:nth-child(5)  { animation-delay: 0.19s; }
.result-card:nth-child(6)  { animation-delay: 0.23s; }
.result-card:nth-child(7)  { animation-delay: 0.27s; }
.result-card:nth-child(8)  { animation-delay: 0.31s; }
.result-card:nth-child(n+9) { animation-delay: 0.35s; }

/* --- Search stats fade-in --- */
.search-stats {
    animation: fadeIn 0.25s ease-out both;
}

/* --- Modal entrance --- */
.modal-card {
    animation: slideUpModal 0.28s cubic-bezier(0.34, 1.30, 0.64, 1) both;
}

/* --- Overlay fade --- */
.modal-overlay {
    animation: fadeIn 0.18s ease-out both;
}

/* --- Tab active indicator: animated underline --- */
.tab-btn {
    position: relative;
}

.tab-btn.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 20%;
    width: 60%;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    animation: scaleIn 0.18s ease-out both;
}

/* --- Button press: subtle spring --- */
.btn-primary:active {
    transform: scale(0.97);
    transition: transform 0.08s ease-in;
}

/* --- Preset / history / example tags: scale-in --- */
.preset-btn,
.history-tag,
.example-btn,
.quick-class-tag {
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.preset-btn:hover,
.history-tag:hover,
.example-btn:hover,
.quick-class-tag:hover {
    transform: scale(1.06);
}

/* --- Skeleton loading shimmer (replaces blur) --- */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-elevated)  50%,
        var(--bg-tertiary) 75%
    );
    background-size: 600px 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: var(--radius-sm);
}

.result-card.loading > * {
    filter: none;
    opacity: 1;
}

.result-card.loading .doc-number,
.result-card.loading .status-badge,
.result-card.loading .tm-name,
.result-card.loading .patent-title,
.result-card.loading .owner-name,
.result-card.loading .patent-abstract-snippet {
    color: transparent;
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-elevated)  50%,
        var(--bg-tertiary) 75%
    );
    background-size: 600px 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: var(--radius-sm);
    pointer-events: none;
}

/* --- Filter panel open/close --- */
.filters-panel {
    overflow: hidden;
    transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.2s ease;
    max-height: 1000px;
    opacity: 1;
}

.filters-panel.collapsed {
    display: block; /* Override display:none — use max-height instead */
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

/* --- Favorites badge pop-in --- */
.favorites-badge {
    animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* --- Gallery counter & dots entrance --- */
.gallery-counter {
    animation: floatUp 0.22s ease-out 0.06s both;
}
.gallery-dots {
    animation: floatUp 0.22s ease-out 0.1s both;
}
.gallery-thumbs {
    animation: floatUp 0.22s ease-out 0.14s both;
}

/* --- Favorite button heartbeat on add --- */
.favorite-btn.pop {
    animation: heartBeat 0.42s ease-out both;
}

/* --- Search stats: slide in from left --- */
.search-stats {
    animation: slideInLeft 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* --- Status badge entrance --- */
.status-badge {
    animation: popIn 0.24s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: inherit;
}

/* --- btn-primary ripple on focus-visible --- */
.btn-primary:focus-visible {
    outline: none;
    animation: popIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Spinner accent --- */
.spinner {
    border-top-color: var(--accent);
}

/* =============================================================
 * REDUCED MOTION
 * ============================================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.1ms !important;
        scroll-behavior: auto !important;
    }
}

/* =============================================================
 * AUTH — LOGIN BUTTON, USER PILL, MODAL
 * ============================================================= */

/* Utility: hide without display:none in HTML */
.auth-hidden { display: none !important; }

/* --- Login button (logged-out state) --- */
.auth-login-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent-subtle);
    border: 1px solid rgba(79, 139, 255, 0.3);
    border-radius: 20px;
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    white-space: nowrap;
}
.auth-login-btn:hover {
    background: rgba(79, 139, 255, 0.15);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.auth-login-btn:active { transform: scale(0.97); }
@media (max-width: 480px) { .auth-login-label { display: none; } }

/* --- Profile pill wrap (relative container for dropdown) --- */
.profile-pill-wrap {
    position: relative;
}

/* --- User pill (logged-in state) — now a button --- */
.auth-user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    transition: border-color 0.18s, background 0.18s;
}
.auth-user-pill:hover {
    border-color: var(--accent);
    background: rgba(79,139,255,0.08);
}
.pill-chevron {
    color: var(--text-secondary);
    transition: transform 0.2s ease, color 0.18s;
    flex-shrink: 0;
}
.auth-user-pill:hover .pill-chevron {
    color: var(--text-primary);
}
.auth-user-pill[aria-expanded="true"] .pill-chevron {
    transform: rotate(180deg);
    color: var(--accent);
}

/* --- Profile dropdown --- */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--dropdown-bg, #1a1d2e);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);
    z-index: 200;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
    pointer-events: none;
}
.profile-dropdown--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 12px;
}
.pd-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    background-size: cover;
    background-position: center;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.pd-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pd-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pd-username {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0 10px;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}
.profile-dropdown-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}
.profile-dropdown-item--danger:hover {
    background: rgba(239,68,68,0.1);
    color: #f87171;
}
.pd-count {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

/* ============================================================
 * SUBSCRIPTIONS DRAWER
 * ============================================================ */

.subs-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    opacity: 0;
    transition: opacity 0.28s ease;
}
.subs-backdrop--open { opacity: 1; }

.subs-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 92vw;
    background: var(--dropdown-bg);
    border-left: 1px solid var(--border-color);
    z-index: 301;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -16px 0 48px rgba(0,0,0,0.3);
}
.subs-drawer--open { transform: translateX(0); }

.subs-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.subs-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.subs-drawer-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.subs-drawer-close:hover {
    background: rgba(239,68,68,0.1);
    color: #f87171;
    border-color: rgba(239,68,68,0.3);
}

.subs-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.subs-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0 0 14px;
    line-height: 1.5;
}

.subs-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.subs-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--subs-item-bg, rgba(255,255,255,0.06));
    border: 1px solid var(--border-color);
    gap: 8px;
    transition: background 0.15s;
}
.subs-item:hover { background: var(--subs-item-bg-hover, rgba(255,255,255,0.1)); }

.subs-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}
.subs-item-bell { color: #f59e0b; flex-shrink: 0; }
.subs-item-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subs-unsubscribe-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.subs-unsubscribe-btn:hover {
    background: rgba(239,68,68,0.1);
    color: #f87171;
    border-color: rgba(239,68,68,0.25);
}

.subs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 20px;
    text-align: center;
}
.subs-empty p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}
.subs-empty span {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.auth-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    background-size: cover;
    background-position: center;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-family: var(--font-heading);
}

.auth-user-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 2px;
}
@media (max-width: 480px) { .auth-user-name { display: none; } }

.auth-logout-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}
.auth-logout-btn:hover {
    background: rgba(255, 80, 80, 0.12);
    color: #f87171;
}

/* --- Auth modal --- */
.auth-modal-overlay {
    display: none;
    z-index: 3000;
}
.auth-modal-overlay[aria-hidden="false"] {
    display: flex;
}

.auth-modal-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-modal);
    animation: slideUpModal 0.28s cubic-bezier(0.34, 1.3, 0.64, 1) both;
    overflow: hidden;
}

.auth-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 1;
}

.auth-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 2.5rem 2rem 2rem;
    text-align: center;
}

.auth-tg-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(34, 158, 217, 0.12);
    border: 1px solid rgba(34, 158, 217, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s both;
}

.auth-modal-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.auth-modal-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.auth-tg-widget-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 56px;
}

.auth-widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
}

.auth-widget-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255,255,255,0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: authSpin 0.7s linear infinite;
}

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

.auth-widget-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 0.82rem;
    line-height: 1.55;
    text-align: left;
}

.auth-widget-error svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #f87171;
}

.auth-widget-error a {
    color: #93c5fd;
    text-decoration: underline;
}

.auth-widget-error code {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 0.8rem;
    color: #e2e8f0;
}

.auth-modal-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
    padding-bottom: 0.5rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1rem 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.auth-divider span {
    padding: 0 0.75rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.auth-email-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
}

.auth-email-input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.92rem;
    text-align: center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-email-input::placeholder {
    color: var(--text-muted);
}

.auth-email-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-email-submit {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 1.5px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease;
}

.auth-email-submit:hover {
    background: var(--accent-subtle);
}

.auth-email-submit:active {
    transform: translateY(1px);
}

.auth-email-submit:disabled {
    opacity: 0.7;
    cursor: default;
}

.auth-email-submit-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent-glow);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.auth-email-submit.is-loading .auth-email-submit-spinner { display: inline-block; }
.auth-email-submit.is-loading .auth-email-submit-label { opacity: 0.85; }

.auth-email-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.6rem 0 0;
    text-align: center;
}

.auth-email-status.success { color: #4ade80; }
.auth-email-status.error   { color: #f87171; }

/* Bot-link auth button */
.auth-tg-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 26px;
    border-radius: 12px;
    background: #2AABEE;
    color: #fff;
    font-size: 0.97rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.18s, transform 0.12s;
}

.auth-tg-link-btn:hover {
    background: #1a9bde;
    transform: translateY(-1px);
}

.auth-tg-link-btn:active {
    transform: translateY(0);
}

.auth-tg-link-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 6px 0 0;
    text-align: center;
    line-height: 1.5;
}

/* Polling status indicator */
.auth-poll-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.auth-poll-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: authPollPulse 1.4s ease-in-out infinite;
}

@keyframes authPollPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ============================================================
 * SUBSCRIPTION BELL BUTTON
 * ============================================================ */

.owner-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.owner-row .owner-name {
    margin: 0;
    flex: 1 1 auto;
}

.sub-bell-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.18s, background 0.18s, border-color 0.18s, transform 0.12s;
    position: relative;
}

.sub-bell-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

.sub-bell-btn:active {
    transform: scale(0.9);
}

.sub-bell-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Icon visibility toggling */
.sub-bell-btn .bell-filled { display: none; }
.sub-bell-btn .bell-outline { display: block; }

.sub-bell-btn.subscribed {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.1);
}

.sub-bell-btn.subscribed .bell-filled  { display: block; }
.sub-bell-btn.subscribed .bell-outline { display: none; }

.sub-bell-btn.subscribed:hover {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
}

/* Subscribe animation on activation */
@keyframes bellRing {
    0%   { transform: rotate(0); }
    15%  { transform: rotate(14deg); }
    30%  { transform: rotate(-10deg); }
    45%  { transform: rotate(8deg); }
    60%  { transform: rotate(-6deg); }
    75%  { transform: rotate(3deg); }
    100% { transform: rotate(0); }
}

.sub-bell-btn.ring svg {
    animation: bellRing 0.5s ease;
}

/* ============================================================
 * TOAST NOTIFICATIONS
 * ============================================================ */

.sp-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    max-width: calc(100vw - 40px);
    white-space: nowrap;
}

.sp-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sp-toast--success { background: rgba(16, 185, 129, 0.92); }
.sp-toast--error   { background: rgba(239, 68, 68, 0.92); }
.sp-toast--info    { background: rgba(99, 102, 241, 0.92); }

.sp-toast svg { flex-shrink: 0; }

/* =============================================================
 * Фича #1: Ринг оценки риска регистрации (AI Risk Gauge)
 * ============================================================= */

.risk-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.12rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
    border: 1px solid transparent;
}
.risk-badge--high {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #ef4444;
}
.risk-badge--medium {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.35);
    color: #f59e0b;
}
.risk-badge--low {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
    color: #22c55e;
}
body.light-theme .risk-badge--high { background: rgba(239,68,68,0.08); }
body.light-theme .risk-badge--medium { background: rgba(245,158,11,0.08); }
body.light-theme .risk-badge--low { background: rgba(34,197,94,0.08); }

.risk-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* Кольцевой индикатор риска в модалке */
.risk-gauge {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    background: var(--bg-tertiary, rgba(0,0,0,0.03));
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.risk-gauge__ring {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}
.risk-gauge__ring svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}
.risk-gauge__track {
    fill: none;
    stroke: rgba(128, 128, 128, 0.15);
    stroke-width: 7;
}
.risk-gauge__progress {
    fill: none;
    stroke-width: 7;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease, stroke 0.3s ease;
}
.risk-gauge__progress--high { stroke: #ef4444; }
.risk-gauge__progress--medium { stroke: #f59e0b; }
.risk-gauge__progress--low { stroke: #22c55e; }
.risk-gauge__value {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.1rem;
    line-height: 1;
}
.risk-gauge__value small {
    font-size: 0.6rem;
    font-weight: 600;
    opacity: 0.6;
    margin-top: 2px;
}
.risk-gauge__info {
    flex: 1;
    min-width: 0;
}
.risk-gauge__label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}
.risk-gauge__label--high { color: #ef4444; }
.risk-gauge__label--medium { color: #f59e0b; }
.risk-gauge__label--low { color: #22c55e; }
.risk-gauge__desc {
    font-size: 0.8rem;
    opacity: 0.75;
    line-height: 1.4;
}
.risk-reasons {
    margin-top: 0.75rem;
    padding-left: 1.1rem;
}
.risk-reasons li {
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 0.3rem;
    opacity: 0.85;
}
.risk-reasons li::marker {
    color: var(--accent);
}

/* =============================================================
 * Фича #3: Калькулятор пошлин Роспатента
 * ============================================================= */

.fee-calculator {
    margin-top: 0.75rem;
    padding: 0.85rem;
    border-radius: 10px;
    background: var(--bg-tertiary, rgba(0,0,0,0.03));
    border: 1px solid var(--border-color);
}
.fee-calculator__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}
.fee-calculator__title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.fee-calculator__toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    cursor: pointer;
    user-select: none;
}
.fee-calculator__toggle input { cursor: pointer; }
.fee-calculator__rows {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.fee-calculator__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    padding: 0.2rem 0;
}
.fee-calculator__row--total {
    border-top: 1px solid var(--border-color);
    margin-top: 0.3rem;
    padding-top: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
}
.fee-calculator__row--discount {
    color: #22c55e;
    font-size: 0.75rem;
}
.fee-calculator__amount {
    font-family: var(--font-heading);
    font-weight: 600;
}
.fee-calculator__amount--total {
    font-size: 1.05rem;
    color: var(--accent);
}
.fee-calculator__bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(128,128,128,0.15);
    overflow: hidden;
    margin-top: 0.5rem;
}
.fee-calculator__bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f8bff, #22c55e);
    border-radius: 3px;
    transition: width 0.4s ease;
}
.fee-calculator__hint {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 0.4rem;
    line-height: 1.4;
}

/* =============================================================
 * Фича #5: Кнопка Multi-PDF экспорта
 * ============================================================= */

.multi-pdf-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.multi-pdf-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
