/* =====================================================
   KORE Atlas — Design System
   Navy + Gold, fundo claro, identidade executiva.
   Back-office interno da KORE Tecnologia.
   ===================================================== */

/* =====================================================
   1. TOKENS
   ===================================================== */
:root {
  /* Marca */
  --navy:        #1F3A5F;
  --navy-dark:   #15293F;
  --gold:        #C9A961;
  --gold-dim:    rgba(201,169,97,0.14);

  /* Superfícies */
  --bg:          #F2F2F2;
  --surface:     #FFFFFF;

  /* Tipografia */
  --text:        #1B2430;
  --text-dim:    #5B6675;

  /* Linhas e estados */
  --border:      rgba(31,58,95,0.12);
  --green:       #16A34A;
  --green-deep:  #15803D;
  --red:         #991B1B;
  --yellow:      #F59E0B;

  /* Forma */
  --radius:      8px;
  --shadow:      0 2px 8px rgba(31,58,95,0.08);
  --shadow-hover:0 6px 18px rgba(31,58,95,0.14);

  /* Tipografia — stack */
  --font-stack:  'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;

  /* Espaçamento (4px base) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* Layout */
  --sidebar-w: 240px;
  --header-h:  60px;

  /* Camadas */
  --z-sidebar:  10;
  --z-header:   20;
  --z-drawer:   80;
  --z-modal:    90;
  --z-toast:   100;
}

/* =====================================================
   2. RESET & BASE
   ===================================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-stack);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

code {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  background: var(--gold-dim);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--navy-dark);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(31,58,95,0.18); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(31,58,95,0.32); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius);
}
:focus:not(:focus-visible) { outline: none; }

/* =====================================================
   3. LAYOUT GLOBAL
   ===================================================== */
.atlas-app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "header  header"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
}

/* ----- Header global ----- */
.atlas-header {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  z-index: var(--z-header);
}

.atlas-header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
  user-select: none;
}
.atlas-header-logo .kore {
  color: var(--navy);
  font-weight: 700;
}
.atlas-header-logo .divider {
  width: 1px;
  height: 18px;
  background: var(--gold);
  display: inline-block;
}
.atlas-header-logo .atlas {
  color: var(--gold);
  font-weight: 600;
  font-style: italic;
}

.atlas-header-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-dim);
  gap: 0;
}
.atlas-header-breadcrumb .crumb { color: var(--text-dim); }
.atlas-header-breadcrumb .crumb.current { color: var(--navy); font-weight: 600; }
.atlas-header-breadcrumb .sep {
  margin: 0 10px;
  color: rgba(31,58,95,0.32);
  font-size: 11px;
}

.atlas-header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}
.atlas-header-user .user-name { font-weight: 600; line-height: 1.1; }
.atlas-header-user .user-role {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.1;
  margin-top: 2px;
}
.atlas-header-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--navy-dark));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ----- Sidebar ----- */
.atlas-sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  overflow-y: auto;
  z-index: var(--z-sidebar);
}

.atlas-sidebar-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
  margin: 20px 14px 8px;
  font-weight: 700;
}
.atlas-sidebar-section:first-child { margin-top: 4px; }

.atlas-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  margin-bottom: 2px;
  user-select: none;
}
.atlas-nav-item:hover {
  background: var(--gold-dim);
  color: var(--navy);
}
.atlas-nav-item.active {
  background: var(--gold-dim);
  color: var(--navy);
  font-weight: 600;
  border-left-color: var(--gold);
}
.atlas-nav-item .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ----- Main ----- */
.atlas-main {
  grid-area: main;
  padding: 24px;
  overflow-y: auto;
}
.atlas-main h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}
.atlas-main h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.atlas-main p {
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* =====================================================
   4. CARDS & KPIs
   ===================================================== */
.atlas-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow .2s, transform .2s;
}
.atlas-card:hover { box-shadow: var(--shadow-hover); }

.atlas-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.atlas-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}

.atlas-card-body { color: var(--text); }
.atlas-card-body p { margin-bottom: 10px; }
.atlas-card-body p:last-child { margin-bottom: 0; }

.atlas-card-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.atlas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.atlas-kpi {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.atlas-kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.atlas-kpi-value {
  font-size: 38px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.05;
  letter-spacing: -1px;
}
.atlas-kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 9999px;
  align-self: flex-start;
}
.atlas-kpi-delta.up   { background: rgba(22,163,74,0.14); color: var(--green); }
.atlas-kpi-delta.down { background: rgba(153,27,27,0.14); color: var(--red); }
.atlas-kpi-delta.flat { background: rgba(245,158,11,0.14); color: var(--yellow); }

/* =====================================================
   5. TABELAS
   ===================================================== */
