/* ─── Eve Dashboard — Studio Bacchelli ─── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --primary: #1A7A6D;
  --primary-light: #22a394;
  --primary-dark: #135e54;
  --bg: #0c1220;
  --bg-card: #131c2e;
  --bg-sidebar: #0f1729;
  --bg-input: #182236;
  --border: #1e2d44;
  --text: #e2e8f0;
  --text-dim: #7c8db0;
  --text-muted: #4a5e80;
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --yellow: #eab308;
  --yellow-bg: rgba(234,179,8,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.25);
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ─── LOGIN ─── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 380px;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 1rem;
}

.login-card h2 { margin-bottom: 0.25rem; font-size: 1.3rem; }
.login-card p { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 1.5rem; }

.login-card .input {
  width: 100%;
  margin-bottom: 1rem;
  text-align: center;
  font-size: 1rem;
}

.login-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

/* ─── APP SHELL ─── */
#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand { font-weight: 600; font-size: 1rem; }
.sidebar-brand small { display: block; font-size: 0.7rem; color: var(--text-dim); font-weight: 400; }

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.nav-item.active {
  color: var(--primary-light);
  background: rgba(26,122,109,0.1);
  border-right: 3px solid var(--primary);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  padding: 0.4rem 0;
}
.btn-logout:hover { color: var(--red); }

/* ─── MAIN ─── */
.main {
  flex: 1;
  margin-left: 240px;
  padding: 2rem;
  min-height: 100vh;
}

/* ─── PAGE HEADER ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 600; }

/* ─── KPI GRID ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.kpi-label { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.35rem; }
.kpi-value { font-size: 1.5rem; font-weight: 700; }
.kpi-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.kpi-warn { color: var(--yellow); }
.kpi-accent { color: var(--primary-light); }

/* ─── GRIDS ─── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ─── CARD ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── TABS ─── */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
  width: fit-content;
}

.tab {
  padding: 0.45rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

/* ─── BUTTONS ─── */
.btn {
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-input); }

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

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 0.3rem;
  line-height: 1;
}
.btn-icon:hover { color: var(--red); }

/* ─── INPUTS ─── */
.input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--primary); }

.input-sm {
  padding: 0.35rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
}

textarea.input { resize: vertical; }

label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
label .input { margin-top: 0.25rem; }

/* ─── TABLE ─── */
.table-responsive { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(30,45,68,0.5);
  vertical-align: middle;
}
.table tr:hover td { background: rgba(255,255,255,0.02); }
.td-desc { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toggle-btn {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.toggle-btn.on { background: var(--green-bg); color: var(--green); border-color: rgba(34,197,94,0.3); }
.toggle-btn.off { background: var(--bg-input); color: var(--text-muted); }
.toggle-btn:hover { opacity: 0.8; }

/* ─── FILTERS ─── */
.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ─── BADGES ─── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-gray { background: rgba(148,163,184,0.1); color: var(--text-dim); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }

/* ─── DEADLINES ─── */
.deadline-list { display: flex; flex-direction: column; gap: 0.5rem; }

.deadline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
}
.deadline-row.urgent { border-left-color: var(--red); }
.deadline-row.soon { border-left-color: var(--yellow); }

.deadline-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.deadline-amount { font-weight: 600; color: var(--text); }

.days-badge {
  background: rgba(255,255,255,0.06);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.deadline-type { margin-left: 0.5rem; }

/* ─── TASKS ─── */
.task-list { display: flex; flex-direction: column; gap: 0.4rem; }

.task-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(30,45,68,0.3);
}
.task-info { display: flex; align-items: center; gap: 0.5rem; }
.task-meta { display: flex; align-items: center; gap: 0.75rem; font-size: 0.82rem; color: var(--text-dim); }
.task-client { font-size: 0.78rem; color: var(--text-muted); }
.task-assigned { color: var(--primary-light); font-weight: 500; }
.task-due { color: var(--text-dim); }

.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}
.task-card.task-done { opacity: 0.5; }
.task-card-top { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.task-desc { font-size: 0.85rem; color: var(--text-dim); margin: 0.5rem 0; }
.task-card-bottom {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.btn-complete { background: var(--green-bg); color: var(--green); border-color: rgba(34,197,94,0.3); }
.btn-complete:hover { background: rgba(34,197,94,0.2); }

/* ─── FISCOZEN ─── */
.fiscozen-status {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  padding: 1.5rem 0;
}
.fiscozen-item { text-align: center; font-size: 0.85rem; color: var(--text-dim); }
.fiscozen-num { display: block; font-size: 2rem; font-weight: 700; margin-bottom: 0.25rem; }
.fiscozen-ok .fiscozen-num { color: var(--green); }
.fiscozen-pending .fiscozen-num { color: var(--yellow); }

/* ─── RECURRING ─── */
.rec-section { font-size: 0.85rem; }
.rec-section h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 0.75rem 0 0.35rem; }
.rec-income-title { color: var(--green) !important; }
.rec-expense-title { color: var(--red) !important; }
.rec-row { display: flex; align-items: center; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid rgba(30,45,68,0.3); }
.rec-amount { font-weight: 600; }
.rec-pos { color: var(--green); }
.rec-neg { color: var(--red); }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 440px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.modal h3 { font-size: 1.1rem; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ─── TEXT COLORS ─── */
.text-green { color: var(--green); }
.text-red { color: var(--red); }

/* ─── TOAST ─── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.toast-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

/* ─── CHART ─── */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap-lg { position: relative; height: 280px; }

/* ─── LOADING ─── */
.loading { display: flex; justify-content: center; padding: 3rem; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--text-muted); font-size: 0.88rem; padding: 1.5rem; text-align: center; }

.error-msg { color: var(--red); padding: 2rem; text-align: center; }

/* ─── RESPONSIVE ─── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 100;
  }

  .sidebar-header, .sidebar-footer { display: none; }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    padding: 0;
    overflow-x: auto;
    width: 100%;
    justify-content: space-around;
  }

  .nav-item {
    flex-direction: column;
    padding: 0.5rem 0.6rem;
    font-size: 0.65rem;
    gap: 0.2rem;
    text-align: center;
    min-width: 0;
    border-right: none;
  }
  .nav-item.active { border-right: none; border-top: 2px solid var(--primary); }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item span { display: none; }

  .main {
    margin-left: 0;
    padding: 1rem 1rem 5rem;
  }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .page-header h1 { font-size: 1.2rem; }

  .toast { bottom: 5rem; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.2rem; }
}
