/* Base Styles and Typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #2563eb;
    --bg-color: #384755;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #384755;
    /* Slate 100 */
    margin: 0;
    padding: 0;
    color: #0c1d35;
    /* Slate 700 */
    line-height: 1.5;
}

/* Header */
header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1.5rem 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

header h1 {
    color: #0f172a;
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.025em;
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
}

.icon-btn {
    flex: 1;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1/1;
    min-width: 0;
    border-radius: 4px;
    border: 1px solid rgba(226, 232, 240, 0.4);
    box-shadow: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.icon-btn:active {
    background-color: rgba(0, 0, 0, 0.1);
}

.icon-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.icon-btn.warning,
.icon-btn.secondary {
    background: transparent;
    border-color: rgba(226, 232, 240, 0.4);
}

/* Controls Wrapper */
.header-controls {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    gap: 12px;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.controls a {
    display: contents;
    /* Allow anchor children buttons to participate in flex */
}

select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    color: #0f172a;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

select:focus {
    outline: none;
    border-color: #3b82f6;
    /* Blue 500 */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: #ffffff;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid #cbd5e1;
    transition: all 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

button:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    color: #1e293b;
}

button.primary {
    background-color: #2563eb;
    /* Blue 600 */
    color: white;
    border: 1px solid transparent;
}

button.primary:hover {
    background-color: #1d4ed8;
    /* Blue 700 */
}

button.secondary {
    color: #ef4444;
    /* Red 500 */
    border-color: #fecaca;
    background-color: #fef2f2;
}

button.secondary:hover {
    background-color: #fee2e2;
    border-color: #fca5a5;
}

button.warning {
    color: #92400e;
    /* Amber 800 */
    border-color: #fde68a;
    /* Amber 200 */
    background-color: #fffbeb;
    /* Amber 50 */
}

button.warning:hover {
    background-color: #fef3c7;
    /* Amber 100 */
    border-color: #fcd34d;
    /* Amber 300 */
}

#refreshBtn {
    background-color: transparent;
    color: inherit;
    border: 1px solid rgba(226, 232, 240, 0.4);
}

#refreshBtn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Input Area */
.add-item-section {
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
}

.autocomplete-wrapper {
    position: relative;
    flex-grow: 1;
}

input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s;
    background-color: #f8fafc;
}

input[type="text"]:focus {
    outline: none;
    background-color: #fff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#addBtn {
    background-color: #10b981;
    /* Emerald 500 */
    color: white;
    font-weight: 600;
    border: none;
    padding: 0 24px;
}

#addBtn:hover {
    background-color: #059669;
}

/* List */
.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    /* Slate 500 */
    margin: 24px 0 8px 12px;
}

/* UNSURE OF LOCATION specific title styling */
.section-title.unsure-of-location {
    color: #ef4444 !important;
    /* Red 500 */
}

/* ANOTHER SHOP specific title styling */
.section-title.another-shop {
    color: #2563eb !important;
    /* Blue 600 */
}

/* Selected Section specific styling */
.section-title.selected-section-title {
    margin-top: 40px;
    color: #10b981; /* Emerald 500 */
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
}

.section-container.selected-section .list-item {
    opacity: 0.75;
}

.section-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    min-height: 10px;
    /* Drop target */
    transition: box-shadow 0.2s, transform 0.2s, background-color 0.2s;
    border: 2px solid transparent;
}

/* UNSURE OF LOCATION specific item styling */
.unsure-of-location.section-container .list-item {
    background-color: #fef2f2 !important;
    /* Pale Red */
}

.unsure-of-location.section-container .list-item span {
    color: #991b1b !important;
    /* Deep Red */
    font-weight: 700;
}

/* ANOTHER SHOP specific item styling */
.another-shop.section-container .list-item {
    background-color: #eff6ff !important;
    /* Blue 50 */
}

.another-shop.section-container .list-item span {
    color: #1d4ed8 !important;
    /* Blue 700 */
    font-weight: 700;
}

