/* TR Forms — Sistema de interface administrativa */
:root {
  --tr-navy: #101b36;
  --tr-navy-2: #1b2b52;
  --tr-indigo: #4f46e5;
  --tr-indigo-strong: #4338ca;
  --tr-indigo-soft: #eef2ff;
  --tr-page: #f6f7fb;
  --tr-surface: #ffffff;
  --tr-surface-muted: #f9fafc;
  --tr-line: #e6e8f0;
  --tr-line-strong: #d7dbea;
  --tr-text: #18233d;
  --tr-muted: #68738a;
  --tr-subtle: #98a1b3;
  --tr-success: #167a52;
  --tr-success-bg: #ecfdf3;
  --tr-warning: #a85c05;
  --tr-warning-bg: #fff7e8;
  --tr-danger: #b4233d;
  --tr-danger-bg: #fff1f3;
  --tr-shadow-sm: 0 1px 2px rgba(16, 27, 54, .035), 0 1px 3px rgba(16, 27, 54, .035);
  --tr-shadow-md: 0 16px 38px rgba(20, 32, 64, .08);
  --tr-radius: 14px;
  --tr-radius-sm: 10px;
  --tr-ease: cubic-bezier(.2, .8, .2, 1);
}

body:has(.app-shell) {
  background: var(--tr-page);
  color: var(--tr-text);
  font-family: Inter, "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--tr-page);
}

.app-shell .sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: auto;
  height: 100vh;
  padding: 18px 12px 14px;
  overflow-y: auto;
  border-right: 1px solid rgba(220, 224, 236, .86);
  background: rgba(255, 255, 255, .96);
  box-shadow: none;
}

