/* Finance CFO Dashboard — custom.css */

:root {
  --sidebar-width: 240px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #3b82f6;
  --topbar-height: 56px;
  --body-bg: #f8fafc;
  --card-border: #e2e8f0;
}

/* ── Layout ── */
body {
  background: var(--body-bg);
  font-family: 'Inter', system-ui, sans-serif;
}

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 100;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.75rem 1.5rem 0.25rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1.5rem;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  border-radius: 0;
  transition: all 0.15s;
}

.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(59,130,246,0.15);
  border-right: 3px solid var(--sidebar-active);
}

.sidebar-nav .nav-link i {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}

.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  flex: 1;
}

.page-content {
  padding: 1.5rem;
}

/* ── KPI Cards ── */
.kpi-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  transition: box-shadow 0.2s;
}

.kpi-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.kpi-value.text-success { color: #16a34a !important; }
.kpi-value.text-danger  { color: #dc2626 !important; }
.kpi-value.text-warning { color: #d97706 !important; }

.kpi-delta {
  font-size: 0.8rem;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

/* ── Cards generiche ── */
.card {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: none;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #0f172a;
  border-radius: 12px 12px 0 0 !important;
}

/* ── Tabelle ── */
.table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table td {
  font-size: 0.875rem;
  vertical-align: middle;
  color: #1e293b;
}

.table-hover tbody tr:hover {
  background: #f8fafc;
}

/* ── Badge ── */
.badge {
  font-weight: 500;
  font-size: 0.72rem;
  padding: 0.3em 0.65em;
}

/* ── Scostamento ── */
.scost-pos { color: #16a34a; font-weight: 600; }
.scost-neg { color: #dc2626; font-weight: 600; }
.scost-neu { color: #64748b; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}

.login-logo {
  width: 64px; height: 64px;
  background: transparent;
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  margin: 0 auto 1.5rem;
}

/* ── Sidebar avatar ── */
.sidebar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(59,130,246,.3);
  color: #93c5fd;
  font-size: .75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ── Budget table ── */
#budget-table td.editable {
  cursor: pointer;
  transition: background .1s;
}
#budget-table td.editable:hover {
  background: #eff6ff;
}
#budget-table td.editable input {
  width: 100%; min-width: 80px;
  border: none; outline: none;
  background: #dbeafe;
  text-align: right;
  padding: 2px 4px;
  font-size: .875rem;
}
#budget-table tr.tipo-ricavo td { background: #f0fdf4; }
#budget-table tr.tipo-costo   td { background: #fff7ed; }
#budget-table tfoot tr.total  td { font-weight: 700; background: #f8fafc; }

/* ── Scostamento colori ── */
.text-scost-pos { color: #16a34a; }
.text-scost-neg { color: #dc2626; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-wrapper { margin-left: 0; }
}
