/* ===== Componentes ===== */

/* --- layout do app --- */
.app-root { min-height: 100vh; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns var(--t-med); }
.shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: hidden; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; color: #fff; }
.sidebar-brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); display: grid; place-content: center; flex: none; box-shadow: 0 4px 14px rgba(59, 130, 246, .35); }
.sidebar-brand .logo svg { width: 20px; height: 20px; }
.sidebar-brand .name { font-weight: 700; letter-spacing: .02em; font-size: 15px; line-height: 1.1; }
.sidebar-brand .sub { font-size: 11px; color: var(--sidebar-text); opacity: .8; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--sidebar-text); opacity: .55; padding: 14px 10px 6px; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; margin-bottom: 2px; white-space: nowrap; transition: background var(--t-fast), color var(--t-fast); }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-item .kbd { margin-left: auto; opacity: .55; font-size: 10.5px; }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .08); }
.collapsed .sidebar-brand .name, .collapsed .sidebar-brand .sub, .collapsed .nav-group, .collapsed .nav-item span, .collapsed .nav-item .kbd { display: none; }
.collapsed .nav-item { justify-content: center; padding: 10px; }
.main { display: flex; flex-direction: column; min-width: 0; }
.header { height: var(--header-h); display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--bg-elev); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header .title { font-weight: 650; font-size: 15px; }
.header .spacer { flex: 1; }
.content { padding: 20px 24px 40px; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .desc { color: var(--text-2); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: var(--sidebar-w); transform: translateX(-100%); transition: transform var(--t-med); }
  .shell.mobile-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .content { padding: 14px; }
}

/* --- ícones / botões --- */
.icon { width: 18px; height: 18px; vertical-align: -4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius-s); border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); font-weight: 550; line-height: 1.2; min-height: 36px; transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast); white-space: nowrap; user-select: none; }
.btn:hover { background: var(--bg-hover); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); box-shadow: 0 1px 2px rgba(29, 78, 216, .25); }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.95); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); border-color: transparent; }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.btn-lg { padding: 11px 18px; min-height: 44px; font-size: 15px; }
.btn-icon { padding: 7px; min-width: 36px; }
.btn-icon.btn-sm { padding: 5px; min-width: 30px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--text) transparent var(--text) transparent; animation: spin .8s linear infinite; opacity: .7; }
.btn-primary.loading::after { border-color: #fff transparent #fff transparent; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-s) 0 0 var(--radius-s); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.btn-group .btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); position: relative; z-index: 1; }

/* --- formulários --- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .error { font-size: 12px; color: var(--danger); }
.input, .select, .textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-s); background: var(--bg-elev); color: var(--text); min-height: 36px; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.input.invalid { border-color: var(--danger); }
.input[readonly] { background: var(--bg-sunken); }
.input-sm { padding: 5px 8px; min-height: 30px; font-size: 13px; }
.textarea { min-height: 90px; resize: vertical; }
.select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.input-group .btn { border-radius: 0 var(--radius-s) var(--radius-s) 0; margin-left: -1px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 22px; background: var(--border-strong); transition: background var(--t-fast); flex: none; cursor: pointer; border: none; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t-fast); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.search { position: relative; }
.search .input { padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }

/* --- combobox (pesquisa de coligadas etc.) --- */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; min-width: 100%; max-height: 300px; overflow: auto; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 4px; }
.combo-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.combo-item:hover, .combo-item.active { background: var(--primary-soft); }
.combo-item .primary { font-weight: 550; }
.combo-item .secondary { font-size: 12px; color: var(--text-3); }
.combo-empty { padding: 12px; color: var(--text-3); text-align: center; }

/* --- cards --- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 14.5px; }
.card-body { padding: 16px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg-sunken); border-radius: 0 0 var(--radius) var(--radius); }
.stat { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.stat .k { font-size: 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat .d { font-size: 12px; color: var(--text-3); }

/* --- badges / tags --- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--bg-sunken); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-success { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); display: inline-block; }
.dot-on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot-off { background: var(--danger); }
.dot-warn { background: var(--warn); }

/* --- tabelas --- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; z-index: 1; background: var(--bg-sunken); text-align: left; font-weight: 600; font-size: 12px; color: var(--text-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-hover); }
.table tbody tr.selected td { background: var(--primary-soft); }
.table td.info { background: var(--grid-info); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-input { width: 70px; padding: 3px 6px; min-height: 28px; text-align: right; font-weight: 600; }
.table-dense td { padding: 5px 10px; }
.table-empty { padding: 36px; text-align: center; color: var(--text-3); }
.table tr.clickable { cursor: pointer; }
.check-cell { width: 34px; text-align: center; }
.check-mark { display: inline-grid; place-content: center; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border-strong); cursor: pointer; transition: all var(--t-fast); background: var(--bg-elev); }
.check-mark.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.check-mark svg { width: 14px; height: 14px; }

/* --- abas --- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 14px; border: none; background: none; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- modal --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(6, 10, 20, .55); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; animation: fadein .12s ease-out; padding: 16px; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-3); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: fadein .16s ease-out; }
.modal.modal-lg { width: min(900px, 100%); }
.modal.modal-xl { width: min(1200px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 4px 20px 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--border); }

/* --- toasts --- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: 380px; }
.toast { background: var(--bg-elev); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 11px 14px; display: flex; gap: 10px; align-items: flex-start; animation: fadein .18s ease-out; }
.toast.success { border-left-color: var(--accent); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }
.toast .t-title { font-weight: 600; }
.toast .t-msg { color: var(--text-2); font-size: 13px; }
.toast .t-close { margin-left: auto; background: none; border: none; color: var(--text-3); padding: 0 2px; }

/* --- diversos --- */
.empty { padding: 40px 20px; text-align: center; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg { width: 40px; height: 40px; opacity: .5; }
.empty .e-title { font-weight: 600; color: var(--text-2); }
.skeleton { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 37%, var(--bg-sunken) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; min-height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.kbd { display: inline-block; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--bg-sunken); font-family: var(--mono); font-size: 11px; color: var(--text-2); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.alert { padding: 10px 14px; border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--bg-sunken); display: flex; gap: 10px; align-items: flex-start; }
.alert-info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.alert-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-success { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.pill-select { display: inline-flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--bg-sunken); border: 1px solid var(--border); }
.pill-select button { border: none; background: none; padding: 5px 12px; border-radius: 999px; color: var(--text-2); font-weight: 550; }
.pill-select button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-1); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #7c3aed); color: #fff; display: grid; place-content: center; font-weight: 700; font-size: 12.5px; flex: none; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2); min-width: 220px; padding: 6px; z-index: 60; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: none; background: none; text-align: left; border-radius: 6px; color: var(--text); }
.menu-item:hover { background: var(--bg-hover); }
.menu-item svg { width: 16px; height: 16px; color: var(--text-2); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
.progress { height: 6px; border-radius: 6px; background: var(--bg-sunken); overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); transition: width var(--t-med); }
.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 10px 0; color: var(--text-2); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12.5px; font-weight: 550; }
.chip button { background: none; border: none; padding: 0; color: inherit; display: grid; }
.preview-box { background: repeating-conic-gradient(var(--bg-sunken) 0 25%, var(--bg-elev) 0 50%) 0 0 / 16px 16px; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; place-items: center; overflow: auto; }
.preview-box img { background: #fff; box-shadow: var(--shadow-2); image-rendering: pixelated; }
.code-box { background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px 12px; max-height: 320px; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
