:root {
    --fb-bg: #f8f9fc;
    --fb-card: #ffffff;
    --fb-text: #0f172a;
    --fb-muted: #64748b;
    --fb-line: #e2e8f0;
    --fb-blue: #2563eb;
    --fb-green: #22c55e;
    --fb-red: #ef4444;
}

* {
    box-sizing: border-box;
}

body.fb-body {
    margin: 0;
    padding: 0;
    background: var(--fb-bg);
    color: var(--fb-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.5;
}

.fb-topbar {
    height: 56px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--fb-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
}

.fb-brand {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--fb-text);
}

.fb-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--fb-muted);
}

.fb-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fb-nav a {
    color: var(--fb-muted);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.fb-nav a.is-active {
    background: #eff6ff;
    color: var(--fb-blue);
}

.fb-logout {
    background: var(--fb-red);
    color: white;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

.fb-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 24px auto 60px;
}

.fb-hero {
    background: var(--fb-card);
    border: 1px solid var(--fb-line);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.fb-hero h1 {
    margin: 0 0 8px 0;
    font-size: clamp(28px, 5vw, 36px);
    line-height: 1.2;
    letter-spacing: -0.02em;
    font-weight: 700;
}

.fb-hero p {
    margin: 0 0 16px 0;
    color: var(--fb-muted);
    font-size: 14px;
    font-weight: 500;
}

.fb-progress {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    margin: 0 0 14px 0;
    background: #e2e8f0;
}

.fb-progress::-webkit-progress-bar {
    background: #e2e8f0;
}

.fb-progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--fb-blue), #3b82f6);
    transition: width 0.3s ease;
}

.fb-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fb-stats span {
    background: #f1f5f9;
    color: var(--fb-text);
    border: 1px solid var(--fb-line);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
}

.fb-accordion {
    list-style: none;
    padding: 0;
    margin: 0;
}

.fb-accordion > li {
    background: var(--fb-card);
    border: 1px solid var(--fb-line);
    border-radius: 14px;
    margin-bottom: 12px;
    overflow: hidden;
}

.fb-group-title {
    padding: 14px 16px;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--fb-text) !important;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
}

.fb-group-title::before {
    display: none;
}

.fb-group-title::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 14l-7 7m0 0l-7-7m7 7V3'/%3E%3C/svg%3E") no-repeat center;
    background-size: 18px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.uk-open > .fb-group-title::after {
    transform: rotate(180deg);
}

.fb-group-title span {
    font-weight: 600;
}

.fb-group-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.fb-flag {
    width: 22px;
    height: 16px;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
    flex-shrink: 0;
}

.fb-flag-fallback {
    width: 24px;
    height: 18px;
    border-radius: 5px;
    background: #e2e8f0;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 900;
    line-height: 1;
    flex-shrink: 0;
}

.fb-group-title small {
    color: var(--fb-muted);
    font-size: 12px;
    font-weight: 500;
}

.uk-accordion-content {
    margin: 0;
    padding: 12px 12px 14px;
}

