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

:root {
    --ah-blue: #0079C2;
    --ah-blue-dark: #005CA9;
    --ah-blue-light: #E8F4FB;
    --green: #2E7D32;
    --red: #C62828;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-400: #9CA3AF;
    --gray-600: #4B5563;
    --gray-800: #1F2937;
    --radius: 10px;
    --shadow: 0 1px 4px rgba(0,0,0,.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────── */

.app-header {
    background: var(--ah-blue);
    color: #fff;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-ah {
    background: #fff;
    color: var(--ah-blue);
    font-weight: 900;
    font-size: 18px;
    padding: 2px 8px;
    border-radius: 6px;
    letter-spacing: -0.5px;
}

.logo-label {
    font-size: 16px;
    font-weight: 600;
    opacity: .9;
}

.list-id-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    opacity: .85;
}

.list-label { opacity: .7; }

.list-code {
    background: rgba(255,255,255,.15);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

.btn-copy {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background .15s;
}
.btn-copy:hover { background: rgba(255,255,255,.25); }

/* ── Main layout ──────────────────────────────────────────────────── */

.app-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    align-items: start;
}

.panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ── Search panel ─────────────────────────────────────────────────── */

.search-box {
    position: relative;
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.search-icon {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

#search {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color .15s;
    background: var(--gray-50);
}
#search:focus { border-color: var(--ah-blue); background: #fff; }

.product-list {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.hint {
    padding: 24px;
    text-align: center;
    color: var(--gray-400);
    font-size: 14px;
}

.product-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    transition: background .1s;
}
.product-card:hover { background: var(--gray-50); }
.product-card.in-list { background: var(--ah-blue-light); }

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-meta {
    font-size: 12px;
    color: var(--gray-600);
    margin-top: 2px;
    display: block;
}

.btn-add {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--ah-blue);
    background: #fff;
    color: var(--ah-blue);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    font-weight: 300;
}
.btn-add:hover:not(:disabled) {
    background: var(--ah-blue);
    color: #fff;
}
.btn-add.added {
    background: var(--ah-blue);
    color: #fff;
    border-color: var(--ah-blue);
    font-size: 14px;
    cursor: default;
}

/* ── Shopping list panel ──────────────────────────────────────────── */

.panel-list {
    position: sticky;
    top: 72px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 88px);
}

.list-header {
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.list-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
}

.item-count {
    font-size: 12px;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 20px;
}

.list-items {
    flex: 1;
    overflow-y: auto;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    transition: background .1s;
}
.list-item:hover { background: var(--gray-50); }
.list-item.checked .list-item-name {
    text-decoration: line-through;
    opacity: .45;
}
.list-item.checked .list-item-price { opacity: .45; }

.btn-check {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--gray-200);
    background: #fff;
    color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.btn-check:hover { border-color: var(--green); color: var(--green); }
.list-item.checked .btn-check {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.list-item-info {
    flex: 1;
    min-width: 0;
}

.list-item-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-price {
    font-size: 12px;
    color: var(--ah-blue);
    font-weight: 600;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.btn-qty {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--gray-200);
    background: #fff;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: all .15s;
}
.btn-qty:hover { border-color: var(--ah-blue); color: var(--ah-blue); }

.qty-value {
    font-size: 13px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.btn-remove {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.btn-remove:hover { background: #FEE2E2; color: var(--red); }

/* ── List footer ──────────────────────────────────────────────────── */

.list-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    flex-direction: column;
    gap: 10px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 700;
}

.total-price { color: var(--ah-blue); }

.btn-clear-checked {
    width: 100%;
    padding: 8px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    background: #fff;
    color: var(--gray-600);
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
}
.btn-clear-checked:hover { border-color: var(--red); color: var(--red); }

/* ── Toast ────────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--gray-800);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: all .2s;
    pointer-events: none;
    z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 700px) {
    .app-main {
        grid-template-columns: 1fr;
        padding: 10px;
    }
    .panel-list {
        position: static;
        max-height: 60vh;
    }
    .product-list {
        max-height: 55vh;
    }
    .logo-label { display: none; }
    .list-id-wrap { font-size: 12px; }
}
