:root {
    --app-bg: #f4f7fb;
    --app-sidebar: #172033;
    --app-sidebar-soft: #202b42;
    --app-primary: #1f6feb;
    --app-text: #182033;
    --app-muted: #64748b;
    --app-border: #dde5ef;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    color: var(--app-text);
    background: var(--app-bg);
    letter-spacing: 0;
}

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(31, 111, 235, 0.14), rgba(25, 135, 84, 0.08)),
        var(--app-bg);
}

.login-wrapper {
    width: min(100%, 460px);
}

.login-panel,
.panel,
.metric-card {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.login-panel {
    padding: 32px;
}

.login-brand,
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand {
    margin-bottom: 28px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    color: #fff;
    background: #f5b301;
    font-weight: 800;
}

.brand small,
.login-brand small {
    display: block;
    color: var(--app-muted);
    font-size: 0.82rem;
}

.login-panel h1,
.app-header h1 {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 750;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: 280px;
    height: 100vh;
    padding: 24px 18px;
    color: #fff;
    background: var(--app-sidebar);
}

.app-sidebar .brand {
    padding: 0 6px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-sidebar .brand small {
    color: #aab6c8;
}

.app-sidebar .nav {
    margin-top: 24px;
}

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    border-radius: 8px;
    color: #dbe5f3;
    font-weight: 600;
}

.app-sidebar .nav-link:hover,
.app-sidebar .nav-link.active {
    color: #fff;
    background: var(--app-sidebar-soft);
}

.app-sidebar .nav-link.disabled {
    opacity: 0.48;
}

.sidebar-footer {
    margin-top: auto;
}

.app-main {
    flex: 1;
    min-width: 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 92px;
    padding: 22px 32px;
    border-bottom: 1px solid var(--app-border);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--app-border);
    border-radius: 999px;
    color: var(--app-muted);
    background: #fff;
    font-weight: 600;
}

.content-area {
    padding: 32px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 108px;
    padding: 18px;
}

.metric-card small {
    display: block;
    color: var(--app-muted);
    font-weight: 650;
}

.metric-card strong {
    display: block;
    margin-top: 4px;
    font-size: 1.65rem;
    line-height: 1;
}

.metric-icon {
    display: inline-grid;
    flex: 0 0 44px;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: #fff;
    font-size: 1.25rem;
}

