:root {
    --bg:         #1a1a1a;
    --surface:    #222222;
    --border:     #2e2e2e;
    --text:       #e2e2e2;
    --text-muted: #666666;
    --text-sub:   #888888;
    --hover:      #252525;
    --btn-bg:     #cacaca;
    --btn-text:   #111111;
    --danger:     #e05555;
}

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: system-ui, sans-serif;
    max-width: 700px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

h1 {
    margin-top: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.3rem;
}

h2 {
    margin-top: 1.5rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-sub);
}

p {
    margin: 0.5rem 0 1rem;
}

a {
    color: inherit;
}

footer {
    margin-top: 3rem;
    padding-top: 1rem;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

th,
td {
    text-align: left;
    padding: 0.4rem;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: 0.85em;
}

td {
    font-variant-numeric: tabular-nums;
}

input,
button,
select {
    font-size: 1rem;
    padding: 0.6rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--text-sub);
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    margin-bottom: 0.5rem;
}

form button,
#add-btn,
#export-btn {
    width: 100%;
    background: var(--btn-bg);
    color: var(--btn-text);
    border-color: var(--btn-bg);
}

.danger {
    width: 100%;
    background: none;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
}

.subtle {
    width: 100%;
    background: none;
    color: var(--text-sub);
    border: 1px solid var(--text-sub);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
}

button {
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
}

#search-results {
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
}

#search-results div,
#search-results p {
    padding: 0.75rem 0.5rem;
    cursor: pointer;
}

#search-results p {
    cursor: default;
}

#search-results div:hover,
#search-results div:active {
    background: var(--hover);
}

.totals-table {
    table-layout: fixed;
    width: 100%;
}

.totals-table th {
    text-align: center;
}

.totals {
    font-weight: bold;
    text-align: center;
}

.section {
    margin: 1.5rem 0;
}

details {
    margin: 1.5rem 0;
}

summary {
    cursor: pointer;
    font-weight: bold;
}

pre {
    background: var(--surface);
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.8rem;
    max-height: 300px;
    overflow-y: auto;
    border-radius: 6px;
    color: var(--text);
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}

.log-item button {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    min-height: 44px;
    min-width: 44px;
}

.log-item-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-shrink: 0;
}

.log-edit-input {
    width: 5rem;
    margin: 0;
    padding: 0.3rem 0.5rem;
    font-size: 0.95rem;
}

.hidden {
    display: none;
}

.mt {
    margin-top: 0.5rem;
}

.muted {
    color: var(--text-muted);
}

details h3 {
    margin-top: 1rem;
}

#log-list h3 {
    margin-top: 1.5rem;
    margin-bottom: 0;
}

#log-list h3:first-child {
    margin-top: 0;
}

.table-scroll {
    overflow-x: auto;
}

.search-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.search-row input {
    flex: 1;
    margin-bottom: 0;
}

.scan-btn {
    flex-shrink: 0;
    width: auto;
    padding: 0.6rem 0.75rem;
    min-height: 0;
}

#scanner-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    gap: 1rem;
}

#scanner-overlay.hidden {
    display: none;
}

.scanner-wrap {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 16 / 9;
    background: #111;
    border-radius: 8px;
    overflow: hidden;
}

#scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.15s;
}

#scanner-status {
    color: var(--text-sub);
    margin: 0;
    font-size: 0.9rem;
    text-align: center;
}

#scanner-cancel {
    background: none;
    color: var(--text);
    border: 1px solid #555;
    width: auto;
    padding: 0.6rem 1.5rem;
}

.product-table th,
.product-table td {
    white-space: nowrap;
    font-size: 0.85em;
    padding: 0.3rem 0.5rem;
    text-align: center;
}

.product-table td:first-child {
    white-space: normal;
    text-align: left;
}
