:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #142033;
    --muted: #5f6f85;
    --border: #dce4ef;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --success: #067647;
    --success-bg: #ecfdf3;
    --warning: #b54708;
    --warning-bg: #fffaeb;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.12), transparent 24%),
        var(--bg);
}

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

a {
    color: inherit;
}

button {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

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

button:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

.ghost-button {
    background: #e8f5f3;
    color: var(--primary-dark);
}

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

.small-button {
    padding: 8px 12px;
    font-size: 0.87rem;
}

.full-width {
    width: 100%;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    padding: 12px 14px;
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.stack-form,
.product-form,
.movement-form {
    display: grid;
    gap: 16px;
}

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

.full-span {
    grid-column: 1 / -1;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-layout {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: 1.25fr 0.9fr;
    gap: 24px;
    align-items: stretch;
}

.auth-hero,
.auth-card,
.panel,
.stat-card,
.sidebar,
.modal-card,
.state-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(220, 228, 239, 0.85);
    border-radius: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.auth-hero,
.auth-card,
.state-card {
    padding: 32px;
}

.auth-hero h1,
.state-card h1 {
    margin: 0 0 16px;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 0.96;
}

.hero-copy {
    max-width: 56ch;
    color: var(--muted);
    line-height: 1.7;
}

.hero-points {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.hero-points span,
.badge,
.checkbox-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.88rem;
}

.hero-points span {
    background: #edf8f7;
    color: var(--primary-dark);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-danger {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-neutral {
    background: #eef4ff;
    color: #2f5fa7;
}

.section-kicker,
.eyebrow {
    margin: 0 0 10px;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.75rem;
    font-weight: 800;
}

.status-text {
    margin: 0;
    min-height: 24px;
    color: var(--muted);
    line-height: 1.5;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
}

.sidebar,
.main-panel {
    min-height: calc(100vh - 40px);
}

.sidebar {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-nav {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.nav-link {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
}

.nav-link.is-active {
    background: #eff8ff;
    border-color: #d0e5f8;
    color: #1447ad;
}

.main-panel {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 18px;
}

.topbar,
.panel {
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(220, 228, 239, 0.85);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.topbar h1,
.panel h2 {
    margin: 0;
}

.content-stack {
    display: grid;
    gap: 20px;
}

.view {
    display: none;
    gap: 20px;
}

.view.is-active {
    display: grid;
}

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

.stat-card {
    padding: 20px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: 2rem;
}

.panel-heading,
.toolbar,
.button-row,
.inline-actions,
.movement-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar {
    margin-bottom: 18px;
}

.toolbar > input[type="search"] {
    flex: 2 1 280px;
}

.toolbar > select,
.toolbar > label {
    flex: 1 1 180px;
}

.table-wrap {
    overflow: auto;
}

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

th,
td {
    padding: 14px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.94rem;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 700;
}

.category-path {
    font-weight: 700;
}

.table-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.84rem;
}

.empty-state {
    margin-top: 16px;
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: 16px;
    color: var(--muted);
    background: var(--surface-muted);
}

.checkbox-chip {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
}

.checkbox-chip input {
    width: auto;
    margin: 0;
}

.action-panel {
    background: linear-gradient(180deg, rgba(240, 253, 250, 0.9), rgba(255, 255, 255, 0.95));
}

.movement-preview {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.toast-root {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: grid;
    gap: 12px;
    z-index: 50;
}

.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 16px;
    color: #fff;
    box-shadow: var(--shadow);
    animation: slideUp 0.2s ease;
}

.toast-success {
    background: linear-gradient(135deg, #067647, #0f766e);
}

.toast-error {
    background: linear-gradient(135deg, #b42318, #7a271a);
}

.toast.is-hidden {
    opacity: 0;
}

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
}

.modal-root[hidden] {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(460px, calc(100% - 32px));
    padding: 24px;
}

.state-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.link-button {
    display: inline-flex;
    justify-content: center;
    text-decoration: none;
}

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

@media (max-width: 1080px) {
    .app-shell,
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .sidebar,
    .main-panel {
        min-height: auto;
    }

    .stats-grid,
    .product-form,
    .movement-form {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 780px) {
    .stats-grid,
    .product-form,
    .movement-form {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding: 12px;
        gap: 12px;
    }

    .topbar,
    .panel,
    .sidebar {
        padding: 18px;
    }
}
