/* =========================================================================
   LAYTEK - Tokens de design
   ========================================================================= */
:root {
    --bg-0: #08070c;
    --bg-1: #111018;
    --bg-2: #171522;
    --bg-3: #211e2c;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);

    --text: #ece8f7;
    --text-dim: #b0a8c3;
    --text-muted: #736d84;

    --blue: #7c3aed;
    --blue-deep: #5b21b6;
    --cyan: #a855f7;
    --cyan-soft: #c084fc;
    --purple: #9333ea;
    --purple-soft: #d8b4fe;
    --silver: #d7d3e2;
    --green: #28e0a1;
    --amber: #ffb547;
    --red: #ff5577;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --shadow-glow: 0 0 40px rgba(0, 229, 255, 0.08);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.04) inset;

    --font-display: 'Chakra Petch', system-ui, sans-serif;
    --font-body: 'Outfit', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    background: var(--bg-0);
    color: var(--text);
    font-family: var(--font-body);
    font-weight: 400;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(147, 51, 234, 0.22), transparent 60%),
        radial-gradient(900px 500px at 110% 10%, rgba(216, 180, 254, 0.12), transparent 60%),
        radial-gradient(600px 400px at 50% 110%, rgba(124, 58, 237, 0.12), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 1480px;
    margin: 0 auto;
    padding: 28px 32px 80px;
}

/* =========================================================================
   HEADER
   ========================================================================= */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    padding: 18px 22px;
    background: linear-gradient(180deg, rgba(15, 20, 34, 0.7), rgba(10, 14, 24, 0.5));
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-mark {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0b1224 0%, #0a0e18 100%);
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    position: relative;
    box-shadow: var(--shadow-glow);
}

.logo-mark::after {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 6px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--cyan), transparent);
    border-radius: 2px;
    filter: blur(0.5px);
}

.logo-mark .k {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 28px;
    color: #fff;
    letter-spacing: -1px;
}

.logo-mark .kanji {
    position: absolute;
    left: 6px;
    top: 6px;
    color: var(--cyan);
    font-size: 12px;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

.brand-text h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 1px;
    line-height: 1;
}

.brand-text h1 span {
    color: var(--cyan);
}

.brand-text p {
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    margin-top: 4px;
    text-transform: uppercase;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 18px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    50% {
        opacity: 0.5;
    }
}

/* =========================================================================
   KPI ROW
   ========================================================================= */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi {
    position: relative;
    padding: 18px 20px;
    background: linear-gradient(180deg, rgba(15, 20, 34, 0.85), rgba(10, 14, 24, 0.85));
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.kpi:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
}

.kpi::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--cyan);
    opacity: 0.6;
}

.kpi.kpi-blue::before {
    background: var(--blue);
}

.plans-app {
    gap: 22px;
}

.plans-eyebrow {
    color: var(--purple);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.plans-current-card,
.dashboard-plan-card {
    align-items: center;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.12), rgba(0, 212, 255, 0.06)), var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    padding: 20px;
}

.plans-current-card {
    grid-template-columns: minmax(220px, 1fr) auto;
}

.plans-current-card > .btn {
    justify-self: end;
}

.plans-current-card h2,
.dashboard-plan-card h2 {
    color: var(--text);
    font-size: 1.6rem;
    margin: 0 0 6px;
}

.plans-current-card p,
.dashboard-plan-card p {
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
}

.plans-usage-grid,
.dashboard-plan-usage {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(118px, 1fr));
}

.plan-usage-pill,
.dashboard-plan-usage-item,
.account-plan-limit-row,
.plan-limit-line {
    align-items: center;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    min-height: 44px;
    padding: 10px 12px;
}

.plan-usage-pill span,
.dashboard-plan-usage-item span,
.account-plan-limit-row span,
.plan-limit-line span {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: capitalize;
}

.plan-usage-pill strong,
.dashboard-plan-usage-item strong,
.account-plan-limit-row strong,
.plan-limit-line strong {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.88rem;
}

.plans-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.plan-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 100%;
    padding: 20px;
}

.plan-card.is-highlighted {
    border-color: rgba(168, 85, 247, 0.58);
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.18), var(--shadow-soft);
}

.plan-card.is-current {
    border-color: rgba(0, 212, 255, 0.38);
}

.plan-card-top {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.plan-card h2 {
    color: var(--text);
    font-size: 1.35rem;
    margin: 0;
}

.plan-card p {
    color: var(--muted);
    line-height: 1.55;
    margin: 0;
}

.plan-current-badge {
    background: rgba(0, 212, 255, 0.14);
    border: 1px solid rgba(0, 212, 255, 0.34);
    border-radius: 999px;
    color: var(--cyan);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 800;
    padding: 6px 9px;
    text-transform: uppercase;
}

.plan-price {
    align-items: baseline;
    display: flex;
    gap: 8px;
}

.plan-price strong {
    color: var(--text);
    font-size: 2rem;
}

.plan-price span {
    color: var(--muted);
    font-size: 0.92rem;
}

.plan-limits-list,
.account-plan-limits {
    display: grid;
    gap: 8px;
}

.plan-feature-list {
    color: var(--muted);
    display: grid;
    gap: 9px;
    line-height: 1.4;
    list-style: none;
    margin: 0;
    padding: 0;
}

.plan-feature-list li::before {
    color: var(--green);
    content: "✓";
    font-weight: 800;
    margin-right: 8px;
}

.plan-action-btn {
    margin-top: auto;
    width: 100%;
}

.plans-notes-panel {
    margin-top: 2px;
}

.plan-notice {
    align-items: center;
    border-radius: 14px;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 14px;
}

.plan-notice-warn {
    background: rgba(245, 158, 11, 0.10);
    border: 1px solid rgba(245, 158, 11, 0.28);
}

.plan-notice-blocked {
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.30);
}

