:root {
    --color-primary: #f39c12;
    --color-primary-dark: #d35400;
    --color-primary-text: #1e1e1e;
    --color-danger: #e74c3c;
    --color-danger-bg: rgba(231, 76, 60, 0.14);
    --color-bg: #1e1e1e;
    --color-bg-end: #161616;
    --color-surface: #2a2a2a;
    --color-border: #3f3f3f;
    --color-text: #f1f1f1;
    --color-text-muted: #a8a8a8;
    --radius: 12px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--color-primary);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: calc(14px + var(--safe-top)) 16px 14px;
    background: linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg-end) 100%);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

.topbar__title {
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar__logout {
    flex-shrink: 0;
}

.topbar__logout button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.content {
    padding: 16px;
    padding-bottom: calc(88px + var(--safe-bottom));
    max-width: 560px;
    margin: 0 auto;
}

.bottomnav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-bottom: var(--safe-bottom);
    z-index: 10;
}

.bottomnav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 0 8px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.bottomnav__item.is-active {
    color: var(--color-primary);
    font-weight: 600;
}

.bottomnav__icon {
    font-size: 1.3rem;
}

.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.flash--success {
    background: rgba(243, 156, 18, 0.14);
    color: var(--color-primary);
}

.flash--error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.flash--error ul {
    margin: 0;
    padding-left: 18px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    flex: 1;
}

.field-row {
    display: flex;
    gap: 12px;
}

.field-row .field {
    min-width: 0;
}

.field input,
.field select {
    font-size: 1rem;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 0.95rem;
}

.checkbox input[type="checkbox"] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    accent-color: var(--color-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 18px;
    border-radius: 10px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn--block {
    width: 100%;
}

.btn--primary {
    background: linear-gradient(45deg, var(--color-primary), var(--color-primary-dark));
    color: var(--color-primary-text);
}

.btn--danger {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}

.btn--ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

.btn--small {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn--adjust {
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-primary);
    border-radius: 10px;
}

.search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.search-bar input[type="search"] {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--color-border);
}

.search-bar select {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--color-border);
}

.search-bar .btn {
    flex-shrink: 0;
}

.product-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
}

.product-card--low {
    border-color: var(--color-danger);
    background: var(--color-danger-bg);
}

.shopping-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.shopping-item__toggle {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
}

.quick-adjust {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
}

.quick-adjust__input {
    flex: none;
    width: 76px;
    text-align: center;
    padding: 13px 8px;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
}

.quick-adjust__btn {
    flex: 1;
}

.shopping-item--checked {
    opacity: 0.5;
}

.shopping-item--checked .product-card__name {
    text-decoration: line-through;
}

.product-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.product-card__edit {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    text-decoration: none;
    font-size: 1.1rem;
    line-height: 1;
}

.product-card__main {
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.product-card__name {
    font-weight: 600;
    margin-bottom: 4px;
    overflow-wrap: break-word;
}

.product-card__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.product-card__qty {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.product-card__threshold {
    font-size: 0.8rem;
}

.product-card__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
}

.badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-muted);
    font-size: 0.75rem;
    padding: 3px 9px;
    border-radius: 999px;
}

.section-title {
    font-size: 1rem;
    margin: 22px 0 10px;
}

.empty-state {
    color: var(--color-text-muted);
    text-align: center;
    padding: 30px 10px;
}

.login-card {
    max-width: 360px;
    margin: 40px auto 0;
    text-align: center;
}

.login-card__title {
    margin-bottom: 2px;
}

.login-card__subtitle {
    color: var(--color-text-muted);
    margin-top: 0;
    margin-bottom: 24px;
}

.delete-form {
    margin-top: 24px;
}
