* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: #050806;
    color: #eafbf0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    min-height: 100vh;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    width: min(960px, 100%);
    margin: 0 auto;
    padding: 14px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

h1 {
    margin: 0;
    color: #90ffb8;
    font-size: 34px;
    letter-spacing: 0.04em;
}

.subtitle {
    margin: 0;
    color: #8fa99a;
    font-size: 13px;
}

.settings-button,
.sub-button,
.primary-button,
.icon-button {
    border: 1px solid #2e5540;
    background: #102018;
    color: #eafbf0;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
}

.settings-button:hover,
.sub-button:hover,
.primary-button:hover,
.icon-button:hover {
    background: #173222;
}

.scan-panel {
    background: #0c130f;
    border: 1px solid #203a2c;
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 0 0 1px rgba(144, 255, 184, 0.04);
}

.input-label {
    display: block;
    color: #9fcfb1;
    font-size: 13px;
    margin-bottom: 6px;
}

.barcode-input {
    width: 100%;
    border: 2px solid #315f45;
    background: #020403;
    color: #ffffff;
    border-radius: 14px;
    padding: 15px;
    font-size: 24px;
    outline: none;
}

.barcode-input:focus {
    border-color: #90ffb8;
    box-shadow: 0 0 0 3px rgba(144, 255, 184, 0.12);
}

.scan-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.sub-button {
    flex: 1;
}

.danger {
    border-color: #663333;
    background: #211010;
}

.danger:hover {
    background: #331616;
}

.status-box {
    margin-top: 12px;
    padding: 10px 12px;
    background: #07100b;
    border: 1px solid #1a3325;
    border-radius: 12px;
    color: #bdfbd1;
    min-height: 42px;
}

.queue-info {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 10px;
    color: #8fa99a;
    font-size: 13px;
}

.queue-info strong {
    color: #ffffff;
}

.cards-box {
    display: grid;
    gap: 12px;
}

.result-card {
    background: #101814;
    border: 1px solid #2a3f33;
    border-left: 8px solid #55645b;
    border-radius: 18px;
    padding: 14px;
}

.result-card.pending {
    border-left-color: #8fa99a;
}

.result-card.searching {
    border-left-color: #63c7ff;
}

.result-card.rank-1 {
    border-left-color: #ff4d4d;
}

.result-card.rank-2 {
    border-left-color: #ffad33;
}

.result-card.rank-3 {
    border-left-color: #ffd966;
}

.result-card.rank-4 {
    border-left-color: #55d985;
}

.result-card.rank-none {
    border-left-color: #777777;
}

.result-card.error {
    border-left-color: #ff4d4d;
    background: #1a0d0d;
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.code-text {
    color: #bdfbd1;
    font-size: 15px;
    word-break: break-all;
}

.badge {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
}

.pending-badge {
    background: #243229;
    color: #d4e8da;
}

.searching-badge {
    background: #15364a;
    color: #bdeaff;
}

.done-badge {
    background: #173d26;
    color: #90ffb8;
}

.error-badge {
    background: #4a1515;
    color: #ffd0d0;
}

.title-text {
    color: #ffffff;
    font-size: 20px;
    line-height: 1.35;
    font-weight: 700;
    margin-bottom: 10px;
}

.muted {
    color: #8fa99a;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.meta-grid > div {
    background: #07100b;
    border: 1px solid #193124;
    border-radius: 12px;
    padding: 8px;
}

.label {
    display: block;
    color: #8fa99a;
    font-size: 12px;
    margin-bottom: 3px;
}

.value {
    display: block;
    color: #eafbf0;
    font-size: 15px;
    font-weight: 700;
}

.ranking-value {
    color: #ffffff;
}

.price-list {
    background: #07100b;
    border: 1px solid #193124;
    border-radius: 14px;
    padding: 10px;
}

.price-title {
    color: #90ffb8;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}

.price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #15251b;
    padding: 7px 0;
}

.price-row:last-child {
    border-bottom: none;
}

.price-row span {
    color: #8fa99a;
}

.price-row strong {
    color: #ffffff;
    font-size: 18px;
}

.card-note {
    color: #8fa99a;
    font-size: 12px;
    margin-top: 10px;
}

.modal.hidden {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.68);
}

.modal-content {
    position: relative;
    width: min(520px, calc(100% - 24px));
    margin: 40px auto;
    background: #0c130f;
    border: 1px solid #315f45;
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h2 {
    margin: 0;
    color: #90ffb8;
}

.icon-button {
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 24px;
}

.setting-group {
    margin-bottom: 16px;
}

.setting-label {
    display: block;
    color: #bdfbd1;
    font-size: 14px;
    margin-bottom: 8px;
}

.setting-input,
.small-number-input {
    width: 100%;
    border: 1px solid #315f45;
    background: #020403;
    color: #ffffff;
    border-radius: 10px;
    padding: 10px;
}

.rank-setting-row {
    display: grid;
    grid-template-columns: 72px 24px 1fr 24px;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.rank-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #050806;
}

.rank-chip.rank-1 {
    background: #ff4d4d;
}

.rank-chip.rank-2 {
    background: #ffad33;
}

.rank-chip.rank-3 {
    background: #ffd966;
}

.rank-chip.rank-4 {
    background: #55d985;
}

.setting-note {
    color: #8fa99a;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 14px;
}

.primary-button {
    width: 100%;
    background: #1f6f3c;
    border-color: #2fa65a;
    color: #ffffff;
    font-weight: 700;
}

@media (max-width: 560px) {
    .app-shell {
        padding: 10px;
    }

    h1 {
        font-size: 28px;
    }

    .barcode-input {
        font-size: 20px;
    }

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

    .scan-actions {
        flex-direction: column;
    }

    .title-text {
        font-size: 18px;
    }

    .modal-content {
        margin-top: 18px;
    }
}


/* Librion v0.2: condition + collapsible offer list */
.price-row {
    display: grid;
    grid-template-columns: 34px 72px 1fr;
    align-items: center;
    gap: 8px;
}

.price-no {
    color: #8fa99a;
}

.condition-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    border: 1px solid #315f45;
    background: #0d1b13;
    color: #bdfbd1;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 700;
}

