:root {
    --bg: #fff9ef;
    --surface: rgba(255, 255, 255, 0.92);
    --line: rgba(109, 68, 26, 0.16);
    --text: #2c1c0f;
    --muted: #7b5b41;
    --accent: #c45c2e;
    --accent-strong: #943b16;
    --accent-soft: #ffe0b7;
    --danger: #9f1239;
    --shadow: 0 20px 60px rgba(102, 53, 13, 0.18);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 214, 153, 0.8), transparent 34%),
        radial-gradient(circle at top right, rgba(255, 187, 122, 0.5), transparent 28%),
        linear-gradient(180deg, #fff3dc 0%, #fffaf2 45%, #f8ead3 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.screen {
    min-height: 100vh;
    min-height: 100dvh;
}

.login-screen {
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card,
.tpv-header,
.tpv-card,
.tpv-summary {
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.login-card {
    width: min(100%, 420px);
    padding: 2rem;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 0.85rem;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.brand-mark img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid rgba(196, 92, 46, 0.22);
    box-shadow: 0 12px 24px rgba(102, 53, 13, 0.16);
    background: #fff;
}

.brand-mark-inline {
    margin-bottom: 0.75rem;
}

.brand-mark-inline img {
    width: 74px;
    height: 74px;
}

.login-card h1 {
    margin: 1rem 0 0.5rem;
    font-size: clamp(2rem, 6vw, 2.8rem);
    line-height: 1;
}

.login-card p {
    margin: 0 0 1.5rem;
    color: var(--muted);
}

.field {
    display: grid;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.field label {
    font-weight: 700;
    color: var(--accent-strong);
}

.field input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 0.95rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
}

.field select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 0.95rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
}

.field input:focus,
.field select:focus,
.article-button:focus,
.group-filter:focus,
.icon-button:focus,
.primary-button:focus,
.secondary-button:focus {
    outline: 3px solid rgba(196, 92, 46, 0.18);
    border-color: rgba(196, 92, 46, 0.55);
}

.primary-button,
.secondary-button,
.icon-button,
.article-button,
.group-filter {
    border: 0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.article-button:hover,
.group-filter:hover {
    transform: translateY(-1px);
}

.primary-button {
    width: 100%;
    padding: 1rem 1.15rem;
    border-radius: 18px;
    color: #fff8f1;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    box-shadow: 0 12px 24px rgba(148, 59, 22, 0.22);
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1rem;
    border-radius: 16px;
    color: var(--accent-strong);
    background: var(--accent-soft);
    text-decoration: none;
}

a.secondary-button,
a.secondary-button:visited,
a.secondary-button:hover,
a.secondary-button:focus {
    color: var(--accent-strong);
    text-decoration: none;
}

.field input[type="color"] {
    padding: 0.35rem;
    min-height: 3.5rem;
    background: rgba(255, 255, 255, 0.98);
    cursor: pointer;
}

.field input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.field input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: 14px;
}

.field input[type="color"]::-moz-color-swatch {
    border: 0;
    border-radius: 14px;
}

.login-help {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 18px;
    background: rgba(255, 240, 214, 0.75);
    color: var(--muted);
    font-size: 0.95rem;
}

.form-error,
.field-validation-error {
    color: var(--danger);
    font-weight: 700;
}

.tpv-shell {
    display: grid;
    gap: 1rem;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1rem;
}

.tpv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
}

.brand-block h1 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1;
}

.brand-block p {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.user-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-pill {
    padding: 0.75rem 1rem;
    border-radius: 999px;
    background: rgba(255, 247, 237, 0.9);
    color: var(--accent-strong);
    font-weight: 700;
}

.tpv-main {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);
}

.tpv-card,
.tpv-summary {
    padding: 1rem;
}

.toolbar-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

.total-box {
    display: grid;
    gap: 0.35rem;
    padding: 1rem 1.1rem;
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(196, 92, 46, 0.12), rgba(255, 224, 183, 0.55));
}

