:root {
    --primary: #CC1DB9;
    --primary-hover: #E91B95;
    --secondary: #60046C;
    --accent: #F4C542;
    --dark: #1E1F3E;
    --surface: #FEF1FA;
    --surface-hover: #FBD7F5;
    --outline: #FDEFF9;
    --action: #333764;
    --disabled: #EFF0F6;
    --disabled-soft: #E9E3F3;
    --white: #FFFFFF;
    --danger: #B42318;
    --success: #067647;
    --warning: #B54708;
    --shadow: 0 18px 45px rgba(30, 31, 62, 0.12);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--surface);
    color: var(--dark);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

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

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.56;
}

a {
    color: var(--primary);
    font-weight: 700;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--action);
    font-size: 0.88rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #E2D6EB;
    border-radius: var(--radius);
    background: var(--white);
    color: var(--dark);
    outline: none;
    padding: 11px 12px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(204, 29, 185, 0.14);
}

input[readonly],
select:disabled {
    background: var(--disabled);
    color: rgba(51, 55, 100, 0.7);
}

fieldset {
    border: 0;
    border-top: 1px solid #ECDDED;
    margin: 0;
    padding: 22px 0 0;
}

legend,
.fieldset-title-row legend {
    width: 100%;
    color: var(--secondary);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid #F0E2F0;
    padding: 14px 16px;
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--surface);
    color: var(--action);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #FFF7FD;
}

.is-hidden {
    display: none !important;
}

.mobile-only {
    display: none;
}

.stack {
    display: grid;
    gap: 18px;
}

.text-right {
    text-align: right;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 10px 16px;
    font-weight: 800;
    text-decoration: none;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 12px 24px rgba(204, 29, 185, 0.22);
}

.button-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.button-secondary {
    background: var(--secondary);
    color: var(--white);
    box-shadow: 0 12px 24px rgba(96, 4, 108, 0.18);
}

.button-secondary:hover:not(:disabled) {
    background: #4D075B;
}

.button-soft {
    background: var(--outline);
    color: var(--secondary);
    border-color: #F5C4ED;
}

.button-soft:hover:not(:disabled) {
    background: var(--surface-hover);
}

.button-ghost {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    color: #FFE9FA;
    border-color: rgba(255, 255, 255, 0.1);
}

.button-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
}

.button-danger {
    background: #FFF1F0;
    color: var(--danger);
    border-color: #FEE4E2;
}

.button-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 0.82rem;
}

.button-large {
    min-height: 52px;
    font-size: 1rem;
}

.icon-button {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid #E8DAEA;
    border-radius: var(--radius);
    background: var(--white);
    color: var(--action);
    font-size: 1.35rem;
    font-weight: 800;
}

.icon-button:hover {
    background: var(--surface-hover);
}

.login-screen,
.setup-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(254, 241, 250, 0.95), rgba(255, 255, 255, 0.86)),
        radial-gradient(circle at top left, rgba(244, 197, 66, 0.22), transparent 34%),
        var(--surface);
}

.login-card,
.setup-card {
    width: min(100%, 440px);
    background: var(--white);
    border: 1px solid #F2D8EF;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.setup-card {
    width: min(100%, 760px);
}

.brand-lockup,
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-lockup {
    margin-bottom: 28px;
}

.brand-lockup h1,
.section-header h2,
.setup-card h1 {
    margin: 0;
    color: var(--dark);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.9rem, 3vw, 2.5rem);
    line-height: 1.05;
}

.brand-lockup p,
.form-note,
.export-panel p,
.setup-help {
    margin: 6px 0 0;
    color: rgba(51, 55, 100, 0.72);
    line-height: 1.55;
}

.brand-mark {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: var(--radius);
    background: var(--secondary);
    color: var(--accent);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
    font-weight: 800;
}

.brand-mark-small {
    width: 42px;
    height: 42px;
    font-size: 1rem;
}

