/* ═══════════════════════════════════════════════════
   VARIABLES & RESET
═══════════════════════════════════════════════════ */
:root {
  --bg:        #E2E8F0;
  --surf:      #FFFFFF;
  --surf2:     #F8FAFC;
  --surf3:     #CBD5E1;
  --line:      #E9ECEF;
  --accent:    #2563EB;
  --accent-dim:#EFF6FF;
  --green:     #10B981;
  --green-dim: #D1FAE5;
  --mtn:       #F59E0B;
  --mtn-dim:   #FEF3C7;
  --orange:    #F97316;
  --orange-dim:#FFEDD5;
  --text:      #475569;
  --title:     #0F172A;
  --dim:       #64748B;
  --dim2:      #94A3B8;
  --danger:    #EF4444;
  --white:     #FFFFFF;
  --radius:    12px;
  --mono:      'DM Mono', monospace;
  --sans:      'Syne', sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow:    0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════ */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 20% 50%, #00C8FF0A 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 80% 20%, #FFB80008 0%, transparent 60%),
    var(--bg);
}

.login-box {
  width: 100%;
  max-width: 460px;
  padding: 56px 48px;
  background: var(--surf);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-logo {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.login-title {
  font-size: 34px;
  font-weight: 800;
  color: var(--title);
  margin-bottom: 6px;
  line-height: 1.1;
}

.login-sub {
  font-size: 14px;
  color: var(--dim);
  margin-bottom: 36px;
  font-family: var(--mono);
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

.field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 18px;
  color: var(--title);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  margin-bottom: 20px;
}

.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  margin-top: 4px;
}

.btn-primary:hover { opacity: .88; }
.btn-primary:active { transform: scale(.98); }

.login-error {
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--danger);
  font-size: 13px;
  font-family: var(--mono);
  margin-bottom: 16px;
  display: none;
}

/* ═══════════════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════════════ */
#app { display: none; height: 100vh; flex-direction: row; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  background: var(--surf);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  z-index: 100;
}

.sidebar-header {
  padding: 0 28px 24px;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--title);
  letter-spacing: .5px;
}

.sidebar-logo span { color: var(--accent); }

.sidebar-footer {
  padding: 24px 28px 0;
  margin-top: auto;
}

/* ── Content Area ── */
.content-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.header {
  height: 72px;
  background: transparent;
  display: flex;
  align-items: center;
  padding: 0 36px;
  gap: 20px;
  justify-content: space-between;
}

.header-badges { display: flex; gap: 8px; }

.badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: .5px;
}