.section-container.drag-over {
    background-color: #eff6ff;
    border-color: #3b82f6;
    border-style: dashed;
    box-shadow: none;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: grab;
    transition: background-color 0.15s;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background-color: #f8fafc;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.qty-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.qty-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #94a3b8;
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-text {
    font-size: 14px;
    color: #64748b;
    font-weight: 600;
    min-width: 35px;
    text-align: center;
}

.list-item.dragging {
    background-color: #f1f5f9;
    opacity: 0.6;
}

.list-item:active {
    background-color: #f1f5f9;
    transform: scale(0.98);
}

.list-item span {
    font-size: 16px;
    color: #334155;
    font-weight: 500;
    transition: color 0.2s;
    text-transform: lowercase;
}

/* Checkbox */
.checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    margin-right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background-color: #fff;
}

.list-item:hover .checkbox {
    border-color: #94a3b8;
}

/* Checked State */
.list-item.checked {
    background-color: #f8fafc;
}

.list-item.checked span {
    text-decoration: line-through;
    color: #94a3b8;
}

.list-item.checked .checkbox {
    background-color: #10b981;
    /* Emerald 500 */
    border-color: #10b981;
}

.list-item.checked .checkbox::after {
    content: '';
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

/* Autocomplete Dropdown */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.autocomplete-list div {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}

.autocomplete-list div:last-child {
    border-bottom: none;
}

.autocomplete-list div:hover {
    background-color: #f1f5f9;
}

.autocomplete-list div.autocomplete-active {
    background-color: #e0f2fe;
    color: #0284c7;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: #64748b;
    display: none;
}

.loading.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .controls {
        flex-direction: row;
        width: 100%;
    }

    .controls a,
    .controls button {
        flex: 1;
    }

    .add-item-section {
        flex-direction: column;
        align-items: stretch;
    }

    #addBtn {
        width: 100%;
        padding: 12px;
        border-radius: 8px;
    }

    input[type="text"] {
        border-radius: 8px;
        appearance: none;
        /* remove iOS internal styling */
        -webkit-appearance: none;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #fefefe;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #0f172a;
}

.modal-subtitle {
    margin: 4px 0 0 0;
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Sortable List in Modal */
.sortable-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sortable-item {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    cursor: move;
    cursor: grab;
    user-select: none;
    gap: 10px;
}

.sort-handle {
    font-size: 20px;
    color: #94a3b8;
    cursor: move;
    /* Explicit cursor for handle */
}

.modal-cat-input {
    flex-grow: 1;
    border: 1px solid transparent;
    background: transparent;
    padding: 6px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    transition: all 0.2s;
}

.modal-cat-input:focus {
    background: white;
    border-color: #3b82f6;
    outline: none;
}

.delete-cat-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 20px;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    border-radius: 4px;
}

.delete-cat-btn:hover {
    background-color: #fee2e2;
    color: #b91c1c;
}

/* Other Locations Zone */
.other-locations-zone {
    margin-top: 30px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background-color: #384755;
    text-align: center;
    transition: all 0.3s;
    overflow: hidden;
}

.zone-label {
    padding: 15px;
    font-weight: 600;
    color: #64748b;
    /* pointer-events: none; removed to allow interaction if needed */
}

/* Expand when dragging over */
.other-locations-zone.drag-active {
    background-color: #465563;
    border-color: #3b82f6;
    min-height: 50px;
    /* Ensure small target is always easy to find */
}

.other-locations-zone:hover,
.other-locations-zone.drag-active:hover {
    background-color: #465563;
}

.zone-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.3s ease-in-out;
}

.other-locations-zone.zone-hovered {
    overflow: visible;
    /* Ensure nothing clips when expanded */
}

.other-locations-zone.zone-hovered .zone-content {
    max-height: 5000px;
    /* Use large number for transition support */
    opacity: 1;
    padding: 10px;
}