.plan-notice strong {
    color: var(--text);
    display: block;
    margin-bottom: 4px;
}

.plan-notice p {
    color: var(--muted);
    margin: 0;
}

@media (max-width: 1024px) {
    .plans-current-card,
    .dashboard-plan-card {
        grid-template-columns: 1fr;
    }

    .plans-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .plans-usage-grid,
    .dashboard-plan-usage {
        grid-template-columns: 1fr 1fr;
    }

    .plan-notice {
        align-items: flex-start;
        flex-direction: column;
    }
}

.kpi.kpi-purple::before {
    background: var(--purple);
}

.kpi.kpi-green::before {
    background: var(--green);
}

.kpi.kpi-amber::before {
    background: var(--amber);
}

.kpi.kpi-red::before {
    background: var(--red);
}

.kpi .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.kpi .value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 24px;
    margin-top: 8px;
    color: #fff;
}

.kpi .sub {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    font-family: var(--font-mono);
}

.metric-icon {
    position: absolute;
    top: 18px;
    right: 18px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: var(--cyan);
    background: rgba(0, 212, 255, 0.1);
}

.metric-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kpi-purple .metric-icon {
    color: var(--purple);
    background: rgba(151, 71, 255, 0.12);
}

.kpi-green .metric-icon {
    color: var(--green);
    background: rgba(40, 224, 161, 0.1);
}

.kpi.alert-glow {
    box-shadow: 0 0 0 1px rgba(255, 85, 119, 0.4), 0 10px 30px rgba(255, 85, 119, 0.15);
}

.kpi.success-glow {
    box-shadow: 0 0 0 1px rgba(40, 224, 161, 0.4), 0 10px 30px rgba(40, 224, 161, 0.15);
}

/* =========================================================================
   MAIN GRID
   ========================================================================= */
.main-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 20px;
    margin-bottom: 24px;
}

.panel {
    background: linear-gradient(180deg, rgba(15, 20, 34, 0.7), rgba(10, 14, 24, 0.7));
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: 24px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    gap: 12px;
}

.panel-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--cyan);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--cyan);
}

.panel-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    border: 1px solid var(--line);
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 1px;
}

.panel-body {
    padding: 22px;
}

/* MARKETPLACE */
.marketplace-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 22px;
}

.mp-btn {
    padding: 12px 8px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text-dim);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.mp-btn:hover {
    color: #fff;
    border-color: var(--line-strong);
}

.mp-btn.active {
    background: linear-gradient(135deg, var(--blue), var(--blue-deep));
    border-color: var(--blue);
    color: #fff;
    box-shadow: 0 4px 14px rgba(45, 108, 255, 0.4);
}

/* FORM */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.field label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .prefix,
.input-wrap .suffix {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-wrap .prefix {
    left: 12px;
}

.input-wrap .suffix {
    right: 12px;
}

.field input,
.field select {
    width: 100%;
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.field input.has-prefix {
    padding-left: 30px;
}

.field input.has-suffix {
    padding-right: 34px;
}

.field input::placeholder {
    color: var(--text-muted);
}

.field input:focus,
.field select:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.12);
    background: #161e35;
}

/* Select estilizado */
.select-styled {
    font-family: var(--font-body) !important;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2300e5ff' stroke-width='3'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}

.select-styled option {
    background: var(--bg-2);
    color: #fff;
}

/* RESULT CARDS */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.result-card {
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
}

.result-card .label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.result-card .value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    margin-top: 6px;
}

.result-card.highlight {
    background: linear-gradient(135deg, rgba(45, 108, 255, 0.18), rgba(0, 229, 255, 0.08));
    border-color: rgba(0, 229, 255, 0.3);
}

.result-card.highlight .value {
    color: var(--cyan);
}

/* Card de economia/batch */
.result-card.savings {
    background: linear-gradient(135deg, rgba(40, 224, 161, 0.12), rgba(40, 224, 161, 0.04));
    border-color: rgba(40, 224, 161, 0.3);
}

.result-card.savings .value {
    color: var(--green);
}

.result-card.savings .label::before {
    content: '⚡';
    margin-right: 4px;
}

/* Linha de qty na tabela */
.qty-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0, 229, 255, 0.12);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: var(--cyan-soft);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
}

.qty-badge.single {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--line);
    color: var(--text-dim);
}

/* Subtítulo nos result cards (per un / total) */
.result-card .sub-label {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 3px;
    display: block;
}

.alert-box {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 12px;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
    line-height: 1.5;
    display: none;
}

.alert-box.warn {
    background: rgba(255, 181, 71, 0.08);
    border: 1px solid rgba(255, 181, 71, 0.3);
    color: var(--amber);
    display: flex;
}

.alert-box.error {
    background: rgba(255, 85, 119, 0.08);
    border: 1px solid rgba(255, 85, 119, 0.3);
    color: var(--red);
    display: flex;
}

.alert-box.success {
    background: rgba(40, 224, 161, 0.08);
    border: 1px solid rgba(40, 224, 161, 0.3);
    color: var(--green);
    display: flex;
}