.badge-mtn    { background: var(--mtn-dim);    color: #b45309;    border: 1px solid #FFB80033; }
.badge-orange { background: var(--orange-dim); color: #c2410c; border: 1px solid #FF6B3533; }

.header-right { display: flex; align-items: center; flex: 1; justify-content: flex-end; }
.header-sep { width: 1px; height: 16px; background: var(--line); margin: 0 16px; }

.clock {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
}

.user-pill {
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 8px;
  transition: background .2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill:hover { background: #EF444415; }

/* ── Nav Tabs ── */
.nav {
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  gap: 6px;
  border-bottom: none;
  background: transparent;
}

.nav-tab {
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--dim);
  padding: 12px 16px;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  transition: all .2s;
  white-space: nowrap;
}

.nav-tab i { margin-right: 12px; }
.nav-tab:hover { background: var(--surf2); color: var(--title); }
.nav-tab.active { background: var(--accent-dim); color: var(--accent); font-weight: 700; border: none; }

/* ── Main content ── */
.main { flex: 1; padding: 12px 36px 36px; overflow-y: auto; }

.page { display: none; }
.page.active { display: block; }
/* ═══════════════════════════════════════════════════
   STAT CARDS — sans bordure, sobre
═══════════════════════════════════════════════════ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--surf);
  padding: 24px;
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
}

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

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surf2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c, var(--accent));
  margin-bottom: 20px;
}

.card-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.2;
}

.icon-sm {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

.card-value {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--title);
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.card-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--dim);
}

/* ═══════════════════════════════════════════════════
   TOOLBAR
═══════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: center;
}

.input-search {
  flex: 1;
  min-width: 200px;
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--title);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.input-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input-search::placeholder { color: var(--dim); }

.select-filter {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--title);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color .2s;
}
.select-filter:focus { border-color: var(--accent); }

.btn {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 18px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn:hover { border-color: var(--dim2); color: var(--title); }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.btn-accent:hover { background: #1D4ED8; color: #FFFFFF; border-color: #1D4ED8; }

.btn-danger {
  background: #FEF2F2;
  border-color: #FECACA;
  color: var(--danger);
  box-shadow: none;
}

.btn-danger:hover { background: var(--danger); color: #FFFFFF; border-color: var(--danger); }

.btn-green {
  background: var(--green);
  border-color: var(--green);
  color: #FFFFFF;
}

.btn-green:hover { background: #059669; color: #FFFFFF; border-color: #059669; }
/* ═══════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════ */
.table-wrap {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 14px;
}

thead th {
  background: var(--surf2);
  color: var(--dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 16px 20px;
  text-align: left;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background .15s;
  cursor: pointer;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surf2); }
tbody tr.selected { background: var(--accent-dim); }

tbody td {
  padding: 14px 20px;
  color: var(--text);
  white-space: nowrap;
}

.tag-mtn {
  display: inline-block;
  background: var(--mtn-dim);
  color: #b45309;
  border: 1px solid #fef3c7;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
}

.tag-orange {
  display: inline-block;
  background: var(--orange-dim);
  color: #c2410c;
  border: 1px solid #ffedd5;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
}

.amount { color: var(--title); font-weight: 700; }

.table-empty {
  text-align: center;
  padding: 48px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════
   ÉTAT COMPTABLE
═══════════════════════════════════════════════════ */
.acc-section { margin-bottom: 24px; }

.acc-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 2px;
  padding: 0 2px;
}

.acc-table-wrap {
  background: var(--surf);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  overflow-x: auto;
}

.acc-table-wrap table thead th {
  background: var(--surf2);
  color: var(--title);
  font-size: 11px;
}

.acc-table-wrap tbody tr.total-row td {
  color: var(--title);
  font-weight: 700;
  background: var(--surf2);
  border-top: 1px solid var(--line);
}

.col-mtn    { color: var(--mtn) !important; }
.col-orange { color: var(--orange) !important; }
.col-green  { color: var(--green) !important; }

/* ═══════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: #00000088;
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surf);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--title);
  margin-bottom: 24px;
}

.form-row { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--title);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.modal-actions { display: flex; gap: 8px; margin-top: 24px; justify-content: flex-end; }

/* ═══════════════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surf2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 20px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  z-index: 300;
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  max-width: 320px;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }


/* ═══════════════════════════════════════════════════
   SECTION HEADERS
═══════════════════════════════════════════════════ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}

/* ═══════════════════════════════════════════════════
   STATUS BAR
═══════════════════════════════════════════════════ */
.statusbar {
  height: 48px;
  background: transparent;
  display: flex;
  align-items: center;
  padding: 0 36px;
  gap: 24px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  margin-right: 6px;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ═══════════════════════════════════════════════════
   LOADING SKELETON
═══════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--surf2) 25%, var(--surf3) 50%, var(--surf2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  height: 14px;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════
   ANIMATIONS PAGE
═══════════════════════════════════════════════════ */
.page.active { animation: fade-up .25s ease; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* spacing helpers */
.mt-20 { margin-top: 20px; }
.mb-4  { margin-bottom: 4px; }
.gap-section { margin-bottom: 28px; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE MOBILE
═══════════════════════════════════════════════════ */
@media screen and (max-width: 768px) {
  #app {
    flex-direction: column !important;
  }
  
  .sidebar {
    width: 100% !important;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 16px 0 !important;
  }
  
  .sidebar-header {
    text-align: center;
    padding: 0 16px 12px !important;
  }
  
  .nav {
    flex-direction: row !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px !important;
    padding: 0 8px !important;
  }
  
  .nav-tab {
    padding: 8px 12px !important;
    font-size: 13px !important;
  }
  
  .nav-tab i {
    margin-right: 6px !important;
  }

  .sidebar-footer {
    padding: 12px 16px 0 !important;
    display: flex;
    justify-content: center;
  }
  
  .header {
    flex-direction: column;
    height: auto !important;
    padding: 16px !important;
    gap: 12px !important;
    align-items: flex-start !important;
  }
  
  .header-badges {
    flex-wrap: wrap;
  }
  
  .header-right {
    justify-content: flex-start !important;
    width: 100%;
  }
  
  .header-sep {
    display: none;
  }
  
  .main {
    padding: 16px !important;
  }
  
  .cards-grid {
    grid-template-columns: 1fr !important;
  }

  #page-settings > div[style*="display:grid"],
  .modal > div[style*="display:grid"] {
    grid-template-columns: 1fr !important;
  }
  
  .toolbar {
    flex-direction: column;
    align-items: stretch !important;
  }
  
  .toolbar > * {
    width: 100%;
  }
}