.other-category-target {
    background: #f0fdf4;
    /* Lighter Emerald 50 */
    border: 1px solid #bbf7d0;
    /* Emerald 200 */
    border-radius: 8px;
    padding: 0;
    min-height: 48px;
    /* Solid hit target */
    display: flex;
    align-items: center;
    font-size: 15px;
    color: #0f172a;
    /* Slate 900 */
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    position: relative;
}

/* Make input fill the space but look transparent unless focused */
.category-name-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 14px;
    /* More padding for larger target */
    font-family: inherit;
    font-size: 15px;
    color: #0f172a !important;
    /* Force dark text */
    font-weight: 600;
    cursor: pointer;
    outline: none;
    text-align: center;
}

.category-name-input:focus {
    background: #ffffff;
    cursor: text;
}

.other-category-target.drag-over {
    background-color: #10b981;
    border-color: #10b981;
}

/* Ensure text is white on drag over, though input might cover it */
.other-category-target.drag-over .category-name-input {
    color: rgb(40, 172, 71);
    pointer-events: none;
    /* disable input interaction while dragging over */
}

/* Global Drag State Support - Surgical approach */
/* We only want to disable pointer-events on LEAF elements that might steal events
   from their parent drop targets. The targets themselves MUST remain active. */

body.dragging-active .category-name-input,
body.dragging-active .list-item span,
body.dragging-active .list-item .checkbox,
body.dragging-active .zone-label {
    pointer-events: none !important;
}

/* Ensure targets are explicitly interactive during drag */
body.dragging-active .other-category-target,
body.dragging-active .section-container,
body.dragging-active .other-locations-zone {
    pointer-events: auto !important;
}

/* Login Page Styles */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.login-card p {
    color: #666;
    margin-bottom: 2rem;
}

.login-card input[type="password"] {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 2px solid #eee;
    border-radius: 0.8rem;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.login-card input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-card button {
    width: 100%;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.8rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.login-card button:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.login-card button:active {
    transform: translateY(0);
}

.error-msg {
    color: #e74c3c;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* Undo / Redo */
.icon-btn.svg-btn svg {
    width: 55%;
    height: 55%;
    fill: none;
    stroke: #0f172a;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    max-width: calc(100% - 32px);
    padding: 10px 18px;
    border-radius: 10px;
    background: #0f172a;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.dev-badge {
    font-size: 0.8rem;
    font-weight: 700;
    vertical-align: middle;
    padding: 2px 8px;
    border-radius: 6px;
    background: #f59e0b;
    color: #fff;
}

/* Header: kebab menu + undo/redo row */
header {
    position: relative;
}

.header-controls {
    flex-direction: row;
    align-items: center;
}

.header-controls select {
    flex: 1;
    min-width: 0;
}

.undo-redo {
    display: flex;
    gap: 8px;
}

.undo-redo .icon-btn {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border-color: #cbd5e1;
}

.kebab-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.kebab-btn:hover,
.kebab-btn[aria-expanded="true"] {
    background: rgba(0, 0, 0, 0.07);
}

.kebab-btn svg {
    width: 22px;
    height: 22px;
    fill: #0f172a;
}

.menu-panel {
    position: absolute;
    top: 56px;
    right: 10px;
    min-width: 210px;
    padding: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    z-index: 1500;
}

.menu-panel[hidden] {
    display: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #0f172a;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
}

.menu-item:hover {
    background: #f1f5f9;
}

.menu-item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex: none;
}

/* Selected section: collapsible, sits below "Move to other location" */
.section-title.selected-section-title {
    margin-top: 24px;
    border-top: none;
    padding-top: 0;
}

.section-title.collapsible {
    cursor: pointer;
    user-select: none;
}

.section-container[hidden] {
    display: none;
}

/* Logo beside the page title */
header h1 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-link {
    display: inline-flex;
    flex: none;
}

.logo-link img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: block;
}

/* Menu icons: single colour, follow the text colour */
.menu-item svg.mi {
    width: 22px;
    height: 22px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.menu-sep {
    height: 1px;
    margin: 6px 4px;
    background: #e2e8f0;
}

/* Settings / About pages */
.page-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    color: #0f172a;
}

.page-card h2 {
    margin: 0 0 4px;
    font-size: 1.1rem;
}

.muted {
    color: #64748b;
    font-size: 0.9rem;
    margin: 4px 0 14px;
}

.theme-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
}