.total-box span {
    color: var(--muted);
    font-weight: 700;
}

.total-box strong {
    font-size: clamp(1.9rem, 4vw, 2.8rem);
    line-height: 1;
}

.status-line {
    min-height: 1.5rem;
    margin-top: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

.status-line.error {
    color: var(--danger);
}

.group-filters {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 0.25rem 0 0.5rem;
    margin: 1rem 0 0.5rem;
}

.group-filter {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 0.85rem 1.15rem;
    background: #fffaf5;
    color: var(--accent-strong);
    font-weight: 800;
    border: 1px solid rgba(109, 68, 26, 0.16);
}

.group-filter.active {
    color: #fff8f1;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    box-shadow: 0 10px 18px rgba(148, 59, 22, 0.18);
}

.articles-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.article-button {
    display: grid;
    gap: 0.75rem;
    min-height: 150px;
    padding: 1rem;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 245, 230, 0.96));
    text-align: left;
    box-shadow: 0 10px 22px rgba(122, 72, 17, 0.08);
}

.article-image,
.article-fallback {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 18px;
}

.article-image {
    object-fit: cover;
}

.article-fallback {
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 1.2rem;
    font-weight: 900;
}

.article-copy {
    display: grid;
    gap: 0.2rem;
}

.article-copy strong {
    font-size: 1.05rem;
}

.article-copy span {
    color: var(--muted);
    font-weight: 700;
}

.summary-head {
    margin-bottom: 1rem;
}

.summary-head h2 {
    margin: 0;
    font-size: 1.15rem;
}

.summary-head p {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.summary-list {
    display: grid;
    gap: 0.75rem;
}

.summary-item {
    display: grid;
    gap: 0.6rem;
    padding: 0.9rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--line);
}

.summary-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.summary-top strong {
    display: block;
}

.summary-top span {
    color: var(--muted);
}

.summary-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.quantity-pill {
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 224, 183, 0.55);
    color: var(--accent-strong);
    font-weight: 800;
}

.icon-button {
    min-width: 44px;
    min-height: 44px;
    border-radius: 14px;
    color: var(--accent-strong);
    background: var(--accent-soft);
    font-size: 1.4rem;
}

.empty-state,
.loading-state {
    padding: 1rem;
    border-radius: 18px;
    background: rgba(255, 247, 237, 0.75);
    color: var(--muted);
    text-align: center;
}

.article-form-screen {
    padding: 1rem;
}

.article-form-shell {
    width: min(100%, 860px);
    margin: 0 auto;
    display: grid;
    gap: 1rem;
}

.article-form-header,
.article-form-card,
.group-choice-card {
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.article-form-header,
.article-form-card {
    padding: 1.25rem;
}

.article-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.article-form-header h1,
.section-copy h2 {
    margin: 0;
}

.article-form-header p,
.section-copy p {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.article-form-grid {
    display: grid;
    gap: 1rem;
}

.article-form-columns {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.group-choice-card {
    padding: 1rem;
}

.form-success {
    margin-bottom: 1rem;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    background: rgba(223, 245, 224, 0.95);
    color: #245c2f;
    font-weight: 700;
}

@media (min-width: 1024px) {
    .tpv-shell {
        padding: 1.25rem;
    }

    .tpv-main {
        grid-template-columns: minmax(0, 1fr) 340px;
        align-items: start;
    }

    .tpv-card,
    .tpv-summary {
        padding: 1.25rem;
    }
}

@media (max-width: 767.98px) {
    .tpv-shell {
        padding: 0.85rem;
        padding-bottom: calc(0.85rem + env(safe-area-inset-bottom));
    }

    .tpv-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .brand-mark-inline img {
        width: 64px;
        height: 64px;
    }

    .user-tools {
        width: 100%;
        justify-content: space-between;
    }

    .articles-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .article-form-screen {
        padding: 0.85rem;
    }

    .article-form-header {
        align-items: flex-start;
        flex-direction: column;
    }
}
