/* ============ Base ============ */
:root {
    --bg: #f4f6fb; --card: #fff; --ink: #0f172a; --text: #1e293b; --muted: #64748b; --line: #e2e8f0; --line-soft: #f1f5f9;
    --brand: #4f46e5; --brand-2: #7c3aed; --brand-soft: #eef2ff;
    --green: #059669; --green-soft: #ecfdf5; --red: #e11d48; --red-soft: #fff1f2; --amber: #d97706; --amber-soft: #fffbeb;
    --radius: 16px; --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
    --grad: linear-gradient(135deg, var(--brand), var(--brand-2));
    --sidebar: 240px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
h3 { font-size: 16px; font-weight: 750; margin: 0; }
.ico { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-amber { color: var(--amber) !important; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }

/* ============ Sidebar ============ */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 14px; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 800; font-size: 16px; line-height: 1.15; padding: 4px 8px 20px; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; color: var(--muted); font-size: 13px; }
.brand-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .3); }
.brand-mark.lg { width: 64px; height: 64px; border-radius: 20px; background: rgba(255, 255, 255, .16); box-shadow: none; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 800; flex-shrink: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; transition: .15s; }
.icon-btn:hover { color: var(--red); border-color: #fecdd3; background: var(--red-soft); text-decoration: none; }
.icon-btn.sm { width: 30px; height: 30px; border-color: transparent; background: transparent; }

.content { margin-left: var(--sidebar); min-height: 100vh; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px 28px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-weight: 500; font-size: 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.back:hover { color: var(--ink); text-decoration: none; }

/* ============ Cards ============ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); }
.card-foot p { margin: 0; }
.card.accent-green { border-top: 4px solid var(--green); }
.card.accent-red { border-top: 4px solid var(--red); }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.section-title .ico { color: var(--brand); }

/* ============ Stats ============ */
.stats { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 13px; opacity: .8; }
.stat.hero { background: var(--grad); border: 0; color: #fff; box-shadow: 0 10px 30px rgba(79, 70, 229, .28); }
.stat.hero .stat-label, .stat.hero .stat-value { color: #fff; }
.stat.hero .stat-label { opacity: .8; }
.stat.hero .stat-value { font-size: 38px; }
.stat-ico { position: absolute; top: 16px; right: 16px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; }
.stat-ico.violet { background: var(--brand-soft); color: var(--brand); }
.stat-ico.green { background: var(--green-soft); color: var(--green); }
.stat-ico.amber { background: var(--amber-soft); color: var(--amber); }

/* ============ Tabelas ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 20px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; font-weight: 700; background: #fafbfd; border-bottom: 1px solid var(--line); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num .bar { margin-left: auto; width: 76px; margin-top: 6px; }

.product { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.product:hover { text-decoration: none; }
.product:hover strong { color: var(--brand); }
.product span:last-child { display: flex; flex-direction: column; line-height: 1.3; }
.product small { font-size: 12.5px; }
.pavatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.pavatar.c0 { background: #eef2ff; color: #4f46e5; } .pavatar.c1 { background: #ecfeff; color: #0891b2; }
.pavatar.c2 { background: #ecfdf5; color: #059669; } .pavatar.c3 { background: #fffbeb; color: #d97706; }
.pavatar.c4 { background: #fdf2f8; color: #db2777; } .pavatar.c5 { background: #f5f3ff; color: #7c3aed; }

.sold { display: inline-block; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 800; font-size: 15px; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); letter-spacing: .02em; }
.sold.zero { background: var(--line-soft); color: var(--muted); }
.bar { height: 6px; border-radius: 99px; background: var(--brand-soft); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.bar.light { background: rgba(255, 255, 255, .25); }
.bar.light span { background: #fff; }

.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.badge.low { background: var(--amber-soft); color: #92400e; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty { text-align: center; color: var(--muted); padding: 36px 16px !important; }
.empty-ico { display: grid; place-items: center; width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }

/* ============ Busca ============ */
.search, .input-icon { position: relative; }
.search { flex: 1; max-width: 340px; }
.search .ico, .input-icon .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; border-radius: 999px; background: var(--bg); border-color: transparent; }
.search input:focus { background: #fff; }
.input-icon input { padding-left: 42px; }

/* ============ Botões ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 10px 18px; font: inherit; font-size: 15px; font-weight: 650; cursor: pointer; background: var(--brand); color: #fff; transition: transform .08s, box-shadow .15s, background .15s; box-shadow: 0 4px 12px rgba(79, 70, 229, .22); white-space: nowrap; }
.btn:hover { text-decoration: none; background: #4338ca; }
.btn:active { transform: translateY(1px); }
.btn.green { background: var(--green); box-shadow: 0 4px 12px rgba(5, 150, 105, .22); } .btn.green:hover { background: #047857; }
.btn.red { background: var(--red); box-shadow: 0 4px 12px rgba(225, 29, 72, .22); } .btn.red:hover { background: #be123c; }
.btn.light { background: #fff; color: var(--text); border: 1px solid var(--line); box-shadow: none; } .btn.light:hover { background: var(--line-soft); }
.btn.ghost { background: rgba(255, 255, 255, .16); box-shadow: none; } .btn.ghost:hover { background: rgba(255, 255, 255, .26); }
.btn.soft-green { background: var(--green-soft); color: var(--green); box-shadow: none; } .btn.soft-green:hover { background: #d1fae5; }
.btn.soft-red { background: var(--red-soft); color: var(--red); box-shadow: none; } .btn.soft-red:hover { background: #ffe4e6; }
.btn.sm { padding: 7px 9px; border-radius: 10px; }
.btn.lg { padding: 14px 22px; font-size: 16px; }
.btn.block { width: 100%; }

/* ============ Formulários ============ */
input, select, textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: 15px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }
input::placeholder { color: #a0aec0; }
label { display: block; font-size: 13.5px; color: var(--text); margin-bottom: 6px; font-weight: 600; }
label .muted { font-weight: 400; }
.field { margin-bottom: 16px; }
.grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--muted); margin: 4px 0 20px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.input-prefix:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12); }
.input-prefix span { padding-left: 14px; color: var(--muted); font-weight: 600; }
.input-prefix input { border: 0; box-shadow: none !important; padding-left: 8px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { text-align: center; font-size: 20px; font-weight: 800; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper button { display: grid; place-items: center; width: 48px; height: 48px; flex-shrink: 0; border: 0; border-radius: 12px; background: var(--brand-soft); color: var(--brand); cursor: pointer; }
.stepper button:hover { background: #e0e7ff; }
.form-narrow { max-width: 760px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 28px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border: 1px solid #fecdd3; border-radius: var(--radius); background: #fff; }
.danger-zone p { margin: 2px 0 0; }

/* ============ Alertas ============ */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.alert .ico { margin-top: 2px; }
.alert.ok { background: var(--green-soft); color: #065f46; border: 1px solid #a7f3d0; }
.alert.err { background: var(--red-soft); color: #9f1239; border: 1px solid #fecdd3; }

/* ============ Entrada / Saída ============ */
.mov-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.mov-grid .card { margin-bottom: 0; }
.product-preview { margin-top: 10px; padding: 14px 16px; border-radius: 12px; background: var(--brand-soft); border: 1px solid #e0e7ff; display: none; align-items: center; gap: 14px; }
.product-preview.show { display: flex; }
.product-preview.miss { background: var(--line-soft); border-color: var(--line); color: var(--muted); }
.pp-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pp-main strong { font-size: 17px; color: var(--ink); }
.pp-main .muted { font-size: 13.5px; }
.pp-main .bar { margin-top: 8px; background: #fff; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 2px; margin-bottom: 12px; border-top: 1px dashed var(--line); }
.total-row strong { font-size: 24px; color: var(--ink); font-variant-numeric: tabular-nums; }
.date-filter { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.date-filter input { padding: 7px 10px; width: auto; font-size: 14px; }

.mov-list { list-style: none; margin: 0; padding: 0; }
.mov-list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-soft); }
.mov-list li:last-child { border-bottom: 0; }
.mov-list li.empty { display: block; }
.mov-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.mov-ico.in { background: var(--green-soft); color: var(--green); }
.mov-ico.out { background: var(--red-soft); color: var(--red); }
.mov-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.mov-main a { color: var(--ink); }
.mov-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mov-val { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.35; font-variant-numeric: tabular-nums; }
.mov-val strong { font-size: 16px; }

/* ============ Produto ============ */
.product-hero { background: var(--grad); color: #fff; border-radius: 22px; padding: 26px; margin-bottom: 16px; box-shadow: 0 14px 36px rgba(79, 70, 229, .28); }
.ph-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.product-hero h1 { color: #fff; }
.product-hero p { margin: 4px 0 0; opacity: .8; }
.ph-actions .btn { color: #fff; }
.ph-sold { display: flex; align-items: baseline; gap: 12px; margin: 24px 0 12px; }
.ph-label { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: -.01em; }
.ph-caption { opacity: .8; }
.ph-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 22px; }
.ph-stats small { display: block; opacity: .75; font-size: 12.5px; }
.ph-stats strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.ph-warn { display: inline-flex; align-items: center; gap: 6px; margin-top: 18px; padding: 6px 12px; border-radius: 10px; background: #fef3c7; color: #92400e; font-weight: 700; font-size: 13.5px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }

/* ============ Paginação ============ */
.pagination { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 14px; font-weight: 600; }
.pagination a:hover { background: var(--line-soft); text-decoration: none; }
.pagination .current { border-color: transparent; color: var(--muted); font-weight: 500; }
.pagination .disabled { color: #cbd5e1; }

/* ============ Login ============ */
.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-hero { background: var(--grad); color: #fff; padding: 64px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(255, 255, 255, .07); right: -120px; bottom: -140px; }
.login-hero h1 { color: #fff; font-size: 38px; margin-top: 24px; }
.login-hero p { font-size: 17px; opacity: .85; max-width: 420px; }
.login-hero ul { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 12px; }
.login-hero li { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.login-hero li .ico { padding: 6px; width: 32px; height: 32px; border-radius: 10px; background: rgba(255, 255, 255, .16); }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 26px; margin: 0; }
.login-card > .muted { margin: 4px 0 24px; }

/* ============ Responsivo ============ */
@media (max-width: 1000px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .mov-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar { position: sticky; top: 0; inset: auto; width: auto; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { padding: 0; }
    .brand > span:last-child { display: none; }
    .brand-mark { width: 36px; height: 36px; }
    .nav { flex-direction: row; flex: 1; justify-content: center; gap: 2px; }
    .nav a { padding: 8px 12px; gap: 6px; font-size: 14px; }
    .sidebar-foot { margin: 0; padding: 0; border: 0; }
    .user { display: none; }
    .content { margin-left: 0; }
    .page { padding: 20px 14px 40px; }
    h1 { font-size: 24px; }
    .login { grid-template-columns: 1fr; }
    .login-hero { padding: 40px 28px; }
    .login-hero h1 { font-size: 28px; }
    .login-hero ul { display: none; }
    .ph-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .hide-sm { display: none; }
    th, td { padding: 12px 12px; }
    .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat { padding: 12px; border-radius: 14px; }
    .stat.hero { grid-column: 1 / -1; padding: 18px; }
    .stat-label { font-size: 12px; }
    .stat-value { font-size: 17px; }
    .stat-ico { display: none; }
    .search { flex-basis: 100%; }
    .nav a { padding: 8px 10px; }
    .nav a .ico { display: none; }
    .pavatar { display: none; }
    .search { max-width: none; }
    .card { padding: 18px; }
    .card-head, .card-foot, .mov-list li { padding-left: 14px; padding-right: 14px; }
    .ph-label { font-size: 40px; }
    .danger-zone { flex-direction: column; align-items: stretch; }
}
