@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

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

:root {
    --font: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
    --bg-base: #f8fafc;
    --bg-accent-1: #fff7ed;
    --bg-accent-2: #ecfeff;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #475569;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --accent-warm: #f97316;
    --danger: #dc2626;
    --shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
    --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.08);
    --radius-lg: 22px;
    --radius: 16px;
    --radius-sm: 10px;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 10% -20%, var(--bg-accent-1) 0%, transparent 60%),
        radial-gradient(900px 500px at 90% 10%, var(--bg-accent-2) 0%, transparent 65%),
        linear-gradient(180deg, var(--bg-base) 0%, #eef2f7 100%);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-text-size-adjust: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-strong);
}

#app {
    width: min(92vw, 920px);
    margin: 32px auto 36px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    animation: liftIn 0.6s ease;
}

.user-info {
    font-size: 0.9rem;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    color: var(--muted);
    margin-bottom: 12px;
    text-align: right;
}

h1 {
    font-size: clamp(1.8rem, 2vw + 1.2rem, 2.6rem);
    margin: 8px 0 18px;
    letter-spacing: 0.04em;
}

h2 {
    font-size: clamp(1.2rem, 1.2vw + 0.9rem, 1.6rem);
    margin: 24px 0 12px;
}

p {
    color: var(--muted);
}

input,
select,
button,
textarea {
    font-family: inherit;
    font-size: 0.98rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 12px 14px;
    background: var(--surface-2);
    color: var(--text);
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.25);
    border-color: var(--accent);
}

button {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-with-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    flex: 0 0 auto;
}

.icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

button:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, #f59e0b, var(--accent-warm));
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, var(--danger));
}

form:not(#addArticleForm):not(.login-form):not(.profile-form) {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 14px;
    margin-bottom: 20px;
    align-items: center;
}

#addArticleForm {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    align-items: center;
}

#addArticleForm input[type="text"],
#addArticleForm select,
#addArticleForm input[type="file"] {
    flex: 1 1 100%;
}

#addArticleForm .add-actions {
    display: flex;
    flex: 1 1 100%;
    gap: 12px;
}

#addArticleForm .add-actions button {
    flex: 1 1 50%;
}

#voiceAddBtn {
    background: linear-gradient(135deg, #1e40af, #0ea5e9);
}

#voiceAddStatus {
    display: block;
    margin-top: 6px;
    font-size: 0.9rem;
    color: var(--muted);
}

#storeList {
    list-style: none;
    padding: 0;
    margin: 18px 0 0;
    display: grid;
    gap: 12px;
}

.store-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    padding: 16px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.store-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.store-item.dragging {
    opacity: 0.6;
    border: 2px dashed var(--accent);
}

.store-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    width: 160px;
}

.store-actions a,
.store-actions form {
    display: flex;
    width: 100%;
}

.store-actions a,
.store-actions button {
    align-items: center;
    justify-content: center;
    height: 36px;
    width: 100%;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    display: flex;
}

.store-actions .view-store {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
}

.store-actions .pdf-store {
    background: linear-gradient(135deg, #f59e0b, var(--accent-warm));
    color: #fff;
}

.delete-store {
    background: linear-gradient(135deg, #ef4444, var(--danger));
    color: #fff;
}

#shoppingTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 18px;
    text-align: left;
    table-layout: fixed;
    overflow: hidden;
    border-radius: var(--radius);
}

#shoppingTable thead {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
}

#shoppingTable th,
#shoppingTable td {
    border-bottom: 1px solid var(--border);
    padding: 12px 10px;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

#shoppingTable th.action-header {
    border-bottom: none;
}

.action-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
}

.action-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    line-height: 1;
}

.action-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

#shoppingTable tbody tr {
    background: var(--surface);
    transition: background-color 0.2s ease;
    cursor: grab;
}

#shoppingTable tbody tr.dragging {
    opacity: 0.6;
}

#shoppingTable tbody tr:nth-child(even) {
    background: #f9fafb;
}

#shoppingTable tbody tr:hover {
    background: #eef2f7;
}

#shoppingTable .cell-name {
    word-break: break-word;
    overflow-wrap: anywhere;
}

#shoppingTable .delete-store {
    padding: 6px 8px;
    min-width: 0;
    width: 34px;
}

.img-thumb {
    height: 44px;
    width: 44px;
    object-fit: cover;
    border-radius: 8px;
    vertical-align: middle;
    margin-right: 0.4rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.img-add-btn {
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 0.2rem 0.6rem;
    font: inherit;
    color: var(--muted);
    cursor: pointer;
}

.img-add-btn:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.inline-unit-select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.2rem 0.35rem;
    font: inherit;
    color: inherit;
}