.atlas-table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.atlas-table {
  width: 100%;
  border-collapse: collapse;
}
.atlas-table thead { background: var(--navy); }
.atlas-table thead th {
  color: #fff;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
}
.atlas-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  vertical-align: middle;
}
.atlas-table tbody tr:nth-child(even) td { background: var(--bg); }
.atlas-table tbody tr { transition: background .12s; }
.atlas-table tbody tr:hover td { background: var(--gold-dim); }
.atlas-table tbody tr:last-child td { border-bottom: none; }

/* =====================================================
   6. BOTÕES
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .08s;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { background: inherit; }

.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover {
  background: var(--navy-dark);
  box-shadow: var(--shadow);
}

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

.btn-success {
  background: var(--green);
  color: #fff;
}
.btn-success:hover {
  background: var(--green-deep);
  box-shadow: var(--shadow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: var(--bg);
  color: var(--navy);
}

/* =====================================================
   7. BADGES
   ===================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-green  { background: rgba(22,163,74,0.14);  color: var(--green); }
.badge-yellow { background: rgba(245,158,11,0.16); color: #B45309; }
.badge-red    { background: rgba(153,27,27,0.14);  color: var(--red); }
.badge-navy   { background: rgba(31,58,95,0.14);   color: var(--navy); }

/* =====================================================
   8. OVERLAYS — MODAL / DRAWER / TOAST
   ===================================================== */

/* ----- Modal ----- */
.atlas-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(31,58,95,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: atlas-fade-in .2s ease-out;
  padding: 24px;
}
.atlas-modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  box-shadow: 0 20px 60px rgba(31,58,95,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: atlas-scale-in .22s ease-out;
}
.atlas-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.atlas-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}
.atlas-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.atlas-modal-close:hover { background: var(--bg); color: var(--navy); }
.atlas-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}
.atlas-modal-body p { color: var(--text); margin-bottom: 10px; }
.atlas-modal-body p:last-child { margin-bottom: 0; }
.atlas-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ----- Drawer (painel lateral direito) ----- */
.atlas-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(31,58,95,0.5);
  z-index: var(--z-drawer);
  animation: atlas-fade-in .2s ease-out;
}
.atlas-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  background: var(--surface);
  box-shadow: -10px 0 30px rgba(31,58,95,0.18);
  display: flex;
  flex-direction: column;
  animation: atlas-slide-in-right .25s ease-out;
  z-index: calc(var(--z-drawer) + 1);
}
.atlas-drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.atlas-drawer-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}
.atlas-drawer-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
}

/* ----- Toast ----- */
.atlas-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast);
  pointer-events: none;
}
.atlas-toast {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px 12px 18px;
  box-shadow: 0 8px 24px rgba(31,58,95,0.18);
  border-left: 4px solid var(--navy);
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  animation: atlas-slide-in-right .25s ease-out;
}
.atlas-toast .title {
  font-weight: 700;
  color: var(--navy);
  font-size: 13px;
  margin-bottom: 2px;
}
.atlas-toast .msg {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}
.atlas-toast.success { border-left-color: var(--green); }
.atlas-toast.success .title { color: var(--green); }
.atlas-toast.warning { border-left-color: var(--yellow); }
.atlas-toast.warning .title { color: #B45309; }
.atlas-toast.error   { border-left-color: var(--red); }
.atlas-toast.error   .title { color: var(--red); }

/* ----- Animações ----- */
@keyframes atlas-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes atlas-scale-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
@keyframes atlas-slide-in-right {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* =====================================================
   9. UTILITÁRIOS
   ===================================================== */
.atlas-flex       { display: flex; }
.atlas-row        { display: flex; flex-direction: row;    align-items: center; gap: 12px; flex-wrap: wrap; }
.atlas-col        { display: flex; flex-direction: column; gap: 12px; }
.atlas-gap-2      { gap: 8px; }
.atlas-gap-3      { gap: 12px; }
.atlas-gap-4      { gap: 16px; }
.atlas-mt-2       { margin-top: 8px; }
.atlas-mt-3       { margin-top: 12px; }
.atlas-mt-4       { margin-top: 16px; }
.atlas-mt-6       { margin-top: 24px; }
.atlas-mb-3       { margin-bottom: 12px; }
.atlas-mb-4       { margin-bottom: 16px; }
.atlas-mb-6       { margin-bottom: 24px; }
.atlas-text-dim   { color: var(--text-dim); }
.atlas-text-right { text-align: right; }
.atlas-text-center{ text-align: center; }
.atlas-grow       { flex: 1; }

/* =====================================================
   10. RESPONSIVO (até 1280px — sem mobile)
   ===================================================== */
@media (max-width: 1280px) {
  :root { --sidebar-w: 208px; }
  .atlas-main { padding: 20px; }
  .atlas-header { padding: 0 18px; gap: 16px; }
  .atlas-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
  }
  .atlas-kpi-value { font-size: 32px; }
  .atlas-header-user .user-role { display: none; }
}
