:root {
  --navy: #061735;
  --navy-2: #0d2b5d;
  --gold: #b3832e;
  --gold-soft: #d6b46f;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #dde3ee;
  --text: #17213a;
  --muted: #647087;
  --green: #2f8f65;
  --red: #c0392b;
  --orange: #d9822b;
  --blue: #2f65c8;
  --shadow: 0 18px 45px rgba(6, 23, 53, 0.09);
  --sidebar-width: 292px;
  --sidebar-collapsed-width: 82px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Inter", Arial, sans-serif;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 23, 53, 0.4);
  backdrop-filter: blur(4px);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.is-active {
  display: block;
  opacity: 1;
}

.sidebar {
  position: sticky;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: var(--navy);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  overflow: hidden;
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-collapse-btn {
  position: absolute;
  top: 24px;
  right: -14px;
  width: 28px;
  height: 28px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--navy);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 60;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.3s;
}

body.sidebar-collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
  right: -14px;
}

.brand {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 24px 22px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.brand img {
  width: 182px;
  max-width: 100%;
  padding: 10px;
  background: #fff;
  border-radius: 6px;
}

.brand span {
  color: var(--gold-soft);
  font-size: 12px;
  font-weight: 700;
  max-width: 210px;
  transition: opacity 0.2s;
}

body.sidebar-collapsed .brand span,
body.sidebar-collapsed .brand img {
  opacity: 0;
  pointer-events: none;
}

.side-nav {
  flex: 1;
  padding: 12px 10px 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

.side-nav::-webkit-scrollbar {
  width: 6px;
}
.side-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
}

.nav-section {
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 24px 14px 8px;
  transition: opacity 0.2s;
}

body.sidebar-collapsed .nav-section {
  opacity: 0;
}

.nav-group {
  margin-bottom: 8px;
}

.nav-children {
  display: none;
}

.nav-group.is-open .nav-children {
  display: block;
}

.nav-group-title,
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
}

.nav-group-title > span,
.nav-link > span {
  transition: opacity 0.2s;
}

body.sidebar-collapsed .nav-group-title > span,
body.sidebar-collapsed .nav-link > span,
body.sidebar-collapsed .chevron {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}

.nav-group-title svg {
  flex-shrink: 0;
}

.nav-group-title {
  color: rgba(255, 255, 255, 0.96);
  font-weight: 700;
}

.nav-link {
  margin-top: 2px;
  padding-left: 44px;
  font-size: 13.5px;
  font-weight: 600;
}

.chevron { 
  margin-left: auto;
  display: flex;
  transition: transform 0.3s;
}

.nav-group.is-open .chevron {
  transform: rotate(180deg);
}

.nav-link:hover,
.nav-link.is-active,
.nav-group-title:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.is-active,
.nav-group-title.is-active {
  background: rgba(214, 180, 111, 0.15);
  color: var(--gold-soft);
}

.sidebar-profile {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.15);
  margin-top: auto;
  overflow: hidden;
}

.sidebar-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.sidebar-profile-card:hover {
  opacity: 0.8;
}