.app-shell .sidebar-topline { display: flex; align-items: center; justify-content: space-between; min-height: 42px; padding: 0 8px; }
.app-shell .brand { gap: 10px; color: var(--tr-navy); font-family: Inter, sans-serif; font-size: 15px; font-weight: 750; letter-spacing: -.03em; text-decoration: none; }
.app-shell .brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(145deg, var(--tr-navy), #304b86); box-shadow: 0 4px 10px rgba(28, 46, 93, .2); }
.app-shell .brand-mark svg { width: 16px; height: 16px; }
.app-shell .brand-mark--image { background: transparent; box-shadow: none; }
.app-shell .sidebar-close { display: none; }
.app-shell .sidebar-body { display: grid; gap: 22px; margin-top: 30px; }
.app-shell .nav-group { display: grid; gap: 7px; }
.app-shell .nav-label { padding: 0 10px; color: var(--tr-subtle); font-size: 10px; font-weight: 750; letter-spacing: .11em; line-height: 1.2; text-transform: uppercase; }
.app-shell .nav { display: grid; gap: 3px; }
.app-shell .nav a { display: flex; align-items: center; min-height: 39px; gap: 11px; padding: 0 10px; border: 1px solid transparent; border-radius: 9px; color: #5c667a; font-size: 13px; font-weight: 560; text-decoration: none; transition: background .16s var(--tr-ease), color .16s var(--tr-ease), border-color .16s var(--tr-ease), transform .16s var(--tr-ease); }
.app-shell .nav a svg { width: 17px; height: 17px; stroke-width: 1.8; }
.app-shell .nav a:hover { border-color: #e6e9f5; background: #f6f7fd; color: var(--tr-navy); }
.app-shell .nav a:active { transform: scale(.985); }
.app-shell .nav a.active { border-color: #e2e5ff; background: var(--tr-indigo-soft); color: var(--tr-indigo-strong); font-weight: 700; }
.app-shell .sidebar-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 8px 4px; border-top: 1px solid var(--tr-line); }
.app-shell .admin-avatar { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e8ebf7; color: var(--tr-navy-2); font-size: 12px; font-weight: 800; }
.app-shell .admin-identity { min-width: 0; color: var(--tr-text); font-size: 12px; font-weight: 700; line-height: 1.25; }
.app-shell .admin-identity small { display: block; margin-top: 3px; overflow: hidden; color: var(--tr-muted); font-size: 10px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .logout-link { display: grid; width: 30px; height: 30px; flex: 0 0 auto; margin-left: auto; place-items: center; border-radius: 8px; color: var(--tr-muted); font-size: 0; text-decoration: none; transition: background .16s var(--tr-ease), color .16s var(--tr-ease); }
.app-shell .logout-link::before { content: "↗"; font-size: 17px; font-weight: 600; transform: rotate(45deg); }
.app-shell .logout-link:hover { background: var(--tr-danger-bg); color: var(--tr-danger); }

.app-content { min-width: 0; }
.desktop-topbar { display: flex; align-items: center; justify-content: space-between; height: 70px; padding: 0 38px; border-bottom: 1px solid rgba(226, 229, 239, .9); background: rgba(255, 255, 255, .82); backdrop-filter: blur(14px); }
.topbar-search { position: relative; display: flex; align-items: center; width: min(390px, 40vw); }
.topbar-search svg { position: absolute; left: 12px; width: 16px; height: 16px; color: #8b95aa; }
.topbar-search input { width: 100%; height: 36px; padding: 0 62px 0 36px; border: 1px solid transparent; border-radius: 9px; background: #f4f5f9; color: var(--tr-text); font: inherit; font-size: 12px; outline: none; transition: background .16s var(--tr-ease), border-color .16s var(--tr-ease), box-shadow .16s var(--tr-ease); }
.topbar-search input:focus { border-color: #bfc4ff; background: #fff; box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.topbar-search kbd { position: absolute; right: 9px; padding: 2px 5px; border: 1px solid #dde0eb; border-radius: 4px; background: #fff; color: #8d96a8; font-family: inherit; font-size: 9px; }
.topbar-actions { display: flex; align-items: center; gap: 7px; }
.topbar-icon, .profile-toggle { display: inline-flex; align-items: center; justify-content: center; height: 34px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #667188; cursor: pointer; font: inherit; text-decoration: none; transition: background .16s var(--tr-ease), color .16s var(--tr-ease); }
.topbar-icon { position: relative; width: 34px; }
.topbar-icon svg { width: 18px; height: 18px; }
.topbar-icon:hover, .profile-toggle:hover { background: #f2f4f9; color: var(--tr-navy); }
.notification-dot { position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border: 1.5px solid #fff; border-radius: 50%; background: var(--tr-indigo); }
.profile-toggle { gap: 8px; padding: 0 5px 0 3px; color: var(--tr-text); font-size: 12px; font-weight: 650; }
.profile-toggle .admin-avatar { width: 27px; height: 27px; font-size: 10px; }

.app-shell .main { max-width: 1500px; margin: 0 auto; padding: 35px 38px 58px; }
.app-shell .page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin: 0 0 28px; }
.app-shell .page-head > div { min-width: 0; }
.app-shell .page-head .eyebrow { display: none; }
.app-shell .page-head h1 { margin: 0; color: var(--tr-navy); font-family: Inter, sans-serif; font-size: clamp(24px, 2.2vw, 30px); font-weight: 750; letter-spacing: -.045em; line-height: 1.15; }
.app-shell .page-head p { max-width: 690px; margin: 8px 0 0; color: var(--tr-muted); font-size: 13px; line-height: 1.55; }
.app-shell .page-head + .page-head { align-items: center; margin-top: -16px !important; margin-bottom: 20px; }
.app-shell .page-head + .page-head > div { display: none; }

.app-shell .card, .app-shell .form-section { border: 1px solid var(--tr-line); border-radius: var(--tr-radius); background: var(--tr-surface); box-shadow: var(--tr-shadow-sm); }
.app-shell .section-card { padding: 0; overflow: hidden; }
.app-shell .form-card, .app-shell .form-layout { gap: 18px; }
.app-shell .form-section { padding: 24px; }
.app-shell .form-section h2, .app-shell .section-head h2, .app-shell .detail-hero h1 { color: var(--tr-navy); font-family: Inter, sans-serif; font-size: 16px; font-weight: 720; letter-spacing: -.025em; }
.app-shell .form-section h2 { margin: 4px 0 7px; }
.app-shell .form-section > p { max-width: 760px; margin: 0 0 20px; color: var(--tr-muted); font-size: 12px; line-height: 1.6; }
.app-shell .section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--tr-line); }
.app-shell .section-head h2 { margin: 0; }
.app-shell .section-head h3 { color: var(--tr-navy); font-family: Inter, sans-serif; }
.app-shell .section-head a { color: var(--tr-indigo); font-size: 12px; font-weight: 700; text-decoration: none; }

.app-shell .button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; gap: 7px; padding: 0 13px; border: 1px solid transparent; border-radius: 9px; background: var(--tr-indigo); box-shadow: 0 1px 2px rgba(67, 56, 202, .2); color: #fff; font-family: Inter, sans-serif; font-size: 12px; font-weight: 700; line-height: 1; text-decoration: none; transition: transform .16s var(--tr-ease), background .16s var(--tr-ease), box-shadow .16s var(--tr-ease), border-color .16s var(--tr-ease), color .16s var(--tr-ease); }
.app-shell .button svg { width: 15px; height: 15px; }
.app-shell .button:hover { background: var(--tr-indigo-strong); box-shadow: 0 6px 16px rgba(67, 56, 202, .18); }
.app-shell .button:active { transform: scale(.975); }
.app-shell .button:focus-visible, .app-shell .nav a:focus-visible, .app-shell input:focus-visible, .app-shell select:focus-visible, .app-shell textarea:focus-visible { outline: 3px solid rgba(79, 70, 229, .24); outline-offset: 2px; }
.app-shell .button.secondary { border-color: var(--tr-line-strong); background: #fff; box-shadow: none; color: #46516a; }
.app-shell .button.secondary:hover { border-color: #c9d0e5; background: #f8f9fc; color: var(--tr-navy); }
.app-shell .button.danger { border-color: #f4c9d2; background: var(--tr-danger-bg); box-shadow: none; color: var(--tr-danger); }
.app-shell .button.danger:hover { border-color: #efabb9; background: #fee6ea; }
.app-shell .button.small { min-height: 32px; padding: 0 10px; border-radius: 8px; font-size: 11px; }

.app-shell .data-table { width: 100%; border-collapse: separate; border-spacing: 0; color: var(--tr-text); font-size: 12px; }
.app-shell .data-table thead th { padding: 11px 20px; border-bottom: 1px solid var(--tr-line); background: #fbfbfd; color: #7a8598; font-size: 10px; font-weight: 750; letter-spacing: .055em; text-align: left; text-transform: uppercase; }
.app-shell .data-table tbody td { padding: 15px 20px; border-bottom: 1px solid #eef0f5; vertical-align: middle; }
.app-shell .data-table tbody tr:last-child td { border-bottom: 0; }
.app-shell .data-table tbody tr { transition: background .16s var(--tr-ease); }
.app-shell .data-table tbody tr:hover { background: #fbfcff; }
.app-shell .template-table-row { cursor: pointer; }
.app-shell .template-list-card { overflow: visible; }
.app-shell .template-list-summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 20px; border-bottom: 1px solid var(--tr-line); color: var(--tr-muted); font-size: 11px; }
.app-shell .template-list-summary span:first-child { color: var(--tr-text); font-weight: 700; }
.app-shell .template-identity { display: flex; align-items: center; gap: 11px; }
.app-shell .template-row-link { display: block; color: inherit; text-decoration: none; }
.app-shell .template-row-link:focus-visible { outline: 3px solid rgba(77, 93, 214, .28); outline-offset: 4px; border-radius: 8px; }
.app-shell .template-row-link .template-identity > span:last-child { display: grid; min-width: 0; gap: 3px; }
.app-shell .template-row-link .sub-cell { display: block; }
.app-shell .template-symbol { display: grid; width: 33px; height: 33px; flex: 0 0 auto; place-items: center; border: 1px solid #e1e5fa; border-radius: 9px; background: #f1f3ff; color: var(--tr-indigo); }
.app-shell .template-symbol svg { width: 16px; height: 16px; }
.app-shell .template-activity { display: flex; align-items: baseline; gap: 4px; color: var(--tr-muted); font-size: 11px; white-space: nowrap; }
.app-shell .template-activity strong { color: var(--tr-text); font-size: 12px; }
.app-shell .template-activity-divider { margin: 0 2px; color: #b4bbca; }
.app-shell .template-row-actions { flex-wrap: nowrap; }
.app-shell .context-menu { position: relative; }
.app-shell .context-menu-toggle { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; gap: 3px; padding: 0; border: 1px solid var(--tr-line-strong); border-radius: 8px; background: #fff; color: var(--tr-muted); cursor: pointer; transition: background .16s var(--tr-ease), border-color .16s var(--tr-ease), color .16s var(--tr-ease); }
.app-shell .context-menu-toggle:hover, .app-shell .context-menu-toggle[aria-expanded="true"] { border-color: #c8cfeb; background: #f7f8fe; color: var(--tr-navy); }
.app-shell .context-menu-toggle span { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.app-shell .context-menu-panel { position: absolute; z-index: 20; top: calc(100% + 7px); right: 0; display: grid; min-width: 205px; padding: 5px; border: 1px solid var(--tr-line); border-radius: 10px; background: #fff; box-shadow: var(--tr-shadow-md); }
.app-shell .context-menu-panel[hidden] { display: none !important; }
.app-shell .context-menu-panel button { display: flex; width: 100%; align-items: center; gap: 8px; min-height: 34px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: #49546a; cursor: pointer; font: 600 11px Inter, sans-serif; text-align: left; transition: background .14s var(--tr-ease), color .14s var(--tr-ease); }
.app-shell .context-menu-panel button:hover { background: #f4f6fb; color: var(--tr-navy); }
.app-shell .context-menu-panel button svg { width: 14px; height: 14px; }
.app-shell .context-menu-panel .context-menu-danger { color: var(--tr-danger); }
.app-shell .context-menu-panel .context-menu-danger:hover { background: var(--tr-danger-bg); }
.app-shell .context-menu-separator { height: 1px; margin: 4px; background: var(--tr-line); }
.app-shell .template-empty { min-height: 330px; }
.app-shell .template-empty > div { display: grid; justify-items: center; max-width: 330px; }
.app-shell .template-empty p { margin: 14px 0 5px; color: var(--tr-navy); font-size: 14px; font-weight: 700; }
.app-shell .template-empty small { margin-bottom: 18px; color: var(--tr-muted); line-height: 1.5; }
.app-shell .empty-symbol { display: grid; width: 50px; height: 50px; place-items: center; border-radius: 14px; background: var(--tr-indigo-soft); color: var(--tr-indigo); }
.app-shell .empty-symbol svg { width: 23px; height: 23px; }
.app-shell .title-cell, .app-shell .data-table strong { color: var(--tr-navy); font-size: 12px; font-weight: 700; text-decoration: none; }
.app-shell .title-cell:hover { color: var(--tr-indigo); }
.app-shell .sub-cell { margin-top: 4px; color: var(--tr-muted); font-size: 11px; line-height: 1.45; }
.app-shell .badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border: 1px solid transparent; border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 1; white-space: nowrap; }
.app-shell .badge::before { content: ""; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.app-shell .badge.published, .app-shell .badge.sent { border-color: #b9ecd5; background: var(--tr-success-bg); color: var(--tr-success); }
.app-shell .badge.draft, .app-shell .badge.not_requested, .app-shell .badge.not_configured { border-color: #ebe1be; background: var(--tr-warning-bg); color: var(--tr-warning); }
.app-shell .badge.closed, .app-shell .badge.failed { border-color: #f4cbd3; background: var(--tr-danger-bg); color: var(--tr-danger); }

.app-shell .stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.app-shell .stat { min-height: 132px; padding: 18px; }
.app-shell .stat > span { color: var(--tr-muted); font-size: 11px; font-weight: 600; }
.app-shell .stat strong { display: block; margin-top: 11px; color: var(--tr-navy); font-size: 28px; font-weight: 760; letter-spacing: -.055em; }
.app-shell .stat small { display: block; margin-top: 6px; color: var(--tr-subtle); font-size: 10px; line-height: 1.35; }
.app-shell .detail-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 23px; background: linear-gradient(120deg, #fff, #f5f7ff); }
.app-shell .detail-hero h1 { margin: 5px 0 6px; font-size: 22px; }
.app-shell .detail-hero p { margin: 0; color: var(--tr-muted); font-size: 12px; }
.app-shell .grid-2 { gap: 18px; }
.app-shell .details { gap: 9px; }
.app-shell .detail-item { padding: 11px; border: 1px solid var(--tr-line); border-radius: var(--tr-radius-sm); background: var(--tr-surface-muted); }
.app-shell .detail-item span { color: var(--tr-muted); font-size: 10px; }
.app-shell .detail-item strong { color: var(--tr-text); font-size: 12px; }
.app-shell .link-box, .app-shell .template-link-box { border-color: var(--tr-line-strong); border-radius: var(--tr-radius-sm); background: var(--tr-surface-muted); }
.app-shell .empty, .app-shell .empty-builder { display: grid; min-height: 190px; place-items: center; padding: 28px; color: var(--tr-muted); font-size: 12px; text-align: center; }
.app-shell .empty .button { margin-top: 8px; }

.app-shell .input-group label { color: #3d4760; font-size: 11px; font-weight: 700; }
.app-shell .input-group input, .app-shell .input-group select, .app-shell .input-group textarea { min-height: 39px; border-color: var(--tr-line-strong); border-radius: 9px; background: #fff; box-shadow: none; color: var(--tr-text); font: inherit; font-size: 12px; transition: border-color .16s var(--tr-ease), box-shadow .16s var(--tr-ease); }
.app-shell .input-group textarea { min-height: 100px; }
.app-shell .input-group input:focus, .app-shell .input-group select:focus, .app-shell .input-group textarea:focus { border-color: #aeb5ff; box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.app-shell .input-group small { color: var(--tr-muted); font-size: 10px; line-height: 1.45; }
.app-shell .form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 2px; }
.app-shell .dashboard-hero { display: flex; align-items: center; justify-content: space-between; gap: 28px; min-height: 174px; margin-bottom: 18px; padding: 28px 30px; overflow: hidden; border: 1px solid #e1e5ff; border-radius: var(--tr-radius); background: radial-gradient(circle at 93% 14%, rgba(122, 132, 255, .21), transparent 30%), linear-gradient(120deg, #111d3a, #203667); color: #fff; box-shadow: 0 12px 30px rgba(19, 33, 68, .12); }
.app-shell .dashboard-hero > div { max-width: 620px; }
.app-shell .dashboard-hero .eyebrow { display: inline-block; color: #b9c7ff; font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.app-shell .dashboard-hero h2 { margin: 7px 0 9px; color: #fff; font: 760 clamp(22px, 2.2vw, 30px)/1.1 Inter, sans-serif; letter-spacing: -.05em; }
.app-shell .dashboard-hero p { max-width: 530px; margin: 0; color: #d5dcf4; font-size: 12px; line-height: 1.6; }
.app-shell .dashboard-hero__action { flex: 0 0 auto; border-color: #fff; background: #fff; color: var(--tr-navy); box-shadow: none; }
.app-shell .dashboard-hero__action:hover { background: #f1f3ff; color: var(--tr-indigo-strong); }
.app-shell .dashboard-templates { margin-bottom: 18px; }
.app-shell .dashboard-template-list { display: grid; padding: 2px 20px; }
.app-shell .dashboard-template-item { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 71px; border-bottom: 1px solid #eef0f5; }
.app-shell .dashboard-template-item[data-row-link] { cursor: pointer; border-radius: 10px; transition: background .16s ease, box-shadow .16s ease; }
.app-shell .dashboard-template-item[data-row-link]:hover { background: #fafbff; }
.app-shell .dashboard-template-item[data-row-link]:focus-visible { outline: 3px solid rgba(83, 92, 255, .28); outline-offset: 3px; }
.app-shell .dashboard-template-item:last-child { border-bottom: 0; }
.app-shell .dashboard-template-item__main { min-width: 0; }
.app-shell .dashboard-template-item__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 6px; color: var(--tr-muted); font-size: 10px; }
.app-shell .dashboard-template-item__actions { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; }
.app-shell .dashboard-bottom { display: grid; gap: 18px; }
.app-shell .dashboard-bottom > .section-card { overflow: hidden; }
.app-shell .button.is-loading { position: relative; min-width: 86px; color: transparent !important; pointer-events: none; }
.app-shell .button.is-loading::after { content: ""; position: absolute; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; color: #fff; animation: tr-spin .7s linear infinite; }
.app-shell .button.secondary.is-loading::after, .app-shell .button.danger.is-loading::after { color: currentColor; }
@keyframes tr-spin { to { transform: rotate(360deg); } }

.app-shell .template-tabs { position: sticky; top: 0; z-index: 6; padding: 6px; border: 1px solid var(--tr-line); border-radius: 12px; background: rgba(255, 255, 255, .94); box-shadow: var(--tr-shadow-sm); backdrop-filter: blur(12px); }
.app-shell .template-tab { min-height: 32px; border-radius: 8px; color: var(--tr-muted); font-size: 11px; font-weight: 650; }
.app-shell .template-tab.is-active { background: var(--tr-indigo-soft); color: var(--tr-indigo-strong); }
.app-shell .template-overview-card, .app-shell .template-preview-card { border-color: var(--tr-line); border-radius: var(--tr-radius); background: #fff; }
.app-shell .builder-card { border-color: var(--tr-line); border-radius: var(--tr-radius-sm); box-shadow: none; }
.app-shell .builder-card:hover { border-color: #cbd2ee; }

.toast-stack { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; width: min(370px, calc(100vw - 32px)); gap: 8px; pointer-events: none; }
.toast-item { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border: 1px solid var(--tr-line); border-radius: 12px; background: rgba(255, 255, 255, .98); box-shadow: var(--tr-shadow-md); color: var(--tr-text); font: 600 12px/1.45 Inter, sans-serif; opacity: 0; pointer-events: auto; transform: translateY(8px); transition: opacity .2s var(--tr-ease), transform .2s var(--tr-ease); }
.toast-item.is-visible { opacity: 1; transform: translateY(0); }
.toast-item::before { content: "✓"; display: grid; width: 19px; height: 19px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--tr-success-bg); color: var(--tr-success); font-size: 11px; }
.toast-item.error::before { content: "!"; background: var(--tr-danger-bg); color: var(--tr-danger); }
.toast-item button { width: 18px; height: 18px; margin-left: auto; padding: 0; border: 0; background: transparent; color: var(--tr-subtle); cursor: pointer; font-size: 17px; line-height: 1; }
.confirm-modal[hidden], .search-palette[hidden] { display: none; }
.confirm-modal, .search-palette { position: fixed; z-index: 110; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(16, 27, 54, .34); }
.confirm-dialog, .search-dialog { width: min(430px, 100%); padding: 22px; border: 1px solid rgba(255, 255, 255, .6); border-radius: 16px; background: #fff; box-shadow: 0 24px 62px rgba(16, 27, 54, .22); }
.confirm-dialog h2 { margin: 0; color: var(--tr-navy); font: 730 17px/1.3 Inter, sans-serif; letter-spacing: -.025em; }
.confirm-dialog p { margin: 9px 0 20px; color: var(--tr-muted); font: 12px/1.55 Inter, sans-serif; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.search-dialog { width: min(540px, 100%); padding: 8px; }
.search-dialog input { width: 100%; height: 45px; padding: 0 12px; border: 0; border-bottom: 1px solid var(--tr-line); outline: none; color: var(--tr-text); font: 600 14px Inter, sans-serif; }
.search-dialog p { padding: 11px 12px 4px; margin: 0; color: var(--tr-muted); font: 11px Inter, sans-serif; }

.auth-page { min-height: 100vh; font-family: Inter, "Plus Jakarta Sans", sans-serif; }
.auth-art { background: radial-gradient(circle at 25% 10%, #344982, transparent 37%), linear-gradient(145deg, #111d3b, #192b57); }
.auth-form-wrap { background: #fbfcff; }
.auth-form { border: 1px solid var(--tr-line); border-radius: 18px; box-shadow: var(--tr-shadow-md); }
@media (min-width: 900px) {
  body:has(.auth-page) { display: grid; place-items: center; min-height: 100vh; background: #e8ebf2; }
  .auth-page {
    width: min(1080px, calc(100vw - 48px));
    min-height: min(720px, calc(100vh - 48px));
    margin: 0;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 28px 70px rgba(16, 27, 54, .16);
  }
  .auth-form { border: 0; box-shadow: none; }
}
.auth-form-meta { margin: 4px 0 0; text-align: center; font: 500 13px/1.4 Inter, sans-serif; }
.auth-link { color: var(--tr-accent, #5267f7); text-decoration: none; font-weight: 600; }
.auth-link:hover { text-decoration: underline; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 218px minmax(0, 1fr); }
  .app-shell .main { padding: 30px 26px 50px; }
  .desktop-topbar { padding: 0 26px; }
  .app-shell .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .app-shell .sidebar { z-index: 80; width: 274px; }
  .desktop-topbar { display: none; }
  .app-shell .main { padding: 23px 16px 42px; }
  .app-shell .mobile-admin-header { min-height: 59px; padding: 0 16px; border-bottom: 1px solid var(--tr-line); background: rgba(255, 255, 255, .95); }
  .app-shell .mobile-admin-header .brand { font-size: 14px; }
  .app-shell .page-head { display: block; margin-bottom: 22px; }
  .app-shell .page-head > .button, .app-shell .page-head > a.button { width: 100%; margin-top: 17px; }
  .app-shell .page-head + .page-head { margin-top: -10px !important; }
  .app-shell .page-head + .page-head > .button, .app-shell .page-head + .page-head > a.button { margin-top: 0; }
  .app-shell .form-section { padding: 18px; }
  .app-shell .section-head { align-items: flex-start; flex-direction: column; padding: 16px; }
  .app-shell .section-head > .button, .app-shell .section-head > a.button { width: 100%; }
  .app-shell .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .app-shell .stat { min-height: 110px; padding: 15px; }
  .app-shell .stat strong { font-size: 24px; }
  .app-shell .detail-hero { flex-direction: column; padding: 18px; }
  .app-shell .data-table thead { display: none; }
  .app-shell .data-table, .app-shell .data-table tbody, .app-shell .data-table tr, .app-shell .data-table td { display: block; width: 100%; }
  .app-shell .data-table tbody tr { padding: 14px 16px; border-bottom: 1px solid var(--tr-line); }
  .app-shell .data-table tbody tr:last-child { border-bottom: 0; }
  .app-shell .data-table tbody td { display: grid; grid-template-columns: minmax(88px, .8fr) minmax(0, 1.5fr); gap: 10px; padding: 5px 0; border: 0; }
  .app-shell .data-table tbody td::before { content: attr(data-label); color: var(--tr-subtle); font-size: 10px; font-weight: 750; text-transform: uppercase; }
  .app-shell .data-table tbody td:empty { display: none; }
  .app-shell .template-tabs { top: 8px; overflow-x: auto; }
  .app-shell .template-tab { flex: 0 0 auto; }
  .toast-stack { right: 16px; bottom: 16px; }
  .app-shell .template-list-summary { padding: 0 16px; }
  .app-shell .template-identity { align-items: flex-start; }
  .app-shell .template-activity { flex-wrap: wrap; white-space: normal; }
  .app-shell .template-row-actions { justify-content: flex-start; }
  .app-shell .context-menu-panel { right: auto; left: 0; }
  .app-shell .dashboard-hero { align-items: flex-start; flex-direction: column; min-height: auto; padding: 23px; }
  .app-shell .dashboard-hero__action { width: 100%; }
  .app-shell .dashboard-template-list { padding: 2px 16px; }
  .app-shell .dashboard-template-item { align-items: flex-start; flex-direction: column; gap: 11px; padding: 15px 0; }
  .app-shell .dashboard-template-item__actions { width: 100%; }
  .app-shell .dashboard-template-item__actions .button { flex: 1; }
}

@media (max-width: 420px) {
  .app-shell .stats { grid-template-columns: 1fr; }
  .app-shell .page-head h1 { font-size: 24px; }
  .app-shell .data-table tbody td { grid-template-columns: 1fr; gap: 3px; }
  .app-shell .data-table tbody td::before { margin-bottom: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell *, .toast-item { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Página de detalhes de formulário */
.app-shell .instance-detail { display: grid; gap: 20px; }
.app-shell .instance-detail__header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 4px; }
.app-shell .instance-detail__heading { min-width: 0; }
.app-shell .instance-detail__back { display: inline-flex; margin-bottom: 14px; color: var(--tr-muted); font-size: 12px; font-weight: 650; text-decoration: none; }
.app-shell .instance-detail__back:hover { color: var(--tr-indigo); }
.app-shell .instance-detail__title-row { display: flex; align-items: flex-start; gap: 14px; }
.app-shell .instance-detail__template, .app-shell .instance-panel__eyebrow { display: block; margin-bottom: 6px; color: var(--tr-indigo); font-size: 10px; font-weight: 750; letter-spacing: .075em; text-transform: uppercase; }
.app-shell .instance-detail__title-row h1 { margin: 0; color: var(--tr-navy); font-family: Inter, sans-serif; font-size: clamp(25px, 2.5vw, 33px); font-weight: 760; letter-spacing: -.05em; line-height: 1.08; }
.app-shell .instance-detail__title-row p { margin: 8px 0 0; color: var(--tr-muted); font-size: 12px; }
.app-shell .instance-detail__header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.app-shell .instance-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.app-shell .instance-metric { min-height: 110px; padding: 17px 18px; border: 1px solid var(--tr-line); border-radius: 12px; background: var(--tr-surface); box-shadow: var(--tr-shadow-sm); }
.app-shell .instance-metric span { display: block; color: var(--tr-muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.app-shell .instance-metric strong { display: block; margin-top: 10px; overflow: hidden; color: var(--tr-navy); font-family: Inter, sans-serif; font-size: 23px; font-weight: 750; letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .instance-metric .instance-metric__status, .app-shell .instance-metric .instance-metric__template { font-size: 16px; }
.app-shell .instance-metric small { display: block; margin-top: 5px; color: var(--tr-muted); font-size: 10px; }
.app-shell .instance-detail__layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 18px; align-items: start; }
.app-shell .instance-detail__main, .app-shell .instance-detail__side { display: grid; gap: 18px; }
.app-shell .instance-panel { overflow: hidden; padding: 22px; }
.app-shell .instance-panel__head, .app-shell .instance-panel__compact-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.app-shell .instance-panel h2 { margin: 0; color: var(--tr-navy); font-family: Inter, sans-serif; font-size: 16px; font-weight: 740; letter-spacing: -.03em; }
.app-shell .instance-panel p { margin: 6px 0 0; color: var(--tr-muted); font-size: 11px; line-height: 1.55; }
.app-shell .instance-panel__external { flex: 0 0 auto; color: var(--tr-indigo); font-size: 11px; font-weight: 700; text-decoration: none; }
.app-shell .instance-public-link__field { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 8px; border: 1px solid #dfe3f0; border-radius: 10px; background: #f8f9fd; }
.app-shell .instance-public-link__url { min-width: 0; flex: 1; padding: 0 5px; overflow: hidden; color: #46516a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .instance-response-total { display: inline-flex; flex: 0 0 auto; min-height: 23px; align-items: center; padding: 0 8px; border-radius: 999px; background: var(--tr-indigo-soft); color: var(--tr-indigo-strong); font-size: 10px; font-weight: 750; }
.app-shell .instance-responses__table-wrap { margin: 18px -22px -22px; border-top: 1px solid var(--tr-line); }
.app-shell .instance-responses__table td .sub-cell { display: block; }
.app-shell .instance-empty-state { display: flex; align-items: flex-start; gap: 13px; margin-top: 18px; padding: 18px; border: 1px dashed #d7ddee; border-radius: 10px; background: #fbfcff; }
.app-shell .instance-empty-state__icon { display: grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--tr-indigo-soft); color: var(--tr-indigo); font-size: 18px; font-weight: 800; }
.app-shell .instance-empty-state strong { color: var(--tr-navy); font-size: 12px; }
.app-shell .instance-empty-state p { margin-top: 4px; }
.app-shell .instance-status-panel { border-top: 3px solid var(--tr-indigo); }
.app-shell .instance-status-form { display: grid; gap: 9px; margin-top: 17px; }
.app-shell .instance-status-form label { color: var(--tr-text); font-size: 11px; font-weight: 700; }
.app-shell .instance-status-form select { height: 38px; width: 100%; border: 1px solid var(--tr-line-strong); border-radius: 8px; background: #fff; color: var(--tr-text); font: 600 12px Inter, sans-serif; }
.app-shell .instance-status-form .button { width: 100%; margin-top: 3px; }
.app-shell .instance-context-list { display: grid; gap: 0; margin: 16px 0 0; }
.app-shell .instance-context-list > div { display: grid; gap: 4px; padding: 11px 0; border-bottom: 1px solid #edf0f5; }
.app-shell .instance-context-list > div:last-child { padding-bottom: 0; border-bottom: 0; }
.app-shell .instance-context-list dt { color: var(--tr-subtle); font-size: 10px; font-weight: 700; text-transform: capitalize; }
.app-shell .instance-context-list dd { margin: 0; overflow-wrap: anywhere; color: var(--tr-text); font-size: 12px; font-weight: 650; }
.app-shell .instance-context-empty { margin-top: 16px !important; padding: 12px; border-radius: 8px; background: #fafbfe; }
.app-shell .instance-danger-panel { border-color: #f3cbd3; background: #fffafb; }
.app-shell .instance-danger-panel .button { width: 100%; margin-top: 16px; }

@media (max-width: 900px) {
  .app-shell .instance-detail__layout { grid-template-columns: 1fr; }
  .app-shell .instance-detail__side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-shell .instance-danger-panel { grid-column: span 2; }
}

@media (max-width: 640px) {
  .app-shell .instance-detail__header, .app-shell .instance-panel__head { align-items: flex-start; flex-direction: column; }
  .app-shell .instance-detail__header-actions { width: 100%; justify-content: stretch; }
  .app-shell .instance-detail__header-actions .button { flex: 1; }
  .app-shell .instance-metrics, .app-shell .instance-detail__side { grid-template-columns: 1fr; }
  .app-shell .instance-danger-panel { grid-column: auto; }
  .app-shell .instance-detail__title-row { flex-direction: column; gap: 9px; }
  .app-shell .instance-public-link__field { align-items: stretch; flex-direction: column; }
  .app-shell .instance-public-link__field .button { width: 100%; }
  .app-shell .instance-panel { padding: 18px; }
  .app-shell .instance-responses__table-wrap { margin: 17px -18px -18px; }
}

/* Listagem de formulários */
.app-shell .forms-metrics { margin-bottom: 18px; }
.app-shell .forms-list-card { overflow: visible; }
.app-shell .forms-filter-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(142px, max-content)); gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--tr-line); background: #fff; }
.app-shell .forms-search { position: relative; display: flex; align-items: center; }
.app-shell .forms-search__icon { position: absolute; left: 12px; color: var(--tr-subtle); font-size: 21px; line-height: 1; transform: rotate(-15deg); }
.app-shell .forms-search input, .app-shell .forms-filter-select select { width: 100%; height: 38px; border: 1px solid var(--tr-line-strong); border-radius: 9px; background: #fff; color: var(--tr-text); font: 600 11px Inter, sans-serif; outline: none; transition: border-color .16s var(--tr-ease), box-shadow .16s var(--tr-ease); }
.app-shell .forms-search input { padding: 0 12px 0 35px; font-weight: 500; }
.app-shell .forms-filter-select { min-width: 0; }
.app-shell .forms-filter-select select { padding: 0 29px 0 10px; color: #4b556b; cursor: pointer; }
.app-shell .forms-search input:focus, .app-shell .forms-filter-select select:focus { border-color: #aeb5ff; box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.app-shell .forms-list-summary { min-height: 45px; }
.app-shell .forms-table-wrap { overflow-x: auto; }
.app-shell .forms-table { min-width: 830px; }
.app-shell .forms-table-row { cursor: pointer; }
.app-shell .forms-table-row:hover { background: #f8f9ff; }
.app-shell .forms-table-row:focus { position: relative; z-index: 1; outline: 3px solid rgba(82, 103, 247, .22); outline-offset: -3px; }
.app-shell .forms-table .template-symbol { background: #f3f5ff; }
.app-shell .forms-response-count { display: inline-flex; min-width: 26px; min-height: 25px; align-items: center; justify-content: center; padding: 0 7px; border-radius: 999px; background: #f2f4f8; color: #6d778a; font-size: 11px; font-weight: 750; }
.app-shell .forms-response-count.has-responses { background: var(--tr-indigo-soft); color: var(--tr-indigo-strong); }
.app-shell .forms-date { color: #59657b; font-size: 11px; font-weight: 600; white-space: nowrap; }
.app-shell .forms-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; min-width: 165px; }
.app-shell .forms-icon-action { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--tr-line-strong); border-radius: 8px; background: #fff; color: var(--tr-muted); cursor: pointer; transition: background .16s var(--tr-ease), border-color .16s var(--tr-ease), color .16s var(--tr-ease), transform .16s var(--tr-ease); }
.app-shell .forms-icon-action:hover { border-color: #c8cfeb; background: #f7f8fe; color: var(--tr-indigo-strong); }
.app-shell .forms-icon-action:active { transform: scale(.96); }
.app-shell .forms-icon-action svg { width: 15px; height: 15px; }
.app-shell .context-menu-panel a { display: flex; width: 100%; min-height: 34px; align-items: center; gap: 8px; padding: 0 9px; border-radius: 7px; color: #49546a; font: 600 11px Inter, sans-serif; text-decoration: none; transition: background .14s var(--tr-ease), color .14s var(--tr-ease); }
.app-shell .context-menu-panel a:hover { background: #f4f6fb; color: var(--tr-navy); }
.app-shell .context-menu-panel a svg { width: 14px; height: 14px; }
.app-shell .forms-filter-empty { display: grid; min-height: 250px; place-items: center; justify-items: center; padding: 30px; color: var(--tr-muted); text-align: center; }
.app-shell .forms-filter-empty[hidden] { display: none !important; }
.app-shell .forms-filter-empty strong { margin-top: 12px; color: var(--tr-navy); font-size: 13px; }
.app-shell .forms-filter-empty p { max-width: 340px; margin: 6px 0 15px; font-size: 11px; line-height: 1.55; }
.app-shell .forms-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 5px; padding: 13px 20px; border-top: 1px solid var(--tr-line); }
.app-shell .forms-pagination button { min-width: 31px; height: 30px; padding: 0 8px; border: 1px solid var(--tr-line-strong); border-radius: 7px; background: #fff; color: #566176; cursor: pointer; font: 700 10px Inter, sans-serif; transition: background .14s var(--tr-ease), border-color .14s var(--tr-ease), color .14s var(--tr-ease); }
.app-shell .forms-pagination button:hover:not(:disabled), .app-shell .forms-pagination button.is-current { border-color: #c5cbff; background: var(--tr-indigo-soft); color: var(--tr-indigo-strong); }
.app-shell .forms-pagination button:disabled { cursor: not-allowed; opacity: .42; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .app-shell .forms-filter-toolbar { grid-template-columns: minmax(210px, 1fr) repeat(2, minmax(135px, 1fr)); }
  .app-shell .forms-filter-select:last-child { grid-column: 2 / 4; }
}

@media (max-width: 720px) {
  .app-shell .forms-filter-toolbar { grid-template-columns: 1fr 1fr; padding: 14px 16px; }
  .app-shell .forms-search { grid-column: span 2; }
  .app-shell .forms-filter-select:last-child { grid-column: auto; }
  .app-shell .forms-list-summary { padding: 0 16px; }
  .app-shell .forms-table { min-width: 0; }
  .app-shell .forms-table-wrap { overflow: visible; }
  .app-shell .forms-table tbody td[data-label="Ações"]::before { display: none; }
  .app-shell .forms-table tbody td[data-label="Ações"] { display: block; padding-top: 10px; }
  .app-shell .forms-row-actions { justify-content: flex-start; }
  .app-shell .forms-pagination { justify-content: center; padding: 13px 16px; }
}

@media (max-width: 430px) {
  .app-shell .forms-filter-toolbar { grid-template-columns: 1fr; }
  .app-shell .forms-search { grid-column: auto; }
  .app-shell .forms-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-shell .forms-row-actions .button { flex: 1; }
}