td[contenteditable="true"] {
    outline: none;
}

.is-editing {
    box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.5);
}

.drag-handle {
    width: 20px;
    height: 20px;
    background-color: #cbd5e1;
    border-radius: 50%;
    margin: 0 auto;
    cursor: grab;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin: 14px 0;
}

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

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.profile-page #app {
    width: min(92vw, 860px);
}

.profile-row {
    width: 100%;
}

.profile-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.profile-input {
    width: 100%;
}

.profile-submit button {
    min-width: 180px;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-list {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.color-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--muted);
}

.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(15, 23, 42, 0.15);
    display: inline-block;
}

.color-swatch {
    width: 28px;
    height: 28px;
    background: none;
    background-image: none;
    border-radius: 999px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}

.color-swatch.is-selected {
    border-color: var(--text);
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.2);
}

.color-info {
    font-size: 0.9rem;
    color: var(--muted);
}

.profile-color-preview {
    margin-top: 6px;
}

.login-shell {
    max-width: 460px;
    margin: 2.5rem auto 2rem;
    padding: 0 1rem;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem 2rem 1.75rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-card h1 {
    font-size: 1.5rem;
    letter-spacing: 0.18em;
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form .login-group {
    display: flex;
    flex-direction: column;
}

.login-form input {
    width: 100%;
}

.login-group label {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    color: var(--muted);
}

.login-error {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
    padding: 0.6rem 0.8rem;
    border-radius: 0.55rem;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.login-submit button {
    width: 100%;
}

.app-footer {
    text-align: center;
    padding: 14px 10px 24px;
    color: var(--muted);
    font-size: 0.9rem;
}

.app-footer a {
    color: var(--accent);
    font-weight: 600;
}

.landing {
    align-items: center;
}

.landing-wrap {
    width: min(92vw, 980px);
    margin: 40px auto;
    display: grid;
    gap: 28px;
}

.landing-hero {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px;
    align-items: center;
}

.landing-card {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.landing-title {
    font-size: clamp(2rem, 2.6vw + 1.2rem, 3.2rem);
    margin: 0 0 14px;
}

.landing-subtitle {
    font-size: 1.05rem;
    color: var(--muted);
    margin: 0 0 22px;
}

.cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: var(--shadow-soft);
}

.cta:hover {
    transform: translateY(-1px);
}

.link-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    font-weight: 600;
    color: var(--text);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.link-pill:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.landing-visual {
    position: relative;
    min-height: 280px;
}

.orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(0.5px);
    opacity: 0.9;
    animation: float 6s ease-in-out infinite;
}

.orb-1 {
    width: 180px;
    height: 180px;
    background: radial-gradient(circle at 30% 30%, #fff7ed, #fdba74);
    top: 20px;
    left: 20px;
}

.orb-2 {
    width: 220px;
    height: 220px;
    background: radial-gradient(circle at 30% 30%, #ecfeff, #67e8f9);
    bottom: 10px;
    right: 30px;
    animation-delay: 1.2s;
}

.orb-3 {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at 30% 30%, #fef3c7, #f59e0b);
    top: 180px;
    right: 140px;
    animation-delay: 2s;
}

@keyframes liftIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 820px) {
    #app {
        width: min(94vw, 900px);
        padding: 22px;
    }

    form:not(#addArticleForm):not(.login-form):not(.profile-form) {
        grid-template-columns: 1fr;
    }

    .store-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .store-actions {
        width: 100%;
        align-items: stretch;
    }

    .store-actions a,
    .store-actions form {
        width: 100%;
    }

    .user-info {
        justify-content: center;
    }

    .img-thumb {
        display: none;
    }

    .landing-hero {
        grid-template-columns: 1fr;
    }

    .landing-visual {
        min-height: 220px;
    }
}

@media (min-width: 641px) {
    .action-icon {
        display: none;
    }
}

@media (max-width: 640px) {
    #app {
        margin: 16px auto 24px;
        padding: 18px;
        border-radius: var(--radius);
    }

    #shoppingTable th,
    #shoppingTable td {
        padding: 8px 6px;
        font-size: 0.85rem;
    }

    #shoppingTable th:last-child,
    #shoppingTable td:last-child {
        width: 46px;
    }

    .action-header {
        justify-content: center;
    }

    .action-header .action-text {
        display: none;
    }

    .action-icon {
        width: 18px;
        height: 18px;
    }

    .login-card {
        padding: 1.5rem 1.4rem;
    }

    .color-list {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.6rem;
    }

    #addArticleForm .add-actions {
        flex-direction: column;
    }

    #shoppingTable {
        font-size: 0.82rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