.form-note {
    font-size: 0.82rem;
}

.app-layout {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--dark);
    color: var(--white);
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-brand strong {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
}

.sidebar-brand span {
    display: block;
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.8rem;
}

.sidebar-nav {
    flex: 1;
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 18px 14px;
    overflow-y: auto;
}

.nav-heading {
    margin: 18px 10px 8px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-nav {
    display: grid;
    gap: 8px;
}

.nav-button {
    width: 100%;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
    padding: 11px 12px;
    text-align: left;
    font-weight: 750;
}

.nav-button:hover,
.nav-button.is-active {
    background: var(--action);
    color: var(--white);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(30, 31, 62, 0.52);
}

.main-shell {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    background: var(--surface);
}

.mobile-header {
    display: none;
}

.content-shell {
    position: relative;
    max-height: 100vh;
    min-height: 100vh;
    overflow-y: auto;
    padding: 32px;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(2px);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--outline);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.view-section {
    max-width: 1180px;
    margin: 0 auto;
}

.section-header {
    margin-bottom: 24px;
}

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.order-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.catalog-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.panel {
    background: var(--white);
    border: 1px solid #F0D9ED;
    border-radius: var(--radius);
    box-shadow: 0 12px 30px rgba(30, 31, 62, 0.08);
    padding: 22px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.span-2 {
    grid-column: span 2;
}

.input-with-hint {
    position: relative;
}

.input-with-hint input {
    padding-right: 76px;
}

.input-with-hint span {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: rgba(51, 55, 100, 0.62);
    font-size: 0.82rem;
    font-weight: 800;
}

.fieldset-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.product-rows {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.product-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px 120px 42px;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid #F0D9ED;
    border-radius: var(--radius);
    background: #FFF8FD;
}

.product-line-total {
    color: var(--secondary);
    font-weight: 900;
    text-align: right;
    white-space: nowrap;
}

.total-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-radius: var(--radius);
    padding: 16px 18px;
}

.total-strip-light {
    margin-top: 14px;
    background: var(--surface);
    border: 1px solid #F0D9ED;
}

.total-strip-dark {
    background: var(--dark);
    color: var(--white);
}

.total-strip strong {
    color: var(--secondary);
    font-size: 1.25rem;
}

.total-strip-dark strong {
    color: var(--accent);
    font-size: clamp(1.55rem, 3vw, 2.1rem);
}

.whatsapp-panel {
    position: sticky;
    top: 24px;
}

.whatsapp-panel h3,
.export-panel h3,
.product-form h3 {
    margin: 0 0 14px;
}

.message-preview {
    min-height: 260px;
    margin: 16px 0;
    border: 1px solid #F0D9ED;
    border-radius: var(--radius);
    background: #FFF8FD;
    padding: 16px;
    color: var(--action);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message-preview.empty {
    display: grid;
    place-items: center;
    color: rgba(51, 55, 100, 0.62);
    text-align: center;
}

.week-switcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #F0D9ED;
    border-radius: var(--radius);
    background: var(--white);
    padding: 6px;
    box-shadow: 0 8px 18px rgba(30, 31, 62, 0.07);
}

.week-switcher strong {
    min-width: 150px;
    color: var(--action);
    text-align: center;
}

.country-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 24px;
    border-bottom: 1px solid #EAD9EA;
}

.country-tab {
    min-height: 44px;
    flex: 0 0 auto;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: rgba(51, 55, 100, 0.72);
    padding: 11px 16px;
    font-weight: 850;
}

.country-tab:hover,
.country-tab.is-active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(255, 255, 255, 0.76);
}

.dispatch-list {
    display: grid;
    gap: 28px;
}

.date-group {
    display: grid;
    gap: 16px;
}

.date-heading {
    margin: 0;
    border-left: 4px solid var(--accent);
    background: var(--white);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: 0 8px 18px rgba(30, 31, 62, 0.06);
    font-size: 1rem;
}

