:root {
  --orange: #F47E25;
  --dark: #202020;
  --text: #212121;
  --bg: #F5F5F5;
  --panel: #FAFAFA;
  --border: #E8E8E8;
  --mid: #80838A;
  --success: #3C9B5F;
  --warning: #E3C83F;
  --danger: #EB242C;
  --field-off: #F0F0F0;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: 'Sora', system-ui, sans-serif; font-size: 14px; color: var(--text);
  background: #202020; display: flex; min-height: 100vh;
}
svg.lucide { width: 16px; height: 16px; stroke-width: 1.8; flex-shrink: 0; }
.muted { color: var(--mid); }

/* Sidebar */
.sidebar { width: 274px; padding: 16px 12px; flex-shrink: 0; }
.logo { height: 48px; margin: 4px 6px 22px; display: block; }
.nav-group { font-size: 12px; color: #8A8D93; margin: 18px 10px 6px; }
.nav {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px;
  color: #E4E4E4; text-decoration: none; font-size: 14.5px;
}
.nav:hover { background: #2E2E2E; }
.nav.active { background: #353535; color: #fff; }
.nav.active svg { color: var(--orange); }
.nav .count { margin-left: auto; color: #8A8D93; font-size: 12px; }

/* Shell */
.shell { flex: 1; background: var(--panel); margin: 8px 8px 8px 0; border-radius: 14px; border: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 8px; color: #555; }
.crumbs b { color: var(--text); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.env { border: 1px solid #ccc; border-radius: 99px; padding: 2px 8px; font-size: 12px; }
.user { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #FDEBDD; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.user-name { font-weight: 500; font-size: 13px; }
.user-role { color: var(--mid); font-size: 12px; }
main { padding: 24px 32px 40px; max-width: 1180px; width: 100%; }

/* Page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 6px; }
.sub { color: #555; font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 12px; }

/* Cards */
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 22px; }
.card-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.card-sub { color: #555; font-size: 13px; margin-top: 2px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }

/* Form */
.grid { display: grid; gap: 14px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g5 { grid-template-columns: 2fr 1.4fr .8fr 1fr 1fr; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3b { grid-template-columns: 1.5fr 1fr 1fr; }
label.lbl { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 6px; }
.hint { color: var(--mid); font-size: 12px; margin-top: 6px; }
.input, select.input {
  width: 100%; height: 40px; border: 1px solid #D6D6D6; border-radius: 8px; padding: 0 12px;
  font: inherit; color: var(--text); background: #fff; outline: none;
}
.input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px #F47E2522; }
.input:disabled, .input[readonly] { background: var(--field-off); border-color: #E2E2E2; }
.input.num { text-align: right; }
.input.err { border-color: var(--danger); background: #FFF3F3; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 12px; color: var(--mid); }
.search-wrap .input { padding-left: 36px; }
.results {
  position: absolute; top: 44px; left: 0; min-width: 100%; width: max-content; z-index: 5; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.1); overflow: hidden;
}
.results table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results th { text-align: left; font-weight: 500; color: var(--mid); padding: 8px 12px; background: var(--bg); }
.results th, .results td { white-space: nowrap; }
.results td { padding: 9px 12px; border-top: 1px solid var(--border); cursor: pointer; }
.results tr:hover td { background: #FFF6EF; }
.results .empty { padding: 12px; color: var(--mid); }

/* Buttons */
.btn {
  height: 36px; padding: 0 14px; border-radius: 8px; border: 0; font: inherit; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; background: #ECECEC; color: var(--text);
}
.btn:hover:not(:disabled) { background: #E2E2E2; }
.btn:disabled { color: #A5A5A5; cursor: default; background: #F1F1F1; }
.btn.primary { background: var(--orange); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #E06C14; }
.btn.primary:disabled { background: #F1F1F1; color: #A5A5A5; }
.btn.dark { background: var(--dark); color: #fff; }
.actions { display: flex; justify-content: space-between; margin-top: 18px; }
.actions > div { display: flex; gap: 8px; }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: 99px; }
.badge.open { background: #FDEBDD; }
.badge.open::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--dark); }
.badge.closed { background: #EEE; color: #444; }
.badge svg { width: 12px; height: 12px; }

/* Toggle */
.toggle { display: flex; align-items: center; gap: 14px; }
.switch { position: relative; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #CFCFCF; border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--orange); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:disabled + span { opacity: .5; cursor: default; }

/* Totals */
.section-title { font-size: 18px; font-weight: 600; margin: 4px 0 12px; }
.section-title small { font-size: 13px; color: #555; font-weight: 400; margin-left: 6px; }
.tot { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 14px; min-width: 0; }
.tot .k { font-size: 13px; color: #444; }
.tot .v { font-size: 20px; white-space: nowrap; font-weight: 600; margin: 4px 0; }
.tot .n { font-size: 11.5px; color: #555; }
.totals { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.tot.total { background: #141414; color: #fff; border-color: #141414; }
.tot.total .k, .tot.total .n { color: #BBB; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { white-space: nowrap; }
table.data th { text-align: left; font-weight: 500; font-size: 13px; color: #444; padding: 10px 16px; background: var(--bg); }
table.data th:first-child { border-radius: 8px 0 0 8px; }
table.data th:last-child { border-radius: 0 8px 8px 0; }
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: #FAFAFA; }
table.data tr.sel td { background: #FFF1E6 !important; }
.r { text-align: right !important; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.empty-row { text-align: center; color: var(--mid); padding: 28px !important; cursor: default; }

/* Tratamento */
.two-col { display: grid; grid-template-columns: minmax(0, 680px) auto; gap: 24px; align-items: start; }
.ops { background: #F0F0F0; border-radius: 10px; padding: 8px; margin-bottom: 20px; }
.op { display: flex; gap: 12px; padding: 12px; border-radius: 8px; cursor: pointer; }
.op input { accent-color: var(--orange); width: 18px; height: 18px; margin: 2px 0 0; }
.op.on { background: #fff; }
.op b { font-weight: 600; display: block; margin-bottom: 2px; }
.op span { font-size: 13px; color: #555; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0 0 20px; }
.checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.checks input { accent-color: var(--orange); width: 16px; height: 16px; }

/* Modal */
.backdrop { position: fixed; inset: 0; background: rgba(20,20,20,.35); display: grid; place-items: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 440px; max-width: calc(100vw - 32px); padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { width: 560px; }
.modal-title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; margin-bottom: 10px; }
.modal-title svg { width: 20px; height: 20px; }
.modal-title.error svg { color: var(--danger); }
.modal-title.warn svg { color: #C9A800; }
.modal-title.ok svg { color: var(--success); }
.modal-title.ask svg { color: var(--orange); }
.modal-msg { color: #333; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.placeholder { text-align: center; color: var(--mid); padding: 80px 0; }

/* Closed (read-only) inventory */
.closed-banner {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin-bottom: 22px;
  background: var(--dark); color: #fff; border-radius: 12px; border-left: 5px solid var(--orange);
}
.closed-banner > svg { width: 24px; height: 24px; color: var(--orange); }
.cb-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.cb-text b { font-size: 15px; }
.cb-text span { color: #BDBDBD; font-size: 13px; }
.cb-actions { display: flex; gap: 8px; }
.cb-actions .btn { background: transparent; color: #fff; border: 1px solid #555; }
.cb-actions .btn:hover:not(:disabled) { background: #333; }
.cb-actions .btn.primary { background: var(--orange); border-color: var(--orange); }
.cb-actions .btn.primary:hover:not(:disabled) { background: #E06C14; }
table.data.readonly tbody tr { cursor: default; }
table.data.readonly tbody tr:hover td { background: transparent; }
table.data.readonly td { color: #555; }

/* Login */
body.login-mode .sidebar, body.login-mode .shell { display: none; }
.logout { color: var(--mid); display: grid; place-items: center; margin-left: 6px; padding: 6px; border-radius: 6px; }
.logout:hover { background: var(--bg); color: var(--text); }
.login { display: flex; min-height: 100vh; width: 100vw; }
.login-brand {
  flex: 1; background: var(--dark); color: #fff; padding: 48px 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  border-right: 6px solid var(--orange);
}
.login-brand img { height: 64px; align-self: flex-start; }
.login-app { font-size: 56px; font-weight: 700; letter-spacing: -1px; }
.login-tag { color: #BDBDBD; font-size: 17px; max-width: 420px; line-height: 1.5; margin-top: 8px; }
.login-foot { color: #8A8D93; font-size: 12px; }
.login-side { flex: 1; background: var(--panel); display: grid; place-items: center; padding: 32px 16px; }
.login-form { width: 100%; max-width: 380px; }
.login-form h1 { font-size: 28px; }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 44px; }
.pass-eye { position: absolute; right: 6px; top: 6px; height: 28px; width: 32px; border: 0; background: none; color: var(--mid); cursor: pointer; display: grid; place-items: center; }
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; margin: 14px 0 6px; }
.login-btn { width: 100%; height: 44px; justify-content: center; font-size: 15px; }
@media (max-width: 800px) {
  .login { flex-direction: column; }
  .login-brand { flex: 0; gap: 24px; padding: 28px 16px; border-right: 0; border-bottom: 6px solid var(--orange); }
  .login-app { font-size: 36px; }
}
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; }
.forgot { font-size: 12.5px; color: var(--orange); text-decoration: none; font-weight: 500; white-space: nowrap; }
.forgot:hover { text-decoration: underline; }
