:root {
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --bg: #0F172A;
    --surface: #1E293B;
    --surface-2: #283548;
    --border: rgba(20, 184, 166, .12);
    --border-hover: rgba(20, 184, 166, .3);
    --primary: #14B8A6;
    --primary-glow: rgba(20, 184, 166, .2);
    --accent: #F59E0B;
    --text: #F1F5F9;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    --green: #4ADE80;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, .4);
    --transition: .25s ease
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    background-image: radial-gradient(ellipse at 20% 0%, rgba(20, 184, 166, .05) 0%, transparent 50%), radial-gradient(ellipse at 80% 100%, rgba(245, 158, 11, .04) 0%, transparent 50%)
}

.header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    background: rgba(15, 23, 42, .8);
    position: sticky;
    top: 0;
    z-index: 50
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 184, 166, .1);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 1.25rem
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.header-tagline {
    font-size: .8rem;
    color: var(--text-muted)
}

.main {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
    width: 100%
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    animation: fadeIn .5s ease backwards
}

.section-title {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: .85rem
}

.sub-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 1rem 0 .5rem
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all .2s ease
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(20, 184, 166, .04)
}

.upload-content {
    pointer-events: none
}

.upload-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .5rem
}

.text-dim {
    font-size: .75rem;
    color: var(--text-dim)
}

.upload-actions {
    display: flex;
    gap: .75rem;
    margin-top: .75rem
}

.preview-row {
    display: flex;
    gap: 1rem;
    align-items: center
}

.preview-img {
    width: 120px;
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border)
}

.progress-info {
    flex: 1
}

.progress-bar {
    height: 8px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: .5rem
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 999px;
    width: 0%;
    transition: width .3s ease
}

.progress-text {
    font-size: .8rem;
    color: var(--text-muted)
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1rem
}

.result-box {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: .75rem;
    border: 1px solid var(--border)
}

.result-box.highlight {
    border-color: var(--primary)
}

.rb-label {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-dim);
    display: block;
    margin-bottom: .25rem
}

.rb-value {
    font-size: .95rem;
    font-weight: 600
}

.rb-total {
    font-size: 1.25rem;
    color: var(--primary)
}

.items-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem
}

.items-table th {
    background: var(--surface-2);
    padding: .5rem .75rem;
    text-align: left;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted)
}

.items-table td {
    padding: .4rem .75rem;
    border-top: 1px solid var(--border)
}

.raw-text {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .75rem;
    font-family: var(--font-mono);
    font-size: .75rem;
    line-height: 1.5;
    color: var(--text-muted);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 1rem
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: .4rem
}

.hist-item {
    padding: .5rem .75rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem
}

.hist-meta {
    color: var(--text-dim);
    font-size: .7rem
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary), #0D9488);
    color: #fff;
    padding: .6rem 1.1rem;
    font-weight: 600;
    box-shadow: 0 4px 16px var(--primary-glow)
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--primary-glow)
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    padding: .4rem .75rem
}

.btn--ghost:hover {
    background: rgba(20, 184, 166, .1);
    color: var(--text)
}

.btn--sm {
    font-size: .8rem;
    padding: .35rem .65rem
}

.form-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap
}

.hidden {
    display: none !important
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: all .4s cubic-bezier(.16, 1, .3, 1);
    z-index: 100
}

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

.footer {
    text-align: center;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: .8rem
}

.footer a {
    color: var(--primary);
    text-decoration: none
}

@media(max-width:768px) {
    .header {
        padding: 1rem
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: .25rem
    }

    .main {
        padding: 1rem
    }

    .preview-row {
        flex-direction: column
    }

    .result-grid {
        grid-template-columns: 1fr 1fr
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}