:root {
  --bg-dark: #05070b;
  --bg-card: #0c1016;
  --bg-card-soft: #111622;
  --accent: #17c964;
  --accent-soft: #26d07c;
  --danger: #ff4d4f;
  --text-light: #f5f5f5;
  --text-muted: #9ca3af;
  --border-soft: #1f2933;
  --shadow-soft: 0 18px 45px rgba(0,0,0,0.65);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #101520 0, #05070b 55%);
  color: var(--text-light);
}

/* LOGIN */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(145deg, #0b0f18, #05070b);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  padding: 28px 28px 24px;
  border: 1px solid rgba(255,255,255,0.03);
}

.login-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.login-title h1 {
  font-size: 1.4rem;
  margin: 0;
}

.badge-soft {
  background: rgba(23,201,100,0.12);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
}

.login-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 4px;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  background: #05070b;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--text-light);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(23,201,100,0.35);
}

.btn {
  border-radius: 999px;
  border: none;
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #05070b;
}

.btn-primary:hover {
  filter: brightness(1.04);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.alert {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.alert-error {
  background: rgba(255,77,79,0.1);
  color: #ffb3b4;
  border: 1px solid rgba(255,77,79,0.35);
}

/* LAYOUT APP */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR DESKTOP */
.sidebar {
  width: 240px;
  background: #05070b;
  border-right: 1px solid var(--border-soft);
  padding: 18px 16px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  z-index: 1000;
}

.sidebar-logo {
  font-weight: 600;
  margin-bottom: 24px;
  font-size: 1.1rem;
}

.sidebar-logo span {
  color: var(--accent);
}

.nav-group {
  margin-bottom: 18px;
}

.nav-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  padding: 8px 10px;
  border-radius: 10px;
  color: #e5e7eb;
  text-decoration: none;
}

.nav-link:hover {
  background: rgba(255,255,255,0.03);
}

.nav-link.active {
  background: rgba(23,201,100,0.1);
  color: var(--accent);
}

/* MAIN AREA */
.app-main {
  flex: 1;
  padding: 18px 22px 28px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.app-header-title {
  font-size: 1.1rem;
  font-weight: 500;
}

.chip {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
}

/* TABLES */
.table-wrapper {
  background: var(--bg-card-soft);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.03);
  padding: 14px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 8px 6px;
  text-align: left;
}

th {
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border-soft);
}

tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

/* INVOICE ITEMS GRID */
.items-grid {
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  padding: 10px;
  background: #05070b;
}

.items-header, .item-row {
  display: grid;
  grid-template-columns: 2.3fr 0.7fr 0.9fr 0.9fr 0.3fr;
  gap: 6px;
  align-items: center;
}

.items-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.item-row input {
  font-size: 0.8rem;
}

.btn-xs {
  padding: 6px 8px;
  font-size: 0.75rem;
  border-radius: 999px;
}

/* RESPONSIVIDADE */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.7rem;
  color: var(--text-light);
  cursor: pointer;
  z-index: 2001;
}

/* OVERLAY MOBILE */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 1500;
}

/* MOBILE */
@media (max-width: 768px) {

  .hamburger-btn {
    display: block;
  }

  /* Sidebar esconde por padrão */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 240px;
    background: #05070b;
    padding: 18px 16px;
    transform: translateX(-260px);
    transition: transform .3s ease;
    z-index: 2000;
  }

  /* Sidebar aberta */
  .sidebar.open {
    transform: translateX(0);
  }

  /* Conteúdo principal reduzido */
  .app-main {
    padding: 14px 12px 22px;
  }

  /* Overlay ativo */
  .sidebar-overlay.open {
    display: block;
  }
}

/* GARANTIA DESKTOP */
@media (min-width: 769px) {
  .sidebar {
    transform: none !important;
    position: sticky;
  }
  .sidebar-overlay {
    display: none !important;
  }
}

/*======================================= HEADER ================================== */
.tp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #090d14;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Botão hambúrguer */
.tp-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-light);
  cursor: pointer;
  margin-right: 10px;
}

/* Área do usuário */
.tp-header-user {
  display: flex;
  flex-direction: column;
}

.tp-header-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.tp-header-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Ações do lado direito */
.tp-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tp-status-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
}

.tp-logout-btn {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.tp-logout-btn:hover {
  color: var(--accent);
}

/* MOBILE */
@media (max-width: 768px) {
  
  .tp-header {
    padding: 12px 14px;
    gap: 12px;
  }

  .tp-hamburger {
    display: block;
  }

  .tp-header-title {
    font-size: 1rem;
  }

  .tp-header-actions {
    gap: 8px;
  }

  .tp-status-chip {
    font-size: 0.7rem;
    padding: 3px 8px;
  }
}
/*======================================= FIM HEADER ================================== */

/* AREA DE CONTEÚDO (USADA EM TODAS AS TELAS) */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* CARDS BASE (USADOS EM VÁRIAS TELAS) */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 14px 14px 12px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 14px 30px rgba(0,0,0,0.6);
}

.card-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-value {
  font-size: 1.2rem;
  font-weight: 600;
}

.card-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* =================================== DASHBOARD ======================================= */

.dash-kpi-section {
  margin-bottom: 24px;
}

.dash-kpi-card {
  position: relative;
  overflow: hidden;
}

/* Barrinha lateral verde nos cards do dashboard */
.dash-kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-soft));
}

/* Ajusta conteúdo para não ficar em cima da barrinha */
.dash-kpi-card > * {
  margin-left: 4px;
}

/* Seção de últimos invoices */
.dash-last-section {
  margin-top: 10px;
}

.dash-last-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dash-section-title {
  font-size: 1rem;
}

.dash-new-invoice-btn {
  text-decoration: none;
}

/* MOBILE ESPECÍFICO DO DASHBOARD */
@media (max-width: 768px) {

  .dash-kpi-section {
    margin-top: 6px;
  }

  .dash-last-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .dash-new-invoice-btn {
    width: 100%;
    justify-content: center;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }
}
/* =================================== FIM DASHBOARD ======================================= */
/* Scroll da sidebar SOMENTE no mobile */
@media (max-width: 768px) {

    .sidebar {
        max-height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* suave no iPhone */
    }

    /* Esconde scroll horizontal, caso apareça */
    .sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.15);
        border-radius: 10px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: transparent;
    }
}