.metric-icon.primary { background: #1f6feb; }
.metric-icon.success { background: #198754; }
.metric-icon.info { background: #0dcaf0; color: #083344; }
.metric-icon.warning { background: #ffc107; color: #422006; }
.metric-icon.danger { background: #dc3545; }
.metric-icon.muted { background: #64748b; }
.metric-icon.secondary { background: #6f42c1; }
.metric-icon.dark { background: #212529; }

.panel {
    padding: 22px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 750;
}

.panel-header p {
    margin: 4px 0 0;
    color: var(--app-muted);
}

.integration-state,
.empty-state {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 8px;
    background: #f8fafc;
}

.integration-state i,
.empty-state i {
    color: var(--app-primary);
    font-size: 1.7rem;
}

.integration-state span,
.empty-state p {
    display: block;
    margin: 0;
    color: var(--app-muted);
}

.sync-summary {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px 14px;
    margin: 0;
}

.sync-summary dt {
    color: var(--app-muted);
}

.sync-summary dd {
    margin: 0;
    font-weight: 600;
}

.product-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 16px;
}

.product-card {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 14px;
    min-height: 150px;
    padding: 14px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.product-card-image {
    width: 92px;
    height: 92px;
    object-fit: cover;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #f8fafc;
}

.product-card-body {
    display: grid;
    align-content: space-between;
    gap: 12px;
    min-width: 0;
}

.product-card-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--app-muted);
    font-size: 0.82rem;
}

.product-card h3 {
    display: -webkit-box;
    overflow: hidden;
    min-height: 40px;
    margin: 0;
    font-size: 0.98rem;
    font-weight: 760;
    line-height: 1.35;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-card-meta {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 4px 10px;
    margin: 0;
    font-size: 0.9rem;
}

.product-card-meta dt {
    color: var(--app-muted);
    font-weight: 650;
}

.product-card-meta dd {
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.product-carousel .carousel-item img {
    height: 62vh;
    object-fit: contain;
    border-radius: 8px;
    background: #f8fafc;
}

.product-carousel .carousel-control-prev-icon,
.product-carousel .carousel-control-next-icon {
    padding: 18px;
    border-radius: 999px;
    background-color: rgba(15, 23, 42, 0.72);
}

.carousel-url {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.orders-list {
    display: grid;
    gap: 16px;
}

.order-card {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.order-summary {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr 1fr 0.8fr 0.7fr;
    gap: 16px;
    align-items: center;
    padding: 18px;
    border-bottom: 1px solid var(--app-border);
}

.order-summary h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.order-summary strong,
.order-summary span {
    display: block;
}

.order-items {
    display: grid;
    gap: 0;
    padding: 6px 18px 18px;
}

.order-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 80px 110px 110px;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--app-border);
}

.order-item:last-child {
    border-bottom: 0;
}

.order-item small {
    display: block;
    color: var(--app-muted);
}

.questions-list {
    display: grid;
    gap: 16px;
}

.question-card {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 18px;
    padding: 18px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.question-product {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.question-product img,
.question-image-placeholder {
    width: 88px;
    height: 88px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #f8fafc;
}

.question-product img {
    object-fit: cover;
}

.question-image-placeholder {
    display: grid;
    place-items: center;
    color: var(--app-muted);
    font-size: 1.8rem;
}

.question-product h3 {
    margin: 8px 0 4px;
    font-size: 1rem;
    font-weight: 780;
}

.question-product small,
.question-product a,
.question-text span,
.question-answer span {
    display: block;
    color: var(--app-muted);
}

.question-body {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.question-text,
.question-answer {
    padding: 14px;
    border-radius: 8px;
    background: #f8fafc;
}

.question-answer {
    border: 1px solid #badbcc;
    background: #f0fff6;
}

.question-text p,
.question-answer p {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
    font-size: 1rem;
}

.question-reply-form textarea {
    resize: vertical;
}

.post-sale-list {
    display: grid;
    gap: 16px;
}

.post-sale-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.post-sale-header {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 180px;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--app-border);
}

.post-sale-header h3 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 800;
}

.post-sale-header strong {
    display: block;
    overflow-wrap: anywhere;
}

.post-sale-messages {
    display: grid;
    gap: 10px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
}

.post-sale-message {
    width: min(100%, 760px);
    padding: 12px 14px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #f8fafc;
}

.post-sale-message.seller {
    justify-self: end;
    border-color: #badbcc;
    background: #f0fff6;
}

.post-sale-message span {
    display: block;
    color: var(--app-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.post-sale-message p {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
}

.post-sale-empty-thread {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border: 1px dashed var(--app-border);
    border-radius: 8px;
    color: var(--app-muted);
    background: #f8fafc;
    font-weight: 700;
}

.post-sale-empty-thread i {
    color: var(--app-primary);
    font-size: 1.35rem;
}

.post-sale-reply {
    display: grid;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--app-border);
}

.post-sale-reply textarea {
    resize: vertical;
}

.post-sale-reply-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.quick-replies-list {
    display: grid;
    gap: 16px;
}

.quick-reply-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.quick-reply-card.inactive {
    opacity: 0.68;
}

.quick-reply-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.quick-reply-card h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.quick-reply-card small {
    display: block;
    margin-top: 4px;
    color: var(--app-muted);
    font-weight: 700;
}

.quick-reply-card p {
    margin: 10px 0 0;
    overflow-wrap: anywhere;
}

.quick-reply-actions {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.detail-main-image {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #f8fafc;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.image-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.image-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: #f8fafc;
    border-radius: 8px;
}

.debug-json {
    max-height: 460px;
    overflow: auto;
    margin-top: 16px;
    padding: 16px;
    border-radius: 8px;
    color: #dbeafe;
    background: #0f172a;
}

.conference-scan-panel,
.conference-empty,
.conference-order-panel,
.conference-items-panel {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.conference-scan-panel {
    padding: 22px;
    margin-bottom: 20px;
}

.conference-scan-form .form-label {
    font-size: 1rem;
    font-weight: 760;
}

.conference-scan-input {
    font-size: 1.35rem;
    font-weight: 750;
}

.conference-layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px;
}

.conference-order-panel,
.conference-items-panel {
    padding: 20px;
}

.conference-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 14px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 800;
}

.conference-status.pending {
    color: #664d03;
    background: #fff3cd;
}

.conference-status.done {
    color: #0f5132;
    background: #d1e7dd;
}

.conference-summary {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 10px 12px;
    margin: 0 0 18px;
}

.conference-summary dt {
    color: var(--app-muted);
    font-weight: 700;
}

.conference-summary dd {
    margin: 0;
    overflow-wrap: anywhere;
    font-weight: 760;
}

.conference-message {
    padding: 14px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #f8fafc;
}

.conference-message span {
    display: block;
    margin-bottom: 6px;
    color: var(--app-muted);
    font-weight: 750;
}

.conference-message p {
    margin: 0;
    font-size: 1.05rem;
}

.conference-messages-list {
    display: grid;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
}

.conference-message-line {
    padding: 10px;
    border-radius: 8px;
    background: #fff;
}

.conference-message-line strong,
.conference-message-line small {
    display: block;
}

.conference-message-line small {
    color: var(--app-muted);
    font-size: 0.78rem;
}

.conference-message-line p {
    margin: 4px 0;
}

.conference-label-box {
    display: none;
}

.conference-label-box span {
    color: var(--app-muted);
    font-weight: 750;
}

.conference-label-box small {
    color: var(--app-muted);
}

.conference-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.conference-toolbar h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
}

.conference-toolbar p {
    margin: 4px 0 0;
    color: var(--app-muted);
}

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

.conference-items {
    display: grid;
    gap: 14px;
}

.conference-item {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr) 180px;
    gap: 16px;
    align-items: center;
    padding: 14px;
    border: 2px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.conference-item.checked {
    border-color: #198754;
    background: #f0fff6;
}

.conference-item-image,
.conference-item-placeholder {
    width: 104px;
    height: 104px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #f8fafc;
}

.conference-item-image {
    object-fit: cover;
}

.conference-item-placeholder {
    display: grid;
    place-items: center;
    color: var(--app-muted);
    font-size: 2rem;
}

.conference-item-info h3 {
    margin: 0 0 10px;
    font-size: 1.15rem;
    font-weight: 820;
}

.conference-item-codes,
.conference-item-values {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    color: var(--app-muted);
}

.conference-item-check {
    display: grid;
    gap: 8px;
}

.conference-check-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    border: 2px solid #198754;
    border-radius: 8px;
    color: #0f5132;
    background: #fff;
    font-weight: 820;
    cursor: pointer;
}

.conference-check-button input {
    width: 18px;
    height: 18px;
}

.conference-finish-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--app-border);
}

.conference-empty {
    display: grid;
    place-items: center;
    min-height: 340px;
    padding: 40px;
    text-align: center;
}

.conference-empty i {
    color: var(--app-primary);
    font-size: 4rem;
}

.conference-empty h2 {
    margin: 12px 0 4px;
    font-weight: 820;
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .conference-layout {
        grid-template-columns: 1fr;
    }

    .post-sale-header {
        grid-template-columns: 1fr;
    }

    .question-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: static;
        width: 100%;
        height: auto;
    }

    .sidebar-footer {
        margin-top: 20px;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 20px;
    }

    .content-area {
        padding: 20px;
    }
}

@media (max-width: 560px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .login-panel {
        padding: 24px;
    }

    .user-chip {
        width: 100%;
        justify-content: center;
    }

    .product-card {
        grid-template-columns: 84px minmax(0, 1fr);
    }

    .product-card-image {
        width: 84px;
        height: 84px;
    }

    .carousel-url {
        display: grid;
    }

    .order-summary,
    .order-item {
        grid-template-columns: 1fr;
    }

    .conference-item,
    .conference-finish-panel {
        grid-template-columns: 1fr;
    }

    .post-sale-reply-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .quick-reply-card,
    .quick-reply-actions {
        grid-template-columns: 1fr;
    }

    .quick-reply-actions {
        display: grid;
    }

    .conference-item-image,
    .conference-item-placeholder {
        width: 84px;
        height: 84px;
    }
}