.fb-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.fb-card {
    position: relative;
    background: var(--fb-card);
    border: 1px solid var(--fb-line);
    border-radius: 12px;
    min-height: 275px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fb-card-id {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 700;
}

.fb-card-media {
    height: 140px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    position: relative;
}

.fb-card-media img {
    max-width: 100px;
    max-height: 130px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 6px;
}

.fb-card-media img.is-hidden {
    display: none;
}

.fb-card-placeholder {
    display: none;
    width: 100px;
    height: 130px;
    border: 1px dashed var(--fb-line);
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    background: #f0f4f8;
    color: var(--fb-muted);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    padding: 4px;
}

.fb-card-media.has-error .fb-card-placeholder {
    display: flex;
}

.fb-card-content {
    padding: 8px 10px 6px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fb-code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.fb-code-row strong {
    color: var(--fb-text);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fb-code-row span {
    background: #eff6ff;
    color: var(--fb-blue);
    border-radius: 999px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.fb-card h3 {
    margin: 0;
    font-size: 13px;
    line-height: 1.3;
    font-weight: 600;
    color: var(--fb-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fb-card p {
    margin: 0;
    color: var(--fb-muted);
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fb-status {
    width: fit-content;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin: 0;
}

.is-missing .fb-status {
    background: #fee2e2;
    color: #dc2626;
}

.is-owned .fb-status {
    background: #dcfce7;
    color: #16a34a;
}

.is-repeat .fb-status {
    background: #fef3c7;
    color: #b45309;
}

.fb-card-actions {
    margin-top: auto;
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    border-top: 1px solid #e8ebf2;
    overflow: hidden;
}

.fb-card-actions form {
    margin: 0;
}

.fb-card-actions button {
    width: 100%;
    height: 38px;
    border: 0;
    appearance: none;
    -webkit-appearance: none;
    background: #f5f7fb;
    color: #172033;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    padding: 0;
    border-radius: 0;
    line-height: 1;
}

.fb-card-actions form:last-child button {
    background: #2563eb;
    color: #fff;
}

.fb-card-actions button:active {
    opacity: 0.8;
}

.fb-card-actions .js-quantity {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #172033;
}

@media (min-width: 640px) {
    .fb-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 960px) {
    .fb-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .fb-topbar {
        padding: 0 14px;
    }

    .fb-brand span {
        display: none;
    }

    .fb-nav {
        gap: 2px;
    }

    .fb-nav a {
        padding: 5px 8px;
        font-size: 11px;
    }

    .fb-user span {
        display: none;
    }

    .fb-shell {
        width: calc(100% - 16px);
        margin-top: 12px;
        margin-bottom: 50px;
    }

    .fb-hero {
        padding: 16px;
        border-radius: 14px;
        margin-bottom: 14px;
    }

    .fb-hero h1 {
        font-size: 24px;
        margin-bottom: 6px;
    }

    .fb-hero p {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .fb-stats {
        gap: 6px;
    }

    .fb-stats span {
        padding: 4px 10px;
        font-size: 11px;
    }

    .fb-accordion > li {
        border-radius: 12px;
        margin-bottom: 10px;
    }

    .fb-group-title {
        padding: 12px 14px;
        font-size: 14px;
    }

    .fb-group-title small {
        font-size: 11px;
    }

    .uk-accordion-content {
        padding: 10px 10px 12px;
    }

    .fb-grid {
        gap: 8px;
    }

    .fb-card {
        border-radius: 10px;
    }

    .fb-card-media {
        height: 130px;
        padding: 8px;
    }

    .fb-card-media img,
    .fb-card-placeholder {
        max-height: 120px;
    }

    .fb-card-content {
        padding: 8px;
        gap: 4px;
    }

    .fb-code-row strong {
        font-size: 11px;
    }

    .fb-code-row span {
        font-size: 9px;
        padding: 2px 5px;
    }

    .fb-card h3 {
        font-size: 12px;
    }

    .fb-card p {
        font-size: 10px;
    }

    .fb-status {
        font-size: 9px;
        padding: 2px 6px;
    }

    .fb-card-actions {
        grid-template-columns: 42px 1fr 42px;
    }
}

.fb-market-shell {
    max-width: 760px;
}

.fb-market-head {
    margin-bottom: 14px;
}

.fb-market-head h1 {
    margin: 0 0 4px;
    font-size: 30px;
    line-height: 1.1;
    font-weight: 800;
}

.fb-market-head p {
    margin: 0;
    color: var(--fb-muted);
    font-size: 13px;
}

.fb-market-tabs {
    position: sticky;
    top: 56px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 0;
    background: var(--fb-bg);
}

.fb-market-tabs button {
    border: 1px solid var(--fb-line);
    border-radius: 8px;
    background: #fff;
    color: var(--fb-muted);
    font-size: 12px;
    font-weight: 800;
    min-height: 38px;
    cursor: pointer;
}

.fb-market-tabs button.is-active {
    background: var(--fb-blue);
    border-color: var(--fb-blue);
    color: #fff;
}

.fb-market-panel {
    display: none;
}

.fb-market-panel.is-active {
    display: block;
}

.fb-market-actions {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 8px;
    margin: 8px 0 14px;
}

.fb-copy-btn,
.fb-whatsapp-btn {
    border: 0;
    border-radius: 8px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.fb-copy-btn {
    background: #eef2f7;
    color: #172033;
}

.fb-whatsapp-btn {
    background: #16a34a;
    color: #fff;
}

.fb-market-group {
    margin-bottom: 14px;
}

.fb-market-group h2 {
    margin: 0 0 7px;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 900;
}

.fb-market-list {
    display: grid;
    gap: 7px;
}

.fb-market-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--fb-line);
    border-radius: 8px;
    padding: 9px 10px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.fb-market-mark {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fb-market-code {
    color: var(--fb-blue);
    font-size: 12px;
    font-weight: 900;
}

.fb-market-title {
    color: var(--fb-text);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-market-meta {
    color: var(--fb-muted);
    font-size: 11px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-market-item-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.fb-market-badge,
.fb-market-available {
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 900;
    white-space: nowrap;
}

.fb-market-badge {
    background: #fee2e2;
    color: #dc2626;
}

.is-owned .fb-market-badge {
    background: #dcfce7;
    color: #16a34a;
}

.is-repeat .fb-market-badge {
    background: #fef3c7;
    color: #b45309;
}

.fb-market-available {
    background: #eff6ff;
    color: var(--fb-blue);
}

.fb-market-quick-form {
    width: 100%;
}

.fb-market-quick-form button {
    width: 100%;
    min-height: 30px;
    border: 0;
    border-radius: 8px;
    background: var(--fb-blue);
    color: #fff;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
    white-space: nowrap;
}

.fb-market-quick-form button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.is-repeat .fb-market-quick-form button {
    background: #b45309;
}

.fb-market-search {
    position: sticky;
    top: 110px;
    z-index: 10;
    padding: 8px 0;
    background: var(--fb-bg);
}

.fb-market-search input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--fb-line);
    border-radius: 8px;
    background: #fff;
    color: var(--fb-text);
    font-size: 14px;
    font-weight: 600;
    padding: 0 12px;
}

.fb-market-search input:focus {
    outline: none;
    border-color: var(--fb-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.fb-empty {
    background: #fff;
    border: 1px dashed var(--fb-line);
    border-radius: 8px;
    color: var(--fb-muted);
    font-size: 13px;
    font-weight: 700;
    padding: 18px;
    text-align: center;
}

.market-shell {
    max-width: 760px;
    padding-bottom: 42px;
}

.market-header {
    margin: 0 0 14px;
}

.market-header h1 {
    margin: 0 0 4px;
    color: var(--fb-text);
    font-size: 30px;
    font-weight: 900;
    line-height: 1.08;
}

.market-header p {
    margin: 0;
    color: var(--fb-muted);
    font-size: 13px;
    font-weight: 600;
}

.market-tabs {
    position: sticky;
    top: 56px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 0;
    margin-bottom: 2px;
    background: var(--fb-bg);
}

.market-tab {
    min-height: 38px;
    border: 1px solid var(--fb-line);
    border-radius: 8px;
    background: #fff;
    color: var(--fb-muted);
    padding: 0 8px;
    font: inherit;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

.market-tab.is-active {
    background: var(--fb-blue);
    border-color: var(--fb-blue);
    color: #fff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.market-panel {
    display: none;
}

.market-panel.is-active {
    display: block;
}

.market-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    gap: 8px;
    margin: 8px 0 16px;
}

.market-copy-button,
.market-whatsapp-button {
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.15;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.market-copy-button {
    background: #eef2f7;
    color: #172033;
}

.market-whatsapp-button {
    background: #16a34a;
    color: #fff;
}

.market-whatsapp-button:hover,
.market-whatsapp-button:focus {
    color: #fff;
    text-decoration: none;
}

.market-group {
    margin: 0 0 16px;
}

.market-group-title {
    margin: 0 0 7px;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.2;
}

.market-list {
    display: grid;
    gap: 7px;
}

.market-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--fb-line);
    border-radius: 8px;
    padding: 9px 10px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.market-item-mark {
    display: flex;
    align-items: center;
    justify-content: center;
}

.market-item-main {
    min-width: 0;
}

.market-item-code {
    color: var(--fb-blue);
    font-size: 12px;
    font-weight: 900;
    line-height: 1.2;
}

.market-item-title {
    color: var(--fb-text);
    font-size: 13px;
    font-weight: 900;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-item-meta {
    color: var(--fb-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-item-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.market-badge,
.market-available {
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
}

.market-badge {
    background: #fee2e2;
    color: #dc2626;
}

.is-owned .market-badge {
    background: #dcfce7;
    color: #16a34a;
}

.is-repeat .market-badge {
    background: #fef3c7;
    color: #b45309;
}

.market-available {
    background: #eff6ff;
    color: var(--fb-blue);
}

.market-quick-form {
    width: 100%;
}

.market-quick-form button {
    width: 100%;
    min-height: 30px;
    border: 0;
    border-radius: 8px;
    background: var(--fb-blue);
    color: #fff;
    padding: 0 10px;
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    line-height: 1.1;
    cursor: pointer;
    white-space: nowrap;
}

.is-repeat .market-quick-form button {
    background: #b45309;
}

.market-quick-form button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.market-search {
    position: sticky;
    top: 110px;
    z-index: 10;
    padding: 8px 0;
    background: var(--fb-bg);
}

.market-search input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--fb-line);
    border-radius: 8px;
    background: #fff;
    color: var(--fb-text);
    padding: 0 12px;
    font-size: 14px;
    font-weight: 700;
}

.market-search input:focus {
    outline: none;
    border-color: var(--fb-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

@media (max-width: 640px) {
    .market-header h1 {
        font-size: 26px;
    }

    .market-actions {
        grid-template-columns: 1fr;
    }

    .market-item {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
    }

    .market-item-side {
        grid-column: 1 / -1;
        align-items: stretch;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .market-quick-form {
        flex: 1 1 100%;
    }
}