.alert-box svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* BUTTONS */
.actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 18px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--bg-3);
    color: #fff;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: #fff;
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue), var(--blue-deep));
    border-color: var(--blue);
    box-shadow: 0 6px 18px rgba(45, 108, 255, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 8px 24px rgba(45, 108, 255, 0.5);
}

.btn-cyan {
    background: linear-gradient(135deg, var(--cyan), #00a0c0);
    border-color: var(--cyan);
    color: #001620;
    box-shadow: 0 6px 18px rgba(0, 229, 255, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
}

.btn-ghost:hover {
    color: var(--red);
    border-color: var(--red);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 11px;
}

/* TABLE */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 14px 16px;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    vertical-align: middle;
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: rgba(0, 229, 255, 0.04);
}

tbody tr.empty td {
    text-align: center;
    color: var(--text-muted);
    font-family: var(--font-body);
    padding: 30px 16px;
    font-style: italic;
}

.row-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--red);
    border-color: var(--red);
}

.icon-btn.edit:hover {
    color: var(--cyan);
    border-color: var(--cyan);
}

.icon-btn svg {
    width: 14px;
    height: 14px;
}

.cell-positive {
    color: var(--green);
}

.cell-negative {
    color: var(--red);
}

.cell-warn {
    color: var(--amber);
}

.totals-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 20px;
    padding: 20px 22px;
    background: linear-gradient(180deg, rgba(45, 108, 255, 0.08), rgba(0, 229, 255, 0.04));
    border: 1px solid rgba(0, 229, 255, 0.18);
    border-radius: 14px;
}

.total-cell .label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.total-cell .value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 22px;
    margin-top: 6px;
    color: #fff;
}

.total-cell.profit .value {
    color: var(--cyan);
}

/* =========================================================================
   ESTOQUE DE FILAMENTOS
   ========================================================================= */
.stock-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 22px;
}

.stock-kpi {
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
}

.stock-kpi::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--cyan);
}

.stock-kpi.warn::before {
    background: var(--amber);
}

.stock-kpi .label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stock-kpi .value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 20px;
    margin-top: 4px;
}

.stock-kpi.warn .value {
    color: var(--amber);
}

/* Swatch de cor */
.swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    flex-shrink: 0;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.3);
    display: inline-block;
    vertical-align: middle;
}

.swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, transparent 45%, transparent 55%, rgba(0, 0, 0, 0.15) 100%);
    border-radius: 7px;
}

.swatch-sm {
    width: 18px;
    height: 18px;
    border-radius: 5px;
}

/* Tag de material */
.material-tag {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 4px 8px;
    border-radius: 5px;
    background: rgba(45, 108, 255, 0.12);
    border: 1px solid rgba(45, 108, 255, 0.3);
    color: var(--cyan-soft);
    text-transform: uppercase;
}

/* Barra de progresso */
.progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.progress {
    flex: 1;
    min-width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress>div {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--cyan));
    border-radius: 3px;
    transition: width 0.4s ease;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.progress.warn>div {
    background: var(--amber);
    box-shadow: 0 0 8px rgba(255, 181, 71, 0.4);
}

.progress.danger>div {
    background: var(--red);
    box-shadow: 0 0 8px rgba(255, 85, 119, 0.4);
}

.stock-text {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
}

/* =========================================================================
   MODAL — filamento
   ========================================================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 4, 10, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-backdrop.show {
    display: flex;
    animation: backdropIn 0.2s ease;
}

@keyframes backdropIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: linear-gradient(180deg, rgba(20, 27, 45, 0.98), rgba(10, 14, 24, 0.98));
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 229, 255, 0.08);
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--cyan);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--cyan);
}

.modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text-dim);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--red);
    border-color: var(--red);
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
}

.modal-footer {
    padding: 18px 22px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: rgba(0, 0, 0, 0.2);
}

/* Color picker */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.color-option {
    aspect-ratio: 1;
    border-radius: 7px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s ease, border-color 0.15s ease;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}

.color-option:hover {
    transform: scale(1.12);
}

.color-option.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--cyan), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1100px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-grid {
        grid-template-columns: 1fr;
    }

    .stock-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .app {
        padding: 18px 14px 60px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .kpi-row {
        grid-template-columns: 1fr 1fr;
    }

    .form-grid,
    .result-grid {
        grid-template-columns: 1fr;
    }

    .marketplace-row {
        grid-template-columns: 1fr 1fr;
    }

    .totals-row {
        grid-template-columns: 1fr;
    }

    .stock-kpis {
        grid-template-columns: 1fr 1fr;
    }

    .brand-text h1 {
        font-size: 18px;
    }

    .kpi .value {
        font-size: 20px;
    }
}

