/* Inventário + modal de cadastro */
.inv-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.inv-head h1 { margin: 0; }
.inv-counters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.inv-ct { font-size: 13px; color: var(--text-secondary); background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 11px; display: inline-flex; align-items: center; gap: 4px; }
.inv-ct b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.inv-ct.warn b { color: var(--warning); }
.inv-ct.good b { color: var(--good); }
.inv-recent { border-color: var(--good); margin-bottom: 14px; }
.inv-recent h2 { margin-top: 0; }
.inv-op { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: 12.5px; color: var(--text-secondary); }
.inv-name:hover strong { text-decoration: underline; }
.inv-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tagchip { --tag: #3987e5; display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px; color: var(--text-primary);
  background: color-mix(in srgb, var(--tag) 16%, transparent); border: 1px solid color-mix(in srgb, var(--tag) 55%, transparent); }
.tagchip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tag); }
.inv-complete { background: var(--warning); color: #1a1408; box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 22%, transparent); }
.inv-wrap { overflow: visible; }
@media (max-width: 900px) { .inv-wrap { overflow-x: auto; } }
.inv-mth { white-space: nowrap; position: relative; }
.inv-mf { position: relative; display: inline-block; margin-left: 6px; text-transform: none; letter-spacing: 0; }
.inv-mf-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary); padding: 2px 6px;
  border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; }
.inv-mf-btn.on { border-color: var(--accent); color: var(--accent); }
.inv-mf-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 70; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; width: 240px; box-shadow: 0 14px 40px rgba(0,0,0,.4); padding: 8px; display: block; cursor: default; font-weight: 400; }
.inv-mf-menu[hidden] { display: none; }
.inv-mf-list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }
.inv-mf-list label { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 6px; font-size: 13px; color: var(--text-primary); cursor: pointer; }
.inv-mf-list label:hover { background: var(--surface-2); }
.inv-mf-list input { width: auto; accent-color: var(--accent); }
.inv-mf-actions { display: flex; justify-content: space-between; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 6px; }
#inv-tbody.inv-refreshing { opacity: .55; transition: opacity .15s; }


/* cadastro (modal + página cheia), tudo escopado em .am-* */
.am-ov { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 20px; overflow-y: auto; }
.am-ov[hidden], .am-ov [hidden] { display: none !important; }
html[data-theme="light"] .am-ov[data-mode="modal"] { background: rgba(40,40,30,.38); }
.am-box { width: 1180px; max-width: 100%; background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5); animation: amIn .18s ease-out; }
@keyframes amIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.am-ov[data-mode="page"] { position: static; inset: auto; z-index: auto; background: none; padding: 0; display: block; overflow: visible; }
.am-ov[data-mode="page"] .am-box { width: 100%; box-shadow: none; animation: none; }

.am-top { position: sticky; top: 0; z-index: 20; padding: 20px 28px 16px; background: var(--surface-1);
  border-bottom: 1px solid var(--border); border-radius: 14px 14px 0 0; }
.am-top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.am-head { min-width: 0; flex: 1; }
.am-kicker { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); font-weight: 600; }
#am-title { margin: 4px 0 8px; font-size: 26px; line-height: 1.2; color: var(--text-primary); font-weight: 700; overflow-wrap: anywhere; }
.am-t-op { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; color: var(--accent); font-weight: 700; }
.am-t-op:not(:empty)::after { content: " \00B7 "; color: var(--text-muted); font-family: -apple-system, "Segoe UI", sans-serif; }
.am-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.am-top-actions { display: flex; gap: 10px; flex-shrink: 0; }
.am-top-actions .btn { padding: 10px 20px; }

.am-tagbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.am-chips { display: contents; }
.am-chip { font-size: 13.5px; padding: 5px 6px 5px 12px; gap: 8px; }
.am-chip::before { width: 9px; height: 9px; }
.am-chip button { background: transparent; color: var(--text-secondary); padding: 0; width: 22px; height: 22px; border-radius: 50%; line-height: 1; font-size: 15px; }
.am-chip button:hover { background: color-mix(in srgb, var(--tag) 30%, transparent); color: var(--text-primary); filter: none; }
.am-tagbar .am-chip[data-nb] { padding-right: 12px; }
.am-tagwrap { position: relative; }
.am-addtag { background: transparent; border: 1px dashed var(--border); color: var(--accent); padding: 6px 13px; border-radius: 999px; font-size: 13px; }
.am-addtag:hover, .am-addtag[aria-expanded="true"] { border-color: var(--accent); filter: none; }
.am-tagpanel { position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; width: 360px; max-width: calc(100vw - 32px);
  max-height: min(70vh, 520px); overflow-y: auto; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.45); padding: 14px; }