.city-group {
    display: grid;
    gap: 12px;
}

.city-heading {
    margin: 0;
    color: var(--secondary);
    font-size: 0.98rem;
}

.order-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.order-card {
    display: grid;
    gap: 14px;
    border: 1px solid #F0D9ED;
    border-radius: var(--radius);
    background: var(--white);
    padding: 16px;
    box-shadow: 0 10px 24px rgba(30, 31, 62, 0.07);
}

.order-card.is-dispatched {
    background: #FBF8FC;
    opacity: 0.78;
}

.order-card-header,
.order-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.order-code {
    color: var(--secondary);
    font-weight: 900;
}

.time-badge,
.status-badge,
.count-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--outline);
    color: var(--action);
    font-size: 0.78rem;
    font-weight: 900;
    white-space: nowrap;
}

.status-badge.success {
    background: #ECFDF3;
    color: var(--success);
}

.status-badge.warning {
    background: #FFFAEB;
    color: var(--warning);
}

.order-card dl {
    display: grid;
    gap: 7px;
    margin: 0;
}

.order-card div.row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
}

.order-card dt {
    color: rgba(51, 55, 100, 0.62);
    font-size: 0.78rem;
    font-weight: 900;
}

.order-card dd {
    margin: 0;
    color: var(--dark);
    overflow-wrap: anywhere;
}

.order-total {
    color: var(--secondary);
    font-size: 1.1rem;
    font-weight: 900;
}

.dispatch-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--action);
    font-size: 0.86rem;
    font-weight: 850;
}

.dispatch-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--success);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.table-toolbar input {
    max-width: 420px;
}

.table-scroll {
    overflow-x: auto;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 180px;
    border: 1px dashed #E7CDE7;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.68);
    color: rgba(51, 55, 100, 0.68);
    text-align: center;
    padding: 24px;
}

.export-panel {
    max-width: 620px;
    text-align: center;
}

.export-icon {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid #F0D9ED;
    color: var(--secondary);
    font-weight: 900;
}

.toast-container {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    border-radius: var(--radius);
    padding: 13px 14px;
    background: var(--action);
    color: var(--white);
    box-shadow: var(--shadow);
    font-weight: 750;
    line-height: 1.45;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.notice {
    border-radius: var(--radius);
    margin: 14px 0;
    padding: 12px 14px;
    line-height: 1.5;
}

.notice-success {
    background: #ECFDF3;
    color: var(--success);
}

.notice-info {
    background: var(--outline);
    color: var(--secondary);
}

.notice-warning {
    background: #FFFAEB;
    color: var(--warning);
}

.notice-danger {
    background: #FEF3F2;
    color: var(--danger);
}

.setup-form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.setup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 980px) {
    .order-layout,
    .catalog-layout {
        grid-template-columns: 1fr;
    }

    .whatsapp-panel {
        position: static;
    }
}

@media (max-width: 760px) {
    body {
        font-size: 14px;
    }

    .mobile-only {
        display: inline-flex;
    }

    .app-layout {
        display: block;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 200ms ease;
        box-shadow: var(--shadow);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: 12px;
        border-bottom: 1px solid #F0D9ED;
        background: var(--white);
        padding: 12px 14px;
    }

    .content-shell {
        max-height: none;
        min-height: calc(100vh - 65px);
        padding: 18px 14px 32px;
        overflow-y: visible;
    }

    .section-header-row,
    .table-toolbar,
    .fieldset-title-row {
        align-items: stretch;
        flex-direction: column;
    }

    .week-switcher {
        width: 100%;
        justify-content: space-between;
    }

    .form-grid,
    .setup-grid,
    .product-row {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .product-line-total {
        text-align: left;
    }

    th,
    td {
        padding: 12px 10px;
    }

    .login-card,
    .setup-card,
    .panel {
        padding: 18px;
    }
}

