:root {
    color-scheme: dark;
    --bg: #050505;
    --panel: #0b0b0b;
    --panel-raised: #101010;
    --border: #222;
    --border-strong: #3a3a3a;
    --text: #e8e8e8;
    --muted: #8a8a8a;
    --danger: #ff7b72;
    --warn: #f2cc60;
    --info: #76c7ff;
    --ok: #7ee787;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "SF Mono", "Monaco", "Menlo", "Consolas", "Liberation Mono", monospace;
    line-height: 1.45;
}

body {
    min-height: 100vh;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
input,
textarea,
select,
a {
    color: inherit;
}

button,
input,
textarea,
select {
    appearance: none;
    border-radius: 0;
}

button,
input,
textarea,
select {
    background: transparent;
    border: 1px solid var(--border);
}

.ghost-link {
    border: 1px solid var(--border);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: none;
    border-color: var(--border-strong);
}

a {
    text-decoration: none;
}

.app-shell {
    width: min(100%, 820px);
    margin: 0 auto;
    padding: 20px 16px 40px;
}

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

.app-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

.app-header p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.toolbar,
.composer-section,
.category-block,
.empty-state {
    border-top: 1px solid var(--border);
}

.toolbar {
    padding-top: 16px;
}

.quick-add-form {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto;
    gap: 8px;
}

.quick-add-form input,
.quick-add-form button,
.editor-form input,
.editor-form textarea,
.editor-form select,
.panel-actions button,
.ghost-button,
.ghost-link,
.item-edit {
    min-height: 42px;
    padding: 10px 12px;
}

.quick-add-form button,
.panel-actions button,
.ghost-button,
.ghost-link,
.item-edit {
    cursor: pointer;
}

.quick-add-form button[disabled] {
    opacity: 0.55;
    cursor: default;
}

.summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
}

.summary-bar-compact {
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    white-space: nowrap;
}

.summary-bar-compact::-webkit-scrollbar {
    display: none;
}

.stream-live {
    color: var(--ok);
}

.stream-connecting,
.stream-reconnecting {
    color: var(--warn);
}

.stream-offline {
    color: var(--danger);
}

.feedback,
.loading-state {
    margin: 12px 0 0;
    color: var(--danger);
    font-size: 13px;
}

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

.inline-editor-header strong {
    font-size: 14px;
}

.editor-form {
    display: grid;
    gap: 10px;
}

.editor-form label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}

.editor-form input,
.editor-form textarea,
.editor-form select {
    color: var(--text);
}

.editor-form textarea {
    resize: vertical;
    min-height: 88px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    min-height: 18px;
    margin: 0;
    position: relative;
}

.checkbox-row input:checked::after {
    content: "";
    position: absolute;
    inset: 3px;
    background: var(--ok);
}

.panel-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ghost-button,
.ghost-link,
.muted-text {
    color: var(--muted);
}

.button-primary {
    background: var(--ok);
    border-color: var(--ok);
    color: var(--bg);
    font-weight: 600;
}

.button-primary:hover {
    background: #9df0a7;
    border-color: #9df0a7;
    color: var(--bg);
}

.button-primary[disabled] {
    opacity: 0.7;
    cursor: default;
}

.content {
    padding-top: 6px;
}

.composer-section {
    padding-top: 16px;
}

.category-block {
    padding: 18px 0 0;
}

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

.category-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.category-header span {
    color: var(--muted);
    font-size: 12px;
}

.category-list {
    display: grid;
    gap: 4px;
}

.item-stack {
    display: grid;
    gap: 0;
}

.item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: baseline;
    padding: 1px 0;
}

.inline-editor {
    margin: 4px 0 10px 22px;
    padding: 12px 12px 10px;
    border-left: 1px solid var(--border-strong);
    background: var(--panel-raised);
}

.inline-editor-feedback {
    margin: 0 0 10px;
    color: var(--danger);
    font-size: 13px;
}

.inline-editor .ghost-button {
    min-height: 32px;
    padding: 6px 10px;
}

.inline-editor .ghost-link,
.inline-editor .panel-actions button {
    min-height: 36px;
    padding: 8px 10px;
}

.item-cycle {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    width: 100%;
    align-items: baseline;
    padding: 0;
    text-align: left;
    cursor: pointer;
    border: 0;
    background: transparent;
}

.item-cycle:hover,
.item-edit:hover,
.ghost-button:hover,
.ghost-link:hover,
.quick-add-form button:hover,
.panel-actions button:hover {
    color: #fff;
}

.panel-actions .button-primary:hover {
    color: var(--bg);
}

.item-symbol {
    color: var(--muted);
}

.item-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
    font-size: 14px;
}

.item-status {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.item-edit {
    padding: 0 0 0 4px;
    min-height: 20px;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.status-in_stock .item-status {
    color: var(--ok);
}

.status-out_of_stock .item-status {
    color: var(--danger);
}

.status-almost_gone .item-status {
    color: var(--warn);
}

.status-ordering .item-status {
    color: var(--info);
}

.empty-state {
    padding: 18px 0 0;
    color: var(--muted);
}

.empty-state p {
    margin: 0 0 8px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 640px) {
    .app-shell {
        padding: 14px 12px 28px;
    }

    .app-header {
        gap: 8px;
        margin-bottom: 10px;
    }

    .app-header h1 {
        font-size: 18px;
    }

    .app-header p {
        font-size: 11px;
    }

    .quick-add-form {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px;
    }

    .panel-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar {
        padding-top: 10px;
    }

    .composer-section {
        padding-top: 14px;
    }

    .quick-add-form input,
    .quick-add-form button {
        min-height: 36px;
        padding: 7px 10px;
        font-size: 13px;
    }

    .summary-bar {
        gap: 6px;
        font-size: 11px;
        letter-spacing: 0.01em;
        margin-top: 6px;
    }

    .category-block {
        padding-top: 14px;
    }

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

    .item-row {
        gap: 8px;
    }

    .inline-editor {
        margin-left: 16px;
        padding: 10px;
    }

    .item-cycle {
        gap: 6px;
    }

    .item-name {
        font-size: 13px;
    }

    .item-status,
    .item-edit {
        font-size: 11px;
    }

    .item-status {
        letter-spacing: 0;
    }
}