.am-tp-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.am-tp-list { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.am-tp-list button { display: flex; align-items: center; gap: 10px; background: transparent; color: var(--text-primary); font-weight: 500;
  padding: 8px; border-radius: 8px; text-align: left; font-size: 14px; }
.am-tp-list button:hover { background: var(--surface-2); filter: none; }
.am-tp-list .am-ck { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; color: #fff; }
.am-tp-list button[aria-pressed="true"] .am-ck { background: var(--accent); border-color: var(--accent); }
.am-tp-list .am-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tag); flex-shrink: 0; }
.am-empty { color: var(--text-muted); font-size: 13px; padding: 4px 0; }
.am-tagnew { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.am-palette { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.am-palette button { width: 100%; aspect-ratio: 1; max-width: 26px; padding: 0; border-radius: 50%; border: 2px solid transparent; justify-self: center; }
.am-palette button[aria-checked="true"] { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--surface-1) inset; }
.am-tp-prev { display: flex; align-items: center; gap: 10px; }
.am-tagnew > .btn { align-self: flex-end; }

.am-body { padding: 8px 28px 28px; }
.am-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 44px; }
.am-sec { padding: 20px 0 4px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.am-sec h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.am-body .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); position: relative; min-width: 0; }
.am-body input, .am-body select, .am-body textarea { padding: 11px 13px; min-width: 0; }
.am-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.am-mono { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; }
.am-req { color: var(--accent); }
.am-auto { font-weight: 400; color: var(--text-muted); font-size: 11.5px; margin-left: 4px; }
.am-row { display: flex; gap: 8px; align-items: stretch; min-width: 0; }
.am-row > input { flex: 1; }
.am-readonly, .am-ro { opacity: .75; background: var(--surface-0) !important; }
.am-ro { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 11px 13px; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.am-lbl { font-size: 13px; }
.am-opt { display: flex; gap: 8px; }
.am-ghost { background: transparent; color: var(--accent); border: 1px dashed var(--border); padding: 5px 12px; font-size: 12.5px; }
.am-ghost:hover { border-color: var(--accent); filter: none; }
.am-found { align-self: flex-start; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text-primary); border: 1px solid var(--accent);
  padding: 5px 11px; font-size: 12.5px; font-weight: 500; }
.am-found b { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; color: var(--accent); }
.am-seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-0); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.am-seg button { background: transparent; color: var(--text-secondary); font-weight: 500; padding: 9px 10px; border-radius: 7px; }
.am-seg button:hover { background: var(--surface-2); filter: none; }
.am-seg button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.am-notes { margin-top: 22px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-0); }
.am-notes summary { cursor: pointer; padding: 12px 16px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); font-weight: 600; }
.am-notes textarea { display: block; margin: 0 16px 16px; width: calc(100% - 32px); resize: vertical; }
.am-error { margin: 16px 0 0; border: 1px solid var(--critical); color: var(--critical); background: color-mix(in srgb, var(--critical) 9%, transparent);
  border-radius: 8px; padding: 10px 12px; font-size: 13.5px; white-space: pre-line; }
.am-error .btn { margin-top: 8px; }
.am-loading { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 44px; padding: 22px 0; }
.sk { height: 42px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-0), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
.sk.short { width: 55%; }
@keyframes sk { to { background-position: -200% 0; } }

.am-sugg { position: absolute; top: 100%; left: 0; right: 0; z-index: 10; list-style: none; margin: 4px 0 0; padding: 4px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.35); max-height: 260px; overflow-y: auto; }
.am-sugg li { padding: 8px 10px; border-radius: 7px; cursor: pointer; color: var(--text-primary); }
.am-sugg li small { display: block; color: var(--text-muted); font-size: 11.5px; }
.am-sugg li[aria-selected="true"], .am-sugg li:hover { background: var(--surface-2); }
.am-linked { margin-top: 6px; border: 1px solid var(--good); border-radius: 8px; padding: 8px 11px; font-size: 12.5px; color: var(--text-secondary); }
.am-linked .badge { margin-right: 6px; }
.am-linked-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 160px; overflow-y: auto; }
.am-linked-list li { padding: 3px 0; border-top: 1px solid var(--border); }

.am-cal { position: absolute; z-index: 12; top: 100%; left: 0; margin-top: 6px; width: 300px; max-width: 100%; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 16px 44px rgba(0,0,0,.4); padding: 10px; }
.cal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: var(--text-primary); font-weight: 600; text-transform: capitalize; }
.cal-h button { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); padding: 2px 9px; }
.cal-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-g .wd { font-size: 10.5px; color: var(--text-muted); text-align: center; padding: 3px 0; }
.cal-g button { background: transparent; color: var(--text-primary); padding: 6px 0; font-weight: 500; font-size: 13px; position: relative; border-radius: 7px; }
.cal-g button:hover { background: var(--surface-2); filter: none; }
.cal-g button.today { box-shadow: inset 0 0 0 1px var(--border); }
.cal-g button.sig::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--good); }
.cal-g button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.cal-f { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; font-size: 11.5px; color: var(--text-muted); align-items: center; }

.am-confirm { position: fixed; z-index: 520; left: 50%; top: 22vh; transform: translateX(-50%); width: 460px; max-width: calc(100vw - 32px);
  background: var(--surface-1); border: 1px solid var(--warning); border-radius: 14px; padding: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.am-confirm[hidden] { display: none; }
.am-confirm h3 { margin: 0 0 4px; font-size: 16px; color: var(--text-primary); }
.am-cf-name { margin: 0 0 10px; color: var(--text-secondary); }
.am-cf-list { list-style: none; margin: 0 0 14px; padding: 0; max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.am-cf-list li { padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.am-cf-list li:last-child { border-bottom: 0; }
.am-cf-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.am-box :focus-visible, .am-confirm :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 900px) {
  .am-cols, .am-loading { grid-template-columns: 1fr; }
  .am-top { padding: 14px 16px 12px; }
  .am-body { padding: 4px 16px 20px; }
  #am-title { font-size: 21px; }
}
@media (max-width: 720px) {
  .am-ov[data-mode="modal"] { padding: 0; }
  .am-ov[data-mode="modal"] .am-box { border-radius: 0; min-height: 100dvh; }
  .am-top { border-radius: 0; }
  .am-top-row { flex-direction: column; gap: 12px; }
  .am-top-actions { width: 100%; }
  .am-top-actions .btn { flex: 1; }
  .am-pair { grid-template-columns: 1fr; }
  .am-tagpanel { position: fixed; left: 16px; right: 16px; top: auto; width: auto; max-height: 60vh; margin-top: 8px; }
  .am-cal { width: 100%; }
}