.price-extra.hidden {
    display: none;
}

.price-expand-button {
    width: 100%;
    margin-top: 10px;
    border: 1px solid #315f45;
    background: #102018;
    color: #90ffb8;
    border-radius: 12px;
    padding: 10px;
    font-weight: 700;
    cursor: pointer;
}

.price-expand-button:hover {
    background: #173222;
}

.setting-note-inline {
    color: #8fa99a;
    font-size: 12px;
    line-height: 1.5;
    margin-top: 6px;
}


/* Librion v0.3: camera scanner */
.camera-modal.hidden {
    display: none;
}

.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
}

.camera-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
}

.camera-content {
    position: relative;
    width: min(720px, calc(100% - 20px));
    margin: 18px auto;
    background: #0c130f;
    border: 1px solid #315f45;
    border-radius: 20px;
    padding: 14px;
    box-shadow: 0 20px 90px rgba(0, 0, 0, 0.65);
}

.camera-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.camera-header h2 {
    margin: 0;
    color: #90ffb8;
    font-size: 22px;
}

.camera-header p {
    margin: 2px 0 0;
    color: #8fa99a;
    font-size: 13px;
}

.camera-video-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #000000;
    border: 1px solid #203a2c;
    border-radius: 16px;
    aspect-ratio: 16 / 9;
}

.camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-frame {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 34%;
    bottom: 34%;
    border: 3px solid #90ffb8;
    border-radius: 14px;
    box-shadow:
        0 0 0 999px rgba(0, 0, 0, 0.18),
        0 0 18px rgba(144, 255, 184, 0.55);
    pointer-events: none;
}

.camera-status {
    margin-top: 10px;
    padding: 10px 12px;
    background: #07100b;
    border: 1px solid #193124;
    border-radius: 12px;
    color: #bdfbd1;
    min-height: 42px;
}

@media (max-width: 560px) {
    .camera-content {
        margin: 10px auto;
        width: calc(100% - 12px);
        padding: 10px;
    }

    .camera-video-wrap {
        aspect-ratio: 3 / 4;
    }

    .scan-frame {
        left: 6%;
        right: 6%;
        top: 38%;
        bottom: 38%;
    }
}


/* Librion camera fix: compact scanner */
.camera-backdrop {
    display: none;
}

.camera-modal {
    position: fixed;
    top: 8px;
    left: 0;
    right: 0;
    bottom: auto;
    z-index: 2000;
    pointer-events: none;
}

.camera-content {
    pointer-events: auto;
    width: min(720px, calc(100% - 16px));
    margin: 0 auto;
    padding: 10px;
    border-radius: 18px;
}

.camera-header {
    margin-bottom: 6px;
}

.camera-header h2 {
    font-size: 18px;
}

.camera-header p {
    font-size: 12px;
}

.camera-video-wrap {
    aspect-ratio: 16 / 5;
    max-height: 190px;
}

.scan-frame {
    left: 6%;
    right: 6%;
    top: 34%;
    bottom: 40%;
    border-width: 2px;
}

.camera-status {
    margin-top: 8px;
    padding: 8px 10px;
    min-height: 36px;
    font-size: 13px;
}

body.camera-active .app-shell {
    padding-top: 240px;
}

body.camera-active .scan-panel {
    display: none;
}

@media (max-width: 560px) {
    .camera-content {
        width: calc(100% - 8px);
        margin-top: 4px;
        padding: 8px;
    }

    .camera-video-wrap {
        aspect-ratio: 16 / 6;
        max-height: 150px;
    }

    .scan-frame {
        left: 5%;
        right: 5%;
        top: 34%;
        bottom: 40%;
    }

    .camera-status {
        font-size: 12px;
    }

    body.camera-active .app-shell {
        padding-top: 205px;
    }

    body.camera-active .app-header {
        margin-bottom: 8px;
    }
}


/* Librion API settings */
.api-setting-group {
    border: 1px solid #1f3d2c;
    border-radius: 14px;
    padding: 12px;
    background: #07100b;
}

.api-section-title {
    color: #90ffb8;
    font-weight: 700;
    font-size: 14px;
    margin: 12px 0 8px;
}

.api-section-title:first-of-type {
    margin-top: 0;
}

.mini-label {
    display: block;
    color: #8fa99a;
    font-size: 12px;
    margin: 9px 0 4px;
}

.secret-input {
    letter-spacing: 0.02em;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #eafbf0;
    background: #0d1b13;
    border: 1px solid #1f3d2c;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
}

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