.theme-option input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.about-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 16px;
    margin: 0;
}

.about-list dt {
    color: #64748b;
}

.about-list dd {
    margin: 0;
    word-break: break-word;
}

.about-list a {
    color: #2563eb;
}

button.wide {
    width: 100%;
    padding: 12px;
}

.back-link {
    display: inline-block;
    margin: 8px 4px;
    color: #e2e8f0;
    text-decoration: none;
    font-weight: 500;
}

/* ---------------- Dark theme ---------------- */
html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] body {
    background-color: #0b1220;
    color: #e2e8f0;
}

html[data-theme="dark"] header {
    background: #111827;
    border-bottom-color: #1f2937;
}

html[data-theme="dark"] header h1 {
    color: #f1f5f9;
}

html[data-theme="dark"] select,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"] {
    background-color: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}

html[data-theme="dark"] input[type="text"]:focus {
    background-color: #0f172a;
}

html[data-theme="dark"] button {
    background-color: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

html[data-theme="dark"] button:hover {
    background-color: #273449;
    color: #f1f5f9;
}

html[data-theme="dark"] button.primary {
    background-color: #2563eb;
    color: #fff;
}

html[data-theme="dark"] #addBtn {
    background-color: #10b981;
    color: #fff;
}

html[data-theme="dark"] .icon-btn {
    background: transparent;
    border-color: #334155;
}

html[data-theme="dark"] .icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .icon-btn.svg-btn svg,
html[data-theme="dark"] .kebab-btn svg {
    stroke: #e2e8f0;
}

html[data-theme="dark"] .kebab-btn svg {
    fill: #e2e8f0;
    stroke: none;
}