.sidebar-profile-card .avatar {
  width: 38px;
  height: 38px;
  background: var(--gold-soft);
  color: var(--navy);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-profile-card .info strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.sidebar-profile-card .info small {
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  text-transform: capitalize;
}

body.sidebar-collapsed .sidebar-profile-card .info {
  opacity: 0;
  width: 0;
}

.workspace {
  flex: 1;
  min-width: 0;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-title strong,
.topbar-title span {
  display: block;
}

.topbar-title strong {
  color: var(--navy);
  font-size: 20px;
}

.topbar-title span {
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button,
.menu-toggle {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.icon-button svg,
.empty-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.menu-toggle {
  display: none;
}

.menu-toggle span {
  width: 18px;
  height: 2px;
  background: currentColor;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar-user-chip {
  display: none;
}

.user-chip > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--navy);
  background: #f3ead7;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
}

.user-chip strong,
.user-chip small {
  display: block;
}

.user-chip small {
  color: var(--muted);
  font-size: 12px;
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  border: 2px solid #fff;
}

.icon-button {
  position: relative;
}

/* Central de Notificações */
.notification-list {
  display: grid;
  gap: 12px;
}

.notification-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 14px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.notification-item:hover {
  border-color: var(--gold-soft);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.notification-item.unread {
  background: #fdfbf7;
  border-left: 4px solid var(--gold);
}

.notification-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  margin-top: 6px;
}

.notification-item.unread .notification-indicator {
  background: var(--gold);
}

.notification-title {
  color: var(--navy);
  font-weight: 700;
  margin-bottom: 4px;
}

.notification-message {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.notification-time {
  color: #888;
  font-size: 12px;
}

.btn-mark-read {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-mark-read:hover {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.content {
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0;
  color: var(--navy);
  font-size: 32px;
  line-height: 1.1;
}

.page-header p {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

.btn.primary {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.btn.gold {
  color: var(--navy);
  background: var(--gold-soft);
  border-color: var(--gold-soft);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card,
.panel,
.form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(6, 23, 53, 0.04);
}

.metric-card {
  display: grid;
  gap: 10px;
  min-height: 132px;
  padding: 18px;
  border-top: 4px solid var(--navy);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.metric-card.warning { border-top-color: var(--orange); }
.metric-card.danger { border-top-color: var(--red); }
.metric-card.success { border-top-color: var(--green); }
.metric-card.gold { border-top-color: var(--gold); }

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric-card strong {
  color: var(--navy);
  font-size: 30px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 18px;
}

.panel-body {
  padding: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ticket-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
}

.global-search {
  grid-column: 1 / -1;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-filters {
  justify-content: center;
  flex-wrap: nowrap;
}

.primary-filters select {
  width: 168px;
  min-width: 168px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

input[readonly] {
  color: var(--muted);
  background: #f4f6fa;
}

textarea {
  min-height: 150px;
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  font: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.sort-button span {
  color: var(--gold);
}

td {
  color: var(--text);
  font-size: 14px;
}

.ticket-number {
  color: var(--navy);
  font-weight: 800;
}

.sla-time {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.blue { color: #174b92; background: #e8f0ff; }
.badge.gold { color: #7d5815; background: #f6ead0; }
.badge.green { color: #1f6a4b; background: #e3f4ec; }
.badge.orange { color: #9a5314; background: #fff0dc; }
.badge.red { color: #9f2a20; background: #ffe3df; }
.badge.gray { color: #4e5b70; background: #eef1f6; }
.badge.navy { color: #fff; background: var(--navy); }

.sla-list {
  display: grid;
  gap: 12px;
}

.sla-item {
  display: grid;
  gap: 6px;
  padding: 14px;
  background: #f9fafc;
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: 6px;
}

.sla-item.danger {
  border-left-color: var(--red);
}

.sla-item strong {
  color: var(--navy);
}

.sla-item span {
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field.full {
  grid-column: 1 / -1;
}

.form-actions {
  align-items: start;
}

.compact-action {
  width: auto;
  min-width: 156px;
  padding-right: 18px;
  padding-left: 18px;
}

.form-panel {
  padding: 20px;
}

.user-form-panel {
  max-width: 780px;
}

.user-form-panel .form-grid {
  max-width: 100%;
}

.inline-header {
  margin: -20px -20px 18px;
}

.ticket-detail {
  display: grid;
  grid-template-columns: minmax(260px, 0.46fr) minmax(520px, 1.54fr);
  gap: 18px;
}

.ticket-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.ticket-summary article {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-summary strong {
  color: var(--navy);
  font-size: 14px;
}

.ticket-summary small {
  color: var(--muted);
  font-size: 12px;
}

.compact-form {
  grid-template-columns: 1fr;
  gap: 10px;
}

.interaction-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.interaction-form .field.full:first-child {
  grid-column: 1 / -1;
}

.timeline {
  display: grid;
  gap: 14px;
}

.timeline-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  border-radius: 6px;
}

.timeline-item.internal {
  border-left-color: var(--gold);
  background: #fffaf0;
}

.time-entry {
  margin-top: 12px;
  padding: 12px;
  background: #f4f6fa;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.report-grid,
.crud-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.admin-table {
  min-width: 760px;
}

.report-card,
.crud-card {
  display: grid;
  gap: 12px;
  min-height: 170px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: 8px;
}

.progress {
  height: 9px;
  overflow: hidden;
  background: #e7ebf2;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--gold);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 40px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  place-items: center;
  color: var(--navy);
  background: #f3ead7;
  border-radius: 8px;
}

/* Modais e Toasts */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 23, 53, 0.6);
  backdrop-filter: blur(4px);
}

.modal-overlay.is-active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 24px 54px rgba(6, 23, 53, 0.16);
  overflow: hidden;
}

.modal-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
  color: var(--navy);
  font-size: 20px;
}

.modal-close {
  font-size: 24px;
  font-weight: bold;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100;
  display: grid;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 420px;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(6, 23, 53, 0.12);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  animation: slideIn 220ms ease forwards;
}

.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--orange); }

@keyframes slideIn {
  from { transform: translateX(120%); }
  to { transform: translateX(0); }
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .report-grid,
  .crud-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout-grid,
  .ticket-detail,
  .ticket-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.is-mobile-open {
    transform: translateX(0);
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .menu-toggle {
    display: grid;
  }

  .topbar {
    padding: 12px 16px;
  }

  .content {
    padding: 18px 16px;
  }

  .user-chip div {
    display: none;
  }
}

@media (max-width: 680px) {
  .dashboard-grid,
  .report-grid,
  .crud-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .ticket-toolbar {
    grid-template-columns: 1fr;
  }

  .primary-filters select {
    min-width: 100%;
    width: 100%;
  }

  .page-header h1 {
    font-size: 26px;
  }

  .btn {
    width: 100%;
  }

  .compact-action {
    width: 100%;
  }
}