@media (max-width: 820px) {
    .layout {
        display: block;
        min-height: 100vh;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 1200;
        height: auto;
        min-height: 0;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: rgba(10, 9, 16, 0.96);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        display: flex;
        align-items: center;
        gap: 10px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .sidebar::-webkit-scrollbar {
        display: none;
    }

    .sidebar-logo {
        margin: 0;
        font-size: 18px;
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .nav-link {
        width: auto;
        flex: 0 0 auto;
        min-width: max-content;
        margin: 0;
        padding: 10px 12px;
        font-size: 13px;
        text-align: center;
    }

    .content,
    .app {
        width: 100%;
        max-width: none;
    }

    .app {
        padding: 18px 14px 76px;
    }

    .header {
        border-radius: 16px;
        padding: 14px;
    }

    .header-status {
        display: none;
    }

    .kpi-row,
    .stock-kpis,
    .account-kpis {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .main-grid,
    .account-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .panel {
        border-radius: 14px;
        margin-bottom: 14px;
    }

    .panel-header,
    .panel-body {
        padding: 16px;
    }

    .table-wrap {
        margin: 0 -16px;
        padding: 0 16px;
        overflow-x: auto;
    }

    table {
        min-width: 720px;
    }

    .modal-backdrop {
        align-items: flex-end;
        padding: 10px;
    }

    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 18px;
    }

    .toast {
        left: 14px;
        right: 14px;
        bottom: 14px;
        max-width: none;
    }
}

/* =========================================================================
   Calculator/Product integration polish
   ========================================================================= */
.info-tip {
    position: relative;
    width: 16px;
    height: 16px;
    display: inline-grid;
    place-items: center;
    margin-left: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    cursor: help;
}

.info-tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 30;
    width: min(260px, 78vw);
    padding: 10px 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 10px;
    background: rgba(17, 21, 34, 0.98);
    color: var(--text);
    box-shadow: var(--shadow-card);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.45;
    text-transform: none;
    transform: translateX(-50%) translateY(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.info-tip:hover::after,
.info-tip:focus::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.calc-filaments-box {
    max-height: 245px;
    overflow-y: auto;
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: transparent;
}

.calc-filament-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 110px auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 10px;
}

.calc-filament-field,
.calc-filament-weight-field,
.calc-filament-action {
    min-width: 0;
}

.calc-filament-weight {
    width: 100%;
}

.calc-filament-action .btn {
    white-space: nowrap;
}

.filament-color-dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    flex: 0 0 auto;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.filament-color-dot.is-empty {
    border-style: dashed;
    background: transparent;
}

.filament-select-wrap {
    position: relative;
}

.filament-select-wrap .filament-color-dot {
    position: absolute;
    left: 12px;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
}

.select-styled.has-color-dot {
    padding-left: 34px;
}

.product-image-picker {
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.product-image-preview {
    width: 118px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px dashed rgba(148, 163, 184, 0.26);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-muted);
    font-size: 12px;
}

.product-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image-actions {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.product-image-actions .field-hint {
    flex-basis: 100%;
    margin-top: 0;
}

.product-name-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 190px;
}

.product-thumb {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(154, 77, 255, 0.09);
}

.product-thumb-placeholder {
    display: grid;
    place-items: center;
    color: var(--purple-soft);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
}

.account-page-chip {
    font-family: var(--font-body);
    cursor: pointer;
}

.account-page-chip:disabled {
    cursor: not-allowed;
}

.account-page-chip.is-allowed:hover {
    border-color: rgba(154, 77, 255, 0.48);
    background: rgba(154, 77, 255, 0.14);
    color: #fff;
}

@media (max-width: 640px) {
    .calc-filament-row {
        grid-template-columns: 16px minmax(0, 1fr);
    }

    .calc-filament-action {
        grid-column: 2;
    }

    .product-image-picker {
        grid-template-columns: 1fr;
    }

    .product-image-preview {
        width: 100%;
        max-width: 180px;
    }
}

@media (max-width: 520px) {
    .kpi-row,
    .stock-kpis,
    .account-kpis,
    .result-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .actions,
    .modal-footer {
        flex-direction: column;
    }

    .actions .btn,
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-1);
}

::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--blue);
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi,
.panel,
.totals-row {
    animation: fadeUp 0.5s ease backwards;
}

.kpi:nth-child(1) {
    animation-delay: 0.05s;
}

.kpi:nth-child(2) {
    animation-delay: 0.1s;
}

.kpi:nth-child(3) {
    animation-delay: 0.15s;
}

.kpi:nth-child(4) {
    animation-delay: 0.2s;
}

.kpi:nth-child(5) {
    animation-delay: 0.25s;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-2);
    border: 1px solid var(--cyan);
    color: #fff;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 13px;
    box-shadow: 0 10px 30px rgba(0, 229, 255, 0.2);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 340px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast svg {
    width: 18px;
    height: 18px;
    color: var(--cyan);
    flex-shrink: 0;
}

.toast.error {
    border-color: var(--red);
    box-shadow: 0 10px 30px rgba(255, 85, 119, 0.25);
}

.toast.error svg {
    color: var(--red);
}

.layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, rgba(16, 14, 24, 0.98), rgba(10, 9, 16, 0.98));
    border-right: 1px solid var(--line);
    padding: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-logo {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 28px;
    color: var(--silver);
}

.sidebar-logo span {
    color: var(--purple-soft);
}

.sidebar-menu-toggle {
    display: none;
}

.sidebar-session-card {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
}

.sidebar-session-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-session-value {
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #fff;
    word-break: break-word;
}

.sidebar-session-subvalue {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-dim);
    word-break: break-word;
}

.sidebar-signout-btn {
    margin-top: 12px;
    width: 100%;
    justify-content: center;
}

.nav-link {
    width: 100%;
    display: block;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    padding: 12px 14px;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    margin-bottom: 8px;
    font-family: var(--font-body);
}

.nav-link.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-link:hover,
.nav-link.active {
    background: var(--bg-3);
    color: white;
    border-color: rgba(168, 85, 247, 0.32);
    box-shadow: inset 0 0 0 1px rgba(168, 85, 247, 0.08);
}