html[data-theme="dark"] .kebab-btn:hover,
html[data-theme="dark"] .kebab-btn[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .add-item-section,
html[data-theme="dark"] .section-container,
html[data-theme="dark"] .page-card,
html[data-theme="dark"] .catalog-section {
    background: #1e293b;
    color: #e2e8f0;
}

html[data-theme="dark"] .section-title {
    color: #94a3b8;
}

html[data-theme="dark"] .section-title.selected-section-title {
    color: #34d399;
}

html[data-theme="dark"] .list-item {
    border-bottom-color: #2b3a50;
}

html[data-theme="dark"] .list-item:hover,
html[data-theme="dark"] .list-item.dragging,
html[data-theme="dark"] .list-item:active {
    background-color: #273449;
}

html[data-theme="dark"] .list-item span {
    color: #e2e8f0;
}

html[data-theme="dark"] .list-item.checked {
    background-color: #1a2536;
}

html[data-theme="dark"] .list-item.checked span {
    color: #64748b;
}

html[data-theme="dark"] .checkbox {
    background-color: #0f172a;
    border-color: #475569;
}

html[data-theme="dark"] .list-item.checked .checkbox {
    background-color: #10b981;
    border-color: #10b981;
}

html[data-theme="dark"] .qty-btn {
    background: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}

html[data-theme="dark"] .qty-btn:hover {
    background: #334155;
    color: #fff;
}

html[data-theme="dark"] .unsure-of-location.section-container .list-item {
    background-color: #3b1d22 !important;
}

html[data-theme="dark"] .unsure-of-location.section-container .list-item span {
    color: #fca5a5 !important;
}

html[data-theme="dark"] .another-shop.section-container .list-item {
    background-color: #172a4a !important;
}

html[data-theme="dark"] .another-shop.section-container .list-item span {
    color: #93c5fd !important;
}

html[data-theme="dark"] .section-container.drag-over {
    background-color: #172a4a;
}

html[data-theme="dark"] .other-locations-zone {
    background-color: #0b1220;
    border-color: #334155;
}

html[data-theme="dark"] .other-category-target {
    background: #12332a;
    border-color: #166534;
}

html[data-theme="dark"] .other-category-target,
html[data-theme="dark"] .category-name-input {
    color: #d1fae5 !important;
}

html[data-theme="dark"] .autocomplete-list {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

html[data-theme="dark"] .autocomplete-list div {
    border-bottom-color: #2b3a50;
}

html[data-theme="dark"] .autocomplete-list div:hover,
html[data-theme="dark"] .autocomplete-list div.autocomplete-active {
    background-color: #273449;
    color: #e2e8f0;
}

html[data-theme="dark"] .menu-panel {
    background: #1e293b;
    border-color: #334155;
}

html[data-theme="dark"] .menu-item {
    color: #e2e8f0;
}

html[data-theme="dark"] .menu-item:hover {
    background: #273449;
}

html[data-theme="dark"] .menu-sep {
    background: #334155;
}

html[data-theme="dark"] .modal-content {
    background-color: #1e293b;
    color: #e2e8f0;
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: #334155;
}

html[data-theme="dark"] .modal-header h2 {
    color: #f1f5f9;
}

html[data-theme="dark"] .sortable-item {
    background: #0f172a;
    border-color: #334155;
}

html[data-theme="dark"] .modal-cat-input {
    color: #e2e8f0;
}

html[data-theme="dark"] .modal-cat-input:focus {
    background: #1e293b;
}

html[data-theme="dark"] .toast {
    background: #e2e8f0;
    color: #0f172a;
}

html[data-theme="dark"] .theme-option {
    border-color: #334155;
}

html[data-theme="dark"] .about-list dt,
html[data-theme="dark"] .muted {
    color: #94a3b8;
}

html[data-theme="dark"] .about-list a {
    color: #60a5fa;
}

html[data-theme="dark"] .catalog-section h3 {
    background: #0f172a;
    color: #e2e8f0;
}

html[data-theme="dark"] .add-to-cat {
    background: #0f172a;
}

html[data-theme="dark"] .login-card {
    background: #1e293b;
    color: #e2e8f0;
}

/* History page */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.chip {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.chip.active {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.activity-day {
    margin: 16px 0 6px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.activity-day:first-child {
    margin-top: 0;
}

.activity-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.activity-row:last-child {
    border-bottom: none;
}

.activity-tag {
    flex: none;
    min-width: 76px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    background: #e2e8f0;
    color: #334155;
}

.kind-check .activity-tag,
.kind-select_all .activity-tag { background: #d1fae5; color: #065f46; }
.kind-uncheck .activity-tag,
.kind-select_none .activity-tag { background: #fef3c7; color: #92400e; }
.kind-add .activity-tag { background: #dbeafe; color: #1e40af; }
.kind-remove .activity-tag,
.kind-clear .activity-tag { background: #fee2e2; color: #991b1b; }
.kind-move .activity-tag,
.kind-edit .activity-tag { background: #ede9fe; color: #5b21b6; }
.kind-undo .activity-tag,
.kind-redo .activity-tag { background: #f1f5f9; color: #475569; }

.kind-undo .activity-text,
.kind-redo .activity-text {
    color: #64748b;
    font-style: italic;
}

.activity-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.activity-time {
    flex: none;
    font-size: 12px;
    color: #94a3b8;
}

html[data-theme="dark"] .activity-row {
    border-bottom-color: #2b3a50;
}

html[data-theme="dark"] .activity-tag {
    background: #334155;
    color: #e2e8f0;
}

html[data-theme="dark"] .kind-check .activity-tag,
html[data-theme="dark"] .kind-select_all .activity-tag { background: #064e3b; color: #a7f3d0; }
html[data-theme="dark"] .kind-uncheck .activity-tag,
html[data-theme="dark"] .kind-select_none .activity-tag { background: #5b3a0a; color: #fde68a; }
html[data-theme="dark"] .kind-add .activity-tag { background: #1e3a6e; color: #bfdbfe; }
html[data-theme="dark"] .kind-remove .activity-tag,
html[data-theme="dark"] .kind-clear .activity-tag { background: #5b1d1d; color: #fecaca; }
html[data-theme="dark"] .kind-move .activity-tag,
html[data-theme="dark"] .kind-edit .activity-tag { background: #3b2a6e; color: #ddd6fe; }
html[data-theme="dark"] .kind-undo .activity-tag,
html[data-theme="dark"] .kind-redo .activity-tag { background: #1e293b; color: #94a3b8; }
html[data-theme="dark"] .activity-day { color: #94a3b8; }
html[data-theme="dark"] .kind-undo .activity-text,
html[data-theme="dark"] .kind-redo .activity-text { color: #94a3b8; }

/* Floating copy that follows the finger during a touch drag */
.drag-clone {
    position: fixed;
    z-index: 3000;
    pointer-events: none;
    opacity: 0.9;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
    transform: scale(1.03);
}

html[data-theme="dark"] .drag-clone {
    background: #273449;
    color: #e2e8f0;
}

/* Light theme: page background 50% lighter, text sitting directly on it darkened to stay readable */
html:not([data-theme="dark"]) body {
    background-color: #93a3aa;
}

html:not([data-theme="dark"]) .section-title {
    color: #1e293b;
}

html:not([data-theme="dark"]) .section-title.unsure-of-location {
    color: #b91c1c !important;
}

html:not([data-theme="dark"]) .section-title.another-shop {
    color: #1d4ed8 !important;
}

html:not([data-theme="dark"]) .section-title.selected-section-title {
    color: #047857;
}

html:not([data-theme="dark"]) .other-locations-zone {
    background-color: #93a3aa;
    border-color: #475569;
}

html:not([data-theme="dark"]) .other-locations-zone.drag-active,
html:not([data-theme="dark"]) .other-locations-zone.drag-active:hover {
    background-color: #a9b6bc;
}

html:not([data-theme="dark"]) .zone-label,
html:not([data-theme="dark"]) .loading,
html:not([data-theme="dark"]) .back-link {
    color: #1e293b;
}

/* Quick Select page */
.qs-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -16px -4px 12px;
    padding: 12px 4px;
    background: #93a3aa;
}

.qs-bar input {
    flex: 1;
    min-width: 0;
}

.qs-count {
    flex: none;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.qs-card {
    padding: 8px 12px 12px;
}

.qs-letter {
    margin: 14px 0 4px;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: #64748b;
}

.qs-letter:first-child {
    margin-top: 6px;
}

.qs-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 4px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.qs-row input {
    width: 22px;
    height: 22px;
    margin: 0;
    flex: none;
    accent-color: #10b981;
}

.qs-row.on .qs-name {
    font-weight: 600;
}

.qs-name {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.qs-tag {
    flex: none;
    padding: 2px 8px;
    border-radius: 6px;
    background: #fef3c7;
    color: #92400e;
    font-size: 11px;
    font-weight: 600;
}

html[data-theme="dark"] .qs-bar {
    background: #0b1220;
}

html[data-theme="dark"] .qs-count {
    color: #cbd5e1;
}

html[data-theme="dark"] .qs-row {
    border-bottom-color: #2b3a50;
}

html[data-theme="dark"] .qs-letter {
    color: #94a3b8;
}

html[data-theme="dark"] .qs-tag {
    background: #5b3a0a;
    color: #fde68a;
}

/* Header title: logo + title left-aligned with the content column (kebab stays at the right edge) */
header h1 {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    justify-content: flex-start;
    box-sizing: border-box;
    padding-right: 48px; /* keep clear of the kebab button */
}
