:root {
   --bg: #f4f7fb;
   --card: #ffffff;
   --text: #0f172a;
   --muted: #64748b;
   --border: #e2e8f0;
   --primary: #1565c0;
   --primary-light: #1e88e5;
   --sidebar: #0f172a;
   --sidebar-hover: rgba(255, 255, 255, 0.08);
   --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
   --radius: 18px;
}

* {
   box-sizing: border-box;
}

body {
   margin: 0;
   min-height: 100vh;
   background:
      radial-gradient(circle at top right, rgba(30, 136, 229, 0.10), transparent 35%),
      var(--bg);
   color: var(--text);
   font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Layout */
.app-layout {
   display: flex;
   min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
   width: 270px;
   min-width: 270px;
   min-height: 100vh;
   background: var(--sidebar);
   color: #ffffff;
   display: flex;
   flex-direction: column;
   position: fixed;
   left: 0;
   top: 0;
   bottom: 0;
   z-index: 1000;
   box-shadow: 14px 0 35px rgba(15, 23, 42, 0.14);
}

.sidebar-brand {
   height: 86px;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 18px;
   border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand img {
   max-width: 160px;
   max-height: 52px;
   object-fit: contain;
}

.sidebar-menu {
   padding: 22px 14px;
   flex: 1;
}

.sidebar-link {
   height: 50px;
   width: 100%;
   display: grid;
   grid-template-columns: 28px 1fr;
   align-items: center;
   gap: 12px;
   padding: 0 16px;
   margin-bottom: 8px;
   color: #cbd5e1;
   text-decoration: none;
   border-radius: 14px;
   transition: all 0.2s ease;
}

.sidebar-link i {
   font-size: 23px;
   width: 28px;
   height: 28px;
   display: flex;
   align-items: center;
   justify-content: center;
   color: #93c5fd;
   line-height: 1;
}

.sidebar-link span {
   font-size: 14px;
   font-weight: 700;
   line-height: 1;
   white-space: nowrap;
}

.sidebar-link:hover,
.sidebar-link.active {
   background: var(--sidebar-hover);
   color: #ffffff;
}

.sidebar-link:hover i,
.sidebar-link.active i {
   color: #ffffff;
}

.sidebar-footer {
   padding: 18px;
   border-top: 1px solid rgba(255, 255, 255, 0.08);
   color: #94a3b8;
   display: flex;
   justify-content: space-between;
   gap: 12px;
   font-size: 12px;
}

/* Main */
.app-main {
   width: 100%;
   min-height: 100vh;
   margin-left: 270px;
   display: flex;
   flex-direction: column;
}

/* Topbar */
.app-topbar {
   height: 86px;
   background: rgba(255, 255, 255, 0.94);
   border-bottom: 1px solid var(--border);
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 18px;
   padding: 0 28px;
   position: sticky;
   top: 0;
   z-index: 900;
   backdrop-filter: blur(12px);
   box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.topbar-title h1 {
   margin: 0;
   font-size: 25px;
   font-weight: 850;
   letter-spacing: -0.5px;
   color: var(--text);
}

.topbar-title p {
   margin: 5px 0 0;
   color: var(--muted);
   font-size: 14px;
}

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

.user-box {
   align-items: center;
   gap: 10px;
   padding: 8px 12px;
   border: 1px solid var(--border);
   border-radius: 16px;
   background: #ffffff;
}

.user-icon {
   width: 38px;
   height: 38px;
   border-radius: 13px;
   background: linear-gradient(135deg, var(--primary), var(--primary-light));
   color: #ffffff;
   display: flex;
   align-items: center;
   justify-content: center;
}

.user-icon i {
   font-size: 22px;
}

.user-box small {
   display: block;
   color: var(--muted);
   font-size: 11px;
   font-weight: 700;
   text-transform: uppercase;
   letter-spacing: 0.4px;
   line-height: 1.1;
}

.user-box strong {
   display: block;
   color: var(--text);
   font-size: 13px;
   line-height: 1.2;
   max-width: 220px;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

.logout-btn,
.sidebar-toggle {
   width: 44px;
   height: 44px;
   border-radius: 15px;
   border: 1px solid var(--border);
   background: #ffffff;
   color: #ef4444;
   display: flex;
   align-items: center;
   justify-content: center;
   text-decoration: none;
   transition: all 0.2s ease;
}

.sidebar-toggle {
   color: var(--text);
}

.logout-btn i,
.sidebar-toggle i {
   font-size: 23px;
}

.logout-btn:hover {
   background: #fee2e2;
   border-color: #fecaca;
   color: #dc2626;
}

/* Conteúdo */
.app-content {
   padding: 28px;
   flex: 1;
}

.content-card {
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   box-shadow: var(--shadow);
   padding: 24px;
}

/* Toast */
.toast-area {
   position: fixed;
   top: 102px;
   right: 28px;
   width: calc(100% - 56px);
   max-width: 430px;
   z-index: 1100;
}

/* Melhorias gerais nas páginas antigas */
.card {
   border: 1px solid var(--border);
   border-radius: var(--radius);
   box-shadow: 0 12px 35px rgba(15, 23, 42, 0.06);
}

.card-header {
   background: #ffffff;
   border-bottom: 1px solid var(--border);
   border-radius: var(--radius) var(--radius) 0 0 !important;
}

.form-control,
.form-select {
   border-radius: 12px;
   border-color: var(--border);
   min-height: 42px;
}

.form-control:focus,
.form-select:focus {
   border-color: var(--primary-light);
   box-shadow: 0 0 0 4px rgba(30, 136, 229, 0.12);
}

.btn {
   border-radius: 12px;
   font-weight: 700;
}

.btn-primary {
   background: linear-gradient(135deg, var(--primary), var(--primary-light));
   border: none;
   box-shadow: 0 12px 24px rgba(30, 136, 229, 0.20);
}

.btn-primary:hover {
   filter: brightness(0.96);
}

.table {
   background: #ffffff;
}

.table thead th {
   border-top: none;
   background: #f8fafc;
   color: #334155;
   font-size: 12px;
   text-transform: uppercase;
   letter-spacing: 0.5px;
}

.table td,
.table th {
   vertical-align: middle;
}

/* Mobile */
.sidebar-backdrop {
   display: none;
}

@media (max-width: 991px) {
   .app-sidebar {
      transform: translateX(-100%);
      transition: transform 0.25s ease;
   }

   body.sidebar-open .app-sidebar {
      transform: translateX(0);
   }

   .sidebar-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.55);
      z-index: 950;
   }

   body.sidebar-open .sidebar-backdrop {
      display: block;
   }

   .app-main {
      margin-left: 0;
   }

   .app-topbar {
      height: auto;
      min-height: 76px;
      padding: 14px 18px;
   }

   .topbar-title h1 {
      font-size: 21px;
   }

   .topbar-title p {
      display: none;
   }

   .app-content {
      padding: 18px;
   }

   .content-card {
      padding: 18px;
   }

   .toast-area {
      top: 88px;
      right: 16px;
      width: calc(100% - 32px);
   }
}

@media (max-width: 575px) {
   .app-topbar {
      gap: 10px;
   }

   .topbar-title h1 {
      font-size: 18px;
   }

   .app-content {
      padding: 14px;
   }

   .content-card {
      padding: 14px;
      border-radius: 16px;
   }
}