.content {
    min-width: 0;
}

.auth-mode .layout {
    grid-template-columns: 1fr;
}

.auth-mode .sidebar {
    display: none;
}

.auth-mode .content {
    min-height: 100vh;
}

.app-boot-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.app-boot-loader {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--purple-soft);
    box-shadow: 0 0 24px rgba(168, 85, 247, 0.18);
    animation: bootSpin 0.8s linear infinite;
}

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

.auth-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

.auth-card {
    width: min(500px, 100%);
    padding: 34px 28px 28px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(27, 27, 31, 0.97), rgba(22, 22, 26, 0.97));
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-card);
    position: relative;
}

.auth-card::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -1px;
    transform: translateX(-50%);
    width: 84px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(168, 85, 247, 0), rgba(168, 85, 247, 0.95), rgba(168, 85, 247, 0));
    box-shadow: 0 0 24px rgba(168, 85, 247, 0.45);
}

.auth-eyebrow {
    font-family: var(--font-display);
    font-size: 12px;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: var(--cyan);
}

.auth-back-site {
    display: inline-flex;
    margin-bottom: 18px;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.auth-back-site:hover {
    color: #fff;
}

.auth-card h1 {
    margin-top: 10px;
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    color: #fff;
}

.auth-card p {
    margin-top: 10px;
    color: var(--text-dim);
    line-height: 1.6;
}

.auth-social-btn {
    width: 100%;
    margin-top: 22px;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    background: #111216;
    color: #f5f7fb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.auth-social-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.14);
    background: #15171d;
}

.auth-google-mark {
    width: 18px;
    height: 18px;
    display: inline-flex;
}

.auth-google-mark svg {
    width: 18px;
    height: 18px;
}

.auth-divider {
    margin: 24px 0 18px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.auth-message {
    margin: 18px 0;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 181, 71, 0.08);
    border: 1px solid rgba(255, 181, 71, 0.3);
    color: var(--amber);
    line-height: 1.5;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    color: var(--text-dim);
    background: transparent;
    cursor: pointer;
    transform: translateY(-50%);
    transition: color 0.2s ease, background 0.2s ease;
}

.password-toggle:hover,
.password-toggle.is-visible {
    color: var(--purple-soft);
    background: rgba(168, 85, 247, 0.12);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.password-toggle .eye-closed {
    opacity: 0;
}

.password-toggle.is-visible .eye-open {
    opacity: 0.42;
}

.password-toggle.is-visible .eye-closed {
    opacity: 1;
}

.auth-config-list {
    margin: 12px 0 0;
    padding-left: 18px;
    color: var(--text-dim);
}

.auth-config-list li + li {
    margin-top: 6px;
}

.auth-actions {
    margin-top: 20px;
}

.auth-primary-btn {
    width: 100%;
    justify-content: center;
    min-height: 52px;
    font-size: 16px;
    background: linear-gradient(180deg, #a855f7, #7c3aed);
    border-color: rgba(168, 85, 247, 0.95);
    box-shadow: 0 16px 28px rgba(124, 58, 237, 0.26);
}

.auth-primary-btn:hover {
    border-color: rgba(216, 180, 254, 0.9);
    box-shadow: 0 18px 30px rgba(124, 58, 237, 0.32);
}

.auth-secondary-actions {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.auth-footer {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-dim);
    font-size: 14px;
}

.auth-inline-link {
    background: none;
    border: 0;
    color: var(--purple-soft);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.auth-inline-link:hover {
    color: #f0e8ff;
}

.auth-secondary-actions .auth-inline-link {
    color: var(--text-dim);
}

.auth-secondary-actions .auth-inline-link:hover {
    color: #fff;
}

.auth-legal-links {
    margin-top: 18px;
    display: flex;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-legal-links a {
    color: var(--text-dim);
    text-decoration: none;
}

.auth-legal-links a:hover {
    color: #fff;
}

.legal-page {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 48px 18px;
    display: flex;
    justify-content: center;
}

.legal-card {
    width: min(860px, 100%);
    padding: 34px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(27, 27, 31, 0.97), rgba(14, 13, 20, 0.97));
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-card);
}

.legal-card h1 {
    margin-top: 10px;
    font-family: var(--font-display);
    font-size: 34px;
    color: #fff;
}

.legal-card h2 {
    margin-top: 28px;
    font-family: var(--font-display);
    font-size: 18px;
    color: #fff;
}

.legal-card p {
    margin-top: 10px;
    color: var(--text-dim);
    line-height: 1.7;
}

.legal-card a {
    color: var(--purple-soft);
    text-decoration: none;
}

.legal-card a:hover {
    color: #fff;
}

.legal-updated {
    color: var(--text-muted) !important;
}

.legal-actions {
    margin-top: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.account-kpis {
    grid-template-columns: repeat(4, 1fr);
}

.account-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 20px;
}

.account-stack {
    display: grid;
    gap: 12px;
}

.account-info-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.account-info-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.account-info-value {
    min-width: 0;
    font-family: var(--font-mono);
    color: #fff;
    word-break: break-word;
}

.account-status-card {
    padding: 18px 18px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.account-status-card.is-active {
    border-color: rgba(40, 224, 161, 0.32);
    background: rgba(40, 224, 161, 0.08);
}

.account-status-card.is-pending {
    border-color: rgba(255, 181, 71, 0.32);
    background: rgba(255, 181, 71, 0.08);
}

.account-status-card.is-canceled {
    border-color: rgba(255, 85, 119, 0.32);
    background: rgba(255, 85, 119, 0.08);
}

.account-status-card.is-trial {
    border-color: rgba(45, 108, 255, 0.32);
    background: rgba(45, 108, 255, 0.08);
}

.account-status-card.is-local {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.account-status-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.account-status-value {
    margin-top: 8px;
    font-family: var(--font-display);
    font-size: 28px;
    color: #fff;
}

.account-status-card p {
    margin-top: 10px;
    color: var(--text-dim);
    line-height: 1.6;
}

.account-bullets {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.account-bullet {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim);
    line-height: 1.6;
}

.account-bullet strong {
    color: #fff;
}

.account-banner {
    margin: 0 0 20px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    line-height: 1.6;
}

.account-banner-warn {
    background: rgba(255, 181, 71, 0.08);
    border-color: rgba(255, 181, 71, 0.28);
    color: var(--amber);
}

.account-banner-error {
    background: rgba(255, 85, 119, 0.08);
    border-color: rgba(255, 85, 119, 0.28);
    color: #ff8ea5;
}

.account-access-state {
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.account-access-success {
    border-color: rgba(40, 224, 161, 0.28);
    background: rgba(40, 224, 161, 0.08);
}

.account-access-warn {
    border-color: rgba(255, 181, 71, 0.28);
    background: rgba(255, 181, 71, 0.08);
}

.account-access-error {
    border-color: rgba(255, 85, 119, 0.28);
    background: rgba(255, 85, 119, 0.08);
}

.account-access-title {
    font-family: var(--font-display);
    font-size: 18px;
    color: #fff;
}

.account-access-state p {
    margin-top: 8px;
    color: var(--text-dim);
    line-height: 1.6;
}

.account-page-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.account-page-chip {
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.account-page-chip.is-allowed {
    background: rgba(40, 224, 161, 0.08);
    border-color: rgba(40, 224, 161, 0.28);
    color: #9cf3d3;
}

.account-page-chip.is-blocked {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
}

.account-flow-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.account-flow-step {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.account-flow-step.is-active {
    border-color: rgba(0, 229, 255, 0.28);
    background: rgba(0, 229, 255, 0.08);
}

.account-flow-title {
    font-family: var(--font-display);
    font-size: 16px;
    color: #fff;
}

.account-flow-step p {
    margin-top: 8px;
    color: var(--text-dim);
    line-height: 1.6;
}

.account-hint {
    margin-top: 14px;
    color: var(--text-dim);
    line-height: 1.6;
}

.color-hex-row {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

.color-field {
    position: relative;
}

.color-preview-chip {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.color-hex-wrap {
    min-width: 0;
}

.field-hint {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.field-hint.success {
    color: var(--green);
}

.field-hint.warn {
    color: var(--amber);
}

.color-popover {
    display: none;
    position: absolute;
    z-index: 20;
    left: 0;
    top: calc(100% + 8px);
    width: min(320px, 100%);
    padding: 14px;
    background: rgba(17, 16, 24, 0.98);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.color-popover.show {
    display: block;
}

.color-popover-title {
    margin-bottom: 10px;
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.color-popover input[type="color"] {
    width: 100%;
    height: 42px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-2);
    cursor: pointer;
}

.color-swatch-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.color-swatch-btn {
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 9px;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .account-grid,
    .account-kpis {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .account-grid,
    .account-kpis {
        grid-template-columns: 1fr;
    }

    .account-info-row {
        grid-template-columns: 1fr;
    }

    .account-flow-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   MOBILE APP SHELL - final override
   ========================================================================= */
@media (max-width: 820px) {
    html,
    body {
        width: 100%;
        overflow-x: hidden;
    }

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

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 1500;
        width: 100%;
        height: auto;
        min-height: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 42px;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: rgba(10, 9, 16, 0.97);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    .sidebar-logo {
        margin: 0;
        min-width: 0;
        font-size: 20px;
        line-height: 1;
        white-space: nowrap;
    }

    .sidebar-menu-toggle {
        width: 42px;
        height: 42px;
        display: inline-grid;
        place-items: center;
        gap: 4px;
        padding: 10px;
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.04);
        color: #fff;
        cursor: pointer;
    }

    .sidebar-menu-toggle span {
        width: 4px;
        height: 4px;
        display: block;
        border-radius: 999px;
        background: currentColor;
    }

    .nav-link {
        display: none;
        grid-column: 1 / -1;
        width: 100%;
        margin: 0;
        padding: 12px 14px;
        text-align: left;
        border-radius: 10px;
    }

    .sidebar.menu-open {
        max-height: 88vh;
        overflow-y: auto;
    }

    .sidebar.menu-open .nav-link {
        display: block;
    }

    .content,
    .app {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .app {
        padding: 16px 12px 72px;
    }

    .header {
        padding: 14px;
        border-radius: 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .brand-text h1 {
        font-size: 20px;
        line-height: 1.1;
    }

    .brand-text p {
        font-size: 11px;
        line-height: 1.35;
    }

    .header-status {
        display: none;
    }

    .main-grid,
    .account-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .kpi-row,
    .stock-kpis,
    .account-kpis,
    .form-grid,
    .result-grid,
    .totals-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .panel {
        margin-bottom: 14px;
        border-radius: 14px;
    }

    .panel-header,
    .panel-body {
        padding: 14px;
    }

    .field input,
    .field select,
    .field textarea,
    .select-styled {
        width: 100%;
        min-width: 0;
    }

    .actions,
    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .actions .btn,
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    .table-wrap {
        width: 100%;
        margin: 0;
        padding-bottom: 4px;
        overflow-x: auto;
    }

    table {
        min-width: 680px;
    }
}

@media (max-width: 420px) {
    .app {
        padding-left: 10px;
        padding-right: 10px;
    }

    .sidebar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand-text h1 {
        font-size: 18px;
    }

    .result-card .value,
    .kpi .value {
        font-size: 20px;
    }
}

/* =========================================================================
   MOBILE APP EXPERIENCE
   ========================================================================= */
@media (max-width: 760px) {
    :root {
        --radius-lg: 14px;
        --radius-md: 10px;
        --radius-sm: 8px;
    }

    html,
    body {
        width: 100%;
        min-width: 0;
        overflow-x: hidden;
        background: #07060d;
    }

    body::before {
        background:
            radial-gradient(360px 220px at 50% -80px, rgba(147, 51, 234, 0.24), transparent 72%),
            radial-gradient(240px 220px at 100% 20%, rgba(216, 180, 254, 0.08), transparent 70%);
    }

    body::after {
        background-size: 34px 34px;
        opacity: 0.65;
    }

    .layout {
        display: block;
        width: 100%;
        min-height: 100vh;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 2000;
        width: 100%;
        height: auto;
        min-height: 56px;
        display: grid;
        grid-template-columns: 44px 1fr 44px;
        align-items: center;
        gap: 0;
        padding: 8px 14px;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        background: rgba(7, 6, 13, 0.94);
        box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        overflow: visible;
    }

    .sidebar::after {
        content: '';
        width: 44px;
        height: 44px;
        grid-column: 3;
        grid-row: 1;
    }

    .sidebar-logo {
        grid-column: 2;
        grid-row: 1;
        margin: 0;
        justify-self: center;
        font-size: 18px;
        line-height: 1;
        letter-spacing: 0;
        white-space: nowrap;
        color: #fff;
    }

    .sidebar-logo span {
        color: var(--purple-soft);
    }

    .sidebar-menu-toggle {
        grid-column: 1;
        grid-row: 1;
        width: 38px;
        height: 38px;
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
        padding: 0;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: #f8f4ff;
        cursor: pointer;
    }

    .sidebar-menu-toggle span {
        width: 16px;
        height: 2px;
        display: block;
        border-radius: 999px;
        background: currentColor;
    }

    .nav-link {
        display: none;
        grid-column: 1 / -1;
        width: 100%;
        margin: 0;
        padding: 13px 14px;
        border-radius: 10px;
        text-align: left;
        font-size: 14px;
        background: rgba(255, 255, 255, 0.035);
        border-color: rgba(255, 255, 255, 0.06);
    }

    .sidebar.menu-open {
        gap: 8px;
        max-height: 92vh;
        overflow-y: auto;
    }

    .sidebar.menu-open .nav-link {
        display: block;
    }

    .content {
        width: 100%;
        min-width: 0;
    }

    .app {
        width: 100%;
        max-width: none;
        min-width: 0;
        margin: 0;
        padding: 10px 14px 28px;
    }

    .header {
        min-height: 54px;
        margin-bottom: 10px;
        padding: 10px 12px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        border-radius: 8px;
        background: linear-gradient(180deg, rgba(22, 19, 35, 0.92), rgba(14, 13, 24, 0.92));
    }

    .brand,
    .brand-text {
        min-width: 0;
    }

    .brand-text h1 {
        font-size: 16px;
        line-height: 1.05;
        letter-spacing: 0;
    }

    .brand-text p {
        margin-top: 4px;
        max-width: 240px;
        font-size: 8px;
        line-height: 1.25;
        letter-spacing: 0.4px;
    }

    .logo-mark {
        width: 34px;
        height: 34px;
        border-radius: 9px;
        font-size: 16px;
    }

    .header-status {
        display: none;
    }

    .main-grid,
    .account-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .panel {
        margin-bottom: 10px;
        border-radius: 8px;
        background: linear-gradient(180deg, rgba(15, 17, 29, 0.94), rgba(12, 13, 23, 0.94));
    }

    .panel-header {
        min-height: 38px;
        padding: 10px 12px;
    }

    .panel-title {
        font-size: 10px;
        letter-spacing: 0.7px;
    }

    .panel-body {
        padding: 10px 12px 12px;
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 9px 8px;
    }

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

    .field label {
        margin-bottom: 5px;
        font-size: 8px;
        line-height: 1.2;
        letter-spacing: 0.5px;
    }

    .field input,
    .field select,
    .select-styled {
        min-height: 34px;
        padding: 8px 10px;
        border-radius: 7px;
        font-size: 11px;
        line-height: 1.2;
        background-color: rgba(42, 35, 55, 0.88);
    }

    .select-styled {
        padding-right: 28px !important;
        background-position: right 10px center;
    }

    #calc-filament-rows {
        display: grid;
        gap: 8px;
    }

    .calc-filament-row {
        grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
        gap: 8px;
        padding: 0;
    }

    .calc-filament-row .field:last-child {
        grid-column: 1 / -1;
    }

    .calc-filament-row .field:last-child label {
        display: none;
    }

    .calc-remove-filament-row {
        min-height: 32px;
        padding: 8px 10px;
    }

    .field.full > .actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 8px !important;
    }

    .result-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 8px;
    }

    .result-card {
        min-height: 50px;
        padding: 9px 10px;
        border-radius: 7px;
        background: rgba(42, 35, 55, 0.82);
    }

    .result-card .label {
        font-size: 8px;
        letter-spacing: 0.45px;
    }

    .result-card .value {
        margin-top: 3px;
        font-size: 12px;
        line-height: 1.2;
    }

    .result-card.highlight {
        background: linear-gradient(135deg, rgba(124, 58, 237, 0.36), rgba(0, 229, 255, 0.08));
    }

    .actions,
    .modal-footer {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 8px;
        align-items: stretch;
    }

    .actions .btn,
    .modal-footer .btn,
    .btn {
        width: 100%;
        min-height: 34px;
        justify-content: center;
        padding: 8px 10px;
        border-radius: 7px;
        font-size: 10px;
        letter-spacing: 0.3px;
    }

    .kpi-row,
    .stock-kpis,
    .account-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .table-wrap {
        width: 100%;
        margin: 0;
        overflow-x: auto;
    }

    table {
        min-width: 640px;
    }

    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-width: none;
    }
}

@media (max-width: 360px) {
    .app {
        padding-left: 10px;
        padding-right: 10px;
    }

    .field input,
    .field select,
    .select-styled {
        font-size: 10px;
    }

    .actions,
    .modal-footer,
    .field.full > .actions {
        grid-template-columns: 1fr;
    }
}

/* =========================================================================
   Premium SaaS refresh
   ========================================================================= */
:root {
    --bg-0: #090a12;
    --bg-1: #0d1020;
    --bg-2: #111522;
    --bg-3: #1e2638;
    --line: rgba(148, 163, 184, 0.14);
    --line-strong: rgba(154, 77, 255, 0.38);
    --text: #f7f7fb;
    --text-dim: #b8bdca;
    --text-muted: #7d8496;
    --blue: #9a4dff;
    --blue-deep: #7c3aed;
    --cyan: #00d4ff;
    --cyan-soft: #65e4ff;
    --purple: #9a4dff;
    --purple-soft: #c084fc;
    --green: #20e39f;
    --amber: #ffb648;
    --red: #ff5f7a;
    --shadow-glow: 0 0 32px rgba(154, 77, 255, 0.18);
    --shadow-card: 0 18px 38px rgba(0, 0, 0, 0.28), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

body::before {
    background:
        radial-gradient(780px 520px at 8% 0%, rgba(154, 77, 255, 0.16), transparent 70%),
        radial-gradient(640px 420px at 100% 10%, rgba(0, 212, 255, 0.06), transparent 68%);
}

.app {
    max-width: 1720px;
    padding: 28px 30px 70px;
}

.layout {
    grid-template-columns: 238px 1fr;
}

.sidebar {
    padding: 22px 16px;
    background: rgba(13, 16, 32, 0.96);
    border-right: 1px solid rgba(148, 163, 184, 0.12);
}

.sidebar-logo {
    margin-bottom: 28px;
    padding: 0 4px;
    color: #fff;
    font-size: 20px;
}

.sidebar-logo::after {
    content: none;
}

.nav-section-label {
    margin: 22px 0 8px;
    padding: 0 4px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.nav-link {
    position: relative;
    margin-bottom: 4px;
    padding: 11px 12px 11px 34px;
    border-radius: 12px;
    color: #cbd3e5;
    font-weight: 600;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 13px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    border: 1px solid currentColor;
    transform: translateY(-50%) rotate(45deg);
    opacity: 0.58;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(154, 77, 255, 0.18);
    color: #fff;
    border-color: rgba(154, 77, 255, 0.45);
    box-shadow: none;
}

.nav-link.active::before {
    background: var(--purple);
    border-color: var(--purple);
    box-shadow: 0 0 12px rgba(154, 77, 255, 0.75);
}

.header,
.panel,
.kpi {
    background: rgba(17, 21, 34, 0.88);
    border-color: rgba(148, 163, 184, 0.14);
    border-radius: 14px;
}

.panel-header {
    min-height: 58px;
    border-bottom-color: rgba(148, 163, 184, 0.12);
}

.panel-title::before {
    background: var(--purple);
    box-shadow: 0 0 10px var(--purple);
}

table thead {
    background: rgba(9, 10, 18, 0.44);
}

tbody tr:hover {
    background: rgba(154, 77, 255, 0.05);
}

.btn.primary,
button.primary,
.auth-primary-btn {
    background: linear-gradient(135deg, #9a4dff, #7c3aed);
    box-shadow: 0 14px 24px rgba(124, 58, 237, 0.25);
}

@media (max-width: 820px) {
    .layout {
        display: block;
    }

    .sidebar {
        grid-template-columns: 42px 1fr 42px;
        padding: 10px 14px;
        background: rgba(9, 10, 18, 0.94);
    }

    .sidebar-logo {
        padding: 0;
        font-size: 18px;
    }

    .sidebar-logo::after,
    .nav-section-label {
        display: none;
    }

    .sidebar.menu-open .nav-section-label {
        display: block;
        grid-column: 1 / -1;
        margin: 14px 0 2px;
    }

    .sidebar.menu-open .nav-link {
        display: block;
    }

    .nav-link {
        padding: 13px 14px 13px 36px;
        border-radius: 10px;
    }

    .app {
        padding: 12px 12px 28px;
    }
}
